blob: 97e3f9957a612d7438a21ce1f82b2bb622c8c775 [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
kwibergb7f89d62016-02-17 10:04:18 -0800174void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800175 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800176 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100177}
178
solenberg94218532016-06-16 10:53:22 -0700179void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800180 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800181 channel()->SetInputMute(muted);
solenberg94218532016-06-16 10:53:22 -0700182}
183
mflodman3d7db262016-04-29 00:57:13 -0700184void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800185 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700186 int error = channel()->RegisterExternalTransport(transport);
187 RTC_DCHECK_EQ(0, error);
188}
189
190void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800191 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700192 channel()->DeRegisterExternalTransport();
193}
194
nisse657bab22017-02-21 06:28:10 -0800195void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700196 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800197 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700198}
199
200bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
201 // May be called on either worker thread or network thread.
202 return channel()->ReceivedRTCPPacket(packet, length) == 0;
203}
204
ossu29b1a8d2016-06-13 07:34:51 -0700205const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700206 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800207 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700208 return channel()->GetAudioDecoderFactory();
209}
210
solenberg217fb662016-06-17 08:30:54 -0700211void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800212 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800213 channel()->SetChannelOutputVolumeScaling(scaling);
solenberg217fb662016-06-17 08:30:54 -0700214}
215
ivoc14d5dbe2016-07-04 07:06:55 -0700216void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800217 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700218 channel()->SetRtcEventLog(event_log);
219}
220
minyue6b825df2016-10-31 04:08:32 -0700221void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800222 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700223 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
224 RTC_DCHECK(ret);
225;}
226
227void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800228 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700229 channel()->DisableAudioNetworkAdaptor();
230}
231
232void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
233 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800234 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700235 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
236 max_frame_length_ms);
237}
238
aleloi6c278492016-10-20 14:24:39 -0700239AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
240 int sample_rate_hz,
241 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800242 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700243 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700244}
245
aleloi051f6782016-10-31 03:26:40 -0700246int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800247 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700248 return static_cast<int>(channel()->NeededFrequency(-1));
249}
250
michaelt79e05882016-11-08 02:50:09 -0800251void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800252 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800253 channel()->SetTransportOverhead(transport_overhead_per_packet);
254}
255
solenberg7602aab2016-11-14 11:30:07 -0800256void ChannelProxy::AssociateSendChannel(
257 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800258 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800259 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
260}
261
262void ChannelProxy::DisassociateSendChannel() {
solenberg08b19df2017-02-15 00:42:31 -0800263 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800264 channel()->set_associate_send_channel(ChannelOwner(nullptr));
265}
266
solenberg3ebbcb52017-01-31 03:58:40 -0800267void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
268 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800269 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800270 RTC_DCHECK(rtp_rtcp);
271 RTC_DCHECK(rtp_receiver);
272 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
273 RTC_DCHECK_EQ(0, error);
274}
275
solenberg3ebbcb52017-01-31 03:58:40 -0800276uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800277 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800278 unsigned int timestamp = 0;
279 int error = channel()->GetPlayoutTimestamp(timestamp);
280 RTC_DCHECK(!error || timestamp == 0);
281 return timestamp;
282}
283
284void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800285 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800286 // Limit to range accepted by both VoE and ACM, so we're at least getting as
287 // close as possible, instead of failing.
288 delay_ms = std::max(0, std::min(delay_ms, 10000));
289 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800290 if (0 != error) {
291 LOG(LS_WARNING) << "Error setting minimum playout delay.";
292 }
solenberg3ebbcb52017-01-31 03:58:40 -0800293}
294
michaelt9332b7d2016-11-30 07:51:13 -0800295void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800296 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800297 channel()->SetRtcpRttStats(rtcp_rtt_stats);
298}
299
solenbergbd9a77f2017-02-06 12:53:57 -0800300bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800301 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800302 return channel()->GetRecCodec(*codec_inst) == 0;
303}
304
305bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800306 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800307 return channel()->GetSendCodec(*codec_inst) == 0;
308}
309
310bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800311 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800312 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
313}
314
315bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800316 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800317 return channel()->SetCodecFECStatus(enable) == 0;
318}
319
320bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800321 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800322 return channel()->SetOpusDtx(enable) == 0;
323}
324
325bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800326 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800327 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
328}
329
330bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800331 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800332 // Validation code copied from VoECodecImpl::SetSendCodec().
333 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
334 (codec_inst.pacsize >= 960)) {
335 return false;
336 }
337 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
338 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
339 !STR_CASE_CMP(codec_inst.plname, "RED")) {
340 return false;
341 }
342 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
343 return false;
344 }
345 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
346 return false;
347 }
348 return channel()->SetSendCodec(codec_inst) == 0;
349}
350
351bool ChannelProxy::SetSendCNPayloadType(int type,
352 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800353 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800354 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
355 if (type < 96 || type > 127) {
356 // Only allow dynamic range: 96 to 127
357 return false;
358 }
359 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
360 // It is not possible to modify the payload type for CN/8000.
361 // We only allow modification of the CN payload type for CN/16000
362 // and CN/32000.
363 return false;
364 }
365 return channel()->SetSendCNPayloadType(type, frequency) == 0;
366}
367
elad.alond12a8e12017-03-23 11:04:48 -0700368void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) {
369 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
370 channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate);
371}
372
elad.alondadb4dc2017-03-23 15:29:50 -0700373void ChannelProxy::OnRecoverableUplinkPacketLossRate(
374 float recoverable_packet_loss_rate) {
375 // TODO(elad.alon): This fails in UT; fix and uncomment.
376 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
377 channel()->OnRecoverableUplinkPacketLossRate(recoverable_packet_loss_rate);
378}
379
solenberg358057b2015-11-27 10:46:42 -0800380Channel* ChannelProxy::channel() const {
381 RTC_DCHECK(channel_owner_.channel());
382 return channel_owner_.channel();
383}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100384
solenberg13725082015-11-25 08:16:52 -0800385} // namespace voe
386} // namespace webrtc