| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| 11 #include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h" |
| 12 | 12 |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 | 14 |
| 15 #include <set> | 15 #include <set> |
| 16 #include <sstream> | 16 #include <sstream> |
| 17 #include <string> | 17 #include <string> |
| 18 | 18 |
| 19 #include "gflags/gflags.h" | |
| 20 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" | 19 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" |
| 21 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" | 20 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" |
| 22 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 21 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
| 23 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" | 22 #include "webrtc/modules/rtp_rtcp/include/rtp_payload_registry.h" |
| 23 #include "webrtc/rtc_base/flags.h" |
| 24 #include "webrtc/test/rtp_file_reader.h" | 24 #include "webrtc/test/rtp_file_reader.h" |
| 25 | 25 |
| 26 namespace flags { | 26 namespace flags { |
| 27 | 27 |
| 28 DEFINE_string(extension_type, | 28 DEFINE_string(extension_type, |
| 29 "abs", | 29 "abs", |
| 30 "Extension type, either abs for absolute send time or tsoffset " | 30 "Extension type, either abs for absolute send time or tsoffset " |
| 31 "for timestamp offset."); | 31 "for timestamp offset."); |
| 32 std::string ExtensionType() { | 32 std::string ExtensionType() { |
| 33 return static_cast<std::string>(FLAGS_extension_type); | 33 return static_cast<std::string>(FLAG_extension_type); |
| 34 } | 34 } |
| 35 | 35 |
| 36 DEFINE_int32(extension_id, 3, "Extension id."); | 36 DEFINE_int(extension_id, 3, "Extension id."); |
| 37 int ExtensionId() { | 37 int ExtensionId() { |
| 38 return static_cast<int>(FLAGS_extension_id); | 38 return static_cast<int>(FLAG_extension_id); |
| 39 } | 39 } |
| 40 | 40 |
| 41 DEFINE_string(input_file, "", "Input file."); | 41 DEFINE_string(input_file, "", "Input file."); |
| 42 std::string InputFile() { | 42 std::string InputFile() { |
| 43 return static_cast<std::string>(FLAGS_input_file); | 43 return static_cast<std::string>(FLAG_input_file); |
| 44 } | 44 } |
| 45 | 45 |
| 46 DEFINE_string(ssrc_filter, | 46 DEFINE_string(ssrc_filter, |
| 47 "", | 47 "", |
| 48 "Comma-separated list of SSRCs in hexadecimal which are to be " | 48 "Comma-separated list of SSRCs in hexadecimal which are to be " |
| 49 "used as input to the BWE (only applicable to pcap files)."); | 49 "used as input to the BWE (only applicable to pcap files)."); |
| 50 std::set<uint32_t> SsrcFilter() { | 50 std::set<uint32_t> SsrcFilter() { |
| 51 std::string ssrc_filter_string = static_cast<std::string>(FLAGS_ssrc_filter); | 51 std::string ssrc_filter_string = static_cast<std::string>(FLAG_ssrc_filter); |
| 52 if (ssrc_filter_string.empty()) | 52 if (ssrc_filter_string.empty()) |
| 53 return std::set<uint32_t>(); | 53 return std::set<uint32_t>(); |
| 54 std::stringstream ss; | 54 std::stringstream ss; |
| 55 std::string ssrc_filter = ssrc_filter_string; | 55 std::string ssrc_filter = ssrc_filter_string; |
| 56 std::set<uint32_t> ssrcs; | 56 std::set<uint32_t> ssrcs; |
| 57 | 57 |
| 58 // Parse the ssrcs in hexadecimal format. | 58 // Parse the ssrcs in hexadecimal format. |
| 59 ss << std::hex << ssrc_filter; | 59 ss << std::hex << ssrc_filter; |
| 60 uint32_t ssrc; | 60 uint32_t ssrc; |
| 61 while (ss >> ssrc) { | 61 while (ss >> ssrc) { |
| 62 ssrcs.insert(ssrc); | 62 ssrcs.insert(ssrc); |
| 63 ss.ignore(1, ','); | 63 ss.ignore(1, ','); |
| 64 } | 64 } |
| 65 return ssrcs; | 65 return ssrcs; |
| 66 } | 66 } |
| 67 |
| 68 DEFINE_bool(help, false, "Print this message."); |
| 67 } // namespace flags | 69 } // namespace flags |
| 68 | 70 |
| 69 bool ParseArgsAndSetupEstimator(int argc, | 71 bool ParseArgsAndSetupEstimator(int argc, |
| 70 char** argv, | 72 char** argv, |
| 71 webrtc::Clock* clock, | 73 webrtc::Clock* clock, |
| 72 webrtc::RemoteBitrateObserver* observer, | 74 webrtc::RemoteBitrateObserver* observer, |
| 73 webrtc::test::RtpFileReader** rtp_reader, | 75 webrtc::test::RtpFileReader** rtp_reader, |
| 74 webrtc::RtpHeaderParser** parser, | 76 webrtc::RtpHeaderParser** parser, |
| 75 webrtc::RemoteBitrateEstimator** estimator, | 77 webrtc::RemoteBitrateEstimator** estimator, |
| 76 std::string* estimator_used) { | 78 std::string* estimator_used) { |
| 77 google::ParseCommandLineFlags(&argc, &argv, true); | 79 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) { |
| 80 return 1; |
| 81 } |
| 82 if (FLAG_help) { |
| 83 rtc::FlagList::Print(nullptr, false); |
| 84 return 0; |
| 85 } |
| 78 std::string filename = flags::InputFile(); | 86 std::string filename = flags::InputFile(); |
| 79 | 87 |
| 80 std::set<uint32_t> ssrc_filter = flags::SsrcFilter(); | 88 std::set<uint32_t> ssrc_filter = flags::SsrcFilter(); |
| 81 fprintf(stderr, "Filter on SSRC: "); | 89 fprintf(stderr, "Filter on SSRC: "); |
| 82 for (auto& s : ssrc_filter) { | 90 for (auto& s : ssrc_filter) { |
| 83 fprintf(stderr, "0x%08x, ", s); | 91 fprintf(stderr, "0x%08x, ", s); |
| 84 } | 92 } |
| 85 fprintf(stderr, "\n"); | 93 fprintf(stderr, "\n"); |
| 86 if (filename.substr(filename.find_last_of(".")) == ".pcap") { | 94 if (filename.substr(filename.find_last_of(".")) == ".pcap") { |
| 87 fprintf(stderr, "Opening as pcap\n"); | 95 fprintf(stderr, "Opening as pcap\n"); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock); | 134 new webrtc::RemoteBitrateEstimatorSingleStream(observer, clock); |
| 127 *estimator_used = "RemoteBitrateEstimator"; | 135 *estimator_used = "RemoteBitrateEstimator"; |
| 128 break; | 136 break; |
| 129 } | 137 } |
| 130 default: | 138 default: |
| 131 assert(false); | 139 assert(false); |
| 132 } | 140 } |
| 133 } | 141 } |
| 134 return true; | 142 return true; |
| 135 } | 143 } |
| OLD | NEW |