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

Side by Side Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 2534173002: Wire up x-google-{min,start,max}-bitrate to WebRtcVoiceMediaChannel. (Closed)
Patch Set: Clean up comment. Created 4 years 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) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 // If OPUS, change what we send according to the "stereo" codec 271 // If OPUS, change what we send according to the "stereo" codec
272 // parameter, and not the "channels" parameter. We set 272 // parameter, and not the "channels" parameter. We set
273 // voe_codec.channels to 2 if "stereo=1" and 1 otherwise. If 273 // voe_codec.channels to 2 if "stereo=1" and 1 otherwise. If
274 // the bitrate is not specified, i.e. is <= zero, we set it to the 274 // the bitrate is not specified, i.e. is <= zero, we set it to the
275 // appropriate default value for mono or stereo Opus. 275 // appropriate default value for mono or stereo Opus.
276 voe_codec->channels = IsCodecFeatureEnabled(codec, kCodecParamStereo) ? 2 : 1; 276 voe_codec->channels = IsCodecFeatureEnabled(codec, kCodecParamStereo) ? 2 : 1;
277 voe_codec->rate = GetOpusBitrate(codec, *max_playback_rate); 277 voe_codec->rate = GetOpusBitrate(codec, *max_playback_rate);
278 } 278 }
279 279
280 webrtc::Call::Config::BitrateConfig GetBitrateConfigForCodec(
281 const AudioCodec& codec) {
282 webrtc::Call::Config::BitrateConfig config;
283 int bitrate_kbps;
the sun 2016/11/30 11:22:27 nit: always default init
stefan-webrtc 2016/11/30 11:44:42 Done.
284 if (codec.GetParam(kCodecParamMinBitrate, &bitrate_kbps) &&
285 bitrate_kbps > 0) {
286 config.min_bitrate_bps = bitrate_kbps * 1000;
287 } else {
288 config.min_bitrate_bps = 0;
289 }
290 if (codec.GetParam(kCodecParamStartBitrate, &bitrate_kbps) &&
291 bitrate_kbps > 0) {
292 config.start_bitrate_bps = bitrate_kbps * 1000;
293 } else {
294 // Do not reconfigure start bitrate unless it's specified and positive.
295 config.start_bitrate_bps = -1;
the sun 2016/11/30 11:22:27 Change the optional fields in the config to use rt
stefan-webrtc 2016/11/30 11:44:42 I'd prefer making interface changes later.
296 }
297 if (codec.GetParam(kCodecParamMaxBitrate, &bitrate_kbps) &&
298 bitrate_kbps > 0) {
299 config.max_bitrate_bps = bitrate_kbps * 1000;
300 } else {
301 config.max_bitrate_bps = -1;
302 }
303 return config;
304 }
305
280 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) { 306 webrtc::AudioState::Config MakeAudioStateConfig(VoEWrapper* voe_wrapper) {
281 webrtc::AudioState::Config config; 307 webrtc::AudioState::Config config;
282 config.voice_engine = voe_wrapper->engine(); 308 config.voice_engine = voe_wrapper->engine();
283 config.audio_mixer = webrtc::AudioMixerImpl::Create(); 309 config.audio_mixer = webrtc::AudioMixerImpl::Create();
284 return config; 310 return config;
285 } 311 }
286 312
287 class WebRtcVoiceCodecs final { 313 class WebRtcVoiceCodecs final {
288 public: 314 public:
289 // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec 315 // TODO(solenberg): Do this filtering once off-line, add a simple AudioCodec
(...skipping 1319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1635 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1610 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " 1636 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: "
1611 << params.ToString(); 1637 << params.ToString();
1612 // TODO(pthatcher): Refactor this to be more clean now that we have 1638 // TODO(pthatcher): Refactor this to be more clean now that we have
1613 // all the information at once. 1639 // all the information at once.
1614 1640
1615 if (!SetSendCodecs(params.codecs)) { 1641 if (!SetSendCodecs(params.codecs)) {
1616 return false; 1642 return false;
1617 } 1643 }
1618 1644
1645 if (params.max_bandwidth_bps >= 0) {
the sun 2016/11/30 11:22:27 Is this logic the same for video? Does it make sen
stefan-webrtc 2016/11/30 11:44:43 It is the same, not sure about making it a util th
1646 // Note that max_bandwidth_bps intentionally takes priority over the
1647 // bitrate config for the codec. This allows FEC to be applied above the
minyue-webrtc 2016/11/29 22:10:55 Not sure about the reasoning on FEC in the comment
stefan-webrtc 2016/11/30 11:44:43 I made it a bit more generic.
1648 // codec target bitrate.
1649 bitrate_config_.max_bitrate_bps =
1650 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps;
1651 }
1652 call_->SetBitrateConfig(bitrate_config_);
1653
1619 if (!ValidateRtpExtensions(params.extensions)) { 1654 if (!ValidateRtpExtensions(params.extensions)) {
1620 return false; 1655 return false;
1621 } 1656 }
1622 std::vector<webrtc::RtpExtension> filtered_extensions = 1657 std::vector<webrtc::RtpExtension> filtered_extensions =
1623 FilterRtpExtensions(params.extensions, 1658 FilterRtpExtensions(params.extensions,
1624 webrtc::RtpExtension::IsSupportedForAudio, true); 1659 webrtc::RtpExtension::IsSupportedForAudio, true);
1625 if (send_rtp_extensions_ != filtered_extensions) { 1660 if (send_rtp_extensions_ != filtered_extensions) {
1626 send_rtp_extensions_.swap(filtered_extensions); 1661 send_rtp_extensions_.swap(filtered_extensions);
1627 for (auto& it : send_streams_) { 1662 for (auto& it : send_streams_) {
1628 it.second->RecreateAudioSendStream(send_rtp_extensions_); 1663 it.second->RecreateAudioSendStream(send_rtp_extensions_);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 // playback rate, and opus internal dtx. 1961 // playback rate, and opus internal dtx.
1927 if (IsCodec(*codec, kOpusCodecName)) { 1962 if (IsCodec(*codec, kOpusCodecName)) {
1928 GetOpusConfig(*codec, &send_codec_spec.codec_inst, 1963 GetOpusConfig(*codec, &send_codec_spec.codec_inst,
1929 &send_codec_spec.enable_codec_fec, 1964 &send_codec_spec.enable_codec_fec,
1930 &send_codec_spec.opus_max_playback_rate, 1965 &send_codec_spec.opus_max_playback_rate,
1931 &send_codec_spec.enable_opus_dtx, 1966 &send_codec_spec.enable_opus_dtx,
1932 &send_codec_spec.min_ptime_ms, 1967 &send_codec_spec.min_ptime_ms,
1933 &send_codec_spec.max_ptime_ms); 1968 &send_codec_spec.max_ptime_ms);
1934 } 1969 }
1935 1970
1971 bitrate_config_ = GetBitrateConfigForCodec(*codec);
1972 if (send_codec_spec_set_ && send_codec_spec == send_codec_spec_) {
minyue-webrtc 2016/11/29 22:10:55 I don't think this is the place we reset codec. pl
the sun 2016/11/30 11:22:27 I don't get the logic involving send_codec_spec_se
stefan-webrtc 2016/11/30 11:44:42 I tried to the changes into WebRtcAudioSendStream
stefan-webrtc 2016/11/30 11:44:43 I don't think the send_codec_spec_set_ check is ne
1973 // If the codec isn't changing, set the start bitrate to -1 which means
1974 // "unchanged" so that BWE isn't affected.
1975 bitrate_config_.start_bitrate_bps = -1;
1976 }
1977
1936 // Set packet size if the AudioCodec param kCodecParamPTime is set. 1978 // Set packet size if the AudioCodec param kCodecParamPTime is set.
1937 int ptime_ms = 0; 1979 int ptime_ms = 0;
1938 if (codec->GetParam(kCodecParamPTime, &ptime_ms)) { 1980 if (codec->GetParam(kCodecParamPTime, &ptime_ms)) {
1939 if (!WebRtcVoiceCodecs::SetPTimeAsPacketSize( 1981 if (!WebRtcVoiceCodecs::SetPTimeAsPacketSize(
1940 &send_codec_spec.codec_inst, ptime_ms)) { 1982 &send_codec_spec.codec_inst, ptime_ms)) {
1941 LOG(LS_WARNING) << "Failed to set packet size for codec " 1983 LOG(LS_WARNING) << "Failed to set packet size for codec "
1942 << send_codec_spec.codec_inst.plname; 1984 << send_codec_spec.codec_inst.plname;
1943 return false; 1985 return false;
1944 } 1986 }
1945 } 1987 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 dtmf_payload_type_ = rtc::Optional<int>(dtmf_codec.id); 2025 dtmf_payload_type_ = rtc::Optional<int>(dtmf_codec.id);
1984 dtmf_payload_freq_ = dtmf_codec.clockrate; 2026 dtmf_payload_freq_ = dtmf_codec.clockrate;
1985 break; 2027 break;
1986 } 2028 }
1987 } 2029 }
1988 } 2030 }
1989 2031
1990 // Apply new settings to all streams. 2032 // Apply new settings to all streams.
1991 if (send_codec_spec_ != send_codec_spec) { 2033 if (send_codec_spec_ != send_codec_spec) {
1992 send_codec_spec_ = std::move(send_codec_spec); 2034 send_codec_spec_ = std::move(send_codec_spec);
2035 send_codec_spec_set_ = true;
1993 for (const auto& kv : send_streams_) { 2036 for (const auto& kv : send_streams_) {
1994 kv.second->RecreateAudioSendStream(send_codec_spec_); 2037 kv.second->RecreateAudioSendStream(send_codec_spec_);
1995 } 2038 }
1996 } 2039 }
1997 2040
1998 // Check if the transport cc feedback or NACK status has changed on the 2041 // Check if the transport cc feedback or NACK status has changed on the
1999 // preferred send codec, and in that case reconfigure all receive streams. 2042 // preferred send codec, and in that case reconfigure all receive streams.
2000 if (recv_transport_cc_enabled_ != send_codec_spec_.transport_cc_enabled || 2043 if (recv_transport_cc_enabled_ != send_codec_spec_.transport_cc_enabled ||
2001 recv_nack_enabled_ != send_codec_spec_.nack_enabled) { 2044 recv_nack_enabled_ != send_codec_spec_.nack_enabled) {
2002 LOG(LS_INFO) << "Recreate all the receive streams because the send " 2045 LOG(LS_INFO) << "Recreate all the receive streams because the send "
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 2681 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
2639 const auto it = send_streams_.find(ssrc); 2682 const auto it = send_streams_.find(ssrc);
2640 if (it != send_streams_.end()) { 2683 if (it != send_streams_.end()) {
2641 return it->second->channel(); 2684 return it->second->channel();
2642 } 2685 }
2643 return -1; 2686 return -1;
2644 } 2687 }
2645 } // namespace cricket 2688 } // namespace cricket
2646 2689
2647 #endif // HAVE_WEBRTC_VOICE 2690 #endif // HAVE_WEBRTC_VOICE
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvoiceengine.h ('k') | webrtc/media/engine/webrtcvoiceengine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698