OLD | NEW |
---|---|
(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/source/rtp_header_extension.h" | |
16 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | |
17 | |
18 namespace webrtc { | |
19 | |
20 PlayoutDelayOracle::PlayoutDelayOracle() {} | |
21 PlayoutDelayOracle::~PlayoutDelayOracle() {} | |
22 | |
23 bool PlayoutDelayOracle::ShouldIncludePlayoutDelayExtension(int ssrc) const { | |
24 bool ret = | |
25 send_playout_delay_ssrc_.find(ssrc) != send_playout_delay_ssrc_.end() && | |
26 send_playout_delay_ssrc_.at(ssrc); | |
sprang_webrtc
2016/05/24 14:46:08
Store iterator and dereference if != end(), rather
Irfan
2016/05/25 09:32:53
I removed the map
| |
27 return ret; | |
28 } | |
29 | |
30 int PlayoutDelayOracle::MinPlayoutDelayMs(int ssrc) const { | |
31 return ssrc_to_min_playout_delay_.at(ssrc); | |
32 } | |
33 | |
34 int PlayoutDelayOracle::MaxPlayoutDelayMs(int ssrc) const { | |
35 return ssrc_to_max_playout_delay_.at(ssrc); | |
36 } | |
37 | |
38 void PlayoutDelayOracle::Update(int ssrc, | |
39 int min_playout_delay_ms, | |
40 int max_playout_delay_ms, | |
41 int seq_num) { | |
42 RTC_DCHECK_LE(min_playout_delay_ms, kPlayoutDelayMaxMs); | |
43 RTC_DCHECK_LE(max_playout_delay_ms, kPlayoutDelayMaxMs); | |
44 if (min_playout_delay_ms >= 0 && | |
45 min_playout_delay_ms != ssrc_to_min_playout_delay_[ssrc]) { | |
46 send_playout_delay_ssrc_[ssrc] = true; | |
47 ssrc_to_min_playout_delay_[ssrc] = min_playout_delay_ms; | |
48 ssrc_to_high_seq_num_[ssrc] = seq_num; | |
49 } | |
50 | |
51 if (max_playout_delay_ms >= 0 && | |
52 max_playout_delay_ms != ssrc_to_max_playout_delay_[ssrc]) { | |
53 send_playout_delay_ssrc_[ssrc] = true; | |
54 ssrc_to_max_playout_delay_[ssrc] = max_playout_delay_ms; | |
55 ssrc_to_high_seq_num_[ssrc] = seq_num; | |
56 } | |
57 } | |
58 | |
59 // If an ACK is received on the packet containing the playout delay extension, | |
60 // we stop sending the extension on future packets. | |
61 void PlayoutDelayOracle::OnReceivedRtcpReceiverReport( | |
62 const ReportBlockList& report_blocks) { | |
63 for (const RTCPReportBlock& report_block : report_blocks) { | |
64 auto found = ssrc_to_high_seq_num_.find(report_block.sourceSSRC); | |
65 if (found != ssrc_to_high_seq_num_.end()) { | |
66 if (send_playout_delay_ssrc_[report_block.sourceSSRC] && | |
67 report_block.extendedHighSeqNum > | |
68 ssrc_to_high_seq_num_[report_block.sourceSSRC]) { | |
69 send_playout_delay_ssrc_[report_block.sourceSSRC] = false; | |
70 } | |
71 } | |
72 } | |
73 } | |
74 | |
75 } // namespace webrtc | |
OLD | NEW |