Make neteq_rtpplay parse RTP header extensions
This removes the warning printouts about unknown header extensions. BUG=webrtc:2692 Review-Url: https://codereview.webrtc.org/2266403005 Cr-Commit-Position: refs/heads/master@{#13912}
This commit is contained in:
committed by
Commit bot
parent
5f09980bb5
commit
8a6a600c16
@ -60,8 +60,12 @@ std::unique_ptr<NetEqInput::PacketData> NetEqPacketSourceInput::PopPacket() {
|
||||
return packet_data;
|
||||
}
|
||||
|
||||
NetEqRtpDumpInput::NetEqRtpDumpInput(const std::string& file_name)
|
||||
NetEqRtpDumpInput::NetEqRtpDumpInput(const std::string& file_name,
|
||||
const RtpHeaderExtensionMap& hdr_ext_map)
|
||||
: source_(RtpFileSource::Create(file_name)) {
|
||||
for (const auto& ext_pair : hdr_ext_map) {
|
||||
source_->RegisterRtpHeaderExtension(ext_pair.second, ext_pair.first);
|
||||
}
|
||||
LoadNextPacket();
|
||||
}
|
||||
|
||||
@ -82,8 +86,12 @@ PacketSource* NetEqRtpDumpInput::source() {
|
||||
return source_.get();
|
||||
}
|
||||
|
||||
NetEqEventLogInput::NetEqEventLogInput(const std::string& file_name)
|
||||
NetEqEventLogInput::NetEqEventLogInput(const std::string& file_name,
|
||||
const RtpHeaderExtensionMap& hdr_ext_map)
|
||||
: source_(RtcEventLogSource::Create(file_name)) {
|
||||
for (const auto& ext_pair : hdr_ext_map) {
|
||||
source_->RegisterRtpHeaderExtension(ext_pair.second, ext_pair.first);
|
||||
}
|
||||
LoadNextPacket();
|
||||
AdvanceOutputEvent();
|
||||
}
|
||||
|
||||
@ -11,9 +11,11 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_PACKET_SOURCE_INPUT_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_PACKET_SOURCE_INPUT_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
@ -24,6 +26,8 @@ class RtcEventLogSource;
|
||||
// An adapter class to dress up a PacketSource object as a NetEqInput.
|
||||
class NetEqPacketSourceInput : public NetEqInput {
|
||||
public:
|
||||
using RtpHeaderExtensionMap = std::map<int, webrtc::RTPExtensionType>;
|
||||
|
||||
NetEqPacketSourceInput();
|
||||
rtc::Optional<int64_t> NextPacketTime() const override;
|
||||
std::unique_ptr<PacketData> PopPacket() override;
|
||||
@ -43,7 +47,8 @@ class NetEqPacketSourceInput : public NetEqInput {
|
||||
// Implementation of NetEqPacketSourceInput to be used with an RtpFileSource.
|
||||
class NetEqRtpDumpInput final : public NetEqPacketSourceInput {
|
||||
public:
|
||||
explicit NetEqRtpDumpInput(const std::string& file_name);
|
||||
NetEqRtpDumpInput(const std::string& file_name,
|
||||
const RtpHeaderExtensionMap& hdr_ext_map);
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
void AdvanceOutputEvent() override;
|
||||
@ -61,7 +66,8 @@ class NetEqRtpDumpInput final : public NetEqPacketSourceInput {
|
||||
// RtcEventLogSource.
|
||||
class NetEqEventLogInput final : public NetEqPacketSourceInput {
|
||||
public:
|
||||
explicit NetEqEventLogInput(const std::string& file_name);
|
||||
NetEqEventLogInput(const std::string& file_name,
|
||||
const RtpHeaderExtensionMap& hdr_ext_map);
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
void AdvanceOutputEvent() override;
|
||||
|
||||
@ -74,6 +74,13 @@ bool ValidateSsrcValue(const char* flagname, const std::string& str) {
|
||||
return ParseSsrc(str, &dummy_ssrc);
|
||||
}
|
||||
|
||||
static bool ValidateExtensionId(const char* flagname, int32_t value) {
|
||||
if (value > 0 && value <= 255) // Value is ok.
|
||||
return true;
|
||||
printf("Invalid value for --%s: %d\n", flagname, static_cast<int>(value));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Define command line flags.
|
||||
DEFINE_int32(pcmu, 0, "RTP payload type for PCM-u");
|
||||
const bool pcmu_dummy =
|
||||
@ -136,6 +143,12 @@ DEFINE_string(ssrc,
|
||||
"starting with 0x)");
|
||||
const bool hex_ssrc_dummy =
|
||||
google::RegisterFlagValidator(&FLAGS_ssrc, &ValidateSsrcValue);
|
||||
DEFINE_int32(audio_level, 1, "Extension ID for audio level (RFC 6464)");
|
||||
const bool audio_level_dummy =
|
||||
google::RegisterFlagValidator(&FLAGS_audio_level, &ValidateExtensionId);
|
||||
DEFINE_int32(abs_send_time, 3, "Extension ID for absolute sender time");
|
||||
const bool abs_send_time_dummy =
|
||||
google::RegisterFlagValidator(&FLAGS_abs_send_time, &ValidateExtensionId);
|
||||
|
||||
// Maps a codec type to a printable name string.
|
||||
std::string CodecName(NetEqDecoder codec) {
|
||||
@ -297,13 +310,18 @@ int RunTest(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Gather RTP header extensions in a map.
|
||||
NetEqPacketSourceInput::RtpHeaderExtensionMap rtp_ext_map = {
|
||||
{FLAGS_audio_level, kRtpExtensionAudioLevel},
|
||||
{FLAGS_abs_send_time, kRtpExtensionAbsoluteSendTime}};
|
||||
|
||||
const std::string input_file_name = argv[1];
|
||||
std::unique_ptr<NetEqInput> input;
|
||||
if (RtpFileSource::ValidRtpDump(input_file_name) ||
|
||||
RtpFileSource::ValidPcap(input_file_name)) {
|
||||
input.reset(new NetEqRtpDumpInput(input_file_name));
|
||||
input.reset(new NetEqRtpDumpInput(input_file_name, rtp_ext_map));
|
||||
} else {
|
||||
input.reset(new NetEqEventLogInput(input_file_name));
|
||||
input.reset(new NetEqEventLogInput(input_file_name, rtp_ext_map));
|
||||
}
|
||||
|
||||
std::cout << "Input file: " << input_file_name << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user