aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
diff options
context:
space:
mode:
authorChih-hung Hsieh <chh@google.com>2015-12-01 17:07:48 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-12-01 17:07:48 +0000
commita4acd9d6bc9b3b033d7d274316e75ee067df8d20 (patch)
tree672a185b294789cf991f385c3e395dd63bea9063 /webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
parent3681b90ba4fe7a27232dd3e27897d5d7ed9d651c (diff)
parentfe8b4a657979b49e1701bd92f6d5814a99e0b2be (diff)
downloadwebrtc-a4acd9d6bc9b3b033d7d274316e75ee067df8d20.tar.gz
Merge changes I7bbf776e,I1b827825
am: fe8b4a6579 * commit 'fe8b4a657979b49e1701bd92f6d5814a99e0b2be': (7237 commits) WIP: Changes after merge commit 'cb3f9bd' Make the nonlinear beamformer steerable Utilize bitrate above codec max to protect video. Enable VP9 internal resize by default. Filter overlapping RTP header extensions. Make VCMEncodedFrameCallback const. MediaCodecVideoEncoder: Add number of quality resolution downscales to Encoded callback. Remove redudant encoder rate calls. Create isolate files for nonparallel tests. Register header extensions in RtpRtcpObserver to avoid log spam. Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table ACM: Move NACK functionality inside NetEq Fix chromium-style warnings in webrtc/sound/. Create a 'webrtc_nonparallel_tests' target. Update scalability structure data according to updates in the RTP payload profile. audio_coding: rename interface -> include Rewrote perform_action_on_all_files to be parallell. Update reference indices according to updates in the RTP payload profile. Disable P2PTransport...TestFailoverControlledSide on Memcheck pass clangcl compile options to ignore warnings in gflags.cc ...
Diffstat (limited to 'webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc')
-rw-r--r--webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc113
1 files changed, 113 insertions, 0 deletions
diff --git a/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
new file mode 100644
index 0000000000..19e4a07b4d
--- /dev/null
+++ b/webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp_play.cc
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include <stdio.h>
+
+#include "webrtc/base/format_macros.h"
+#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
+#include "webrtc/modules/remote_bitrate_estimator/tools/bwe_rtp.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h"
+#include "webrtc/modules/rtp_rtcp/interface/rtp_payload_registry.h"
+#include "webrtc/test/rtp_file_reader.h"
+
+class Observer : public webrtc::RemoteBitrateObserver {
+ public:
+ explicit Observer(webrtc::Clock* clock) : clock_(clock) {}
+
+ // Called when a receive channel group has a new bitrate estimate for the
+ // incoming streams.
+ virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
+ unsigned int bitrate) {
+ printf("[%u] Num SSRCs: %d, bitrate: %u\n",
+ static_cast<uint32_t>(clock_->TimeInMilliseconds()),
+ static_cast<int>(ssrcs.size()), bitrate);
+ }
+
+ virtual ~Observer() {}
+
+ private:
+ webrtc::Clock* clock_;
+};
+
+int main(int argc, char** argv) {
+ webrtc::test::RtpFileReader* reader;
+ webrtc::RemoteBitrateEstimator* estimator;
+ webrtc::RtpHeaderParser* parser;
+ std::string estimator_used;
+ webrtc::SimulatedClock clock(0);
+ Observer observer(&clock);
+ if (!ParseArgsAndSetupEstimator(argc, argv, &clock, &observer, &reader,
+ &parser, &estimator, &estimator_used)) {
+ return -1;
+ }
+ rtc::scoped_ptr<webrtc::test::RtpFileReader> rtp_reader(reader);
+ rtc::scoped_ptr<webrtc::RtpHeaderParser> rtp_parser(parser);
+ rtc::scoped_ptr<webrtc::RemoteBitrateEstimator> rbe(estimator);
+
+ // Process the file.
+ int packet_counter = 0;
+ int64_t next_rtp_time_ms = 0;
+ int64_t first_rtp_time_ms = -1;
+ int abs_send_time_count = 0;
+ int ts_offset_count = 0;
+ webrtc::test::RtpPacket packet;
+ if (!rtp_reader->NextPacket(&packet)) {
+ printf("No RTP packet found\n");
+ return 0;
+ }
+ first_rtp_time_ms = packet.time_ms;
+ packet.time_ms = packet.time_ms - first_rtp_time_ms;
+ while (true) {
+ if (next_rtp_time_ms <= clock.TimeInMilliseconds()) {
+ if (!parser->IsRtcp(packet.data, packet.length)) {
+ webrtc::RTPHeader header;
+ parser->Parse(packet.data, packet.length, &header);
+ if (header.extension.hasAbsoluteSendTime)
+ ++abs_send_time_count;
+ if (header.extension.hasTransmissionTimeOffset)
+ ++ts_offset_count;
+ size_t packet_length = packet.length;
+ // Some RTP dumps only include the header, in which case packet.length
+ // is equal to the header length. In those cases packet.original_length
+ // usually contains the original packet length.
+ if (packet.original_length > 0) {
+ packet_length = packet.original_length;
+ }
+ rbe->IncomingPacket(clock.TimeInMilliseconds(),
+ packet_length - header.headerLength, header, true);
+ ++packet_counter;
+ }
+ if (!rtp_reader->NextPacket(&packet)) {
+ break;
+ }
+ packet.time_ms = packet.time_ms - first_rtp_time_ms;
+ next_rtp_time_ms = packet.time_ms;
+ }
+ int64_t time_until_process_ms = rbe->TimeUntilNextProcess();
+ if (time_until_process_ms <= 0) {
+ rbe->Process();
+ }
+ int64_t time_until_next_event =
+ std::min(rbe->TimeUntilNextProcess(),
+ next_rtp_time_ms - clock.TimeInMilliseconds());
+ clock.AdvanceTimeMilliseconds(std::max<int64_t>(time_until_next_event, 0));
+ }
+ printf("Parsed %d packets\nTime passed: %" PRId64 " ms\n", packet_counter,
+ clock.TimeInMilliseconds());
+ printf("Estimator used: %s\n", estimator_used.c_str());
+ printf("Packets with absolute send time: %d\n",
+ abs_send_time_count);
+ printf("Packets with timestamp offset: %d\n",
+ ts_offset_count);
+ printf("Packets with no extension: %d\n",
+ packet_counter - ts_offset_count - abs_send_time_count);
+ return 0;
+}