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

Side by Side Diff: webrtc/voice_engine/channel_proxy.cc

Issue 2808513003: Add SafeClamp(), which accepts args of different types (Closed)
Patch Set: rebase Created 3 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
« no previous file with comments | « webrtc/tools/agc/activity_metric.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/voice_engine/channel_proxy.h" 11 #include "webrtc/voice_engine/channel_proxy.h"
12 12
13 #include <utility> 13 #include <utility>
14 14
15 #include "webrtc/api/call/audio_sink.h" 15 #include "webrtc/api/call/audio_sink.h"
16 #include "webrtc/base/checks.h" 16 #include "webrtc/base/checks.h"
17 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
18 #include "webrtc/base/safe_minmax.h"
18 #include "webrtc/call/rtp_transport_controller_send_interface.h" 19 #include "webrtc/call/rtp_transport_controller_send_interface.h"
19 #include "webrtc/voice_engine/channel.h" 20 #include "webrtc/voice_engine/channel.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 namespace voe { 23 namespace voe {
23 ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} 24 ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
24 25
25 ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : 26 ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
26 channel_owner_(channel_owner) { 27 channel_owner_(channel_owner) {
27 RTC_CHECK(channel_owner_.channel()); 28 RTC_CHECK(channel_owner_.channel());
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 unsigned int timestamp = 0; 284 unsigned int timestamp = 0;
284 int error = channel()->GetPlayoutTimestamp(timestamp); 285 int error = channel()->GetPlayoutTimestamp(timestamp);
285 RTC_DCHECK(!error || timestamp == 0); 286 RTC_DCHECK(!error || timestamp == 0);
286 return timestamp; 287 return timestamp;
287 } 288 }
288 289
289 void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) { 290 void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
290 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread()); 291 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
291 // Limit to range accepted by both VoE and ACM, so we're at least getting as 292 // Limit to range accepted by both VoE and ACM, so we're at least getting as
292 // close as possible, instead of failing. 293 // close as possible, instead of failing.
293 delay_ms = std::max(0, std::min(delay_ms, 10000)); 294 delay_ms = rtc::SafeClamp(delay_ms, 0, 10000);
294 int error = channel()->SetMinimumPlayoutDelay(delay_ms); 295 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
295 if (0 != error) { 296 if (0 != error) {
296 LOG(LS_WARNING) << "Error setting minimum playout delay."; 297 LOG(LS_WARNING) << "Error setting minimum playout delay.";
297 } 298 }
298 } 299 }
299 300
300 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { 301 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
301 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 302 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
302 channel()->SetRtcpRttStats(rtcp_rtt_stats); 303 channel()->SetRtcpRttStats(rtcp_rtt_stats);
303 } 304 }
(...skipping 28 matching lines...) Expand all
332 return channel()->GetSources(); 333 return channel()->GetSources();
333 } 334 }
334 335
335 Channel* ChannelProxy::channel() const { 336 Channel* ChannelProxy::channel() const {
336 RTC_DCHECK(channel_owner_.channel()); 337 RTC_DCHECK(channel_owner_.channel());
337 return channel_owner_.channel(); 338 return channel_owner_.channel();
338 } 339 }
339 340
340 } // namespace voe 341 } // namespace voe
341 } // namespace webrtc 342 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/tools/agc/activity_metric.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698