blob: f60728aadc96b070d65700c6a1c9dee6be476bea [file] [log] [blame]
solenberg13725082015-11-25 08:16:52 -08001/*
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
Tommif888bb52015-12-12 01:37:01 +010013#include <utility>
14
kjellander@webrtc.org7ffeab52016-02-26 22:46:09 +010015#include "webrtc/audio_sink.h"
solenberg13725082015-11-25 08:16:52 -080016#include "webrtc/base/checks.h"
17#include "webrtc/voice_engine/channel.h"
18
19namespace webrtc {
20namespace voe {
21ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
22
23ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
24 channel_owner_(channel_owner) {
25 RTC_CHECK(channel_owner_.channel());
26}
27
Tommif888bb52015-12-12 01:37:01 +010028ChannelProxy::~ChannelProxy() {}
29
solenberg13725082015-11-25 08:16:52 -080030void ChannelProxy::SetRTCPStatus(bool enable) {
solenberg358057b2015-11-27 10:46:42 -080031 channel()->SetRTCPStatus(enable);
solenberg13725082015-11-25 08:16:52 -080032}
33
34void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
solenberg358057b2015-11-27 10:46:42 -080035 RTC_DCHECK(thread_checker_.CalledOnValidThread());
36 int error = channel()->SetLocalSSRC(ssrc);
solenberg13725082015-11-25 08:16:52 -080037 RTC_DCHECK_EQ(0, error);
38}
39
40void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
solenberg358057b2015-11-27 10:46:42 -080041 RTC_DCHECK(thread_checker_.CalledOnValidThread());
solenberg13725082015-11-25 08:16:52 -080042 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
43 std::string c_name_limited = c_name.substr(0, 255);
solenberg358057b2015-11-27 10:46:42 -080044 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
solenberg13725082015-11-25 08:16:52 -080045 RTC_DCHECK_EQ(0, error);
46}
solenberg358057b2015-11-27 10:46:42 -080047
solenberg971cab02016-06-14 10:02:41 -070048void ChannelProxy::SetNACKStatus(bool enable, int max_packets) {
49 RTC_DCHECK(thread_checker_.CalledOnValidThread());
50 channel()->SetNACKStatus(enable, max_packets);
51}
52
solenberg358057b2015-11-27 10:46:42 -080053void ChannelProxy::SetSendAbsoluteSenderTimeStatus(bool enable, int id) {
54 RTC_DCHECK(thread_checker_.CalledOnValidThread());
55 int error = channel()->SetSendAbsoluteSenderTimeStatus(enable, id);
56 RTC_DCHECK_EQ(0, error);
57}
58
59void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
60 RTC_DCHECK(thread_checker_.CalledOnValidThread());
61 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
62 RTC_DCHECK_EQ(0, error);
63}
64
65void ChannelProxy::SetReceiveAbsoluteSenderTimeStatus(bool enable, int id) {
66 RTC_DCHECK(thread_checker_.CalledOnValidThread());
67 int error = channel()->SetReceiveAbsoluteSenderTimeStatus(enable, id);
68 RTC_DCHECK_EQ(0, error);
69}
70
71void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
72 RTC_DCHECK(thread_checker_.CalledOnValidThread());
73 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
74 RTC_DCHECK_EQ(0, error);
75}
76
stefan3313ec92016-01-21 06:32:43 -080077void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
78 RTC_DCHECK(thread_checker_.CalledOnValidThread());
79 channel()->EnableSendTransportSequenceNumber(id);
80}
81
82void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
83 RTC_DCHECK(thread_checker_.CalledOnValidThread());
84 channel()->EnableReceiveTransportSequenceNumber(id);
85}
86
stefanbba9dec2016-02-01 04:39:55 -080087void ChannelProxy::RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010088 RtpPacketSender* rtp_packet_sender,
89 TransportFeedbackObserver* transport_feedback_observer,
90 PacketRouter* packet_router) {
91 RTC_DCHECK(thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080092 channel()->RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010093 rtp_packet_sender, transport_feedback_observer, packet_router);
94}
95
stefanbba9dec2016-02-01 04:39:55 -080096void ChannelProxy::RegisterReceiverCongestionControlObjects(
97 PacketRouter* packet_router) {
98 RTC_DCHECK(thread_checker_.CalledOnValidThread());
99 channel()->RegisterReceiverCongestionControlObjects(packet_router);
100}
101
102void ChannelProxy::ResetCongestionControlObjects() {
103 RTC_DCHECK(thread_checker_.CalledOnValidThread());
104 channel()->ResetCongestionControlObjects();
105}
106
solenberg358057b2015-11-27 10:46:42 -0800107CallStatistics ChannelProxy::GetRTCPStatistics() const {
108 RTC_DCHECK(thread_checker_.CalledOnValidThread());
109 CallStatistics stats = {0};
110 int error = channel()->GetRTPStatistics(stats);
111 RTC_DCHECK_EQ(0, error);
112 return stats;
113}
114
115std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
116 RTC_DCHECK(thread_checker_.CalledOnValidThread());
117 std::vector<webrtc::ReportBlock> blocks;
118 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
119 RTC_DCHECK_EQ(0, error);
120 return blocks;
121}
122
123NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
124 RTC_DCHECK(thread_checker_.CalledOnValidThread());
125 NetworkStatistics stats = {0};
126 int error = channel()->GetNetworkStatistics(stats);
127 RTC_DCHECK_EQ(0, error);
128 return stats;
129}
130
131AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
132 RTC_DCHECK(thread_checker_.CalledOnValidThread());
133 AudioDecodingCallStats stats;
134 channel()->GetDecodingCallStatistics(&stats);
135 return stats;
136}
137
138int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
139 RTC_DCHECK(thread_checker_.CalledOnValidThread());
140 uint32_t level = 0;
141 int error = channel()->GetSpeechOutputLevelFullRange(level);
142 RTC_DCHECK_EQ(0, error);
143 return static_cast<int32_t>(level);
144}
145
146uint32_t ChannelProxy::GetDelayEstimate() const {
147 RTC_DCHECK(thread_checker_.CalledOnValidThread());
148 return channel()->GetDelayEstimate();
149}
150
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100151bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type) {
152 RTC_DCHECK(thread_checker_.CalledOnValidThread());
153 return channel()->SetSendTelephoneEventPayloadType(payload_type) == 0;
154}
155
solenberg8842c3e2016-03-11 03:06:41 -0800156bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100157 RTC_DCHECK(thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800158 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100159}
160
kwibergb7f89d62016-02-17 10:04:18 -0800161void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
Tommif888bb52015-12-12 01:37:01 +0100162 RTC_DCHECK(thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800163 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100164}
165
solenberg94218532016-06-16 10:53:22 -0700166void ChannelProxy::SetInputMute(bool muted) {
167 RTC_DCHECK(thread_checker_.CalledOnValidThread());
168 int error = channel()->SetInputMute(muted);
169 RTC_DCHECK_EQ(0, error);
170}
171
mflodman3d7db262016-04-29 00:57:13 -0700172void ChannelProxy::RegisterExternalTransport(Transport* transport) {
173 RTC_DCHECK(thread_checker_.CalledOnValidThread());
174 int error = channel()->RegisterExternalTransport(transport);
175 RTC_DCHECK_EQ(0, error);
176}
177
178void ChannelProxy::DeRegisterExternalTransport() {
179 RTC_DCHECK(thread_checker_.CalledOnValidThread());
180 channel()->DeRegisterExternalTransport();
181}
182
183bool ChannelProxy::ReceivedRTPPacket(const uint8_t* packet,
184 size_t length,
185 const PacketTime& packet_time) {
186 // May be called on either worker thread or network thread.
187 return channel()->ReceivedRTPPacket(packet, length, packet_time) == 0;
188}
189
190bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
191 // May be called on either worker thread or network thread.
192 return channel()->ReceivedRTCPPacket(packet, length) == 0;
193}
194
ossu29b1a8d2016-06-13 07:34:51 -0700195const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700196 ChannelProxy::GetAudioDecoderFactory() const {
197 RTC_DCHECK(thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700198 return channel()->GetAudioDecoderFactory();
199}
200
solenberg217fb662016-06-17 08:30:54 -0700201void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
202 RTC_DCHECK(thread_checker_.CalledOnValidThread());
203 int error = channel()->SetChannelOutputVolumeScaling(scaling);
204 RTC_DCHECK_EQ(0, error);
205}
206
solenberg358057b2015-11-27 10:46:42 -0800207Channel* ChannelProxy::channel() const {
208 RTC_DCHECK(channel_owner_.channel());
209 return channel_owner_.channel();
210}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100211
solenberg13725082015-11-25 08:16:52 -0800212} // namespace voe
213} // namespace webrtc