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 |
(...skipping 20 matching lines...) Expand all Loading... |
31 static_cast<int>(ssrcs.size()), bitrate); | 31 static_cast<int>(ssrcs.size()), bitrate); |
32 } | 32 } |
33 | 33 |
34 virtual ~Observer() {} | 34 virtual ~Observer() {} |
35 | 35 |
36 private: | 36 private: |
37 webrtc::Clock* clock_; | 37 webrtc::Clock* clock_; |
38 }; | 38 }; |
39 | 39 |
40 int main(int argc, char** argv) { | 40 int main(int argc, char** argv) { |
41 if (argc < 4) { | |
42 printf("Usage: bwe_rtp_play <extension type> <extension id> " | |
43 "<input_file.rtp>\n"); | |
44 printf("<extension type> can either be:\n" | |
45 " abs for absolute send time or\n" | |
46 " tsoffset for timestamp offset.\n" | |
47 "<extension id> is the id associated with the extension.\n"); | |
48 return -1; | |
49 } | |
50 webrtc::test::RtpFileReader* reader; | 41 webrtc::test::RtpFileReader* reader; |
51 webrtc::RemoteBitrateEstimator* estimator; | 42 webrtc::RemoteBitrateEstimator* estimator; |
52 webrtc::RtpHeaderParser* parser; | 43 webrtc::RtpHeaderParser* parser; |
53 std::string estimator_used; | 44 std::string estimator_used; |
54 webrtc::SimulatedClock clock(0); | 45 webrtc::SimulatedClock clock(0); |
55 Observer observer(&clock); | 46 Observer observer(&clock); |
56 if (!ParseArgsAndSetupEstimator(argc, argv, &clock, &observer, &reader, | 47 if (!ParseArgsAndSetupEstimator(argc, argv, &clock, &observer, &reader, |
57 &parser, &estimator, &estimator_used)) { | 48 &parser, &estimator, &estimator_used)) { |
58 return -1; | 49 return -1; |
59 } | 50 } |
60 rtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(reader); | 51 rtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(reader); |
61 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser(parser); | 52 rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser(parser); |
62 rtc::scoped_ptr<webrtc::RemoteBitrateEstimator> rbe(estimator); | 53 rtc::scoped_ptr<webrtc::RemoteBitrateEstimator> rbe(estimator); |
63 | 54 |
64 // Process the file. | 55 // Process the file. |
65 int packet_counter = 0; | 56 int packet_counter = 0; |
66 int64_t next_rtp_time_ms = 0; | 57 int64_t next_rtp_time_ms = 0; |
67 int64_t first_rtp_time_ms = -1; | 58 int64_t first_rtp_time_ms = -1; |
68 int abs_send_time_count = 0; | 59 int abs_send_time_count = 0; |
69 int ts_offset_count = 0; | 60 int ts_offset_count = 0; |
70 webrtc::test::RtpPacket packet; | 61 webrtc::test::RtpPacket packet; |
71 if (!rtp_reader->NextPacket(&packet)) { | 62 if (!rtp_reader->NextPacket(&packet)) { |
72 printf("No RTP packet found\n"); | 63 printf("No RTP packet found\n"); |
73 return 0; | 64 return 0; |
74 } | 65 } |
75 first_rtp_time_ms = packet.time_ms; | 66 first_rtp_time_ms = packet.time_ms; |
76 packet.time_ms = packet.time_ms - first_rtp_time_ms; | 67 packet.time_ms = packet.time_ms - first_rtp_time_ms; |
77 while (true) { | 68 while (true) { |
78 if (next_rtp_time_ms <= clock.TimeInMilliseconds()) { | 69 if (next_rtp_time_ms <= clock.TimeInMilliseconds()) { |
79 webrtc::RTPHeader header; | 70 if (!parser->IsRtcp(packet.data, packet.length)) { |
80 parser->Parse(packet.data, packet.length, &header); | 71 webrtc::RTPHeader header; |
81 if (header.extension.hasAbsoluteSendTime) | 72 parser->Parse(packet.data, packet.length, &header); |
82 ++abs_send_time_count; | 73 if (header.extension.hasAbsoluteSendTime) |
83 if (header.extension.hasTransmissionTimeOffset) | 74 ++abs_send_time_count; |
84 ++ts_offset_count; | 75 if (header.extension.hasTransmissionTimeOffset) |
85 size_t packet_length = packet.length; | 76 ++ts_offset_count; |
86 // Some RTP dumps only include the header, in which case packet.length | 77 size_t packet_length = packet.length; |
87 // is equal to the header length. In those cases packet.original_length | 78 // Some RTP dumps only include the header, in which case packet.length |
88 // usually contains the original packet length. | 79 // is equal to the header length. In those cases packet.original_length |
89 if (packet.original_length > 0) { | 80 // usually contains the original packet length. |
90 packet_length = packet.original_length; | 81 if (packet.original_length > 0) { |
| 82 packet_length = packet.original_length; |
| 83 } |
| 84 rbe->IncomingPacket(clock.TimeInMilliseconds(), |
| 85 packet_length - header.headerLength, header, true); |
| 86 ++packet_counter; |
91 } | 87 } |
92 rbe->IncomingPacket(clock.TimeInMilliseconds(), | |
93 packet_length - header.headerLength, header, true); | |
94 ++packet_counter; | |
95 if (!rtp_reader->NextPacket(&packet)) { | 88 if (!rtp_reader->NextPacket(&packet)) { |
96 break; | 89 break; |
97 } | 90 } |
98 packet.time_ms = packet.time_ms - first_rtp_time_ms; | 91 packet.time_ms = packet.time_ms - first_rtp_time_ms; |
99 next_rtp_time_ms = packet.time_ms; | 92 next_rtp_time_ms = packet.time_ms; |
100 } | 93 } |
101 int64_t time_until_process_ms = rbe->TimeUntilNextProcess(); | 94 int64_t time_until_process_ms = rbe->TimeUntilNextProcess(); |
102 if (time_until_process_ms <= 0) { | 95 if (time_until_process_ms <= 0) { |
103 rbe->Process(); | 96 rbe->Process(); |
104 } | 97 } |
105 int64_t time_until_next_event = | 98 int64_t time_until_next_event = |
106 std::min(rbe->TimeUntilNextProcess(), | 99 std::min(rbe->TimeUntilNextProcess(), |
107 next_rtp_time_ms - clock.TimeInMilliseconds()); | 100 next_rtp_time_ms - clock.TimeInMilliseconds()); |
108 clock.AdvanceTimeMilliseconds(std::max<int64_t>(time_until_next_event, 0)); | 101 clock.AdvanceTimeMilliseconds(std::max<int64_t>(time_until_next_event, 0)); |
109 } | 102 } |
110 printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter, | 103 printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter, |
111 clock.TimeInMilliseconds()); | 104 clock.TimeInMilliseconds()); |
112 printf("Estimator used: %s\n", estimator_used.c_str()); | 105 printf("Estimator used: %s\n", estimator_used.c_str()); |
113 printf("Packets with absolute send time: %d\n", | 106 printf("Packets with absolute send time: %d\n", |
114 abs_send_time_count); | 107 abs_send_time_count); |
115 printf("Packets with timestamp offset: %d\n", | 108 printf("Packets with timestamp offset: %d\n", |
116 ts_offset_count); | 109 ts_offset_count); |
117 printf("Packets with no extension: %d\n", | 110 printf("Packets with no extension: %d\n", |
118 packet_counter - ts_offset_count - abs_send_time_count); | 111 packet_counter - ts_offset_count - abs_send_time_count); |
119 return 0; | 112 return 0; |
120 } | 113 } |
OLD | NEW |