Make the RtpHeaderParserImpl available to tests and tools only.

There are a few reasons for making this test only:
* The code is only used by tests and utilities.
* The pure interface has only a single implementation so an interface isn't really needed.
  (a followup change could remove it altogether)
* The implementation always incorporates locking regardless of how the class gets used.
  See e.g. previous use in the Packet class.
* The implementation is a layer on top of RtpUtility::RtpHeaderParser which is
  sufficient for most production cases.

Change-Id: Ide6d50567cf8ae5127a2eb04cceeb10cf317ec36
Bug: none
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150658
Commit-Queue: Tommi <tommi@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29010}
This commit is contained in:
Tommi 2019-08-29 16:39:05 +02:00 committed by Commit Bot
parent 022a7c8d49
commit 25eb47ccf1
37 changed files with 152 additions and 159 deletions

View File

@ -504,6 +504,7 @@ if (rtc_include_tests) {
"rtc_base/synchronization:sequence_checker_unittests", "rtc_base/synchronization:sequence_checker_unittests",
"rtc_base/task_utils:to_queued_task_unittests", "rtc_base/task_utils:to_queued_task_unittests",
"sdk:sdk_tests", "sdk:sdk_tests",
"test:rtp_test_utils",
"test:test_main", "test:test_main",
"test/network:network_emulation_unittests", "test/network:network_emulation_unittests",
] ]

View File

