blob: 7f6e96c97c331dd787649ad2749089fa8edf55e1 [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
solenberg8d73f8c2017-03-08 01:52:20 -0800131int ChannelProxy::GetSpeechOutputLevel() const {
solenberg796b8f92017-03-01 17:02:23 -0800132 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800133 return channel()->GetSpeechOutputLevel();
solenberg796b8f92017-03-01 17:02:23 -0800134}
135
solenberg8d73f8c2017-03-08 01:52:20 -0800136int ChannelProxy::GetSpeechOutputLevelFullRange() const {
solenberg08b19df2017-02-15 00:42:31 -0800137 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800138 return channel()->GetSpeechOutputLevelFullRange();
solenberg358057b2015-11-27 10:46:42 -0800139}
140
141uint32_t ChannelProxy::GetDelayEstimate() const {
solenberg08b19df2017-02-15 00:42:31 -0800142 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
143 module_process_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800144 return channel()->GetDelayEstimate();
145}
146
solenbergffbbcac2016-11-17 05:25:37 -0800147bool ChannelProxy::SetSendTelephoneEventPayloadType(int payload_type,
148 int payload_frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800149 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergffbbcac2016-11-17 05:25:37 -0800150 return channel()->SetSendTelephoneEventPayloadType(payload_type,
151 payload_frequency) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100152}
153
solenberg8842c3e2016-03-11 03:06:41 -0800154bool ChannelProxy::SendTelephoneEventOutband(int event, int duration_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800155 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8842c3e2016-03-11 03:06:41 -0800156 return channel()->SendTelephoneEventOutband(event, duration_ms) == 0;
Fredrik Solenbergb5727682015-12-04 15:22:19 +0100157}
158
minyue78b4d562016-11-30 04:47:39 -0800159void ChannelProxy::SetBitrate(int bitrate_bps, int64_t probing_interval_ms) {
tommi0f8b4032017-02-22 11:22:05 -0800160 // This method can be called on the worker thread, module process thread
161 // or on a TaskQueue via VideoSendStreamImpl::OnEncoderConfigurationChanged.
162 // TODO(solenberg): Figure out a good way to check this or enforce calling
163 // rules.
164 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
165 // module_process_thread_checker_.CalledOnValidThread());
minyue78b4d562016-11-30 04:47:39 -0800166 channel()->SetBitRate(bitrate_bps, probing_interval_ms);
mflodman86cc6ff2016-07-26 04:44:06 -0700167}
168
kwibergd32bf752017-01-19 07:03:59 -0800169void ChannelProxy::SetRecPayloadType(int payload_type,
170 const SdpAudioFormat& format) {
solenberg08b19df2017-02-15 00:42:31 -0800171 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
kwibergd32bf752017-01-19 07:03:59 -0800172 const int result = channel()->SetRecPayloadType(payload_type, format);
173 RTC_DCHECK_EQ(0, result);
174}
175
kwibergb7f89d62016-02-17 10:04:18 -0800176void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800177 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800178 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100179}
180
solenberg94218532016-06-16 10:53:22 -0700181void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800182 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800183 channel()->SetInputMute(muted);
solenberg94218532016-06-16 10:53:22 -0700184}
185
mflodman3d7db262016-04-29 00:57:13 -0700186void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800187 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700188 int error = channel()->RegisterExternalTransport(transport);
189 RTC_DCHECK_EQ(0, error);
190}
191
192void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800193 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700194 channel()->DeRegisterExternalTransport();
195}
196
nisse657bab22017-02-21 06:28:10 -0800197void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700198 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800199 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700200}
201
202bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
203 // May be called on either worker thread or network thread.
204 return channel()->ReceivedRTCPPacket(packet, length) == 0;
205}
206
ossu29b1a8d2016-06-13 07:34:51 -0700207const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700208 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800209 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700210 return channel()->GetAudioDecoderFactory();
211}
212
solenberg217fb662016-06-17 08:30:54 -0700213void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800214 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg8d73f8c2017-03-08 01:52:20 -0800215 channel()->SetChannelOutputVolumeScaling(scaling);
solenberg217fb662016-06-17 08:30:54 -0700216}
217
ivoc14d5dbe2016-07-04 07:06:55 -0700218void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800219 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700220 channel()->SetRtcEventLog(event_log);
221}
222
minyue6b825df2016-10-31 04:08:32 -0700223void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800224 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700225 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
226 RTC_DCHECK(ret);
227;}
228
229void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800230 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700231 channel()->DisableAudioNetworkAdaptor();
232}
233
234void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
235 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800236 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700237 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
238 max_frame_length_ms);
239}
240
aleloi6c278492016-10-20 14:24:39 -0700241AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
242 int sample_rate_hz,
243 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800244 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700245 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700246}
247
aleloi051f6782016-10-31 03:26:40 -0700248int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800249 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700250 return static_cast<int>(channel()->NeededFrequency(-1));
251}
252
michaelt79e05882016-11-08 02:50:09 -0800253void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800254 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800255 channel()->SetTransportOverhead(transport_overhead_per_packet);
256}
257
solenberg7602aab2016-11-14 11:30:07 -0800258void ChannelProxy::AssociateSendChannel(
259 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800260 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800261 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
262}
263
264void ChannelProxy::DisassociateSendChannel() {
solenberg08b19df2017-02-15 00:42:31 -0800265 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800266 channel()->set_associate_send_channel(ChannelOwner(nullptr));
267}
268
solenberg3ebbcb52017-01-31 03:58:40 -0800269void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
270 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800271 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800272 RTC_DCHECK(rtp_rtcp);
273 RTC_DCHECK(rtp_receiver);
274 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
275 RTC_DCHECK_EQ(0, error);
276}
277
solenberg3ebbcb52017-01-31 03:58:40 -0800278uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800279 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800280 unsigned int timestamp = 0;
281 int error = channel()->GetPlayoutTimestamp(timestamp);
282 RTC_DCHECK(!error || timestamp == 0);
283 return timestamp;
284}
285
286void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800287 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800288 // Limit to range accepted by both VoE and ACM, so we're at least getting as
289 // close as possible, instead of failing.
290 delay_ms = std::max(0, std::min(delay_ms, 10000));
291 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800292 if (0 != error) {
293 LOG(LS_WARNING) << "Error setting minimum playout delay.";
294 }
solenberg3ebbcb52017-01-31 03:58:40 -0800295}
296
michaelt9332b7d2016-11-30 07:51:13 -0800297void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800298 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800299 channel()->SetRtcpRttStats(rtcp_rtt_stats);
300}
301
solenbergbd9a77f2017-02-06 12:53:57 -0800302bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800303 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800304 return channel()->GetRecCodec(*codec_inst) == 0;
305}
306
307bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800308 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800309 return channel()->GetSendCodec(*codec_inst) == 0;
310}
311
312bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800313 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800314 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
315}
316
317bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800318 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800319 return channel()->SetCodecFECStatus(enable) == 0;
320}
321
322bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800323 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800324 return channel()->SetOpusDtx(enable) == 0;
325}
326
327bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800328 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800329 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
330}
331
332bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800333 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800334 // Validation code copied from VoECodecImpl::SetSendCodec().
335 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
336 (codec_inst.pacsize >= 960)) {
337 return false;
338 }
339 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
340 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
341 !STR_CASE_CMP(codec_inst.plname, "RED")) {
342 return false;
343 }
344 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
345 return false;
346 }
347 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
348 return false;
349 }
350 return channel()->SetSendCodec(codec_inst) == 0;
351}
352
353bool ChannelProxy::SetSendCNPayloadType(int type,
354 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800355 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800356 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
357 if (type < 96 || type > 127) {
358 // Only allow dynamic range: 96 to 127
359 return false;
360 }
361 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
362 // It is not possible to modify the payload type for CN/8000.
363 // We only allow modification of the CN payload type for CN/16000
364 // and CN/32000.
365 return false;
366 }
367 return channel()->SetSendCNPayloadType(type, frequency) == 0;
368}
369
solenberg358057b2015-11-27 10:46:42 -0800370Channel* ChannelProxy::channel() const {
371 RTC_DCHECK(channel_owner_.channel());
372 return channel_owner_.channel();
373}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100374
solenberg13725082015-11-25 08:16:52 -0800375} // namespace voe
376} // namespace webrtc