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 | |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 13 | #include <utility> |
| 14 | |
| 15 | #include "webrtc/audio/audio_sink.h" |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 16 | #include "webrtc/base/checks.h" |
| 17 | #include "webrtc/voice_engine/channel.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | namespace voe { |
| 21 | ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {} |
| 22 | |
| 23 | ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) : |
| 24 | channel_owner_(channel_owner) { |
| 25 | RTC_CHECK(channel_owner_.channel()); |
| 26 | } |
| 27 | |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 28 | ChannelProxy::~ChannelProxy() {} |
| 29 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 30 | void ChannelProxy::SetRTCPStatus(bool enable) { |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 31 | channel()->SetRTCPStatus(enable); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 35 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 36 | int error = channel()->SetLocalSSRC(ssrc); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 37 | RTC_DCHECK_EQ(0, error); |
| 38 | } |
| 39 | |
| 40 | void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) { |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 41 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 42 | // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array. |
| 43 | std::string c_name_limited = c_name.substr(0, 255); |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 44 | int error = channel()->SetRTCP_CNAME(c_name_limited.c_str()); |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 45 | RTC_DCHECK_EQ(0, error); |
| 46 | } |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 47 | |
| 48 | void ChannelProxy::SetSendAbsoluteSenderTimeStatus(bool enable, int id) { |
| 49 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 50 | int error = channel()->SetSendAbsoluteSenderTimeStatus(enable, id); |
| 51 | RTC_DCHECK_EQ(0, error); |
| 52 | } |
| 53 | |
| 54 | void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) { |
| 55 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 56 | int error = channel()->SetSendAudioLevelIndicationStatus(enable, id); |
| 57 | RTC_DCHECK_EQ(0, error); |
| 58 | } |
| 59 | |
| 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 | 3313ec9 | 2016-01-21 06:32:43 -0800 | [diff] [blame] | 72 | void ChannelProxy::EnableSendTransportSequenceNumber(int id) { |
| 73 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 74 | channel()->EnableSendTransportSequenceNumber(id); |
| 75 | } |
| 76 | |
| 77 | void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) { |
| 78 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 79 | channel()->EnableReceiveTransportSequenceNumber(id); |
| 80 | } |
| 81 | |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame^] | 82 | void ChannelProxy::RegisterSenderCongestionControlObjects( |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 83 | RtpPacketSender* rtp_packet_sender, |
| 84 | TransportFeedbackObserver* transport_feedback_observer, |
| 85 | PacketRouter* packet_router) { |
| 86 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame^] | 87 | channel()->RegisterSenderCongestionControlObjects( |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 88 | rtp_packet_sender, transport_feedback_observer, packet_router); |
| 89 | } |
| 90 | |
stefan | bba9dec | 2016-02-01 04:39:55 -0800 | [diff] [blame^] | 91 | void ChannelProxy::RegisterReceiverCongestionControlObjects( |
| 92 | PacketRouter* packet_router) { |
| 93 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 94 | channel()->RegisterReceiverCongestionControlObjects(packet_router); |
| 95 | } |
| 96 | |
| 97 | void ChannelProxy::ResetCongestionControlObjects() { |
| 98 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 99 | channel()->ResetCongestionControlObjects(); |
| 100 | } |
| 101 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 102 | CallStatistics ChannelProxy::GetRTCPStatistics() const { |
| 103 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 104 | CallStatistics stats = {0}; |
| 105 | int error = channel()->GetRTPStatistics(stats); |
| 106 | RTC_DCHECK_EQ(0, error); |
| 107 | return stats; |
| 108 | } |
| 109 | |
| 110 | std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const { |
| 111 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 112 | std::vector<webrtc::ReportBlock> blocks; |
| 113 | int error = channel()->GetRemoteRTCPReportBlocks(&blocks); |
| 114 | RTC_DCHECK_EQ(0, error); |
| 115 | return blocks; |
| 116 | } |
| 117 | |
| 118 | NetworkStatistics ChannelProxy::GetNetworkStatistics() const { |
| 119 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 | NetworkStatistics stats = {0}; |
| 121 | int error = channel()->GetNetworkStatistics(stats); |
| 122 | RTC_DCHECK_EQ(0, error); |
| 123 | return stats; |
| 124 | } |
| 125 | |
| 126 | AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const { |
| 127 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 128 | AudioDecodingCallStats stats; |
| 129 | channel()->GetDecodingCallStatistics(&stats); |
| 130 | return stats; |
| 131 | } |
| 132 | |
| 133 | int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const { |
| 134 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 135 | uint32_t level = 0; |
| 136 | int error = channel()->GetSpeechOutputLevelFullRange(level); |
| 137 | RTC_DCHECK_EQ(0, error); |
| 138 | return static_cast<int32_t>(level); |
| 139 | } |
| 140 | |
| 141 | uint32_t ChannelProxy::GetDelayEstimate() const { |
| 142 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 143 | return channel()->GetDelayEstimate(); |
| 144 | } |
| 145 | |
Fredrik Solenberg | b572768 | 2015-12-04 15:22:19 +0100 | [diff] [blame] | 146 | bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) { |
| 147 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 148 | return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0; |
| 149 | } |
| 150 | |
| 151 | bool ChannelProxy::SendTelephoneEventOutband(uint8_t event, |
| 152 | uint32_t duration_ms) { |
| 153 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 154 | return |
| 155 | channel()->SendTelephoneEventOutband(event, duration_ms, 10, false) == 0; |
| 156 | } |
| 157 | |
deadbeef | 2d110be | 2016-01-13 12:00:26 -0800 | [diff] [blame] | 158 | void ChannelProxy::SetSink(rtc::scoped_ptr<AudioSinkInterface> sink) { |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 159 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
deadbeef | 2d110be | 2016-01-13 12:00:26 -0800 | [diff] [blame] | 160 | channel()->SetSink(std::move(sink)); |
Tommi | f888bb5 | 2015-12-12 01:37:01 +0100 | [diff] [blame] | 161 | } |
| 162 | |
solenberg | 358057b | 2015-11-27 10:46:42 -0800 | [diff] [blame] | 163 | Channel* ChannelProxy::channel() const { |
| 164 | RTC_DCHECK(channel_owner_.channel()); |
| 165 | return channel_owner_.channel(); |
| 166 | } |
Stefan Holmer | b86d4e4 | 2015-12-07 10:26:18 +0100 | [diff] [blame] | 167 | |
solenberg | 1372508 | 2015-11-25 08:16:52 -0800 | [diff] [blame] | 168 | } // namespace voe |
| 169 | } // namespace webrtc |