Chromium Code Reviews| Index: webrtc/audio/audio_send_stream.cc |
| diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc |
| index ec18125427282d4624543bc45b274d2b1a42692e..f6f5e4a8af9cc55c0c641141efb7fa2d3f0795e5 100644 |
| --- a/webrtc/audio/audio_send_stream.cc |
| +++ b/webrtc/audio/audio_send_stream.cc |
| @@ -30,15 +30,6 @@ |
| namespace webrtc { |
| -namespace { |
| - |
| -constexpr char kOpusCodecName[] = "opus"; |
| - |
| -bool IsCodec(const webrtc::CodecInst& codec, const char* ref_name) { |
| - return (STR_CASE_CMP(codec.plname, ref_name) == 0); |
| -} |
| -} // namespace |
| - |
| namespace internal { |
| AudioSendStream::AudioSendStream( |
| const webrtc::AudioSendStream::Config& config, |
| @@ -285,58 +276,20 @@ bool AudioSendStream::SetupSendCodec() { |
| channel_proxy_->DisableAudioNetworkAdaptor(); |
| const auto& send_codec_spec = config_.send_codec_spec; |
| - |
| - // We set the codec first, since the below extra configuration is only applied |
| - // to the "current" codec. |
| - |
| - // If codec is already configured, we do not it again. |
| - // TODO(minyue): check if this check is really needed, or can we move it into |
| - // |codec->SetSendCodec|. |
| - webrtc::CodecInst current_codec = {0}; |
| - if (!channel_proxy_->GetSendCodec(¤t_codec) || |
| - (send_codec_spec.codec_inst != current_codec)) { |
| - if (!channel_proxy_->SetSendCodec(send_codec_spec.codec_inst)) { |
| - LOG(LS_WARNING) << "SetSendCodec() failed."; |
| - return false; |
| - } |
| - } |
| - |
| - // Codec internal FEC. Treat any failure as fatal internal error. |
| - if (send_codec_spec.enable_codec_fec) { |
| - if (!channel_proxy_->SetCodecFECStatus(true)) { |
| - LOG(LS_WARNING) << "SetCodecFECStatus() failed."; |
| - return false; |
| - } |
| + channel_proxy_->SetSendFormat(send_codec_spec.payload_type, |
| + send_codec_spec.format.format, |
| + config_.encoder_factory.get()); |
| + // TODO(ossu): Formalize bandwidth parameters and send along to encoder |
|
ossu
2017/02/21 11:04:14
This is one of the open questions: cricket::AudioC
kwiberg-webrtc
2017/02/21 23:35:03
It'd be good if we could do that. But that's only
|
| + // constructor. |
| + if (send_codec_spec.target_bitrate_bps) { |
| + channel_proxy_->SetBitrate(*send_codec_spec.target_bitrate_bps, 0); |
| } |
| - |
| - // DTX and maxplaybackrate are only set if current codec is Opus. |
| - if (IsCodec(send_codec_spec.codec_inst, kOpusCodecName)) { |
| - if (!channel_proxy_->SetOpusDtx(send_codec_spec.enable_opus_dtx)) { |
| - LOG(LS_WARNING) << "SetOpusDtx() failed."; |
| - return false; |
| - } |
| - |
| - // If opus_max_playback_rate <= 0, the default maximum playback rate |
| - // (48 kHz) will be used. |
| - if (send_codec_spec.opus_max_playback_rate > 0) { |
| - if (!channel_proxy_->SetOpusMaxPlaybackRate( |
| - send_codec_spec.opus_max_playback_rate)) { |
| - LOG(LS_WARNING) << "SetOpusMaxPlaybackRate() failed."; |
| - return false; |
| - } |
| - } |
| - |
| - if (config_.audio_network_adaptor_config) { |
| - // Audio network adaptor is only allowed for Opus currently. |
| - // |SetReceiverFrameLengthRange| needs to be called before |
| - // |EnableAudioNetworkAdaptor|. |
| - channel_proxy_->SetReceiverFrameLengthRange(send_codec_spec.min_ptime_ms, |
| - send_codec_spec.max_ptime_ms); |
| - channel_proxy_->EnableAudioNetworkAdaptor( |
| - *config_.audio_network_adaptor_config); |
| - LOG(LS_INFO) << "Audio network adaptor enabled on SSRC " |
| - << config_.rtp.ssrc; |
| - } |
| + if (config_.audio_network_adaptor_config) { |
| + // Audio network adaptor is only allowed for Opus currently. |
| + channel_proxy_->EnableAudioNetworkAdaptor( |
| + *config_.audio_network_adaptor_config); |
| + LOG(LS_INFO) << "Audio network adaptor enabled on SSRC " |
| + << config_.rtp.ssrc; |
| } |
| // Set the CN payloadtype and the VAD status. |
| @@ -371,8 +324,9 @@ bool AudioSendStream::SetupSendCodec() { |
| // Only turn on VAD if we have a CN payload type that matches the |
| // clockrate for the codec we are going to use. |
| - if (send_codec_spec.cng_plfreq == send_codec_spec.codec_inst.plfreq && |
| - send_codec_spec.codec_inst.channels == 1) { |
| + if (send_codec_spec.cng_plfreq == |
| + send_codec_spec.format.format.clockrate_hz && |
| + send_codec_spec.format.info.num_channels == 1) { |
| // TODO(minyue): If CN frequency == 48000 Hz is allowed, consider the |
| // interaction between VAD and Opus FEC. |
| if (!channel_proxy_->SetVADStatus(true)) { |