@ -460,6 +460,7 @@ if (rtc_include_tests) {
"../test:fileutils", "../test:fileutils",
"../test:null_transport", "../test:null_transport",
"../test:perf_test", "../test:perf_test",
"../test:rtp_test_utils",
"../test:test_common", "../test:test_common",
"../test:test_support", "../test:test_support",
"../test:video_test_common", "../test:video_test_common",

View File

@ -40,9 +40,9 @@
#include "modules/congestion_controller/include/receive_side_congestion_controller.h" #include "modules/congestion_controller/include/receive_side_congestion_controller.h"
#include "modules/rtp_rtcp/include/flexfec_receiver.h" #include "modules/rtp_rtcp/include/flexfec_receiver.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/byte_io.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "modules/utility/include/process_thread.h" #include "modules/utility/include/process_thread.h"
#include "modules/video_coding/fec_controller_default.h" #include "modules/video_coding/fec_controller_default.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -155,6 +155,11 @@ std::unique_ptr<rtclog::StreamConfig> CreateRtcLogStreamConfig(
return rtclog_config; return rtclog_config;
} }
bool IsRtcp(const uint8_t* packet, size_t length) {
RtpUtility::RtpHeaderParser rtp_parser(packet, length);
return rtp_parser.RTCP();
}
} // namespace } // namespace
namespace internal { namespace internal {
@ -1322,7 +1327,7 @@ PacketReceiver::DeliveryStatus Call::DeliverPacket(
rtc::CopyOnWriteBuffer packet, rtc::CopyOnWriteBuffer packet,
int64_t packet_time_us) { int64_t packet_time_us) {
RTC_DCHECK_RUN_ON(&configuration_sequence_checker_); RTC_DCHECK_RUN_ON(&configuration_sequence_checker_);
if (RtpHeaderParser::IsRtcp(packet.cdata(), packet.size())) if (IsRtcp(packet.cdata(), packet.size()))
return DeliverRtcp(media_type, packet.cdata(), packet.size()); return DeliverRtcp(media_type, packet.cdata(), packet.size());
return DeliverRtp(media_type, std::move(packet), packet_time_us); return DeliverRtp(media_type, std::move(packet), packet_time_us);

View File

@ -27,7 +27,6 @@
#include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/include/audio_coding_module.h"
#include "modules/audio_device/include/test_audio_device.h" #include "modules/audio_device/include/test_audio_device.h"
#include "modules/audio_mixer/audio_mixer_impl.h" #include "modules/audio_mixer/audio_mixer_impl.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/metrics.h" #include "system_wrappers/include/metrics.h"
@ -41,6 +40,7 @@
#include "test/frame_generator_capturer.h" #include "test/frame_generator_capturer.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/null_transport.h" #include "test/null_transport.h"
#include "test/rtp_header_parser.h"
#include "test/rtp_rtcp_observer.h" #include "test/rtp_rtcp_observer.h"
#include "test/single_threaded_task_queue.h" #include "test/single_threaded_task_queue.h"
#include "test/testsupport/file_utils.h" #include "test/testsupport/file_utils.h"

View File

@ -665,6 +665,7 @@ if (is_linux || is_win) {
"../system_wrappers:field_trial", "../system_wrappers:field_trial",
"../test:field_trial", "../test:field_trial",
"../test:platform_video_capturer", "../test:platform_video_capturer",
"../test:rtp_test_utils",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]

View File

@ -558,6 +558,7 @@ if (rtc_include_tests) {
"../rtc_base/third_party/sigslot", "../rtc_base/third_party/sigslot",
"../test:audio_codec_mocks", "../test:audio_codec_mocks",
"../test:field_trial", "../test:field_trial",
"../test:rtp_test_utils",
"../test:test_main", "../test:test_main",
"../test:test_support", "../test:test_support",
"../test:video_test_common", "../test:video_test_common",

View File

@ -51,7 +51,6 @@
#include "media/engine/fake_webrtc_video_engine.h" #include "media/engine/fake_webrtc_video_engine.h"
#include "media/engine/simulcast.h" #include "media/engine/simulcast.h"
#include "media/engine/webrtc_voice_engine.h" #include "media/engine/webrtc_voice_engine.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/arraysize.h" #include "rtc_base/arraysize.h"
#include "rtc_base/fake_clock.h" #include "rtc_base/fake_clock.h"
#include "rtc_base/gunit.h" #include "rtc_base/gunit.h"
@ -60,6 +59,7 @@
#include "test/field_trial.h" #include "test/field_trial.h"
#include "test/frame_generator.h" #include "test/frame_generator.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/rtp_header_parser.h"
using ::testing::Field; using ::testing::Field;
using ::testing::IsEmpty; using ::testing::IsEmpty;
@ -1417,7 +1417,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
static bool ParseRtpPacket(const rtc::CopyOnWriteBuffer* p, static bool ParseRtpPacket(const rtc::CopyOnWriteBuffer* p,
webrtc::RTPHeader* header) { webrtc::RTPHeader* header) {
std::unique_ptr<webrtc::RtpHeaderParser> parser( std::unique_ptr<webrtc::RtpHeaderParser> parser(
webrtc::RtpHeaderParser::Create()); webrtc::RtpHeaderParser::CreateForTest());
return parser->Parse(p->cdata(), p->size(), header); return parser->Parse(p->cdata(), p->size(), header);
} }

View File

@ -1099,6 +1099,7 @@ rtc_source_set("neteq_test_tools") {
"../../test:rtp_test_utils", "../../test:rtp_test_utils",
"../rtp_rtcp", "../rtp_rtcp",
"../rtp_rtcp:rtp_rtcp_format", "../rtp_rtcp:rtp_rtcp_format",
"//third_party/abseil-cpp/absl/memory:memory",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]

View File

@ -71,12 +71,12 @@ const int kPayloadSizeBytes = kFrameSizeSamples * sizeof(int16_t);
const uint8_t kPayloadType = 111; const uint8_t kPayloadType = 111;
} // namespace } // namespace
class RtpUtility { class RtpData {
public: public:
RtpUtility(int samples_per_packet, uint8_t payload_type) RtpData(int samples_per_packet, uint8_t payload_type)
: samples_per_packet_(samples_per_packet), payload_type_(payload_type) {} : samples_per_packet_(samples_per_packet), payload_type_(payload_type) {}
virtual ~RtpUtility() {} virtual ~RtpData() {}
void Populate(RTPHeader* rtp_header) { void Populate(RTPHeader* rtp_header) {
rtp_header->sequenceNumber = 0xABCD; rtp_header->sequenceNumber = 0xABCD;
@ -163,7 +163,7 @@ class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
class AudioCodingModuleTestOldApi : public ::testing::Test { class AudioCodingModuleTestOldApi : public ::testing::Test {
protected: protected:
AudioCodingModuleTestOldApi() AudioCodingModuleTestOldApi()
: rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)), : rtp_utility_(new RtpData(kFrameSizeSamples, kPayloadType)),
clock_(Clock::GetRealTimeClock()) {} clock_(Clock::GetRealTimeClock()) {}
~AudioCodingModuleTestOldApi() {} ~AudioCodingModuleTestOldApi() {}
@ -239,7 +239,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
VerifyEncoding(); VerifyEncoding();
} }
std::unique_ptr<RtpUtility> rtp_utility_; std::unique_ptr<RtpData> rtp_utility_;
std::unique_ptr<AudioCodingModule> acm_; std::unique_ptr<AudioCodingModule> acm_;
PacketizationCallbackStubOldApi packet_cb_; PacketizationCallbackStubOldApi packet_cb_;
RTPHeader rtp_header_; RTPHeader rtp_header_;

View File

@ -14,81 +14,53 @@
#include <memory> #include <memory>
#include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
namespace test { namespace test {
Packet::Packet(uint8_t* packet_memory, using webrtc::RtpUtility::RtpHeaderParser;
size_t allocated_bytes,
double time_ms,
const RtpHeaderParser& parser)
: payload_memory_(packet_memory),
payload_(NULL),
packet_length_bytes_(allocated_bytes),
payload_length_bytes_(0),
virtual_packet_length_bytes_(allocated_bytes),
virtual_payload_length_bytes_(0),
time_ms_(time_ms) {
valid_header_ = ParseHeader(parser);
}
Packet::Packet(uint8_t* packet_memory, Packet::Packet(uint8_t* packet_memory,
size_t allocated_bytes, size_t allocated_bytes,
size_t virtual_packet_length_bytes, size_t virtual_packet_length_bytes,
double time_ms, double time_ms,
const RtpHeaderParser& parser) const RtpUtility::RtpHeaderParser& parser,
const RtpHeaderExtensionMap* extension_map /*= nullptr*/)
: payload_memory_(packet_memory), : payload_memory_(packet_memory),
payload_(NULL),
packet_length_bytes_(allocated_bytes), packet_length_bytes_(allocated_bytes),
payload_length_bytes_(0),
virtual_packet_length_bytes_(virtual_packet_length_bytes), virtual_packet_length_bytes_(virtual_packet_length_bytes),
virtual_payload_length_bytes_(0), virtual_payload_length_bytes_(0),
time_ms_(time_ms) { time_ms_(time_ms),
valid_header_ = ParseHeader(parser); valid_header_(ParseHeader(parser, extension_map)) {}
}
Packet::Packet(const RTPHeader& header, Packet::Packet(const RTPHeader& header,
size_t virtual_packet_length_bytes, size_t virtual_packet_length_bytes,
size_t virtual_payload_length_bytes, size_t virtual_payload_length_bytes,
double time_ms) double time_ms)
: header_(header), : header_(header),
payload_memory_(),
payload_(NULL),
packet_length_bytes_(0),
payload_length_bytes_(0),
virtual_packet_length_bytes_(virtual_packet_length_bytes), virtual_packet_length_bytes_(virtual_packet_length_bytes),
virtual_payload_length_bytes_(virtual_payload_length_bytes), virtual_payload_length_bytes_(virtual_payload_length_bytes),
time_ms_(time_ms), time_ms_(time_ms),
valid_header_(true) {} valid_header_(true) {}
Packet::Packet(uint8_t* packet_memory, size_t allocated_bytes, double time_ms) Packet::Packet(uint8_t* packet_memory, size_t allocated_bytes, double time_ms)
: payload_memory_(packet_memory), : Packet(packet_memory,
payload_(NULL), allocated_bytes,
packet_length_bytes_(allocated_bytes), allocated_bytes,
payload_length_bytes_(0), time_ms,
virtual_packet_length_bytes_(allocated_bytes), RtpUtility::RtpHeaderParser(packet_memory, allocated_bytes)) {}
virtual_payload_length_bytes_(0),
time_ms_(time_ms) {
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
valid_header_ = ParseHeader(*parser);
}
Packet::Packet(uint8_t* packet_memory, Packet::Packet(uint8_t* packet_memory,
size_t allocated_bytes, size_t allocated_bytes,
size_t virtual_packet_length_bytes, size_t virtual_packet_length_bytes,
double time_ms) double time_ms)
: payload_memory_(packet_memory), : Packet(packet_memory,
payload_(NULL), allocated_bytes,
packet_length_bytes_(allocated_bytes), virtual_packet_length_bytes,
payload_length_bytes_(0), time_ms,
virtual_packet_length_bytes_(virtual_packet_length_bytes), RtpUtility::RtpHeaderParser(packet_memory, allocated_bytes)) {}
virtual_payload_length_bytes_(0),
time_ms_(time_ms) {
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create());
valid_header_ = ParseHeader(*parser);
}
Packet::~Packet() = default; Packet::~Packet() = default;
@ -139,9 +111,10 @@ void Packet::DeleteRedHeaders(std::list<RTPHeader*>* headers) {
} }
} }
bool Packet::ParseHeader(const RtpHeaderParser& parser) { bool Packet::ParseHeader(const RtpHeaderParser& parser,
bool valid_header = parser.Parse( const RtpHeaderExtensionMap* extension_map) {
payload_memory_.get(), static_cast<int>(packet_length_bytes_), &header_); bool valid_header = parser.Parse(&header_, extension_map);
// Special case for dummy packets that have padding marked in the RTP header. // Special case for dummy packets that have padding marked in the RTP header.
// This causes the RTP header parser to report failure, but is fine in this // This causes the RTP header parser to report failure, but is fine in this
// context. // context.

View File

@ -15,11 +15,14 @@
#include <memory> #include <memory>
#include "api/rtp_headers.h" // NOLINT(build/include) #include "api/rtp_headers.h" // NOLINT(build/include)
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
namespace webrtc { namespace webrtc {
namespace RtpUtility {
class RtpHeaderParser; class RtpHeaderParser;
} // namespace RtpUtility
namespace test { namespace test {
@ -32,22 +35,17 @@ class Packet {
// when the Packet object is deleted. The |time_ms| is an extra time // when the Packet object is deleted. The |time_ms| is an extra time
// associated with this packet, typically used to denote arrival time. // associated with this packet, typically used to denote arrival time.
// The first bytes in |packet_memory| will be parsed using |parser|. // The first bytes in |packet_memory| will be parsed using |parser|.
Packet(uint8_t* packet_memory, // |virtual_packet_length_bytes| is typically used when reading RTP dump files
size_t allocated_bytes, // that only contain the RTP headers, and no payload (a.k.a RTP dummy files or
double time_ms, // RTP light). The |virtual_packet_length_bytes| tells what size the packet
const RtpHeaderParser& parser); // had on wire, including the now discarded payload, whereas |allocated_bytes|
// is the length of the remaining payload (typically only the RTP header).
// Same as above, but with the extra argument |virtual_packet_length_bytes|.
// This is typically used when reading RTP dump files that only contain the
// RTP headers, and no payload (a.k.a RTP dummy files or RTP light). The
// |virtual_packet_length_bytes| tells what size the packet had on wire,
// including the now discarded payload, whereas |allocated_bytes| is the
// length of the remaining payload (typically only the RTP header).
Packet(uint8_t* packet_memory, Packet(uint8_t* packet_memory,
size_t allocated_bytes, size_t allocated_bytes,
size_t virtual_packet_length_bytes, size_t virtual_packet_length_bytes,
double time_ms, double time_ms,
const RtpHeaderParser& parser); const RtpUtility::RtpHeaderParser& parser,
const RtpHeaderExtensionMap* extension_map = nullptr);
// Same as above, but creates the packet from an already parsed RTPHeader. // Same as above, but creates the packet from an already parsed RTPHeader.
// This is typically used when reading RTP dump files that only contain the // This is typically used when reading RTP dump files that only contain the
@ -98,25 +96,25 @@ class Packet {
const RTPHeader& header() const { return header_; } const RTPHeader& header() const { return header_; }
void set_time_ms(double time) { time_ms_ = time; }
double time_ms() const { return time_ms_; } double time_ms() const { return time_ms_; }
bool valid_header() const { return valid_header_; } bool valid_header() const { return valid_header_; }
private: private:
bool ParseHeader(const RtpHeaderParser& parser); bool ParseHeader(const webrtc::RtpUtility::RtpHeaderParser& parser,
const RtpHeaderExtensionMap* extension_map);
void CopyToHeader(RTPHeader* destination) const; void CopyToHeader(RTPHeader* destination) const;
RTPHeader header_; RTPHeader header_;
std::unique_ptr<uint8_t[]> payload_memory_; const std::unique_ptr<uint8_t[]> payload_memory_;
const uint8_t* payload_; // First byte after header. const uint8_t* payload_ = nullptr; // First byte after header.
const size_t packet_length_bytes_; // Total length of packet. const size_t packet_length_bytes_ = 0; // Total length of packet.
size_t payload_length_bytes_; // Length of the payload, after RTP header. size_t payload_length_bytes_ = 0; // Length of the payload, after RTP header.
// Zero for dummy RTP packets. // Zero for dummy RTP packets.
// Virtual lengths are used when parsing RTP header files (dummy RTP files). // Virtual lengths are used when parsing RTP header files (dummy RTP files).
const size_t virtual_packet_length_bytes_; const size_t virtual_packet_length_bytes_;
size_t virtual_payload_length_bytes_; size_t virtual_payload_length_bytes_ = 0;
double time_ms_; // Used to denote a packet's arrival time. const double time_ms_; // Used to denote a packet's arrival time.
bool valid_header_; // Set by the RtpHeaderParser. const bool valid_header_; // Set by the RtpHeaderParser.
RTC_DISALLOW_COPY_AND_ASSIGN(Packet); RTC_DISALLOW_COPY_AND_ASSIGN(Packet);
}; };

View File

@ -18,8 +18,8 @@
#include <memory> #include <memory>
#include "absl/memory/memory.h"
#include "modules/audio_coding/neteq/tools/packet.h" #include "modules/audio_coding/neteq/tools/packet.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "test/rtp_file_reader.h" #include "test/rtp_file_reader.h"
@ -49,8 +49,7 @@ RtpFileSource::~RtpFileSource() {}
bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type, bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type,
uint8_t id) { uint8_t id) {
assert(parser_.get()); return rtp_header_extension_map_.RegisterByType(id, type);
return parser_->RegisterRtpHeaderExtension(type, id);
} }
std::unique_ptr<Packet> RtpFileSource::NextPacket() { std::unique_ptr<Packet> RtpFileSource::NextPacket() {
@ -66,9 +65,11 @@ std::unique_ptr<Packet> RtpFileSource::NextPacket() {
} }
std::unique_ptr<uint8_t[]> packet_memory(new uint8_t[temp_packet.length]); std::unique_ptr<uint8_t[]> packet_memory(new uint8_t[temp_packet.length]);
memcpy(packet_memory.get(), temp_packet.data, temp_packet.length); memcpy(packet_memory.get(), temp_packet.data, temp_packet.length);
std::unique_ptr<Packet> packet(new Packet( RtpUtility::RtpHeaderParser parser(packet_memory.get(), temp_packet.length);
auto packet = absl::make_unique<Packet>(
packet_memory.release(), temp_packet.length, packet_memory.release(), temp_packet.length,
temp_packet.original_length, temp_packet.time_ms, *parser_.get())); temp_packet.original_length, temp_packet.time_ms, parser,
&rtp_header_extension_map_);
if (!packet->valid_header()) { if (!packet->valid_header()) {
continue; continue;
} }
@ -83,7 +84,6 @@ std::unique_ptr<Packet> RtpFileSource::NextPacket() {
RtpFileSource::RtpFileSource(absl::optional<uint32_t> ssrc_filter) RtpFileSource::RtpFileSource(absl::optional<uint32_t> ssrc_filter)
: PacketSource(), : PacketSource(),
parser_(RtpHeaderParser::Create()),
ssrc_filter_(ssrc_filter) {} ssrc_filter_(ssrc_filter) {}
bool RtpFileSource::OpenFile(const std::string& file_name) { bool RtpFileSource::OpenFile(const std::string& file_name) {

View File

@ -19,12 +19,11 @@
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "modules/audio_coding/neteq/tools/packet_source.h" #include "modules/audio_coding/neteq/tools/packet_source.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
namespace webrtc { namespace webrtc {
class RtpHeaderParser;
namespace test { namespace test {
class RtpFileReader; class RtpFileReader;
@ -58,8 +57,8 @@ class RtpFileSource : public PacketSource {
bool OpenFile(const std::string& file_name); bool OpenFile(const std::string& file_name);
std::unique_ptr<RtpFileReader> rtp_reader_; std::unique_ptr<RtpFileReader> rtp_reader_;
std::unique_ptr<RtpHeaderParser> parser_;
const absl::optional<uint32_t> ssrc_filter_; const absl::optional<uint32_t> ssrc_filter_;
RtpHeaderExtensionMap rtp_header_extension_map_;
RTC_DISALLOW_COPY_AND_ASSIGN(RtpFileSource); RTC_DISALLOW_COPY_AND_ASSIGN(RtpFileSource);
}; };

View File

@ -20,8 +20,8 @@
#include "absl/flags/parse.h" #include "absl/flags/parse.h"
#include "modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" #include "modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h"
#include "modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h" #include "modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "test/rtp_file_reader.h" #include "test/rtp_file_reader.h"
#include "test/rtp_header_parser.h"
ABSL_FLAG(std::string, ABSL_FLAG(std::string,
extension_type, extension_type,
@ -65,13 +65,13 @@ std::set<uint32_t> SsrcFilter() {
return ssrcs; return ssrcs;
} }
bool ParseArgsAndSetupEstimator(int argc, std::unique_ptr<webrtc::RtpHeaderParser> ParseArgsAndSetupEstimator(
int argc,
char** argv, char** argv,
webrtc::Clock* clock, webrtc::Clock* clock,
webrtc::RemoteBitrateObserver* observer, webrtc::RemoteBitrateObserver* observer,
webrtc::test::RtpFileReader** rtp_reader, std::unique_ptr<webrtc::test::RtpFileReader>* rtp_reader,
webrtc::RtpHeaderParser** parser, std::unique_ptr<webrtc::RemoteBitrateEstimator>* estimator,
webrtc::RemoteBitrateEstimator** estimator,
std::string* estimator_used) { std::string* estimator_used) {
absl::ParseCommandLine(argc, argv); absl::ParseCommandLine(argc, argv);
std::string filename = InputFile(); std::string filename = InputFile();
@ -84,16 +84,16 @@ bool ParseArgsAndSetupEstimator(int argc,
fprintf(stderr, "\n"); fprintf(stderr, "\n");
if (filename.substr(filename.find_last_of('.')) == ".pcap") { if (filename.substr(filename.find_last_of('.')) == ".pcap") {
fprintf(stderr, "Opening as pcap\n"); fprintf(stderr, "Opening as pcap\n");
*rtp_reader = webrtc::test::RtpFileReader::Create( rtp_reader->reset(webrtc::test::RtpFileReader::Create(
webrtc::test::RtpFileReader::kPcap, filename.c_str(), SsrcFilter()); webrtc::test::RtpFileReader::kPcap, filename.c_str(), SsrcFilter()));
} else { } else {
fprintf(stderr, "Opening as rtp\n"); fprintf(stderr, "Opening as rtp\n");
*rtp_reader = webrtc::test::RtpFileReader::Create( rtp_reader->reset(webrtc::test::RtpFileReader::Create(
webrtc::test::RtpFileReader::kRtpDump, filename.c_str()); webrtc::test::RtpFileReader::kRtpDump, filename.c_str()));
} }
if (!*rtp_reader) { if (!*rtp_reader) {
fprintf(stderr, "Cannot open input file %s\n", filename.c_str()); fprintf(stderr, "Cannot open input file %s\n", filename.c_str());
return false; return nullptr;
} }
fprintf(stderr, "Input file: %s\n\n", filename.c_str()); fprintf(stderr, "Input file: %s\n\n", filename.c_str());
@ -105,29 +105,31 @@ bool ParseArgsAndSetupEstimator(int argc,
fprintf(stderr, "Extension: abs\n"); fprintf(stderr, "Extension: abs\n");
} else { } else {
fprintf(stderr, "Unknown extension type\n"); fprintf(stderr, "Unknown extension type\n");
return false; return nullptr;
} }
// Setup the RTP header parser and the bitrate estimator. // Setup the RTP header parser and the bitrate estimator.
*parser = webrtc::RtpHeaderParser::Create(); auto parser = webrtc::RtpHeaderParser::CreateForTest();
(*parser)->RegisterRtpHeaderExtension(extension, ExtensionId()); parser->RegisterRtpHeaderExtension(extension, ExtensionId());
if (estimator) { if (estimator) {
switch (extension) { switch (extension) {
case webrtc::kRtpExtensionAbsoluteSendTime: { case webrtc::kRtpExtensionAbsoluteSendTime: {
*estimator = estimator->reset(
new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock); new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock));
*estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator"; *estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator";
break; break;
} }
case webrtc::kRtpExtensionTransmissionTimeOffset: { case webrtc::kRtpExtensionTransmissionTimeOffset: {
*estimator = estimator->reset(
new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock); new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock));
*estimator_used = "RemoteBitrateEstimator"; *estimator_used = "RemoteBitrateEstimator";
break; break;
} }
default: default:
assert(false); assert(false);
return nullptr;
} }
} }
return true;
return parser;
} }

View File

@ -11,6 +11,7 @@
#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_ #ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
#define MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_ #define MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
#include <memory>
#include <string> #include <string>
namespace webrtc { namespace webrtc {
@ -23,13 +24,13 @@ class RtpFileReader;
} }
} // namespace webrtc } // namespace webrtc
bool ParseArgsAndSetupEstimator(int argc, std::unique_ptr<webrtc::RtpHeaderParser> ParseArgsAndSetupEstimator(
int argc,
char** argv, char** argv,
webrtc::Clock* clock, webrtc::Clock* clock,
webrtc::RemoteBitrateObserver* observer, webrtc::RemoteBitrateObserver* observer,
webrtc::test::RtpFileReader** rtp_reader, std::unique_ptr<webrtc::test::RtpFileReader>* rtp_reader,
webrtc::RtpHeaderParser** parser, std::unique_ptr<webrtc::RemoteBitrateEstimator>* estimator,
webrtc::RemoteBitrateEstimator** estimator,
std::string* estimator_used); std::string* estimator_used);
#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_ #endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_

View File

@ -13,21 +13,20 @@
#include <memory> #include <memory>
#include "modules/remote_bitrate_estimator/tools/bwe_rtp.h" #include "modules/remote_bitrate_estimator/tools/bwe_rtp.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/format_macros.h" #include "rtc_base/format_macros.h"
#include "rtc_base/strings/string_builder.h" #include "rtc_base/strings/string_builder.h"
#include "test/rtp_file_reader.h" #include "test/rtp_file_reader.h"
#include "test/rtp_header_parser.h"
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
webrtc::test::RtpFileReader* reader; std::unique_ptr<webrtc::test::RtpFileReader> reader;
webrtc::RtpHeaderParser* parser; std::unique_ptr<webrtc::RtpHeaderParser> parser(ParseArgsAndSetupEstimator(
if (!ParseArgsAndSetupEstimator(argc, argv, NULL, NULL, &reader, &parser, argc, argv, nullptr, nullptr, &reader, nullptr, nullptr));
NULL, NULL)) { if (!parser)
return -1; return -1;
}
bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0); bool arrival_time_only = (argc >= 5 && strncmp(argv[4], "-t", 2) == 0);
std::unique_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
std::unique_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
fprintf(stdout, fprintf(stdout,
"seqnum timestamp ts_offset abs_sendtime recvtime " "seqnum timestamp ts_offset abs_sendtime recvtime "
"markerbit ssrc size original_size\n"); "markerbit ssrc size original_size\n");
@ -35,7 +34,7 @@ int main(int argc, char* argv[]) {
int non_zero_abs_send_time = 0; int non_zero_abs_send_time = 0;
int non_zero_ts_offsets = 0; int non_zero_ts_offsets = 0;
webrtc::test::RtpPacket packet; webrtc::test::RtpPacket packet;
while (rtp_reader->NextPacket(&packet)) { while (reader->NextPacket(&packet)) {
webrtc::RTPHeader header; webrtc::RTPHeader header;
parser->Parse(packet.data, packet.length, &header); parser->Parse(packet.data, packet.length, &header);
if (header.extension.absoluteSendTime != 0) if (header.extension.absoluteSendTime != 0)

View File

@ -129,7 +129,6 @@ rtc_static_library("rtp_rtcp") {
"include/flexfec_sender.h", "include/flexfec_sender.h",
"include/receive_statistics.h", "include/receive_statistics.h",
"include/remote_ntp_time_estimator.h", "include/remote_ntp_time_estimator.h",
"include/rtp_header_parser.h",
"include/rtp_rtcp.h", "include/rtp_rtcp.h",
"include/ulpfec_receiver.h", "include/ulpfec_receiver.h",
"source/absolute_capture_time_receiver.cc", "source/absolute_capture_time_receiver.cc",
@ -175,7 +174,6 @@ rtc_static_library("rtp_rtcp") {
"source/rtp_format_vp9.h", "source/rtp_format_vp9.h",
"source/rtp_header_extension_size.cc", "source/rtp_header_extension_size.cc",
"source/rtp_header_extension_size.h", "source/rtp_header_extension_size.h",
"source/rtp_header_parser.cc",
"source/rtp_packet_history.cc", "source/rtp_packet_history.cc",
"source/rtp_packet_history.h", "source/rtp_packet_history.h",
"source/rtp_rtcp_config.h", "source/rtp_rtcp_config.h",

View File

@ -17,7 +17,6 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/transport/field_trial_based_config.h" #include "api/transport/field_trial_based_config.h"
#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_codec.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/playout_delay_oracle.h" #include "modules/rtp_rtcp/source/playout_delay_oracle.h"
#include "modules/rtp_rtcp/source/rtcp_packet.h" #include "modules/rtp_rtcp/source/rtcp_packet.h"
@ -28,6 +27,7 @@
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/rtcp_packet_parser.h" #include "test/rtcp_packet_parser.h"
#include "test/rtp_header_parser.h"
using ::testing::_; using ::testing::_;
using ::testing::ElementsAre; using ::testing::ElementsAre;
@ -72,7 +72,7 @@ class SendTransport : public Transport {
size_t len, size_t len,
const PacketOptions& options) override { const PacketOptions& options) override {
RTPHeader header; RTPHeader header;
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::CreateForTest());
EXPECT_TRUE(parser->Parse(static_cast<const uint8_t*>(data), len, &header)); EXPECT_TRUE(parser->Parse(static_cast<const uint8_t*>(data), len, &header));
++rtp_packets_sent_; ++rtp_packets_sent_;
last_rtp_header_ = header; last_rtp_header_ = header;

View File

@ -21,7 +21,6 @@
#include "logging/rtc_event_log/mock/mock_rtc_event_log.h" #include "logging/rtc_event_log/mock/mock_rtc_event_log.h"
#include "modules/rtp_rtcp/include/rtp_cvo.h" #include "modules/rtp_rtcp/include/rtp_cvo.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/include/rtp_packet_sender.h" #include "modules/rtp_rtcp/include/rtp_packet_sender.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
@ -39,6 +38,7 @@
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/mock_transport.h" #include "test/mock_transport.h"
#include "test/rtp_header_parser.h"
namespace webrtc { namespace webrtc {

View File

@ -15,7 +15,6 @@
#include <list> #include <list>
#include <memory> #include <memory>
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h" #include "modules/rtp_rtcp/mocks/mock_recovered_packet_receiver.h"
#include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "modules/rtp_rtcp/mocks/mock_rtp_rtcp.h"
#include "modules/rtp_rtcp/source/byte_io.h" #include "modules/rtp_rtcp/source/byte_io.h"
@ -23,6 +22,7 @@
#include "modules/rtp_rtcp/source/forward_error_correction.h" #include "modules/rtp_rtcp/source/forward_error_correction.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/rtp_header_parser.h"
namespace webrtc { namespace webrtc {
@ -177,7 +177,7 @@ void UlpfecReceiverTest::SurvivesMaliciousPacket(const uint8_t* data,
size_t length, size_t length,
uint8_t ulpfec_payload_type) { uint8_t ulpfec_payload_type) {
RTPHeader header; RTPHeader header;
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::CreateForTest());
ASSERT_TRUE(parser->Parse(data, length, &header)); ASSERT_TRUE(parser->Parse(data, length, &header));
NullRecoveredPacketReceiver null_callback; NullRecoveredPacketReceiver null_callback;

View File

@ -558,6 +558,7 @@ if (rtc_include_tests) {
"../system_wrappers:metrics", "../system_wrappers:metrics",
"../test:field_trial", "../test:field_trial",
"../test:fileutils", "../test:fileutils",
"../test:rtp_test_utils",
"//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings",

View File

@ -20,7 +20,6 @@
#include "api/array_view.h" #include "api/array_view.h"
#include "api/rtc_error.h" #include "api/rtc_error.h"
#include "media/base/rtp_utils.h" #include "media/base/rtp_utils.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" #include "modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
#include "modules/rtp_rtcp/source/rtp_packet.h" #include "modules/rtp_rtcp/source/rtp_packet.h"
#include "modules/rtp_rtcp/source/rtp_packet_received.h" #include "modules/rtp_rtcp/source/rtp_packet_received.h"

View File

@ -131,15 +131,19 @@ rtc_source_set("rtp_test_utils") {
"rtp_file_reader.h", "rtp_file_reader.h",
"rtp_file_writer.cc", "rtp_file_writer.cc",
"rtp_file_writer.h", "rtp_file_writer.h",
"rtp_header_parser.cc",
"rtp_header_parser.h",
] ]
deps = [ deps = [
"../api:array_view", "../api:array_view",
"../api:rtp_parameters",
"../modules/rtp_rtcp", "../modules/rtp_rtcp",
"../modules/rtp_rtcp:rtp_rtcp_format", "../modules/rtp_rtcp:rtp_rtcp_format",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",
"../rtc_base/system:arch", "../rtc_base/system:arch",
"//third_party/abseil-cpp/absl/memory",
] ]
} }
@ -597,6 +601,7 @@ rtc_source_set("direct_transport") {
"direct_transport.h", "direct_transport.h",
] ]
deps = [ deps = [
":rtp_test_utils",
"../api:simulated_network_api", "../api:simulated_network_api",
"../api:transport_api", "../api:transport_api",
"../call:call_interfaces", "../call:call_interfaces",

View File

@ -12,8 +12,8 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "call/call.h" #include "call/call.h"
#include "call/fake_network_pipe.h" #include "call/fake_network_pipe.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
#include "test/rtp_header_parser.h"
#include "test/single_threaded_task_queue.h" #include "test/single_threaded_task_queue.h"
namespace webrtc { namespace webrtc {

View File

@ -616,7 +616,7 @@ webrtc_fuzzer_test("rtp_header_parser_fuzzer") {
"rtp_header_parser_fuzzer.cc", "rtp_header_parser_fuzzer.cc",
] ]
deps = [ deps = [
"../../modules/rtp_rtcp", "../:rtp_test_utils",
] ]
} }
@ -625,7 +625,7 @@ webrtc_fuzzer_test("ssl_certificate_fuzzer") {
"rtp_header_parser_fuzzer.cc", "rtp_header_parser_fuzzer.cc",
] ]
deps = [ deps = [
"../../modules/rtp_rtcp", "../:rtp_test_utils",
] ]
} }

View File

@ -15,7 +15,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "test/rtp_header_parser.h"
namespace webrtc { namespace webrtc {
@ -24,7 +24,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
RtpHeaderParser::GetSsrc(data, size); RtpHeaderParser::GetSsrc(data, size);
RTPHeader rtp_header; RTPHeader rtp_header;
std::unique_ptr<RtpHeaderParser> rtp_header_parser(RtpHeaderParser::Create()); std::unique_ptr<RtpHeaderParser> rtp_header_parser(
RtpHeaderParser::CreateForTest());
rtp_header_parser->Parse(data, size, &rtp_header); rtp_header_parser->Parse(data, size, &rtp_header);
for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) { for (int i = 1; i < kRtpExtensionNumberOfExtensions; ++i) {

View File

@ -23,7 +23,6 @@ rtc_source_set("rtp_replayer") {
"../../../call:call_interfaces", "../../../call:call_interfaces",
"../../../common_video", "../../../common_video",
"../../../media:rtc_internal_video_codecs", "../../../media:rtc_internal_video_codecs",
"../../../modules/rtp_rtcp",
"../../../rtc_base:checks", "../../../rtc_base:checks",
"../../../rtc_base:rtc_base_approved", "../../../rtc_base:rtc_base_approved",
"../../../rtc_base:rtc_json", "../../../rtc_base:rtc_json",

View File

@ -16,7 +16,6 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/strings/json.h" #include "rtc_base/strings/json.h"
#include "system_wrappers/include/clock.h" #include "system_wrappers/include/clock.h"
#include "system_wrappers/include/sleep.h" #include "system_wrappers/include/sleep.h"
@ -24,6 +23,7 @@
#include "test/encoder_settings.h" #include "test/encoder_settings.h"
#include "test/fake_decoder.h" #include "test/fake_decoder.h"
#include "test/rtp_file_reader.h" #include "test/rtp_file_reader.h"
#include "test/rtp_header_parser.h"
namespace webrtc { namespace webrtc {
namespace test { namespace test {
@ -158,7 +158,8 @@ void RtpReplayer::ReplayPackets(Call* call, test::RtpFileReader* rtp_reader) {
break; break;
case PacketReceiver::DELIVERY_UNKNOWN_SSRC: { case PacketReceiver::DELIVERY_UNKNOWN_SSRC: {
RTPHeader header; RTPHeader header;
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); std::unique_ptr<RtpHeaderParser> parser(
RtpHeaderParser::CreateForTest());
parser->Parse(packet.data, packet.length, &header); parser->Parse(packet.data, packet.length, &header);
if (unknown_packets[header.ssrc] == 0) { if (unknown_packets[header.ssrc] == 0) {
@ -171,7 +172,8 @@ void RtpReplayer::ReplayPackets(Call* call, test::RtpFileReader* rtp_reader) {
RTC_LOG(LS_ERROR) RTC_LOG(LS_ERROR)
<< "Packet error, corrupt packets or incorrect setup?"; << "Packet error, corrupt packets or incorrect setup?";
RTPHeader header; RTPHeader header;
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); std::unique_ptr<RtpHeaderParser> parser(
RtpHeaderParser::CreateForTest());
parser->Parse(packet.data, packet.length, &header); parser->Parse(packet.data, packet.length, &header);
RTC_LOG(LS_ERROR) << "Packet packet_length=" << packet.length RTC_LOG(LS_ERROR) << "Packet packet_length=" << packet.length
<< " payload_type=" << header.payloadType << " payload_type=" << header.payloadType

View File

@ -7,10 +7,11 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "test/rtp_header_parser.h"
#include <string.h> #include <memory>
#include "absl/memory/memory.h"
#include "modules/rtp_rtcp/include/rtp_header_extension_map.h" #include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
#include "modules/rtp_rtcp/source/rtp_utility.h" #include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/critical_section.h" #include "rtc_base/critical_section.h"
@ -39,8 +40,8 @@ class RtpHeaderParserImpl : public RtpHeaderParser {
RTC_GUARDED_BY(critical_section_); RTC_GUARDED_BY(critical_section_);
}; };
RtpHeaderParser* RtpHeaderParser::Create() { std::unique_ptr<RtpHeaderParser> RtpHeaderParser::CreateForTest() {
return new RtpHeaderParserImpl; return absl::make_unique<RtpHeaderParserImpl>();
} }
RtpHeaderParserImpl::RtpHeaderParserImpl() {} RtpHeaderParserImpl::RtpHeaderParserImpl() {}

View File

@ -7,8 +7,10 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_ #ifndef TEST_RTP_HEADER_PARSER_H_
#define MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_ #define TEST_RTP_HEADER_PARSER_H_
#include <memory>
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@ -19,7 +21,7 @@ struct RTPHeader;
class RtpHeaderParser { class RtpHeaderParser {
public: public:
static RtpHeaderParser* Create(); static std::unique_ptr<RtpHeaderParser> CreateForTest();
virtual ~RtpHeaderParser() {} virtual ~RtpHeaderParser() {}
// Returns true if the packet is an RTCP packet, false otherwise. // Returns true if the packet is an RTCP packet, false otherwise.
@ -48,4 +50,4 @@ class RtpHeaderParser {
virtual bool DeregisterRtpHeaderExtension(RtpExtension extension) = 0; virtual bool DeregisterRtpHeaderExtension(RtpExtension extension) = 0;
}; };
} // namespace webrtc } // namespace webrtc
#endif // MODULES_RTP_RTCP_INCLUDE_RTP_HEADER_PARSER_H_ #endif // TEST_RTP_HEADER_PARSER_H_

View File

@ -18,12 +18,12 @@
#include "api/test/simulated_network.h" #include "api/test/simulated_network.h"
#include "call/simulated_packet_receiver.h" #include "call/simulated_packet_receiver.h"
#include "call/video_send_stream.h" #include "call/video_send_stream.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/critical_section.h" #include "rtc_base/critical_section.h"
#include "rtc_base/event.h" #include "rtc_base/event.h"
#include "system_wrappers/include/field_trial.h" #include "system_wrappers/include/field_trial.h"
#include "test/direct_transport.h" #include "test/direct_transport.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "test/rtp_header_parser.h"
namespace { namespace {
const int kShortTimeoutMs = 500; const int kShortTimeoutMs = 500;
@ -71,7 +71,8 @@ class RtpRtcpObserver {
protected: protected:
RtpRtcpObserver() : RtpRtcpObserver(0) {} RtpRtcpObserver() : RtpRtcpObserver(0) {}
explicit RtpRtcpObserver(int event_timeout_ms) explicit RtpRtcpObserver(int event_timeout_ms)
: parser_(RtpHeaderParser::Create()), timeout_ms_(event_timeout_ms) {} : parser_(RtpHeaderParser::CreateForTest()),
timeout_ms_(event_timeout_ms) {}
rtc::Event observation_complete_; rtc::Event observation_complete_;
const std::unique_ptr<RtpHeaderParser> parser_; const std::unique_ptr<RtpHeaderParser> parser_;

View File

@ -76,6 +76,7 @@ if (rtc_include_tests) {
":column_printer", ":column_printer",
"../:fake_video_codecs", "../:fake_video_codecs",
"../:fileutils", "../:fileutils",
"../:rtp_test_utils",
"../:test_common", "../:test_common",
"../:test_support", "../:test_support",
"../:video_test_common", "../:video_test_common",

View File

@ -203,7 +203,7 @@ CallClient::CallClient(
clock_(time_controller->GetClock()), clock_(time_controller->GetClock()),
log_writer_factory_(std::move(log_writer_factory)), log_writer_factory_(std::move(log_writer_factory)),
network_controller_factory_(log_writer_factory_.get(), config.transport), network_controller_factory_(log_writer_factory_.get(), config.transport),
header_parser_(RtpHeaderParser::Create()), header_parser_(RtpHeaderParser::CreateForTest()),
task_queue_(time_controller->GetTaskQueueFactory()->CreateTaskQueue( task_queue_(time_controller->GetTaskQueueFactory()->CreateTaskQueue(
"CallClient", "CallClient",
TaskQueueFactory::Priority::NORMAL)) { TaskQueueFactory::Priority::NORMAL)) {

View File

@ -20,11 +20,11 @@
#include "call/call.h" #include "call/call.h"
#include "modules/audio_device/include/test_audio_device.h" #include "modules/audio_device/include/test_audio_device.h"
#include "modules/congestion_controller/goog_cc/test/goog_cc_printer.h" #include "modules/congestion_controller/goog_cc/test/goog_cc_printer.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
#include "rtc_base/task_queue_for_test.h" #include "rtc_base/task_queue_for_test.h"
#include "test/logging/log_writer.h" #include "test/logging/log_writer.h"
#include "test/network/network_emulation.h" #include "test/network/network_emulation.h"
#include "test/rtp_header_parser.h"
#include "test/scenario/column_printer.h" #include "test/scenario/column_printer.h"
#include "test/scenario/network_node.h" #include "test/scenario/network_node.h"
#include "test/scenario/scenario_config.h" #include "test/scenario/scenario_config.h"

View File

@ -611,7 +611,8 @@ TEST_F(StatsEndToEndTest, VerifyNackStats) {
Action OnSendRtp(const uint8_t* packet, size_t length) override { Action OnSendRtp(const uint8_t* packet, size_t length) override {
rtc::CritScope lock(&crit_); rtc::CritScope lock(&crit_);
if (++sent_rtp_packets_ == kPacketNumberToDrop) { if (++sent_rtp_packets_ == kPacketNumberToDrop) {
std::unique_ptr<RtpHeaderParser> parser(RtpHeaderParser::Create()); std::unique_ptr<RtpHeaderParser> parser(
RtpHeaderParser::CreateForTest());
RTPHeader header; RTPHeader header;
EXPECT_TRUE(parser->Parse(packet, length, &header)); EXPECT_TRUE(parser->Parse(packet, length, &header));
dropped_rtp_packet_ = header.sequenceNumber; dropped_rtp_packet_ = header.sequenceNumber;

View File

@ -50,7 +50,7 @@ TEST_F(TransportFeedbackEndToEndTest, AssignsTransportSequenceNumbers) {
BuiltInNetworkBehaviorConfig())), BuiltInNetworkBehaviorConfig())),
sender_call, sender_call,
payload_type_map), payload_type_map),
parser_(RtpHeaderParser::Create()), parser_(RtpHeaderParser::CreateForTest()),
first_media_ssrc_(first_media_ssrc), first_media_ssrc_(first_media_ssrc),
rtx_to_media_ssrcs_(ssrc_map), rtx_to_media_ssrcs_(ssrc_map),
padding_observed_(false), padding_observed_(false),

View File

@ -24,7 +24,6 @@
#include "call/rtp_transport_controller_send.h" #include "call/rtp_transport_controller_send.h"
#include "call/simulated_network.h" #include "call/simulated_network.h"
#include "call/video_send_stream.h" #include "call/video_send_stream.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/include/rtp_rtcp.h" #include "modules/rtp_rtcp/include/rtp_rtcp.h"
#include "modules/rtp_rtcp/source/rtcp_sender.h" #include "modules/rtp_rtcp/source/rtcp_sender.h"
#include "modules/rtp_rtcp/source/rtp_format_vp9.h" #include "modules/rtp_rtcp/source/rtp_format_vp9.h"
@ -53,6 +52,7 @@
#include "test/gtest.h" #include "test/gtest.h"
#include "test/null_transport.h" #include "test/null_transport.h"
#include "test/rtcp_packet_parser.h" #include "test/rtcp_packet_parser.h"
#include "test/rtp_header_parser.h"
#include "test/testsupport/perf_test.h" #include "test/testsupport/perf_test.h"
#include "test/video_encoder_proxy_factory.h" #include "test/video_encoder_proxy_factory.h"
#include "video/send_statistics_proxy.h" #include "video/send_statistics_proxy.h"