| OLD | NEW |
| 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 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 ChannelProxy::~ChannelProxy() {} | 31 ChannelProxy::~ChannelProxy() {} |
| 32 | 32 |
| 33 bool ChannelProxy::SetEncoder(int payload_type, | 33 bool ChannelProxy::SetEncoder(int payload_type, |
| 34 std::unique_ptr<AudioEncoder> encoder) { | 34 std::unique_ptr<AudioEncoder> encoder) { |
| 35 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 35 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 36 return channel()->SetEncoder(payload_type, std::move(encoder)); | 36 return channel()->SetEncoder(payload_type, std::move(encoder)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ChannelProxy::ModifyEncoder( |
| 40 rtc::FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) { |
| 41 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 42 channel()->ModifyEncoder(modifier); |
| 43 } |
| 44 |
| 39 void ChannelProxy::SetRTCPStatus(bool enable) { | 45 void ChannelProxy::SetRTCPStatus(bool enable) { |
| 40 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 46 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 41 channel()->SetRTCPStatus(enable); | 47 channel()->SetRTCPStatus(enable); |
| 42 } | 48 } |
| 43 | 49 |
| 44 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { | 50 void ChannelProxy::SetLocalSSRC(uint32_t ssrc) { |
| 45 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 51 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 46 int error = channel()->SetLocalSSRC(ssrc); | 52 int error = channel()->SetLocalSSRC(ssrc); |
| 47 RTC_DCHECK_EQ(0, error); | 53 RTC_DCHECK_EQ(0, error); |
| 48 } | 54 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { | 234 void ChannelProxy::SetChannelOutputVolumeScaling(float scaling) { |
| 229 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 235 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 230 channel()->SetChannelOutputVolumeScaling(scaling); | 236 channel()->SetChannelOutputVolumeScaling(scaling); |
| 231 } | 237 } |
| 232 | 238 |
| 233 void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { | 239 void ChannelProxy::SetRtcEventLog(RtcEventLog* event_log) { |
| 234 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 240 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 235 channel()->SetRtcEventLog(event_log); | 241 channel()->SetRtcEventLog(event_log); |
| 236 } | 242 } |
| 237 | 243 |
| 238 void ChannelProxy::EnableAudioNetworkAdaptor(const std::string& config_string) { | |
| 239 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 240 bool ret = channel()->EnableAudioNetworkAdaptor(config_string); | |
| 241 RTC_DCHECK(ret); | |
| 242 ;} | |
| 243 | |
| 244 void ChannelProxy::DisableAudioNetworkAdaptor() { | |
| 245 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 246 channel()->DisableAudioNetworkAdaptor(); | |
| 247 } | |
| 248 | |
| 249 void ChannelProxy::SetReceiverFrameLengthRange(int min_frame_length_ms, | |
| 250 int max_frame_length_ms) { | |
| 251 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 252 channel()->SetReceiverFrameLengthRange(min_frame_length_ms, | |
| 253 max_frame_length_ms); | |
| 254 } | |
| 255 | |
| 256 AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( | 244 AudioMixer::Source::AudioFrameInfo ChannelProxy::GetAudioFrameWithInfo( |
| 257 int sample_rate_hz, | 245 int sample_rate_hz, |
| 258 AudioFrame* audio_frame) { | 246 AudioFrame* audio_frame) { |
| 259 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); | 247 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
| 260 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); | 248 return channel()->GetAudioFrameWithInfo(sample_rate_hz, audio_frame); |
| 261 } | 249 } |
| 262 | 250 |
| 263 int ChannelProxy::NeededFrequency() const { | 251 int ChannelProxy::NeededFrequency() const { |
| 264 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); | 252 RTC_DCHECK_RUNS_SERIALIZED(&audio_thread_race_checker_); |
| 265 return static_cast<int>(channel()->NeededFrequency(-1)); | 253 return static_cast<int>(channel()->NeededFrequency(-1)); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { | 300 void ChannelProxy::SetRtcpRttStats(RtcpRttStats* rtcp_rtt_stats) { |
| 313 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 301 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 314 channel()->SetRtcpRttStats(rtcp_rtt_stats); | 302 channel()->SetRtcpRttStats(rtcp_rtt_stats); |
| 315 } | 303 } |
| 316 | 304 |
| 317 bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { | 305 bool ChannelProxy::GetRecCodec(CodecInst* codec_inst) const { |
| 318 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 306 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 319 return channel()->GetRecCodec(*codec_inst) == 0; | 307 return channel()->GetRecCodec(*codec_inst) == 0; |
| 320 } | 308 } |
| 321 | 309 |
| 322 bool ChannelProxy::GetSendCodec(CodecInst* codec_inst) const { | |
| 323 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 324 return channel()->GetSendCodec(*codec_inst) == 0; | |
| 325 } | |
| 326 | |
| 327 bool ChannelProxy::SetVADStatus(bool enable) { | |
| 328 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 329 return channel()->SetVADStatus(enable, VADNormal, false) == 0; | |
| 330 } | |
| 331 | |
| 332 bool ChannelProxy::SetCodecFECStatus(bool enable) { | |
| 333 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 334 return channel()->SetCodecFECStatus(enable) == 0; | |
| 335 } | |
| 336 | |
| 337 bool ChannelProxy::SetOpusDtx(bool enable) { | |
| 338 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 339 return channel()->SetOpusDtx(enable) == 0; | |
| 340 } | |
| 341 | |
| 342 bool ChannelProxy::SetOpusMaxPlaybackRate(int frequency_hz) { | |
| 343 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 344 return channel()->SetOpusMaxPlaybackRate(frequency_hz) == 0; | |
| 345 } | |
| 346 | |
| 347 bool ChannelProxy::SetSendCodec(const CodecInst& codec_inst) { | |
| 348 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 349 // Validation code copied from VoECodecImpl::SetSendCodec(). | |
| 350 if ((STR_CASE_CMP(codec_inst.plname, "L16") == 0) && | |
| 351 (codec_inst.pacsize >= 960)) { | |
| 352 return false; | |
| 353 } | |
| 354 if (!STR_CASE_CMP(codec_inst.plname, "CN") || | |
| 355 !STR_CASE_CMP(codec_inst.plname, "TELEPHONE-EVENT") || | |
| 356 !STR_CASE_CMP(codec_inst.plname, "RED")) { | |
| 357 return false; | |
| 358 } | |
| 359 if ((codec_inst.channels != 1) && (codec_inst.channels != 2)) { | |
| 360 return false; | |
| 361 } | |
| 362 if (!AudioCodingModule::IsCodecValid(codec_inst)) { | |
| 363 return false; | |
| 364 } | |
| 365 return channel()->SetSendCodec(codec_inst) == 0; | |
| 366 } | |
| 367 | |
| 368 bool ChannelProxy::SetSendCNPayloadType(int type, | |
| 369 PayloadFrequencies frequency) { | |
| 370 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | |
| 371 // Validation code copied from VoECodecImpl::SetSendCNPayloadType(). | |
| 372 if (type < 96 || type > 127) { | |
| 373 // Only allow dynamic range: 96 to 127 | |
| 374 return false; | |
| 375 } | |
| 376 if ((frequency != kFreq16000Hz) && (frequency != kFreq32000Hz)) { | |
| 377 // It is not possible to modify the payload type for CN/8000. | |
| 378 // We only allow modification of the CN payload type for CN/16000 | |
| 379 // and CN/32000. | |
| 380 return false; | |
| 381 } | |
| 382 return channel()->SetSendCNPayloadType(type, frequency) == 0; | |
| 383 } | |
| 384 | |
| 385 void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) { | 310 void ChannelProxy::OnTwccBasedUplinkPacketLossRate(float packet_loss_rate) { |
| 386 // TODO(elad.alon): This fails in UT; fix and uncomment. | 311 // TODO(elad.alon): This fails in UT; fix and uncomment. |
| 387 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7405 | 312 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=7405 |
| 388 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 313 // RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 389 channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate); | 314 channel()->OnTwccBasedUplinkPacketLossRate(packet_loss_rate); |
| 390 } | 315 } |
| 391 | 316 |
| 392 void ChannelProxy::OnRecoverableUplinkPacketLossRate( | 317 void ChannelProxy::OnRecoverableUplinkPacketLossRate( |
| 393 float recoverable_packet_loss_rate) { | 318 float recoverable_packet_loss_rate) { |
| 394 // TODO(elad.alon): This fails in UT; fix and uncomment. | 319 // TODO(elad.alon): This fails in UT; fix and uncomment. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 407 return channel()->GetSources(); | 332 return channel()->GetSources(); |
| 408 } | 333 } |
| 409 | 334 |
| 410 Channel* ChannelProxy::channel() const { | 335 Channel* ChannelProxy::channel() const { |
| 411 RTC_DCHECK(channel_owner_.channel()); | 336 RTC_DCHECK(channel_owner_.channel()); |
| 412 return channel_owner_.channel(); | 337 return channel_owner_.channel(); |
| 413 } | 338 } |
| 414 | 339 |
| 415 } // namespace voe | 340 } // namespace voe |
| 416 } // namespace webrtc | 341 } // namespace webrtc |
| OLD | NEW |