blob: 74234a232dd8cf8f8fb376663cc0a9f4703137d7 [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
kjellandera69d9732016-08-31 07:33:05 -070015#include "webrtc/api/call/audio_sink.h"
solenberg13725082015-11-25 08:16:52 -080016#include "webrtc/base/checks.h"
solenberg0335e6c2017-02-22 07:07:04 -080017#include "webrtc/base/logging.h"
nissecae45d02017-04-24 05:53:20 -070018#include "webrtc/call/rtp_transport_controller_send_interface.h"
solenberg13725082015-11-25 08:16:52 -080019#include "webrtc/voice_engine/channel.h"
20
21namespace webrtc {
22namespace voe {
23ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
24
25ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
26 channel_owner_(channel_owner) {
27 RTC_CHECK(channel_owner_.channel());
solenberg08b19df2017-02-15 00:42:31 -080028 module_process_thread_checker_.DetachFromThread();
solenberg13725082015-11-25 08:16:52 -080029}
30
Tommif888bb52015-12-12 01:37:01 +010031ChannelProxy::~ChannelProxy() {}
32
ossu1ffbd6c2017-04-06 12:05:04 -070033bool ChannelProxy::SetEncoder(int payload_type,
34 std::unique_ptr<AudioEncoder> encoder) {
35 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
36 return channel()->SetEncoder(payload_type, std::move(encoder));
37}
38
solenberg13725082015-11-25 08:16:52 -080039void ChannelProxy::SetRTCPStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -080040 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080041 channel()->SetRTCPStatus(enable);
solenberg13725082015-11-25 08:16:52 -080042}
43
44void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
solenberg08b19df2017-02-15 00:42:31 -080045 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080046 int error = channel()->SetLocalSSRC(ssrc);
solenberg13725082015-11-25 08:16:52 -080047 RTC_DCHECK_EQ(0, error);
48}
49
50void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
solenberg08b19df2017-02-15 00:42:31 -080051 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg13725082015-11-25 08:16:52 -080052 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
53 std::string c_name_limited = c_name.substr(0, 255);
solenberg358057b2015-11-27 10:46:42 -080054 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
solenberg13725082015-11-25 08:16:52 -080055 RTC_DCHECK_EQ(0, error);
56}
solenberg358057b2015-11-27 10:46:42 -080057
solenberg971cab02016-06-14 10:02:41 -070058void ChannelProxy::SetNACKStatus(bool enable, int max_packets) {
solenberg08b19df2017-02-15 00:42:31 -080059 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg971cab02016-06-14 10:02:41 -070060 channel()->SetNACKStatus(enable, max_packets);
61}
62
solenberg358057b2015-11-27 10:46:42 -080063void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
solenberg08b19df2017-02-15 00:42:31 -080064 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080065 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
66 RTC_DCHECK_EQ(0, error);
67}
68
solenberg358057b2015-11-27 10:46:42 -080069void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
solenberg08b19df2017-02-15 00:42:31 -080070 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080071 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
72 RTC_DCHECK_EQ(0, error);
73}
74
stefan3313ec92016-01-21 06:32:43 -080075void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
solenberg08b19df2017-02-15 00:42:31 -080076 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefan3313ec92016-01-21 06:32:43 -080077 channel()->EnableSendTransportSequenceNumber(id);
78}
79
80void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
solenberg08b19df2017-02-15 00:42:31 -080081 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefan3313ec92016-01-21 06:32:43 -080082 channel()->EnableReceiveTransportSequenceNumber(id);
83}
84
stefanbba9dec2016-02-01 04:39:55 -080085void ChannelProxy::RegisterSenderCongestionControlObjects(
nisseb8f9a322017-03-27 05:36:15 -070086 RtpTransportControllerSendInterface* transport,
stefan7de8d642017-02-07 07:14:08 -080087 RtcpBandwidthObserver* bandwidth_observer) {
solenberg08b19df2017-02-15 00:42:31 -080088 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
nisseb8f9a322017-03-27 05:36:15 -070089 channel()->RegisterSenderCongestionControlObjects(transport,
90 bandwidth_observer);
Stefan Holmerb86d4e42015-12-07 10:26:18 +010091}
92
stefanbba9dec2016-02-01 04:39:55 -080093void ChannelProxy::RegisterReceiverCongestionControlObjects(
94 PacketRouter* packet_router) {
solenberg08b19df2017-02-15 00:42:31 -080095 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080096 channel()->RegisterReceiverCongestionControlObjects(packet_router);
97}
98
nissefdbfdc92017-03-31 05:44:52 -070099void ChannelProxy::ResetSenderCongestionControlObjects() {
solenberg08b19df2017-02-15 00:42:31 -0800100 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
nissefdbfdc92017-03-31 05:44:52 -0700101 channel()->ResetSenderCongestionControlObjects();
102}
103
104void ChannelProxy::ResetReceiverCongestionControlObjects() {
105 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
106 channel()->ResetReceiverCongestionControlObjects();
stefanbba9dec2016-02-01 04:39:55 -0800107}
108
solenberg358057b2015-11-27 10:46:42 -0800109CallStatistics ChannelProxy::GetRTCPStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800110 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800111 CallStatistics stats = {0};
112 int error = channel()->GetRTPStatistics(stats);
113 RTC_DCHECK_EQ(0, error);
114 return stats;
115}
116
117std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
solenberg08b19df2017-02-15 00:42:31 -0800118 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800119 std::vector<webrtc::ReportBlock> blocks;
120 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
121 RTC_DCHECK_EQ(0, error);
122 return blocks;
123}
124
125NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800126 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800127 NetworkStatistics stats = {0};
128 int error = channel()->GetNetworkStatistics(stats);
129 RTC_DCHECK_EQ(0, error);
130 return stats;
131}
132
133AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800134 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800135 AudioDecodingCallStats stats;
136 channel()->GetDecodingCallStatistics(&stats);
137 return stats;
138}
139
solenberg8d73f8c2017-03-08 01:52:20 -0800140int ChannelProxy::GetSpeechOutputLevel() const {
solenberg796b8f92017-03-01 17:02:23 -0800141 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800142 return channel()->GetSpeechOutputLevel();
solenberg796b8f92017-03-01 17:02:23 -0800143}
144
solenberg8d73f8c2017-03-08 01:52:20 -0800145int ChannelProxy::GetSpeechOutputLevelFullRange() const {
solenberg08b19df2017-02-15 00:42:31 -0800146 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800147 return channel()->GetSpeechOutputLevelFullRange();
solenberg358057b2015-11-27 10:46:42 -0800148}
149
150uint32_t ChannelProxy::GetDelayEstimate() const {
solenberg08b19df2017-02-15 00:42:31 -0800151 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
152 module_process_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800153 return channel()->GetDelayEstimate();
154}
155
solenbergffbbcac2016-11-17 05:25:37 -0800156bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type,
157 int payload_frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800158 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergffbbcac2016-11-17 05:25:37 -0800159 return channel()->SetSendTelephoneEventPayloadType(payload_type,
160 payload_frequency) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100161}
162
solenberg8842c3e2016-03-11 03:06:41 -0800163bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800164 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800165 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100166}
167
minyue78b4d562016-11-30 04:47:39 -0800168void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
tommi0f8b4032017-02-22 11:22:05 -0800169 // This method can be called on the worker thread, module process thread
170 // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
171 // TODO(solenberg): Figure out a good way to check this or enforce calling
172 // rules.
173 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
174 // module_process_thread_checker_.CalledOnValidThread());
minyue78b4d562016-11-30 04:47:39 -0800175 channel()->SetBitRate(bitrate_bps, probing_interval_ms);
mflodman86cc6ff2016-07-26 04:44:06 -0700176}
177
kwibergd32bf752017-01-19 07:03:59 -0800178void ChannelProxy::SetRecPayloadType(int payload_type,
179 const SdpAudioFormat& format) {
solenberg08b19df2017-02-15 00:42:31 -0800180 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
kwibergd32bf752017-01-19 07:03:59 -0800181 const int result = channel()->SetRecPayloadType(payload_type, format);
182 RTC_DCHECK_EQ(0, result);
183}
184
kwiberg1c07c702017-03-27 07:15:49 -0700185void ChannelProxy::SetReceiveCodecs(
186 const std::map<int, SdpAudioFormat>& codecs) {
187 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
188 channel()->SetReceiveCodecs(codecs);
189}
190
kwibergb7f89d62016-02-17 10:04:18 -0800191void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800192 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800193 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100194}
195
solenberg94218532016-06-16 10:53:22 -0700196void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800197 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800198 channel()->SetInputMute(muted);
solenberg94218532016-06-16 10:53:22 -0700199}
200
mflodman3d7db262016-04-29 00:57:13 -0700201void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800202 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700203 int error = channel()->RegisterExternalTransport(transport);
204 RTC_DCHECK_EQ(0, error);
205}
206
207void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800208 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700209 channel()->DeRegisterExternalTransport();
210}
211
nisse657bab22017-02-21 06:28:10 -0800212void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700213 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800214 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700215}
216
217bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
218 // May be called on either worker thread or network thread.
219 return channel()->ReceivedRTCPPacket(packet, length) == 0;
220}
221
ossu29b1a8d2016-06-13 07:34:51 -0700222const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700223 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800224 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700225 return channel()->GetAudioDecoderFactory();
226}
227
solenberg217fb662016-06-17 08:30:54 -0700228void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800229 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800230 channel()->SetChannelOutputVolumeScaling(scaling);
solenberg217fb662016-06-17 08:30:54 -0700231}
232
ivoc14d5dbe2016-07-04 07:06:55 -0700233void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800234 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700235 channel()->SetRtcEventLog(event_log);
236}
237
minyue6b825df2016-10-31 04:08:32 -0700238void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800239 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700240 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
241 RTC_DCHECK(ret);
242;}
243
244void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800245 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700246 channel()->DisableAudioNetworkAdaptor();
247}
248
249void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
250 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800251 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700252 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
253 max_frame_length_ms);
254}
255
aleloi6c278492016-10-20 14:24:39 -0700256AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
257 int sample_rate_hz,
258 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800259 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700260 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700261}
262
aleloi051f6782016-10-31 03:26:40 -0700263int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800264 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700265 return static_cast<int>(channel()->NeededFrequency(-1));
266}
267
michaelt79e05882016-11-08 02:50:09 -0800268void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800269 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800270 channel()->SetTransportOverhead(transport_overhead_per_packet);
271}
272
solenberg7602aab2016-11-14 11:30:07 -0800273void ChannelProxy::AssociateSendChannel(
274 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800275 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800276 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
277}
278
279void ChannelProxy::DisassociateSendChannel() {
solenberg08b19df2017-02-15 00:42:31 -0800280 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800281 channel()->set_associate_send_channel(ChannelOwner(nullptr));
282}
283
solenberg3ebbcb52017-01-31 03:58:40 -0800284void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
285 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800286 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800287 RTC_DCHECK(rtp_rtcp);
288 RTC_DCHECK(rtp_receiver);
289 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
290 RTC_DCHECK_EQ(0, error);
291}
292
solenberg3ebbcb52017-01-31 03:58:40 -0800293uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800294 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800295 unsigned int timestamp = 0;
296 int error = channel()->GetPlayoutTimestamp(timestamp);
297 RTC_DCHECK(!error || timestamp == 0);
298 return timestamp;
299}
300
301void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800302 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800303 // Limit to range accepted by both VoE and ACM, so we're at least getting as
304 // close as possible, instead of failing.
305 delay_ms = std::max(0, std::min(delay_ms, 10000));
306 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800307 if (0 != error) {
308 LOG(LS_WARNING) << "Error setting minimum playout delay.";
309 }
solenberg3ebbcb52017-01-31 03:58:40 -0800310}
311
michaelt9332b7d2016-11-30 07:51:13 -0800312void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800313 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800314 channel()->SetRtcpRttStats(rtcp_rtt_stats);
315}
316
solenbergbd9a77f2017-02-06 12:53:57 -0800317bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800318 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800319 return channel()->GetRecCodec(*codec_inst) == 0;
320}
321
322bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800323 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800324 return channel()->GetSendCodec(*codec_inst) == 0;
325}
326
327bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800328 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800329 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
330}
331
332bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800333 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800334 return channel()->SetCodecFECStatus(enable) == 0;
335}
336
337bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800338 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800339 return channel()->SetOpusDtx(enable) == 0;
340}
341
342bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800343 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800344 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
345}
346
347bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800348 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800349 // Validation code copied from VoECodecImpl::SetSendCodec().
350 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
351 (codec_inst.pacsize >= 960)) {
352 return false;
353 }
354 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
355 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
356 !STR_CASE_CMP(codec_inst.plname, "RED")) {
357 return false;
358 }
359 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
360 return false;
361 }
362 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
363 return false;
364 }
365 return channel()->SetSendCodec(codec_inst) == 0;
366}
367
368bool ChannelProxy::SetSendCNPayloadType(int type,
369 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800370 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800371 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
372 if (type < 96 || type > 127) {
373 // Only allow dynamic range: 96 to 127
374 return false;
375 }
376 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
377 // It is not possible to modify the payload type for CN/8000.
378 // We only allow modification of the CN payload type for CN/16000
379 // and CN/32000.
380 return false;
381 }
382 return channel()->SetSendCNPayloadType(type, frequency) == 0;
383}
384
elad.alond12a8e12017-03-23 11:04:48 -0700385void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) {
elad.alon4e764512017-03-27 08:53:11 -0700386 // TODO(elad.alon): This fails in UT; fix and uncomment.
387 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7405
388 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
elad.alond12a8e12017-03-23 11:04:48 -0700389 channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate);
390}
391
elad.alondadb4dc2017-03-23 15:29:50 -0700392void ChannelProxy::OnRecoverableUplinkPacketLossRate(
393 float recoverable_packet_loss_rate) {
394 // TODO(elad.alon): This fails in UT; fix and uncomment.
elad.alon4e764512017-03-27 08:53:11 -0700395 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7405
elad.alondadb4dc2017-03-23 15:29:50 -0700396 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
397 channel()->OnRecoverableUplinkPacketLossRate(recoverable_packet_loss_rate);
398}
399
kwiberg1c07c702017-03-27 07:15:49 -0700400void ChannelProxy::RegisterLegacyReceiveCodecs() {
401 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
402 channel()->RegisterLegacyReceiveCodecs();
403}
404
hbos8d609f62017-04-10 07:39:05 -0700405std::vector<RtpSource> ChannelProxy::GetSources() const {
406 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
407 return channel()->GetSources();
408}
409
solenberg358057b2015-11-27 10:46:42 -0800410Channel* ChannelProxy::channel() const {
411 RTC_DCHECK(channel_owner_.channel());
412 return channel_owner_.channel();
413}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100414
solenberg13725082015-11-25 08:16:52 -0800415} // namespace voe
416} // namespace webrtc