blob: 64af08b4203bda4f311b0d623df8ff43135660b6 [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
93void ChannelProxy::ResetCongestionControlObjects() {
solenberg08b19df2017-02-15 00:42:31 -080094 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080095 channel()->ResetCongestionControlObjects();
96}
97
solenberg358057b2015-11-27 10:46:42 -080098CallStatistics ChannelProxy::GetRTCPStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -080099 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800100 CallStatistics stats = {0};
101 int error = channel()->GetRTPStatistics(stats);
102 RTC_DCHECK_EQ(0, error);
103 return stats;
104}
105
106std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
solenberg08b19df2017-02-15 00:42:31 -0800107 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800108 std::vector<webrtc::ReportBlock> blocks;
109 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
110 RTC_DCHECK_EQ(0, error);
111 return blocks;
112}
113
114NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800115 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800116 NetworkStatistics stats = {0};
117 int error = channel()->GetNetworkStatistics(stats);
118 RTC_DCHECK_EQ(0, error);
119 return stats;
120}
121
122AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800123 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800124 AudioDecodingCallStats stats;
125 channel()->GetDecodingCallStatistics(&stats);
126 return stats;
127}
128
solenberg8d73f8c2017-03-08 01:52:20 -0800129int ChannelProxy::GetSpeechOutputLevel() const {
solenberg796b8f92017-03-01 17:02:23 -0800130 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800131 return channel()->GetSpeechOutputLevel();
solenberg796b8f92017-03-01 17:02:23 -0800132}
133
solenberg8d73f8c2017-03-08 01:52:20 -0800134int ChannelProxy::GetSpeechOutputLevelFullRange() const {
solenberg08b19df2017-02-15 00:42:31 -0800135 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800136 return channel()->GetSpeechOutputLevelFullRange();
solenberg358057b2015-11-27 10:46:42 -0800137}
138
139uint32_t ChannelProxy::GetDelayEstimate() const {
solenberg08b19df2017-02-15 00:42:31 -0800140 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
141 module_process_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800142 return channel()->GetDelayEstimate();
143}
144
solenbergffbbcac2016-11-17 05:25:37 -0800145bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type,
146 int payload_frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800147 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergffbbcac2016-11-17 05:25:37 -0800148 return channel()->SetSendTelephoneEventPayloadType(payload_type,
149 payload_frequency) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100150}
151
solenberg8842c3e2016-03-11 03:06:41 -0800152bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800153 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800154 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100155}
156
minyue78b4d562016-11-30 04:47:39 -0800157void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
tommi0f8b4032017-02-22 11:22:05 -0800158 // This method can be called on the worker thread, module process thread
159 // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
160 // TODO(solenberg): Figure out a good way to check this or enforce calling
161 // rules.
162 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
163 // module_process_thread_checker_.CalledOnValidThread());
minyue78b4d562016-11-30 04:47:39 -0800164 channel()->SetBitRate(bitrate_bps, probing_interval_ms);
mflodman86cc6ff2016-07-26 04:44:06 -0700165}
166
kwibergd32bf752017-01-19 07:03:59 -0800167void ChannelProxy::SetRecPayloadType(int payload_type,
168 const SdpAudioFormat& format) {
solenberg08b19df2017-02-15 00:42:31 -0800169 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
kwibergd32bf752017-01-19 07:03:59 -0800170 const int result = channel()->SetRecPayloadType(payload_type, format);
171 RTC_DCHECK_EQ(0, result);
172}
173
kwiberg1c07c702017-03-27 07:15:49 -0700174void ChannelProxy::SetReceiveCodecs(
175 const std::map<int, SdpAudioFormat>& codecs) {
176 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
177 channel()->SetReceiveCodecs(codecs);
178}
179
kwibergb7f89d62016-02-17 10:04:18 -0800180void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800181 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800182 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100183}
184
solenberg94218532016-06-16 10:53:22 -0700185void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800186 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800187 channel()->SetInputMute(muted);
solenberg94218532016-06-16 10:53:22 -0700188}
189
mflodman3d7db262016-04-29 00:57:13 -0700190void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800191 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700192 int error = channel()->RegisterExternalTransport(transport);
193 RTC_DCHECK_EQ(0, error);
194}
195
196void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800197 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700198 channel()->DeRegisterExternalTransport();
199}
200
nisse657bab22017-02-21 06:28:10 -0800201void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700202 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800203 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700204}
205
206bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
207 // May be called on either worker thread or network thread.
208 return channel()->ReceivedRTCPPacket(packet, length) == 0;
209}
210
ossu29b1a8d2016-06-13 07:34:51 -0700211const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700212 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800213 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700214 return channel()->GetAudioDecoderFactory();
215}
216
solenberg217fb662016-06-17 08:30:54 -0700217void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800218 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800219 channel()->SetChannelOutputVolumeScaling(scaling);
solenberg217fb662016-06-17 08:30:54 -0700220}
221
ivoc14d5dbe2016-07-04 07:06:55 -0700222void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800223 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700224 channel()->SetRtcEventLog(event_log);
225}
226
minyue6b825df2016-10-31 04:08:32 -0700227void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800228 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700229 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
230 RTC_DCHECK(ret);
231;}
232
233void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800234 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700235 channel()->DisableAudioNetworkAdaptor();
236}
237
238void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
239 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800240 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700241 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
242 max_frame_length_ms);
243}
244
aleloi6c278492016-10-20 14:24:39 -0700245AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
246 int sample_rate_hz,
247 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800248 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700249 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700250}
251
aleloi051f6782016-10-31 03:26:40 -0700252int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800253 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700254 return static_cast<int>(channel()->NeededFrequency(-1));
255}
256
michaelt79e05882016-11-08 02:50:09 -0800257void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800258 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800259 channel()->SetTransportOverhead(transport_overhead_per_packet);
260}
261
solenberg7602aab2016-11-14 11:30:07 -0800262void ChannelProxy::AssociateSendChannel(
263 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800264 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800265 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
266}
267
268void ChannelProxy::DisassociateSendChannel() {
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(ChannelOwner(nullptr));
271}
272
solenberg3ebbcb52017-01-31 03:58:40 -0800273void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
274 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800275 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800276 RTC_DCHECK(rtp_rtcp);
277 RTC_DCHECK(rtp_receiver);
278 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
279 RTC_DCHECK_EQ(0, error);
280}
281
solenberg3ebbcb52017-01-31 03:58:40 -0800282uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800283 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800284 unsigned int timestamp = 0;
285 int error = channel()->GetPlayoutTimestamp(timestamp);
286 RTC_DCHECK(!error || timestamp == 0);
287 return timestamp;
288}
289
290void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800291 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800292 // Limit to range accepted by both VoE and ACM, so we're at least getting as
293 // close as possible, instead of failing.
294 delay_ms = std::max(0, std::min(delay_ms, 10000));
295 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800296 if (0 != error) {
297 LOG(LS_WARNING) << "Error setting minimum playout delay.";
298 }
solenberg3ebbcb52017-01-31 03:58:40 -0800299}
300
michaelt9332b7d2016-11-30 07:51:13 -0800301void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800302 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800303 channel()->SetRtcpRttStats(rtcp_rtt_stats);
304}
305
solenbergbd9a77f2017-02-06 12:53:57 -0800306bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800307 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800308 return channel()->GetRecCodec(*codec_inst) == 0;
309}
310
311bool ChannelProxy::GetSendCodec(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()->GetSendCodec(*codec_inst) == 0;
314}
315
316bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800317 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800318 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
319}
320
321bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800322 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800323 return channel()->SetCodecFECStatus(enable) == 0;
324}
325
326bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800327 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800328 return channel()->SetOpusDtx(enable) == 0;
329}
330
331bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800332 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800333 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
334}
335
336bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800337 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800338 // Validation code copied from VoECodecImpl::SetSendCodec().
339 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
340 (codec_inst.pacsize >= 960)) {
341 return false;
342 }
343 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
344 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
345 !STR_CASE_CMP(codec_inst.plname, "RED")) {
346 return false;
347 }
348 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
349 return false;
350 }
351 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
352 return false;
353 }
354 return channel()->SetSendCodec(codec_inst) == 0;
355}
356
357bool ChannelProxy::SetSendCNPayloadType(int type,
358 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800359 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800360 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
361 if (type < 96 || type > 127) {
362 // Only allow dynamic range: 96 to 127
363 return false;
364 }
365 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
366 // It is not possible to modify the payload type for CN/8000.
367 // We only allow modification of the CN payload type for CN/16000
368 // and CN/32000.
369 return false;
370 }
371 return channel()->SetSendCNPayloadType(type, frequency) == 0;
372}
373
elad.alond12a8e12017-03-23 11:04:48 -0700374void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) {
375 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
376 channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate);
377}
378
elad.alondadb4dc2017-03-23 15:29:50 -0700379void ChannelProxy::OnRecoverableUplinkPacketLossRate(
380 float recoverable_packet_loss_rate) {
381 // TODO(elad.alon): This fails in UT; fix and uncomment.
382 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
383 channel()->OnRecoverableUplinkPacketLossRate(recoverable_packet_loss_rate);
384}
385
kwiberg1c07c702017-03-27 07:15:49 -0700386void ChannelProxy::RegisterLegacyReceiveCodecs() {
387 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
388 channel()->RegisterLegacyReceiveCodecs();
389}
390
solenberg358057b2015-11-27 10:46:42 -0800391Channel* ChannelProxy::channel() const {
392 RTC_DCHECK(channel_owner_.channel());
393 return channel_owner_.channel();
394}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100395
solenberg13725082015-11-25 08:16:52 -0800396} // namespace voe
397} // namespace webrtc