Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Addressed comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc
diff --git a/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..98027ded5dbc150ccbb2036f61dfb4e7674f9bb8
--- /dev/null
+++ b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 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 "webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h"
+
+#include "webrtc/base/checks.h"
+#include "webrtc/base/logging.h"
+#include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
+#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
danilchap 2016/05/25 19:08:48 includes in aplhabetical order: include < source
Irfan 2016/05/26 05:51:47 Done.
+
+namespace webrtc {
+
+PlayoutDelayOracle::PlayoutDelayOracle()
+ : high_sequence_number_(0),
+ min_playout_delay_ms_(-1),
+ max_playout_delay_ms_(-1),
+ ssrc_(0) {}
+PlayoutDelayOracle::~PlayoutDelayOracle() {}
+
+void PlayoutDelayOracle::UpdateRequest(uint32_t ssrc,
+ PlayoutDelay playout_delay,
+ uint16_t seq_num) {
+ RTC_DCHECK_LE(playout_delay.min_ms, kPlayoutDelayMaxMs);
+ RTC_DCHECK_LE(playout_delay.max_ms, kPlayoutDelayMaxMs);
+ int64_t unwrapped_seq_num = unwrapper_.Unwrap(seq_num);
+ if (playout_delay.min_ms >= 0 &&
+ playout_delay.min_ms != min_playout_delay_ms_) {
+ send_playout_delay_ = true;
+ min_playout_delay_ms_ = playout_delay.min_ms;
+ high_sequence_number_ = unwrapped_seq_num;
+ }
+
+ if (playout_delay.max_ms >= 0 &&
+ playout_delay.max_ms != max_playout_delay_ms_) {
+ send_playout_delay_ = true;
+ max_playout_delay_ms_ = playout_delay.max_ms;
+ high_sequence_number_ = unwrapped_seq_num;
+ }
+ ssrc_ = ssrc;
+}
+
+// If an ACK is received on the packet containing the playout delay extension,
+// we stop sending the extension on future packets.
+void PlayoutDelayOracle::OnReceivedRtcpReceiverReport(
+ const ReportBlockList& report_blocks) {
+ for (const RTCPReportBlock& report_block : report_blocks) {
+ if ((ssrc_ == report_block.sourceSSRC) && send_playout_delay_ &&
+ (report_block.extendedHighSeqNum > high_sequence_number_)) {
+ send_playout_delay_ = false;
+ }
+ }
+}
+
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698