OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 return true; | 67 return true; |
68 printf("Invalid value for --%s: %d\n", flagname, static_cast<int>(value)); | 68 printf("Invalid value for --%s: %d\n", flagname, static_cast<int>(value)); |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 bool ValidateSsrcValue(const char* flagname, const std::string& str) { | 72 bool ValidateSsrcValue(const char* flagname, const std::string& str) { |
73 uint32_t dummy_ssrc; | 73 uint32_t dummy_ssrc; |
74 return ParseSsrc(str, &dummy_ssrc); | 74 return ParseSsrc(str, &dummy_ssrc); |
75 } | 75 } |
76 | 76 |
77 static bool ValidateExtensionId(const char* flagname, int32_t value) { | |
78 if (value > 0 && value <= 255) // Value is ok. | |
79 return true; | |
80 printf("Invalid value for --%s: %d\n", flagname, static_cast<int>(value)); | |
ivoc
2016/08/24 15:06:07
The style guide says we should prefer cout over pr
hlundin-webrtc
2016/08/24 15:26:46
I'd rather keep the printf for consistency with th
| |
81 return false; | |
82 } | |
83 | |
77 // Define command line flags. | 84 // Define command line flags. |
78 DEFINE_int32(pcmu, 0, "RTP payload type for PCM-u"); | 85 DEFINE_int32(pcmu, 0, "RTP payload type for PCM-u"); |
79 const bool pcmu_dummy = | 86 const bool pcmu_dummy = |
80 google::RegisterFlagValidator(&FLAGS_pcmu, &ValidatePayloadType); | 87 google::RegisterFlagValidator(&FLAGS_pcmu, &ValidatePayloadType); |
81 DEFINE_int32(pcma, 8, "RTP payload type for PCM-a"); | 88 DEFINE_int32(pcma, 8, "RTP payload type for PCM-a"); |
82 const bool pcma_dummy = | 89 const bool pcma_dummy = |
83 google::RegisterFlagValidator(&FLAGS_pcma, &ValidatePayloadType); | 90 google::RegisterFlagValidator(&FLAGS_pcma, &ValidatePayloadType); |
84 DEFINE_int32(ilbc, 102, "RTP payload type for iLBC"); | 91 DEFINE_int32(ilbc, 102, "RTP payload type for iLBC"); |
85 const bool ilbc_dummy = | 92 const bool ilbc_dummy = |
86 google::RegisterFlagValidator(&FLAGS_ilbc, &ValidatePayloadType); | 93 google::RegisterFlagValidator(&FLAGS_ilbc, &ValidatePayloadType); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 DEFINE_bool(codec_map, false, "Prints the mapping between RTP payload type and " | 136 DEFINE_bool(codec_map, false, "Prints the mapping between RTP payload type and " |
130 "codec"); | 137 "codec"); |
131 DEFINE_string(replacement_audio_file, "", | 138 DEFINE_string(replacement_audio_file, "", |
132 "A PCM file that will be used to populate ""dummy"" RTP packets"); | 139 "A PCM file that will be used to populate ""dummy"" RTP packets"); |
133 DEFINE_string(ssrc, | 140 DEFINE_string(ssrc, |
134 "", | 141 "", |
135 "Only use packets with this SSRC (decimal or hex, the latter " | 142 "Only use packets with this SSRC (decimal or hex, the latter " |
136 "starting with 0x)"); | 143 "starting with 0x)"); |
137 const bool hex_ssrc_dummy = | 144 const bool hex_ssrc_dummy = |
138 google::RegisterFlagValidator(&FLAGS_ssrc, &ValidateSsrcValue); | 145 google::RegisterFlagValidator(&FLAGS_ssrc, &ValidateSsrcValue); |
146 DEFINE_int32(audio_level, 1, "Extension ID for audio level (RFC 6464)"); | |
147 const bool audio_level_dummy = | |
148 google::RegisterFlagValidator(&FLAGS_audio_level, &ValidateExtensionId); | |
149 DEFINE_int32(abs_send_time, 3, "Extension ID for absolute sender time"); | |
150 const bool abs_send_time_dummy = | |
151 google::RegisterFlagValidator(&FLAGS_abs_send_time, &ValidateExtensionId); | |
139 | 152 |
140 // Maps a codec type to a printable name string. | 153 // Maps a codec type to a printable name string. |
141 std::string CodecName(NetEqDecoder codec) { | 154 std::string CodecName(NetEqDecoder codec) { |
142 switch (codec) { | 155 switch (codec) { |
143 case NetEqDecoder::kDecoderPCMu: | 156 case NetEqDecoder::kDecoderPCMu: |
144 return "PCM-u"; | 157 return "PCM-u"; |
145 case NetEqDecoder::kDecoderPCMa: | 158 case NetEqDecoder::kDecoderPCMa: |
146 return "PCM-a"; | 159 return "PCM-a"; |
147 case NetEqDecoder::kDecoderILBC: | 160 case NetEqDecoder::kDecoderILBC: |
148 return "iLBC"; | 161 return "iLBC"; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
290 if (argc != 3) { | 303 if (argc != 3) { |
291 if (FLAGS_codec_map) { | 304 if (FLAGS_codec_map) { |
292 // We have already printed the codec map. Just end the program. | 305 // We have already printed the codec map. Just end the program. |
293 return 0; | 306 return 0; |
294 } | 307 } |
295 // Print usage information. | 308 // Print usage information. |
296 std::cout << google::ProgramUsage(); | 309 std::cout << google::ProgramUsage(); |
297 return 0; | 310 return 0; |
298 } | 311 } |
299 | 312 |
313 // Gather RTP header extensions in a map. | |
314 NetEqPacketSourceInput::RtpHeaderExtensionMap rtp_ext_map = { | |
315 {FLAGS_audio_level, kRtpExtensionAudioLevel}, | |
316 {FLAGS_abs_send_time, kRtpExtensionAbsoluteSendTime}}; | |
317 | |
300 const std::string input_file_name = argv[1]; | 318 const std::string input_file_name = argv[1]; |
301 std::unique_ptr<NetEqInput> input; | 319 std::unique_ptr<NetEqInput> input; |
302 if (RtpFileSource::ValidRtpDump(input_file_name) || | 320 if (RtpFileSource::ValidRtpDump(input_file_name) || |
303 RtpFileSource::ValidPcap(input_file_name)) { | 321 RtpFileSource::ValidPcap(input_file_name)) { |
304 input.reset(new NetEqRtpDumpInput(input_file_name)); | 322 input.reset(new NetEqRtpDumpInput(input_file_name, rtp_ext_map)); |
305 } else { | 323 } else { |
306 input.reset(new NetEqEventLogInput(input_file_name)); | 324 input.reset(new NetEqEventLogInput(input_file_name, rtp_ext_map)); |
307 } | 325 } |
308 | 326 |
309 std::cout << "Input file: " << input_file_name << std::endl; | 327 std::cout << "Input file: " << input_file_name << std::endl; |
310 RTC_CHECK(input) << "Cannot open input file"; | 328 RTC_CHECK(input) << "Cannot open input file"; |
311 RTC_CHECK(!input->ended()) << "Input file is empty"; | 329 RTC_CHECK(!input->ended()) << "Input file is empty"; |
312 | 330 |
313 // Check if an SSRC value was provided. | 331 // Check if an SSRC value was provided. |
314 if (!FLAGS_ssrc.empty()) { | 332 if (!FLAGS_ssrc.empty()) { |
315 uint32_t ssrc; | 333 uint32_t ssrc; |
316 RTC_CHECK(ParseSsrc(FLAGS_ssrc, &ssrc)) << "Flag verification has failed."; | 334 RTC_CHECK(ParseSsrc(FLAGS_ssrc, &ssrc)) << "Flag verification has failed."; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 return 0; | 449 return 0; |
432 } | 450 } |
433 | 451 |
434 } // namespace | 452 } // namespace |
435 } // namespace test | 453 } // namespace test |
436 } // namespace webrtc | 454 } // namespace webrtc |
437 | 455 |
438 int main(int argc, char* argv[]) { | 456 int main(int argc, char* argv[]) { |
439 webrtc::test::RunTest(argc, argv); | 457 webrtc::test::RunTest(argc, argv); |
440 } | 458 } |
OLD | NEW |