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:
@ -20,8 +20,8 @@
|
||||
#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_single_stream.h"
|
||||
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
|
||||
#include "test/rtp_file_reader.h"
|
||||
#include "test/rtp_header_parser.h"
|
||||
|
||||
ABSL_FLAG(std::string,
|
||||
extension_type,
|
||||
@ -65,14 +65,14 @@ std::set<uint32_t> SsrcFilter() {
|
||||
return ssrcs;
|
||||
}
|
||||
|
||||
bool ParseArgsAndSetupEstimator(int argc,
|
||||
char** argv,
|
||||
webrtc::Clock* clock,
|
||||
webrtc::RemoteBitrateObserver* observer,
|
||||
webrtc::test::RtpFileReader** rtp_reader,
|
||||
webrtc::RtpHeaderParser** parser,
|
||||
webrtc::RemoteBitrateEstimator** estimator,
|
||||
std::string* estimator_used) {
|
||||
std::unique_ptr<webrtc::RtpHeaderParser> ParseArgsAndSetupEstimator(
|
||||
int argc,
|
||||
char** argv,
|
||||
webrtc::Clock* clock,
|
||||
webrtc::RemoteBitrateObserver* observer,
|
||||
std::unique_ptr<webrtc::test::RtpFileReader>* rtp_reader,
|
||||
std::unique_ptr<webrtc::RemoteBitrateEstimator>* estimator,
|
||||
std::string* estimator_used) {
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
std::string filename = InputFile();
|
||||
|
||||
@ -84,16 +84,16 @@ bool ParseArgsAndSetupEstimator(int argc,
|
||||
fprintf(stderr, "\n");
|
||||
if (filename.substr(filename.find_last_of('.')) == ".pcap") {
|
||||
fprintf(stderr, "Opening as pcap\n");
|
||||
*rtp_reader = webrtc::test::RtpFileReader::Create(
|
||||
webrtc::test::RtpFileReader::kPcap, filename.c_str(), SsrcFilter());
|
||||
rtp_reader->reset(webrtc::test::RtpFileReader::Create(
|
||||
webrtc::test::RtpFileReader::kPcap, filename.c_str(), SsrcFilter()));
|
||||
} else {
|
||||
fprintf(stderr, "Opening as rtp\n");
|
||||
*rtp_reader = webrtc::test::RtpFileReader::Create(
|
||||
webrtc::test::RtpFileReader::kRtpDump, filename.c_str());
|
||||
rtp_reader->reset(webrtc::test::RtpFileReader::Create(
|
||||
webrtc::test::RtpFileReader::kRtpDump, filename.c_str()));
|
||||
}
|
||||
if (!*rtp_reader) {
|
||||
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());
|
||||
|
||||
@ -105,29 +105,31 @@ bool ParseArgsAndSetupEstimator(int argc,
|
||||
fprintf(stderr, "Extension: abs\n");
|
||||
} else {
|
||||
fprintf(stderr, "Unknown extension type\n");
|
||||
return false;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Setup the RTP header parser and the bitrate estimator.
|
||||
*parser = webrtc::RtpHeaderParser::Create();
|
||||
(*parser)->RegisterRtpHeaderExtension(extension, ExtensionId());
|
||||
auto parser = webrtc::RtpHeaderParser::CreateForTest();
|
||||
parser->RegisterRtpHeaderExtension(extension, ExtensionId());
|
||||
if (estimator) {
|
||||
switch (extension) {
|
||||
case webrtc::kRtpExtensionAbsoluteSendTime: {
|
||||
*estimator =
|
||||
new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock);
|
||||
estimator->reset(
|
||||
new webrtc::RemoteBitrateEstimatorAbsSendTime(observer, clock));
|
||||
*estimator_used = "AbsoluteSendTimeRemoteBitrateEstimator";
|
||||
break;
|
||||
}
|
||||
case webrtc::kRtpExtensionTransmissionTimeOffset: {
|
||||
*estimator =
|
||||
new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock);
|
||||
estimator->reset(
|
||||
new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock));
|
||||
*estimator_used = "RemoteBitrateEstimator";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#ifndef MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
|
||||
#define MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace webrtc {
|
||||
@ -23,13 +24,13 @@ class RtpFileReader;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
bool ParseArgsAndSetupEstimator(int argc,
|
||||
char** argv,
|
||||
webrtc::Clock* clock,
|
||||
webrtc::RemoteBitrateObserver* observer,
|
||||
webrtc::test::RtpFileReader** rtp_reader,
|
||||
webrtc::RtpHeaderParser** parser,
|
||||
webrtc::RemoteBitrateEstimator** estimator,
|
||||
std::string* estimator_used);
|
||||
std::unique_ptr<webrtc::RtpHeaderParser> ParseArgsAndSetupEstimator(
|
||||
int argc,
|
||||
char** argv,
|
||||
webrtc::Clock* clock,
|
||||
webrtc::RemoteBitrateObserver* observer,
|
||||
std::unique_ptr<webrtc::test::RtpFileReader>* rtp_reader,
|
||||
std::unique_ptr<webrtc::RemoteBitrateEstimator>* estimator,
|
||||
std::string* estimator_used);
|
||||
|
||||
#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TOOLS_BWE_RTP_H_
|
||||
|
||||
@ -13,21 +13,20 @@
|
||||
#include <memory>
|
||||
|
||||
#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/strings/string_builder.h"
|
||||
#include "test/rtp_file_reader.h"
|
||||
#include "test/rtp_header_parser.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
webrtc::test::RtpFileReader* reader;
|
||||
webrtc::RtpHeaderParser* parser;
|
||||
if (!ParseArgsAndSetupEstimator(argc, argv, NULL, NULL, &reader, &parser,
|
||||
NULL, NULL)) {
|
||||
std::unique_ptr<webrtc::test::RtpFileReader> reader;
|
||||
std::unique_ptr<webrtc::RtpHeaderParser> parser(ParseArgsAndSetupEstimator(
|
||||
argc, argv, nullptr, nullptr, &reader, nullptr, nullptr));
|
||||
if (!parser)
|
||||
return -1;
|
||||
}
|
||||
|
||||
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,
|
||||
"seqnum timestamp ts_offset abs_sendtime recvtime "
|
||||
"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_ts_offsets = 0;
|
||||
webrtc::test::RtpPacket packet;
|
||||
while (rtp_reader->NextPacket(&packet)) {
|
||||
while (reader->NextPacket(&packet)) {
|
||||
webrtc::RTPHeader header;
|
||||
parser->Parse(packet.data, packet.length, &header);
|
||||
if (header.extension.absoluteSendTime != 0)
|
||||
|
||||
Reference in New Issue
Block a user