2014-08-06 16:26:56 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef TEST_RTP_FILE_READER_H_
|
|
|
|
|
#define TEST_RTP_FILE_READER_H_
|
2014-08-06 16:26:56 +00:00
|
|
|
|
2024-03-14 00:54:32 +01:00
|
|
|
#include <cstdint>
|
2015-07-17 05:27:21 -07:00
|
|
|
#include <set>
|
2014-08-06 16:26:56 +00:00
|
|
|
#include <string>
|
|
|
|
|
|
2022-07-20 12:53:07 +02:00
|
|
|
#include "absl/strings/string_view.h"
|
|
|
|
|
|
2014-08-06 16:26:56 +00:00
|
|
|
namespace webrtc {
|
|
|
|
|
namespace test {
|
2014-11-26 15:50:30 +00:00
|
|
|
|
|
|
|
|
struct RtpPacket {
|
|
|
|
|
// Accommodate for 50 ms packets of 32 kHz PCM16 samples (3200 bytes) plus
|
|
|
|
|
// some overhead.
|
|
|
|
|
static const size_t kMaxPacketBufferSize = 3500;
|
|
|
|
|
uint8_t data[kMaxPacketBufferSize];
|
|
|
|
|
size_t length;
|
2021-07-27 12:46:29 +02:00
|
|
|
// The length the packet had on wire. Will be different from `length` when
|
2014-11-26 15:50:30 +00:00
|
|
|
// reading a header-only RTP dump.
|
|
|
|
|
size_t original_length;
|
|
|
|
|
|
|
|
|
|
uint32_t time_ms;
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-06 16:26:56 +00:00
|
|
|
class RtpFileReader {
|
|
|
|
|
public:
|
2015-03-02 16:18:56 +00:00
|
|
|
enum FileFormat { kPcap, kRtpDump, kLengthPacketInterleaved };
|
2014-08-06 16:26:56 +00:00
|
|
|
|
|
|
|
|
virtual ~RtpFileReader() {}
|
2019-03-14 15:01:30 -07:00
|
|
|
static RtpFileReader* Create(FileFormat format,
|
|
|
|
|
const uint8_t* data,
|
|
|
|
|
size_t size,
|
|
|
|
|
const std::set<uint32_t>& ssrc_filter);
|
2022-07-20 12:53:07 +02:00
|
|
|
static RtpFileReader* Create(FileFormat format, absl::string_view filename);
|
2015-07-17 05:27:21 -07:00
|
|
|
static RtpFileReader* Create(FileFormat format,
|
2022-07-20 12:53:07 +02:00
|
|
|
absl::string_view filename,
|
2015-07-17 05:27:21 -07:00
|
|
|
const std::set<uint32_t>& ssrc_filter);
|
2014-11-26 15:50:30 +00:00
|
|
|
virtual bool NextPacket(RtpPacket* packet) = 0;
|
2014-08-06 16:26:56 +00:00
|
|
|
};
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // TEST_RTP_FILE_READER_H_
|