blob: ca1d3596c888191dbb4a04b99427080d7220f855 [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"
solenberg13725082015-11-25 08:16:52 -080018#include "webrtc/voice_engine/channel.h"
19
20namespace webrtc {
21namespace voe {
22ChannelProxy::ChannelProxy() : channel_owner_(nullptr) {}
23
24ChannelProxy::ChannelProxy(const ChannelOwner& channel_owner) :
25 channel_owner_(channel_owner) {
26 RTC_CHECK(channel_owner_.channel());
solenberg08b19df2017-02-15 00:42:31 -080027 module_process_thread_checker_.DetachFromThread();
solenberg13725082015-11-25 08:16:52 -080028}
29
Tommif888bb52015-12-12 01:37:01 +010030ChannelProxy::~ChannelProxy() {}
31
solenberg13725082015-11-25 08:16:52 -080032void ChannelProxy::SetRTCPStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -080033 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080034 channel()->SetRTCPStatus(enable);
solenberg13725082015-11-25 08:16:52 -080035}
36
37void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
solenberg08b19df2017-02-15 00:42:31 -080038 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080039 int error = channel()->SetLocalSSRC(ssrc);
solenberg13725082015-11-25 08:16:52 -080040 RTC_DCHECK_EQ(0, error);
41}
42
43void ChannelProxy::SetRTCP_CNAME(const std::string& c_name) {
solenberg08b19df2017-02-15 00:42:31 -080044 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg13725082015-11-25 08:16:52 -080045 // Note: VoERTP_RTCP::SetRTCP_CNAME() accepts a char[256] array.
46 std::string c_name_limited = c_name.substr(0, 255);
solenberg358057b2015-11-27 10:46:42 -080047 int error = channel()->SetRTCP_CNAME(c_name_limited.c_str());
solenberg13725082015-11-25 08:16:52 -080048 RTC_DCHECK_EQ(0, error);
49}
solenberg358057b2015-11-27 10:46:42 -080050
solenberg971cab02016-06-14 10:02:41 -070051void ChannelProxy::SetNACKStatus(bool enable, int max_packets) {
solenberg08b19df2017-02-15 00:42:31 -080052 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg971cab02016-06-14 10:02:41 -070053 channel()->SetNACKStatus(enable, max_packets);
54}
55
solenberg358057b2015-11-27 10:46:42 -080056void ChannelProxy::SetSendAudioLevelIndicationStatus(bool enable, int id) {
solenberg08b19df2017-02-15 00:42:31 -080057 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080058 int error = channel()->SetSendAudioLevelIndicationStatus(enable, id);
59 RTC_DCHECK_EQ(0, error);
60}
61
solenberg358057b2015-11-27 10:46:42 -080062void ChannelProxy::SetReceiveAudioLevelIndicationStatus(bool enable, int id) {
solenberg08b19df2017-02-15 00:42:31 -080063 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -080064 int error = channel()->SetReceiveAudioLevelIndicationStatus(enable, id);
65 RTC_DCHECK_EQ(0, error);
66}
67
stefan3313ec92016-01-21 06:32:43 -080068void ChannelProxy::EnableSendTransportSequenceNumber(int id) {
solenberg08b19df2017-02-15 00:42:31 -080069 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefan3313ec92016-01-21 06:32:43 -080070 channel()->EnableSendTransportSequenceNumber(id);
71}
72
73void ChannelProxy::EnableReceiveTransportSequenceNumber(int id) {
solenberg08b19df2017-02-15 00:42:31 -080074 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefan3313ec92016-01-21 06:32:43 -080075 channel()->EnableReceiveTransportSequenceNumber(id);
76}
77
stefanbba9dec2016-02-01 04:39:55 -080078void ChannelProxy::RegisterSenderCongestionControlObjects(
Stefan Holmerb86d4e42015-12-07 10:26:18 +010079 RtpPacketSender* rtp_packet_sender,
80 TransportFeedbackObserver* transport_feedback_observer,
stefan7de8d642017-02-07 07:14:08 -080081 PacketRouter* packet_router,
82 RtcpBandwidthObserver* bandwidth_observer) {
solenberg08b19df2017-02-15 00:42:31 -080083 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080084 channel()->RegisterSenderCongestionControlObjects(
stefan7de8d642017-02-07 07:14:08 -080085 rtp_packet_sender, transport_feedback_observer, packet_router,
86 bandwidth_observer);
Stefan Holmerb86d4e42015-12-07 10:26:18 +010087}
88
stefanbba9dec2016-02-01 04:39:55 -080089void ChannelProxy::RegisterReceiverCongestionControlObjects(
90 PacketRouter* packet_router) {
solenberg08b19df2017-02-15 00:42:31 -080091 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080092 channel()->RegisterReceiverCongestionControlObjects(packet_router);
93}
94
95void ChannelProxy::ResetCongestionControlObjects() {
solenberg08b19df2017-02-15 00:42:31 -080096 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
stefanbba9dec2016-02-01 04:39:55 -080097 channel()->ResetCongestionControlObjects();
98}
99
solenberg358057b2015-11-27 10:46:42 -0800100CallStatistics ChannelProxy::GetRTCPStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800101 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800102 CallStatistics stats = {0};
103 int error = channel()->GetRTPStatistics(stats);
104 RTC_DCHECK_EQ(0, error);
105 return stats;
106}
107
108std::vector<ReportBlock> ChannelProxy::GetRemoteRTCPReportBlocks() const {
solenberg08b19df2017-02-15 00:42:31 -0800109 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800110 std::vector<webrtc::ReportBlock> blocks;
111 int error = channel()->GetRemoteRTCPReportBlocks(&blocks);
112 RTC_DCHECK_EQ(0, error);
113 return blocks;
114}
115
116NetworkStatistics ChannelProxy::GetNetworkStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800117 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800118 NetworkStatistics stats = {0};
119 int error = channel()->GetNetworkStatistics(stats);
120 RTC_DCHECK_EQ(0, error);
121 return stats;
122}
123
124AudioDecodingCallStats ChannelProxy::GetDecodingCallStatistics() const {
solenberg08b19df2017-02-15 00:42:31 -0800125 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800126 AudioDecodingCallStats stats;
127 channel()->GetDecodingCallStatistics(&stats);
128 return stats;
129}
130
solenberg796b8f92017-03-01 17:02:23 -0800131int32_t ChannelProxy::GetSpeechOutputLevel() const {
132 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
133 uint32_t level = 0;
134 int error = channel()->GetSpeechOutputLevel(level);
135 RTC_DCHECK_EQ(0, error);
136 return static_cast<int32_t>(level);
137}
138
solenberg358057b2015-11-27 10:46:42 -0800139int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
solenberg08b19df2017-02-15 00:42:31 -0800140 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800141 uint32_t level = 0;
142 int error = channel()->GetSpeechOutputLevelFullRange(level);
143 RTC_DCHECK_EQ(0, error);
144 return static_cast<int32_t>(level);
145}
146
147uint32_t ChannelProxy::GetDelayEstimate() const {
solenberg08b19df2017-02-15 00:42:31 -0800148 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
149 module_process_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800150 return channel()->GetDelayEstimate();
151}
152
solenbergffbbcac2016-11-17 05:25:37 -0800153bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type,
154 int payload_frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800155 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergffbbcac2016-11-17 05:25:37 -0800156 return channel()->SetSendTelephoneEventPayloadType(payload_type,
157 payload_frequency) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100158}
159
solenberg8842c3e2016-03-11 03:06:41 -0800160bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800161 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800162 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100163}
164
minyue78b4d562016-11-30 04:47:39 -0800165void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
tommi0f8b4032017-02-22 11:22:05 -0800166 // This method can be called on the worker thread, module process thread
167 // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
168 // TODO(solenberg): Figure out a good way to check this or enforce calling
169 // rules.
170 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
171 // module_process_thread_checker_.CalledOnValidThread());
minyue78b4d562016-11-30 04:47:39 -0800172 channel()->SetBitRate(bitrate_bps, probing_interval_ms);
mflodman86cc6ff2016-07-26 04:44:06 -0700173}
174
kwibergd32bf752017-01-19 07:03:59 -0800175void ChannelProxy::SetRecPayloadType(int payload_type,
176 const SdpAudioFormat& format) {
solenberg08b19df2017-02-15 00:42:31 -0800177 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
kwibergd32bf752017-01-19 07:03:59 -0800178 const int result = channel()->SetRecPayloadType(payload_type, format);
179 RTC_DCHECK_EQ(0, result);
180}
181
kwibergb7f89d62016-02-17 10:04:18 -0800182void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800183 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800184 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100185}
186
solenberg94218532016-06-16 10:53:22 -0700187void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800188 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg94218532016-06-16 10:53:22 -0700189 int error = channel()->SetInputMute(muted);
190 RTC_DCHECK_EQ(0, error);
191}
192
mflodman3d7db262016-04-29 00:57:13 -0700193void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800194 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700195 int error = channel()->RegisterExternalTransport(transport);
196 RTC_DCHECK_EQ(0, error);
197}
198
199void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800200 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700201 channel()->DeRegisterExternalTransport();
202}
203
nisse657bab22017-02-21 06:28:10 -0800204void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700205 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800206 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700207}
208
209bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
210 // May be called on either worker thread or network thread.
211 return channel()->ReceivedRTCPPacket(packet, length) == 0;
212}
213
ossu29b1a8d2016-06-13 07:34:51 -0700214const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700215 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800216 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700217 return channel()->GetAudioDecoderFactory();
218}
219
solenberg217fb662016-06-17 08:30:54 -0700220void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800221 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg217fb662016-06-17 08:30:54 -0700222 int error = channel()->SetChannelOutputVolumeScaling(scaling);
223 RTC_DCHECK_EQ(0, error);
224}
225
ivoc14d5dbe2016-07-04 07:06:55 -0700226void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800227 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700228 channel()->SetRtcEventLog(event_log);
229}
230
minyue6b825df2016-10-31 04:08:32 -0700231void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800232 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700233 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
234 RTC_DCHECK(ret);
235;}
236
237void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800238 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700239 channel()->DisableAudioNetworkAdaptor();
240}
241
242void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
243 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800244 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700245 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
246 max_frame_length_ms);
247}
248
aleloi6c278492016-10-20 14:24:39 -0700249AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
250 int sample_rate_hz,
251 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800252 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700253 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700254}
255
aleloi051f6782016-10-31 03:26:40 -0700256int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800257 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700258 return static_cast<int>(channel()->NeededFrequency(-1));
259}
260
michaelt79e05882016-11-08 02:50:09 -0800261void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800262 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800263 channel()->SetTransportOverhead(transport_overhead_per_packet);
264}
265
solenberg7602aab2016-11-14 11:30:07 -0800266void ChannelProxy::AssociateSendChannel(
267 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800268 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800269 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
270}
271
272void ChannelProxy::DisassociateSendChannel() {
solenberg08b19df2017-02-15 00:42:31 -0800273 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800274 channel()->set_associate_send_channel(ChannelOwner(nullptr));
275}
276
solenberg3ebbcb52017-01-31 03:58:40 -0800277void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
278 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800279 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800280 RTC_DCHECK(rtp_rtcp);
281 RTC_DCHECK(rtp_receiver);
282 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
283 RTC_DCHECK_EQ(0, error);
284}
285
solenberg3ebbcb52017-01-31 03:58:40 -0800286uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800287 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800288 unsigned int timestamp = 0;
289 int error = channel()->GetPlayoutTimestamp(timestamp);
290 RTC_DCHECK(!error || timestamp == 0);
291 return timestamp;
292}
293
294void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800295 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800296 // Limit to range accepted by both VoE and ACM, so we're at least getting as
297 // close as possible, instead of failing.
298 delay_ms = std::max(0, std::min(delay_ms, 10000));
299 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800300 if (0 != error) {
301 LOG(LS_WARNING) << "Error setting minimum playout delay.";
302 }
solenberg3ebbcb52017-01-31 03:58:40 -0800303}
304
michaelt9332b7d2016-11-30 07:51:13 -0800305void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800306 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800307 channel()->SetRtcpRttStats(rtcp_rtt_stats);
308}
309
solenbergbd9a77f2017-02-06 12:53:57 -0800310bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800311 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800312 return channel()->GetRecCodec(*codec_inst) == 0;
313}
314
315bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800316 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800317 return channel()->GetSendCodec(*codec_inst) == 0;
318}
319
320bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800321 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800322 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
323}
324
325bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800326 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800327 return channel()->SetCodecFECStatus(enable) == 0;
328}
329
330bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800331 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800332 return channel()->SetOpusDtx(enable) == 0;
333}
334
335bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800336 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800337 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
338}
339
340bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800341 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800342 // Validation code copied from VoECodecImpl::SetSendCodec().
343 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
344 (codec_inst.pacsize >= 960)) {
345 return false;
346 }
347 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
348 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
349 !STR_CASE_CMP(codec_inst.plname, "RED")) {
350 return false;
351 }
352 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
353 return false;
354 }
355 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
356 return false;
357 }
358 return channel()->SetSendCodec(codec_inst) == 0;
359}
360
361bool ChannelProxy::SetSendCNPayloadType(int type,
362 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800363 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800364 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
365 if (type < 96 || type > 127) {
366 // Only allow dynamic range: 96 to 127
367 return false;
368 }
369 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
370 // It is not possible to modify the payload type for CN/8000.
371 // We only allow modification of the CN payload type for CN/16000
372 // and CN/32000.
373 return false;
374 }
375 return channel()->SetSendCNPayloadType(type, frequency) == 0;
376}
377
solenberg358057b2015-11-27 10:46:42 -0800378Channel* ChannelProxy::channel() const {
379 RTC_DCHECK(channel_owner_.channel());
380 return channel_owner_.channel();
381}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100382
solenberg13725082015-11-25 08:16:52 -0800383} // namespace voe
384} // namespace webrtc