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

Side by Side Diff: webrtc/audio/audio_send_stream.cc

Issue 2844803003: Have AudioSendStream register CNG payload types with the RtpRtcpModule. (Closed)
Patch Set: Add mocks for GetRtpRtcp in AudioSendStreamTest. Created 3 years, 7 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
« no previous file with comments | « webrtc/audio/audio_send_stream.h ('k') | webrtc/audio/audio_send_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 10 matching lines...) Expand all
21 #include "webrtc/base/event.h" 21 #include "webrtc/base/event.h"
22 #include "webrtc/base/function_view.h" 22 #include "webrtc/base/function_view.h"
23 #include "webrtc/base/logging.h" 23 #include "webrtc/base/logging.h"
24 #include "webrtc/base/task_queue.h" 24 #include "webrtc/base/task_queue.h"
25 #include "webrtc/base/timeutils.h" 25 #include "webrtc/base/timeutils.h"
26 #include "webrtc/call/rtp_transport_controller_send_interface.h" 26 #include "webrtc/call/rtp_transport_controller_send_interface.h"
27 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" 27 #include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h"
28 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 28 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
29 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h" 29 #include "webrtc/modules/congestion_controller/include/send_side_congestion_cont roller.h"
30 #include "webrtc/modules/pacing/paced_sender.h" 30 #include "webrtc/modules/pacing/paced_sender.h"
31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
32 #include "webrtc/voice_engine/channel_proxy.h" 32 #include "webrtc/voice_engine/channel_proxy.h"
33 #include "webrtc/voice_engine/include/voe_base.h" 33 #include "webrtc/voice_engine/include/voe_base.h"
34 #include "webrtc/voice_engine/transmit_mixer.h" 34 #include "webrtc/voice_engine/transmit_mixer.h"
35 #include "webrtc/voice_engine/voice_engine_impl.h" 35 #include "webrtc/voice_engine/voice_engine_impl.h"
36 36
37 namespace webrtc { 37 namespace webrtc {
38 38
39 namespace internal { 39 namespace internal {
40 // TODO(elad.alon): Subsequent CL will make these values experiment-dependent. 40 // TODO(elad.alon): Subsequent CL will make these values experiment-dependent.
41 constexpr size_t kPacketLossTrackerMaxWindowSizeMs = 15000; 41 constexpr size_t kPacketLossTrackerMaxWindowSizeMs = 15000;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 414 }
415 415
416 // Wrap the encoder in a an AudioEncoderCNG, if VAD is enabled. 416 // Wrap the encoder in a an AudioEncoderCNG, if VAD is enabled.
417 if (spec.cng_payload_type) { 417 if (spec.cng_payload_type) {
418 AudioEncoderCng::Config cng_config; 418 AudioEncoderCng::Config cng_config;
419 cng_config.num_channels = encoder->NumChannels(); 419 cng_config.num_channels = encoder->NumChannels();
420 cng_config.payload_type = *spec.cng_payload_type; 420 cng_config.payload_type = *spec.cng_payload_type;
421 cng_config.speech_encoder = std::move(encoder); 421 cng_config.speech_encoder = std::move(encoder);
422 cng_config.vad_mode = Vad::kVadNormal; 422 cng_config.vad_mode = Vad::kVadNormal;
423 encoder.reset(new AudioEncoderCng(std::move(cng_config))); 423 encoder.reset(new AudioEncoderCng(std::move(cng_config)));
424
425 stream->RegisterCngPayloadType(
426 *spec.cng_payload_type,
427 new_config.send_codec_spec->format.clockrate_hz);
424 } 428 }
425 429
426 stream->channel_proxy_->SetEncoder(new_config.send_codec_spec->payload_type, 430 stream->channel_proxy_->SetEncoder(new_config.send_codec_spec->payload_type,
427 std::move(encoder)); 431 std::move(encoder));
428 return true; 432 return true;
429 } 433 }
430 434
431 bool AudioSendStream::ReconfigureSendCodec(AudioSendStream* stream, 435 bool AudioSendStream::ReconfigureSendCodec(AudioSendStream* stream,
432 const Config& new_config) { 436 const Config& new_config) {
433 const auto& old_config = stream->config_; 437 const auto& old_config = stream->config_;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 } 495 }
492 } 496 }
493 497
494 void AudioSendStream::ReconfigureCNG(AudioSendStream* stream, 498 void AudioSendStream::ReconfigureCNG(AudioSendStream* stream,
495 const Config& new_config) { 499 const Config& new_config) {
496 if (new_config.send_codec_spec->cng_payload_type == 500 if (new_config.send_codec_spec->cng_payload_type ==
497 stream->config_.send_codec_spec->cng_payload_type) { 501 stream->config_.send_codec_spec->cng_payload_type) {
498 return; 502 return;
499 } 503 }
500 504
505 // Register the CNG payload type if it's been added, don't do anything if CNG
506 // is removed. Payload types must not be redefined.
507 if (new_config.send_codec_spec->cng_payload_type) {
508 stream->RegisterCngPayloadType(
509 *new_config.send_codec_spec->cng_payload_type,
510 new_config.send_codec_spec->format.clockrate_hz);
511 }
512
501 // Wrap or unwrap the encoder in an AudioEncoderCNG. 513 // Wrap or unwrap the encoder in an AudioEncoderCNG.
502 stream->channel_proxy_->ModifyEncoder( 514 stream->channel_proxy_->ModifyEncoder(
503 [&](std::unique_ptr<AudioEncoder>* encoder_ptr) { 515 [&](std::unique_ptr<AudioEncoder>* encoder_ptr) {
504 std::unique_ptr<AudioEncoder> old_encoder(std::move(*encoder_ptr)); 516 std::unique_ptr<AudioEncoder> old_encoder(std::move(*encoder_ptr));
505 auto sub_encoders = old_encoder->ReclaimContainedEncoders(); 517 auto sub_encoders = old_encoder->ReclaimContainedEncoders();
506 if (!sub_encoders.empty()) { 518 if (!sub_encoders.empty()) {
507 // Replace enc with its sub encoder. We need to put the sub 519 // Replace enc with its sub encoder. We need to put the sub
508 // encoder in a temporary first, since otherwise the old value 520 // encoder in a temporary first, since otherwise the old value
509 // of enc would be destroyed before the new value got assigned, 521 // of enc would be destroyed before the new value got assigned,
510 // which would be bad since the new value is a part of the old 522 // which would be bad since the new value is a part of the old
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 void AudioSendStream::RemoveBitrateObserver() { 577 void AudioSendStream::RemoveBitrateObserver() {
566 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 578 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
567 rtc::Event thread_sync_event(false /* manual_reset */, false); 579 rtc::Event thread_sync_event(false /* manual_reset */, false);
568 worker_queue_->PostTask([this, &thread_sync_event] { 580 worker_queue_->PostTask([this, &thread_sync_event] {
569 bitrate_allocator_->RemoveObserver(this); 581 bitrate_allocator_->RemoveObserver(this);
570 thread_sync_event.Set(); 582 thread_sync_event.Set();
571 }); 583 });
572 thread_sync_event.Wait(rtc::Event::kForever); 584 thread_sync_event.Wait(rtc::Event::kForever);
573 } 585 }
574 586
587 void AudioSendStream::RegisterCngPayloadType(int payload_type,
588 int clockrate_hz) {
589 RtpRtcp* rtpRtcpModule = nullptr;
590 RtpReceiver* rtpReceiver = nullptr; // Unused, but required for call.
591 channel_proxy_->GetRtpRtcp(&rtpRtcpModule, &rtpReceiver);
592 const CodecInst codec = {payload_type, "CN", clockrate_hz, 0, 1, 0};
593 if (rtpRtcpModule->RegisterSendPayload(codec) != 0) {
594 rtpRtcpModule->DeRegisterSendPayload(codec.pltype);
595 if (rtpRtcpModule->RegisterSendPayload(codec) != 0) {
596 LOG(LS_ERROR) << "RegisterCngPayloadType() failed to register CN to "
597 "RTP/RTCP module";
598 }
599 }
600 }
601
602
575 } // namespace internal 603 } // namespace internal
576 } // namespace webrtc 604 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_send_stream.h ('k') | webrtc/audio/audio_send_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698