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

Side by Side 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: Rename OnReceivedRtcpReport to OnReceivedRtcpReportBlocks Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "webrtc/modules/rtp_rtcp/source/playout_delay_oracle.h"
12
13 #include "webrtc/base/checks.h"
14 #include "webrtc/base/logging.h"
15 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
17
18 namespace webrtc {
19
20 PlayoutDelayOracle::PlayoutDelayOracle()
21 : high_sequence_number_(0),
22 send_playout_delay_(false),
23 ssrc_(0),
24 min_playout_delay_ms_(-1),
25 max_playout_delay_ms_(-1) {
26 thread_checker_.DetachFromThread();
27 }
28 PlayoutDelayOracle::~PlayoutDelayOracle() {}
29
30 void PlayoutDelayOracle::UpdateRequest(uint32_t ssrc,
31 PlayoutDelay playout_delay,
32 uint16_t seq_num) {
33 rtc::CritScope lock(&crit_sect_);
34 RTC_DCHECK_RUN_ON(&thread_checker_);
35 RTC_DCHECK_LE(playout_delay.min_ms, kPlayoutDelayMaxMs);
36 RTC_DCHECK_LE(playout_delay.max_ms, kPlayoutDelayMaxMs);
37 RTC_DCHECK_LE(playout_delay.min_ms, playout_delay.max_ms);
38 int64_t unwrapped_seq_num = unwrapper_.Unwrap(seq_num);
39 if (playout_delay.min_ms >= 0 &&
40 playout_delay.min_ms != min_playout_delay_ms_) {
41 send_playout_delay_ = true;
42 min_playout_delay_ms_ = playout_delay.min_ms;
43 high_sequence_number_ = unwrapped_seq_num;
44 }
45
46 if (playout_delay.max_ms >= 0 &&
47 playout_delay.max_ms != max_playout_delay_ms_) {
48 send_playout_delay_ = true;
49 max_playout_delay_ms_ = playout_delay.max_ms;
50 high_sequence_number_ = unwrapped_seq_num;
51 }
52 ssrc_ = ssrc;
53 }
54
55 // If an ACK is received on the packet containing the playout delay extension,
56 // we stop sending the extension on future packets.
57 void PlayoutDelayOracle::OnReceivedRtcpReportBlocks(
58 const ReportBlockList& report_blocks) {
59 rtc::CritScope lock(&crit_sect_);
60 for (const RTCPReportBlock& report_block : report_blocks) {
61 if ((ssrc_ == report_block.sourceSSRC) && send_playout_delay_ &&
62 (report_block.extendedHighSeqNum > high_sequence_number_)) {
63 send_playout_delay_ = false;
64 }
65 }
66 }
67
68 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698