Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: webrtc/voice_engine/channel_proxy.cc

Issue 2705093002: Injectable audio encoders: WebRtcVoiceEngine and company (Closed)
Patch Set: AudioSendStream::Reconfigure() Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 ChannelProxy::~ChannelProxy() {} 30 ChannelProxy::~ChannelProxy() {}
31 31
32 bool ChannelProxy::SetEncoder(int payload_type, 32 bool ChannelProxy::SetEncoder(int payload_type,
33 std::unique_ptr<AudioEncoder> encoder) { 33 std::unique_ptr<AudioEncoder> encoder) {
34 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 34 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
35 return channel()->SetEncoder(payload_type, std::move(encoder)); 35 return channel()->SetEncoder(payload_type, std::move(encoder));
36 } 36 }
37 37
38 void ChannelProxy::ModifyEncoder(
39 rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) {
40 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
41 channel()->ModifyEncoder(modifier);
42 }
43
38 void ChannelProxy::SetRTCPStatus(bool enable) { 44 void ChannelProxy::SetRTCPStatus(bool enable) {
39 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 45 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
40 channel()->SetRTCPStatus(enable); 46 channel()->SetRTCPStatus(enable);
41 } 47 }
42 48
43 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { 49 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) {
44 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 50 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
45 int error = channel()->SetLocalSSRC(ssrc); 51 int error = channel()->SetLocalSSRC(ssrc);
46 RTC_DCHECK_EQ(0, error); 52 RTC_DCHECK_EQ(0, error);
47 } 53 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { 225 void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) {
220 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 226 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
221 channel()->SetChannelOutputVolumeScaling(scaling); 227 channel()->SetChannelOutputVolumeScaling(scaling);
222 } 228 }
223 229
224 void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { 230 void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) {
225 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 231 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
226 channel()->SetRtcEventLog(event_log); 232 channel()->SetRtcEventLog(event_log);
227 } 233 }
228 234
229 void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) {
230 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
231 bool ret = channel()->EnableAudioNetworkAdaptor(config_string);
232 RTC_DCHECK(ret);
233 ;}
234
235 void ChannelProxy::DisableAudioNetworkAdaptor() {
236 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
237 channel()->DisableAudioNetworkAdaptor();
238 }
239
240 void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms,
241 int max_frame_length_ms) {
242 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
243 channel()->SetReceiverFrameLengthRange(min_frame_length_ms,
244 max_frame_length_ms);
245 }
246
247 AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( 235 AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo(
248 int sample_rate_hz, 236 int sample_rate_hz,
249 AudioFrame* audio_frame) { 237 AudioFrame* audio_frame) {
250 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); 238 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
251 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); 239 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame);
252 } 240 }
253 241
254 int ChannelProxy::NeededFrequency() const { 242 int ChannelProxy::NeededFrequency() const {
255 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); 243 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_);
256 return static_cast<int>(channel()->NeededFrequency(-1)); 244 return static_cast<int>(channel()->NeededFrequency(-1));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { 291 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) {
304 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 292 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
305 channel()->SetRtcpRttStats(rtcp_rtt_stats); 293 channel()->SetRtcpRttStats(rtcp_rtt_stats);
306 } 294 }
307 295
308 bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { 296 bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const {
309 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 297 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
310 return channel()->GetRecCodec(*codec_inst) == 0; 298 return channel()->GetRecCodec(*codec_inst) == 0;
311 } 299 }
312 300
313 bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const {
314 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
315 return channel()->GetSendCodec(*codec_inst) == 0;
316 }
317
318 bool ChannelProxy::SetVADStatus(bool enable) {
319 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
320 return channel()->SetVADStatus(enable, VADNormal, false) == 0;
321 }
322
323 bool ChannelProxy::SetCodecFECStatus(bool enable) {
324 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
325 return channel()->SetCodecFECStatus(enable) == 0;
326 }
327
328 bool ChannelProxy::SetOpusDtx(bool enable) {
329 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
330 return channel()->SetOpusDtx(enable) == 0;
331 }
332
333 bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) {
334 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
335 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0;
336 }
337
338 bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) {
339 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
340 // Validation code copied from VoECodecImpl::SetSendCodec().
341 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) &&
342 (codec_inst.pacsize >= 960)) {
343 return false;
344 }
345 if (!STR_CASE_CMP(codec_inst.plname, "CN") ||
346 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") ||
347 !STR_CASE_CMP(codec_inst.plname, "RED")) {
348 return false;
349 }
350 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) {
351 return false;
352 }
353 if (!AudioCodingModule::IsCodecValid(codec_inst)) {
354 return false;
355 }
356 return channel()->SetSendCodec(codec_inst) == 0;
357 }
358
359 bool ChannelProxy::SetSendCNPayloadType(int type,
360 PayloadFrequencies frequency) {
361 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
362 // Validation code copied from VoECodecImpl::SetSendCNPayloadType().
363 if (type < 96 || type > 127) {
364 // Only allow dynamic range: 96 to 127
365 return false;
366 }
367 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) {
368 // It is not possible to modify the payload type for CN/8000.
369 // We only allow modification of the CN payload type for CN/16000
370 // and CN/32000.
371 return false;
372 }
373 return channel()->SetSendCNPayloadType(type, frequency) == 0;
374 }
375
376 Channel* ChannelProxy::channel() const { 301 Channel* ChannelProxy::channel() const {
377 RTC_DCHECK(channel_owner_.channel()); 302 RTC_DCHECK(channel_owner_.channel());
378 return channel_owner_.channel(); 303 return channel_owner_.channel();
379 } 304 }
380 305
381 } // namespace voe 306 } // namespace voe
382 } // namespace webrtc 307 } // namespace webrtc
OLDNEW
« webrtc/voice_engine/channel.h ('K') | « webrtc/voice_engine/channel_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698