blob: bb56b078d193aedb8859e2bda89d487fc972cbe1 [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"
nisseb8f9a322017-03-27 05:36:15 -070018#include "webrtc/call/rtp_transport_controller_send.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
solenberg13725082015-11-25 08:16:52 -080033void ChannelProxy::SetRTCPStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -080034 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080035 channel()->SetRTCPStatus(enable);
solenberg13725082015-11-25 08:16:52 -080036}
37
38void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
solenberg08b19df2017-02-15 00:42:31 -080039 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080040 int error = channel()->SetLocalSSRC(ssrc);
solenberg13725082015-11-25 08:16:52 -080041 RTC_DCHECK_EQ(0, error);
42}
43
44void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
solenberg08b19df2017-02-15 00:42:31 -080045 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg13725082015-11-25 08:16:52 -080046 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
47 std::string c_name_limited = c_name.substr(0, 255);
solenberg358057b2015-11-27 10:46:42 -080048 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
solenberg13725082015-11-25 08:16:52 -080049 RTC_DCHECK_EQ(0, error);
50}
solenberg358057b2015-11-27 10:46:42 -080051
solenberg971cab02016-06-14 10:02:41 -070052void ChannelProxy::SetNACKStatus(bool enable, int max_packets) {
solenberg08b19df2017-02-15 00:42:31 -080053 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg971cab02016-06-14 10:02:41 -070054 channel()->SetNACKStatus(enable, max_packets);
55}
56
solenberg358057b2015-11-27 10:46:42 -080057void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
solenberg08b19df2017-02-15 00:42:31 -080058 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080059 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
60 RTC_DCHECK_EQ(0, error);
61}
62
solenberg358057b2015-11-27 10:46:42 -080063void ChannelProxy::SetReceiveAudioLevelIndicationStatus(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()->SetReceiveAudioLevelIndicationStatus(enable, id);
66 RTC_DCHECK_EQ(0, error);
67}
68
stefan3313ec92016-01-21 06:32:43 -080069void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
solenberg08b19df2017-02-15 00:42:31 -080070 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefan3313ec92016-01-21 06:32:43 -080071 channel()->EnableSendTransportSequenceNumber(id);
72}
73
74void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
solenberg08b19df2017-02-15 00:42:31 -080075 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefan3313ec92016-01-21 06:32:43 -080076 channel()->EnableReceiveTransportSequenceNumber(id);
77}
78
stefanbba9dec2016-02-01 04:39:55 -080079void ChannelProxy::RegisterSenderCongestionControlObjects(
nisseb8f9a322017-03-27 05:36:15 -070080 RtpTransportControllerSendInterface* transport,
stefan7de8d642017-02-07 07:14:08 -080081 RtcpBandwidthObserver* bandwidth_observer) {
solenberg08b19df2017-02-15 00:42:31 -080082 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
nisseb8f9a322017-03-27 05:36:15 -070083 channel()->RegisterSenderCongestionControlObjects(transport,
84 bandwidth_observer);
Stefan Holmerb86d4e42015-12-07 10:26:18 +010085}
86
stefanbba9dec2016-02-01 04:39:55 -080087void ChannelProxy::RegisterReceiverCongestionControlObjects(
88 PacketRouter* packet_router) {
solenberg08b19df2017-02-15 00:42:31 -080089 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080090 channel()->RegisterReceiverCongestionControlObjects(packet_router);
91}
92
nissefdbfdc92017-03-31 05:44:52 -070093void ChannelProxy::ResetSenderCongestionControlObjects() {
solenberg08b19df2017-02-15 00:42:31 -080094 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
nissefdbfdc92017-03-31 05:44:52 -070095 channel()->ResetSenderCongestionControlObjects();
96}
97
98void ChannelProxy::ResetReceiverCongestionControlObjects() {
99 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
100 channel()->ResetReceiverCongestionControlObjects();
stefanbba9dec2016-02-01 04:39:55 -0800101}
102
solenberg358057b2015-11-27 10:46:42 -0800103CallStatistics ChannelProxy::GetRTCPStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800104 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800105 CallStatistics stats = {0};
106 int error = channel()->GetRTPStatistics(stats);
107 RTC_DCHECK_EQ(0, error);
108 return stats;
109}
110
111std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
solenberg08b19df2017-02-15 00:42:31 -0800112 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800113 std::vector<webrtc::ReportBlock> blocks;
114 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
115 RTC_DCHECK_EQ(0, error);
116 return blocks;
117}
118
119NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800120 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800121 NetworkStatistics stats = {0};
122 int error = channel()->GetNetworkStatistics(stats);
123 RTC_DCHECK_EQ(0, error);
124 return stats;
125}
126
127AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800128 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800129 AudioDecodingCallStats stats;
130 channel()->GetDecodingCallStatistics(&stats);
131 return stats;
132}
133
solenberg8d73f8c2017-03-08 01:52:20 -0800134int ChannelProxy::GetSpeechOutputLevel() const {
solenberg796b8f92017-03-01 17:02:23 -0800135 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800136 return channel()->GetSpeechOutputLevel();
solenberg796b8f92017-03-01 17:02:23 -0800137}
138
solenberg8d73f8c2017-03-08 01:52:20 -0800139int ChannelProxy::GetSpeechOutputLevelFullRange() const {
solenberg08b19df2017-02-15 00:42:31 -0800140 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800141 return channel()->GetSpeechOutputLevelFullRange();
solenberg358057b2015-11-27 10:46:42 -0800142}
143
144uint32_t ChannelProxy::GetDelayEstimate() const {
solenberg08b19df2017-02-15 00:42:31 -0800145 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
146 module_process_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800147 return channel()->GetDelayEstimate();
148}
149
solenbergffbbcac2016-11-17 05:25:37 -0800150bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type,
151 int payload_frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800152 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergffbbcac2016-11-17 05:25:37 -0800153 return channel()->SetSendTelephoneEventPayloadType(payload_type,
154 payload_frequency) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100155}
156
solenberg8842c3e2016-03-11 03:06:41 -0800157bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800158 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800159 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100160}
161
minyue78b4d562016-11-30 04:47:39 -0800162void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
tommi0f8b4032017-02-22 11:22:05 -0800163 // This method can be called on the worker thread, module process thread
164 // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
165 // TODO(solenberg): Figure out a good way to check this or enforce calling
166 // rules.
167 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
168 // module_process_thread_checker_.CalledOnValidThread());
minyue78b4d562016-11-30 04:47:39 -0800169 channel()->SetBitRate(bitrate_bps, probing_interval_ms);
mflodman86cc6ff2016-07-26 04:44:06 -0700170}
171
kwibergd32bf752017-01-19 07:03:59 -0800172void ChannelProxy::SetRecPayloadType(int payload_type,
173 const SdpAudioFormat& format) {
solenberg08b19df2017-02-15 00:42:31 -0800174 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
kwibergd32bf752017-01-19 07:03:59 -0800175 const int result = channel()->SetRecPayloadType(payload_type, format);
176 RTC_DCHECK_EQ(0, result);
177}
178
kwiberg1c07c702017-03-27 07:15:49 -0700179void ChannelProxy::SetReceiveCodecs(
180 const std::map<int, SdpAudioFormat>& codecs) {
181 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
182 channel()->SetReceiveCodecs(codecs);
183}
184
kwibergb7f89d62016-02-17 10:04:18 -0800185void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800186 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800187 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100188}
189
solenberg94218532016-06-16 10:53:22 -0700190void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800191 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800192 channel()->SetInputMute(muted);
solenberg94218532016-06-16 10:53:22 -0700193}
194
mflodman3d7db262016-04-29 00:57:13 -0700195void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800196 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700197 int error = channel()->RegisterExternalTransport(transport);
198 RTC_DCHECK_EQ(0, error);
199}
200
201void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800202 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700203 channel()->DeRegisterExternalTransport();
204}
205
nisse657bab22017-02-21 06:28:10 -0800206void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700207 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800208 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700209}
210
211bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
212 // May be called on either worker thread or network thread.
213 return channel()->ReceivedRTCPPacket(packet, length) == 0;
214}
215
ossu29b1a8d2016-06-13 07:34:51 -0700216const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700217 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800218 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700219 return channel()->GetAudioDecoderFactory();
220}
221
solenberg217fb662016-06-17 08:30:54 -0700222void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800223 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800224 channel()->SetChannelOutputVolumeScaling(scaling);
solenberg217fb662016-06-17 08:30:54 -0700225}
226
ivoc14d5dbe2016-07-04 07:06:55 -0700227void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800228 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700229 channel()->SetRtcEventLog(event_log);
230}
231
minyue6b825df2016-10-31 04:08:32 -0700232void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800233 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700234 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
235 RTC_DCHECK(ret);
236;}
237
238void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800239 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700240 channel()->DisableAudioNetworkAdaptor();
241}
242
243void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
244 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800245 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700246 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
247 max_frame_length_ms);
248}
249
aleloi6c278492016-10-20 14:24:39 -0700250AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
251 int sample_rate_hz,
252 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800253 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700254 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700255}
256
aleloi051f6782016-10-31 03:26:40 -0700257int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800258 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700259 return static_cast<int>(channel()->NeededFrequency(-1));
260}
261
michaelt79e05882016-11-08 02:50:09 -0800262void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800263 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800264 channel()->SetTransportOverhead(transport_overhead_per_packet);
265}
266
solenberg7602aab2016-11-14 11:30:07 -0800267void ChannelProxy::AssociateSendChannel(
268 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800269 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800270 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
271}
272
273void ChannelProxy::DisassociateSendChannel() {
solenberg08b19df2017-02-15 00:42:31 -0800274 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800275 channel()->set_associate_send_channel(ChannelOwner(nullptr));
276}
277
solenberg3ebbcb52017-01-31 03:58:40 -0800278void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
279 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800280 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800281 RTC_DCHECK(rtp_rtcp);
282 RTC_DCHECK(rtp_receiver);
283 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
284 RTC_DCHECK_EQ(0, error);
285}
286
solenberg3ebbcb52017-01-31 03:58:40 -0800287uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800288 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800289 unsigned int timestamp = 0;
290 int error = channel()->GetPlayoutTimestamp(timestamp);
291 RTC_DCHECK(!error || timestamp == 0);
292 return timestamp;
293}
294
295void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800296 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800297 // Limit to range accepted by both VoE and ACM, so we're at least getting as
298 // close as possible, instead of failing.
299 delay_ms = std::max(0, std::min(delay_ms, 10000));
300 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800301 if (0 != error) {
302 LOG(LS_WARNING) << "Error setting minimum playout delay.";
303 }
solenberg3ebbcb52017-01-31 03:58:40 -0800304}
305
michaelt9332b7d2016-11-30 07:51:13 -0800306void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800307 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800308 channel()->SetRtcpRttStats(rtcp_rtt_stats);
309}
310
solenbergbd9a77f2017-02-06 12:53:57 -0800311bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800312 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800313 return channel()->GetRecCodec(*codec_inst) == 0;
314}
315
316bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800317 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800318 return channel()->GetSendCodec(*codec_inst) == 0;
319}
320
321bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800322 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800323 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
324}
325
326bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800327 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800328 return channel()->SetCodecFECStatus(enable) == 0;
329}
330
331bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800332 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800333 return channel()->SetOpusDtx(enable) == 0;
334}
335
336bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800337 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800338 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
339}
340
341bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800342 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800343 // Validation code copied from VoECodecImpl::SetSendCodec().
344 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
345 (codec_inst.pacsize >= 960)) {
346 return false;
347 }
348 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
349 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
350 !STR_CASE_CMP(codec_inst.plname, "RED")) {
351 return false;
352 }
353 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
354 return false;
355 }
356 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
357 return false;
358 }
359 return channel()->SetSendCodec(codec_inst) == 0;
360}
361
362bool ChannelProxy::SetSendCNPayloadType(int type,
363 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800364 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800365 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
366 if (type < 96 || type > 127) {
367 // Only allow dynamic range: 96 to 127
368 return false;
369 }
370 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
371 // It is not possible to modify the payload type for CN/8000.
372 // We only allow modification of the CN payload type for CN/16000
373 // and CN/32000.
374 return false;
375 }
376 return channel()->SetSendCNPayloadType(type, frequency) == 0;
377}
378
elad.alond12a8e12017-03-23 11:04:48 -0700379void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) {
elad.alon4e764512017-03-27 08:53:11 -0700380 // TODO(elad.alon): This fails in UT; fix and uncomment.
381 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7405
382 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
elad.alond12a8e12017-03-23 11:04:48 -0700383 channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate);
384}
385
elad.alondadb4dc2017-03-23 15:29:50 -0700386void ChannelProxy::OnRecoverableUplinkPacketLossRate(
387 float recoverable_packet_loss_rate) {
388 // TODO(elad.alon): This fails in UT; fix and uncomment.
elad.alon4e764512017-03-27 08:53:11 -0700389 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7405
elad.alondadb4dc2017-03-23 15:29:50 -0700390 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
391 channel()->OnRecoverableUplinkPacketLossRate(recoverable_packet_loss_rate);
392}
393
kwiberg1c07c702017-03-27 07:15:49 -0700394void ChannelProxy::RegisterLegacyReceiveCodecs() {
395 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
396 channel()->RegisterLegacyReceiveCodecs();
397}
398
solenberg358057b2015-11-27 10:46:42 -0800399Channel* ChannelProxy::channel() const {
400 RTC_DCHECK(channel_owner_.channel());
401 return channel_owner_.channel();
402}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100403
solenberg13725082015-11-25 08:16:52 -0800404} // namespace voe
405} // namespace webrtc