blob: 86501409e242ebc7d453e42fbd99b3da7163632d [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
131int32_t ChannelProxy::GetSpeechOutputLevelFullRange() const {
solenberg08b19df2017-02-15 00:42:31 -0800132 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg358057b2015-11-27 10:46:42 -0800133 uint32_t level = 0;
134 int error = channel()->GetSpeechOutputLevelFullRange(level);
135 RTC_DCHECK_EQ(0, error);
136 return static_cast<int32_t>(level);
137}
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) {
solenberg08b19df2017-02-15 00:42:31 -0800158 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread() ||
159 module_process_thread_checker_.CalledOnValidThread());
minyue78b4d562016-11-30 04:47:39 -0800160 channel()->SetBitRate(bitrate_bps, probing_interval_ms);
mflodman86cc6ff2016-07-26 04:44:06 -0700161}
162
kwibergd32bf752017-01-19 07:03:59 -0800163void ChannelProxy::SetRecPayloadType(int payload_type,
164 const SdpAudioFormat& format) {
solenberg08b19df2017-02-15 00:42:31 -0800165 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
kwibergd32bf752017-01-19 07:03:59 -0800166 const int result = channel()->SetRecPayloadType(payload_type, format);
167 RTC_DCHECK_EQ(0, result);
168}
169
kwibergb7f89d62016-02-17 10:04:18 -0800170void ChannelProxy::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
solenberg08b19df2017-02-15 00:42:31 -0800171 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
deadbeef2d110be2016-01-13 12:00:26 -0800172 channel()->SetSink(std::move(sink));
Tommif888bb52015-12-12 01:37:01 +0100173}
174
solenberg94218532016-06-16 10:53:22 -0700175void ChannelProxy::SetInputMute(bool muted) {
solenberg08b19df2017-02-15 00:42:31 -0800176 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg94218532016-06-16 10:53:22 -0700177 int error = channel()->SetInputMute(muted);
178 RTC_DCHECK_EQ(0, error);
179}
180
mflodman3d7db262016-04-29 00:57:13 -0700181void ChannelProxy::RegisterExternalTransport(Transport* transport) {
solenberg08b19df2017-02-15 00:42:31 -0800182 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700183 int error = channel()->RegisterExternalTransport(transport);
184 RTC_DCHECK_EQ(0, error);
185}
186
187void ChannelProxy::DeRegisterExternalTransport() {
solenberg08b19df2017-02-15 00:42:31 -0800188 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
mflodman3d7db262016-04-29 00:57:13 -0700189 channel()->DeRegisterExternalTransport();
190}
191
nisse657bab22017-02-21 06:28:10 -0800192void ChannelProxy::OnRtpPacket(const RtpPacketReceived& packet) {
mflodman3d7db262016-04-29 00:57:13 -0700193 // May be called on either worker thread or network thread.
nisse657bab22017-02-21 06:28:10 -0800194 channel()->OnRtpPacket(packet);
mflodman3d7db262016-04-29 00:57:13 -0700195}
196
197bool ChannelProxy::ReceivedRTCPPacket(const uint8_t* packet, size_t length) {
198 // May be called on either worker thread or network thread.
199 return channel()->ReceivedRTCPPacket(packet, length) == 0;
200}
201
ossu29b1a8d2016-06-13 07:34:51 -0700202const rtc::scoped_refptr<AudioDecoderFactory>&
solenberg217fb662016-06-17 08:30:54 -0700203 ChannelProxy::GetAudioDecoderFactory() const {
solenberg08b19df2017-02-15 00:42:31 -0800204 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ossu29b1a8d2016-06-13 07:34:51 -0700205 return channel()->GetAudioDecoderFactory();
206}
207
solenberg217fb662016-06-17 08:30:54 -0700208void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
solenberg08b19df2017-02-15 00:42:31 -0800209 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg217fb662016-06-17 08:30:54 -0700210 int error = channel()->SetChannelOutputVolumeScaling(scaling);
211 RTC_DCHECK_EQ(0, error);
212}
213
ivoc14d5dbe2016-07-04 07:06:55 -0700214void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
solenberg08b19df2017-02-15 00:42:31 -0800215 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
ivoc14d5dbe2016-07-04 07:06:55 -0700216 channel()->SetRtcEventLog(event_log);
217}
218
minyue6b825df2016-10-31 04:08:32 -0700219void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
solenberg08b19df2017-02-15 00:42:31 -0800220 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700221 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
222 RTC_DCHECK(ret);
223;}
224
225void ChannelProxy::DisableAudioNetworkAdaptor() {
solenberg08b19df2017-02-15 00:42:31 -0800226 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700227 channel()->DisableAudioNetworkAdaptor();
228}
229
230void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
231 int max_frame_length_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800232 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
minyue6b825df2016-10-31 04:08:32 -0700233 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
234 max_frame_length_ms);
235}
236
aleloi6c278492016-10-20 14:24:39 -0700237AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
238 int sample_rate_hz,
239 AudioFrame* audio_frame) {
solenberg08b19df2017-02-15 00:42:31 -0800240 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi6c278492016-10-20 14:24:39 -0700241 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
aleloiaed581a2016-10-20 06:32:39 -0700242}
243
aleloi051f6782016-10-31 03:26:40 -0700244int ChannelProxy::NeededFrequency() const {
solenberg08b19df2017-02-15 00:42:31 -0800245 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
aleloi051f6782016-10-31 03:26:40 -0700246 return static_cast<int>(channel()->NeededFrequency(-1));
247}
248
michaelt79e05882016-11-08 02:50:09 -0800249void ChannelProxy::SetTransportOverhead(int transport_overhead_per_packet) {
solenberg08b19df2017-02-15 00:42:31 -0800250 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt79e05882016-11-08 02:50:09 -0800251 channel()->SetTransportOverhead(transport_overhead_per_packet);
252}
253
solenberg7602aab2016-11-14 11:30:07 -0800254void ChannelProxy::AssociateSendChannel(
255 const ChannelProxy& send_channel_proxy) {
solenberg08b19df2017-02-15 00:42:31 -0800256 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800257 channel()->set_associate_send_channel(send_channel_proxy.channel_owner_);
258}
259
260void ChannelProxy::DisassociateSendChannel() {
solenberg08b19df2017-02-15 00:42:31 -0800261 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenberg7602aab2016-11-14 11:30:07 -0800262 channel()->set_associate_send_channel(ChannelOwner(nullptr));
263}
264
solenberg3ebbcb52017-01-31 03:58:40 -0800265void ChannelProxy::GetRtpRtcp(RtpRtcp** rtp_rtcp,
266 RtpReceiver** rtp_receiver) const {
solenberg08b19df2017-02-15 00:42:31 -0800267 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800268 RTC_DCHECK(rtp_rtcp);
269 RTC_DCHECK(rtp_receiver);
270 int error = channel()->GetRtpRtcp(rtp_rtcp, rtp_receiver);
271 RTC_DCHECK_EQ(0, error);
272}
273
solenberg3ebbcb52017-01-31 03:58:40 -0800274uint32_t ChannelProxy::GetPlayoutTimestamp() const {
solenberg08b19df2017-02-15 00:42:31 -0800275 RTC_DCHECK_RUNS_SERIALIZED(&video_capture_thread_race_checker_);
solenberg3ebbcb52017-01-31 03:58:40 -0800276 unsigned int timestamp = 0;
277 int error = channel()->GetPlayoutTimestamp(timestamp);
278 RTC_DCHECK(!error || timestamp == 0);
279 return timestamp;
280}
281
282void ChannelProxy::SetMinimumPlayoutDelay(int delay_ms) {
solenberg08b19df2017-02-15 00:42:31 -0800283 RTC_DCHECK(module_process_thread_checker_.CalledOnValidThread());
solenberg3ebbcb52017-01-31 03:58:40 -0800284 // Limit to range accepted by both VoE and ACM, so we're at least getting as
285 // close as possible, instead of failing.
286 delay_ms = std::max(0, std::min(delay_ms, 10000));
287 int error = channel()->SetMinimumPlayoutDelay(delay_ms);
solenberg0335e6c2017-02-22 07:07:04 -0800288 if (0 != error) {
289 LOG(LS_WARNING) << "Error setting minimum playout delay.";
290 }
solenberg3ebbcb52017-01-31 03:58:40 -0800291}
292
michaelt9332b7d2016-11-30 07:51:13 -0800293void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
solenberg08b19df2017-02-15 00:42:31 -0800294 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
michaelt9332b7d2016-11-30 07:51:13 -0800295 channel()->SetRtcpRttStats(rtcp_rtt_stats);
296}
297
solenbergbd9a77f2017-02-06 12:53:57 -0800298bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800299 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800300 return channel()->GetRecCodec(*codec_inst) == 0;
301}
302
303bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
solenberg08b19df2017-02-15 00:42:31 -0800304 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800305 return channel()->GetSendCodec(*codec_inst) == 0;
306}
307
308bool ChannelProxy::SetVADStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800309 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800310 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
311}
312
313bool ChannelProxy::SetCodecFECStatus(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800314 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800315 return channel()->SetCodecFECStatus(enable) == 0;
316}
317
318bool ChannelProxy::SetOpusDtx(bool enable) {
solenberg08b19df2017-02-15 00:42:31 -0800319 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800320 return channel()->SetOpusDtx(enable) == 0;
321}
322
323bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
solenberg08b19df2017-02-15 00:42:31 -0800324 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800325 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
326}
327
328bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
solenberg08b19df2017-02-15 00:42:31 -0800329 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800330 // Validation code copied from VoECodecImpl::SetSendCodec().
331 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
332 (codec_inst.pacsize >= 960)) {
333 return false;
334 }
335 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
336 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
337 !STR_CASE_CMP(codec_inst.plname, "RED")) {
338 return false;
339 }
340 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
341 return false;
342 }
343 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
344 return false;
345 }
346 return channel()->SetSendCodec(codec_inst) == 0;
347}
348
349bool ChannelProxy::SetSendCNPayloadType(int type,
350 PayloadFrequencies frequency) {
solenberg08b19df2017-02-15 00:42:31 -0800351 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
solenbergbd9a77f2017-02-06 12:53:57 -0800352 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
353 if (type < 96 || type > 127) {
354 // Only allow dynamic range: 96 to 127
355 return false;
356 }
357 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
358 // It is not possible to modify the payload type for CN/8000.
359 // We only allow modification of the CN payload type for CN/16000
360 // and CN/32000.
361 return false;
362 }
363 return channel()->SetSendCNPayloadType(type, frequency) == 0;
364}
365
solenberg358057b2015-11-27 10:46:42 -0800366Channel* ChannelProxy::channel() const {
367 RTC_DCHECK(channel_owner_.channel());
368 return channel_owner_.channel();
369}
Stefan Holmerb86d4e42015-12-07 10:26:18 +0100370
solenberg13725082015-11-25 08:16:52 -0800371} // namespace voe
372} // namespace webrtc