solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 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/voice_engine/channel_proxy.h" |
| 12 | |
| 13 | #include "webrtc/base/checks.h" |
| 14 | #include "webrtc/voice_engine/channel.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | namespace voe { |
| 18 | ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} |
| 19 | |
| 20 | ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : |
| 21 | channel_owner_(channel_owner) { |
| 22 | RTC_CHECK(channel_owner_.channel()); |
| 23 | } |
| 24 | |
| 25 | void ChannelProxy::SetRTCPStatus(bool enable) { |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 26 | channel()->SetRTCPStatus(enable); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 30 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 31 | int error = channel()->SetLocalSSRC(ssrc); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 32 | RTC_DCHECK_EQ(0, error); |
| 33 | } |
| 34 | |
| 35 | void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 36 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 37 | // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. |
| 38 | std::string c_name_limited = c_name.substr(0, 255); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 39 | int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 40 | RTC_DCHECK_EQ(0, error); |
| 41 | } |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 42 | |
| 43 | void ChannelProxy::SetSendAbsoluteSenderTimeStatus(bool enable, int id) { |
| 44 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 45 | int error = channel()->SetSendAbsoluteSenderTimeStatus(enable, id); |
| 46 | RTC_DCHECK_EQ(0, error); |
| 47 | } |
| 48 | |
| 49 | void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { |
| 50 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 51 | int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); |
| 52 | RTC_DCHECK_EQ(0, error); |
| 53 | } |
| 54 | |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame^] | 55 | void ChannelProxy::EnableSendTransportSequenceNumber(int id) { |
| 56 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 57 | channel()->EnableSendTransportSequenceNumber(id); |
| 58 | } |
| 59 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 60 | void ChannelProxy::SetReceiveAbsoluteSenderTimeStatus(bool enable, int id) { |
| 61 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 62 | int error = channel()->SetReceiveAbsoluteSenderTimeStatus(enable, id); |
| 63 | RTC_DCHECK_EQ(0, error); |
| 64 | } |
| 65 | |
| 66 | void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) { |
| 67 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 68 | int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id); |
| 69 | RTC_DCHECK_EQ(0, error); |
| 70 | } |
| 71 | |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame^] | 72 | void ChannelProxy::SetCongestionControlObjects( |
| 73 | RtpPacketSender* rtp_packet_sender, |
| 74 | TransportFeedbackObserver* transport_feedback_observer, |
| 75 | PacketRouter* packet_router) { |
| 76 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 77 | channel()->SetCongestionControlObjects( |
| 78 | rtp_packet_sender, transport_feedback_observer, packet_router); |
| 79 | } |
| 80 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 81 | CallStatistics ChannelProxy::GetRTCPStatistics() const { |
| 82 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 83 | CallStatistics stats = {0}; |
| 84 | int error = channel()->GetRTPStatistics(stats); |
| 85 | RTC_DCHECK_EQ(0, error); |
| 86 | return stats; |
| 87 | } |
| 88 | |
| 89 | std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { |
| 90 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 91 | std::vector<webrtc::ReportBlock> blocks; |
| 92 | int error = channel()->GetRemoteRTCPReportBlocks(&blocks); |
| 93 | RTC_DCHECK_EQ(0, error); |
| 94 | return blocks; |
| 95 | } |
| 96 | |
| 97 | NetworkStatistics ChannelProxy::GetNetworkStatistics() const { |
| 98 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 99 | NetworkStatistics stats = {0}; |
| 100 | int error = channel()->GetNetworkStatistics(stats); |
| 101 | RTC_DCHECK_EQ(0, error); |
| 102 | return stats; |
| 103 | } |
| 104 | |
| 105 | AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { |
| 106 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 107 | AudioDecodingCallStats stats; |
| 108 | channel()->GetDecodingCallStatistics(&stats); |
| 109 | return stats; |
| 110 | } |
| 111 | |
| 112 | int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { |
| 113 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 114 | uint32_t level = 0; |
| 115 | int error = channel()->GetSpeechOutputLevelFullRange(level); |
| 116 | RTC_DCHECK_EQ(0, error); |
| 117 | return static_cast<int32_t>(level); |
| 118 | } |
| 119 | |
| 120 | uint32_t ChannelProxy::GetDelayEstimate() const { |
| 121 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 122 | return channel()->GetDelayEstimate(); |
| 123 | } |
| 124 | |
Fredrik Solenberg | b572768 | 2015-12-04 15:22:19 +0100 | [diff] [blame] | 125 | bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) { |
| 126 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 127 | return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0; |
| 128 | } |
| 129 | |
| 130 | bool ChannelProxy::SendTelephoneEventOutband(uint8_t event, |
| 131 | uint32_t duration_ms) { |
| 132 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 133 | return |
| 134 | channel()->SendTelephoneEventOutband(event, duration_ms, 10, false) == 0; |
| 135 | } |
| 136 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 137 | Channel* ChannelProxy::channel() const { |
| 138 | RTC_DCHECK(channel_owner_.channel()); |
| 139 | return channel_owner_.channel(); |
| 140 | } |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame^] | 141 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 142 | } // namespace voe |
| 143 | } // namespace webrtc |