Chromium Code Reviews| 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..ba0b4d519f249f38c099c089dc56de9582d9d643 |
| --- /dev/null |
| +++ b/webrtc/modules/rtp_rtcp/source/playout_delay_oracle.cc |
| @@ -0,0 +1,75 @@ |
| +/* |
| + * 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" |
| + |
| +namespace webrtc { |
| + |
| +PlayoutDelayOracle::PlayoutDelayOracle() {} |
| +PlayoutDelayOracle::~PlayoutDelayOracle() {} |
| + |
| +bool PlayoutDelayOracle::ShouldIncludePlayoutDelayExtension(int ssrc) const { |
| + bool ret = |
| + send_playout_delay_ssrc_.find(ssrc) != send_playout_delay_ssrc_.end() && |
| + 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
|
| + return ret; |
| +} |
| + |
| +int PlayoutDelayOracle::MinPlayoutDelayMs(int ssrc) const { |
| + return ssrc_to_min_playout_delay_.at(ssrc); |
| +} |
| + |
| +int PlayoutDelayOracle::MaxPlayoutDelayMs(int ssrc) const { |
| + return ssrc_to_max_playout_delay_.at(ssrc); |
| +} |
| + |
| +void PlayoutDelayOracle::Update(int ssrc, |
| + int min_playout_delay_ms, |
| + int max_playout_delay_ms, |
| + int seq_num) { |
| + RTC_DCHECK_LE(min_playout_delay_ms, kPlayoutDelayMaxMs); |
| + RTC_DCHECK_LE(max_playout_delay_ms, kPlayoutDelayMaxMs); |
| + if (min_playout_delay_ms >= 0 && |
| + min_playout_delay_ms != ssrc_to_min_playout_delay_[ssrc]) { |
| + send_playout_delay_ssrc_[ssrc] = true; |
| + ssrc_to_min_playout_delay_[ssrc] = min_playout_delay_ms; |
| + ssrc_to_high_seq_num_[ssrc] = seq_num; |
| + } |
| + |
| + if (max_playout_delay_ms >= 0 && |
| + max_playout_delay_ms != ssrc_to_max_playout_delay_[ssrc]) { |
| + send_playout_delay_ssrc_[ssrc] = true; |
| + ssrc_to_max_playout_delay_[ssrc] = max_playout_delay_ms; |
| + ssrc_to_high_seq_num_[ssrc] = seq_num; |
| + } |
| +} |
| + |
| +// 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) { |
| + auto found = ssrc_to_high_seq_num_.find(report_block.sourceSSRC); |
| + if (found != ssrc_to_high_seq_num_.end()) { |
| + if (send_playout_delay_ssrc_[report_block.sourceSSRC] && |
| + report_block.extendedHighSeqNum > |
| + ssrc_to_high_seq_num_[report_block.sourceSSRC]) { |
| + send_playout_delay_ssrc_[report_block.sourceSSRC] = false; |
| + } |
| + } |
| + } |
| +} |
| + |
| +} // namespace webrtc |