| OLD | NEW |
| 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 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1660 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1661 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " | 1661 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendParameters: " |
| 1662 << params.ToString(); | 1662 << params.ToString(); |
| 1663 // TODO(pthatcher): Refactor this to be more clean now that we have | 1663 // TODO(pthatcher): Refactor this to be more clean now that we have |
| 1664 // all the information at once. | 1664 // all the information at once. |
| 1665 | 1665 |
| 1666 if (!SetSendCodecs(params.codecs)) { | 1666 if (!SetSendCodecs(params.codecs)) { |
| 1667 return false; | 1667 return false; |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 if (params.max_bandwidth_bps >= 0) { | |
| 1671 // Note that max_bandwidth_bps intentionally takes priority over the | |
| 1672 // bitrate config for the codec. | |
| 1673 bitrate_config_.max_bitrate_bps = | |
| 1674 params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps; | |
| 1675 } | |
| 1676 call_->SetBitrateConfig(bitrate_config_); | |
| 1677 | |
| 1678 if (!ValidateRtpExtensions(params.extensions)) { | 1670 if (!ValidateRtpExtensions(params.extensions)) { |
| 1679 return false; | 1671 return false; |
| 1680 } | 1672 } |
| 1681 std::vector<webrtc::RtpExtension> filtered_extensions = | 1673 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1682 FilterRtpExtensions(params.extensions, | 1674 FilterRtpExtensions(params.extensions, |
| 1683 webrtc::RtpExtension::IsSupportedForAudio, true); | 1675 webrtc::RtpExtension::IsSupportedForAudio, true); |
| 1684 if (send_rtp_extensions_ != filtered_extensions) { | 1676 if (send_rtp_extensions_ != filtered_extensions) { |
| 1685 send_rtp_extensions_.swap(filtered_extensions); | 1677 send_rtp_extensions_.swap(filtered_extensions); |
| 1686 for (auto& it : send_streams_) { | 1678 for (auto& it : send_streams_) { |
| 1687 it.second->RecreateAudioSendStream(send_rtp_extensions_); | 1679 it.second->RecreateAudioSendStream(send_rtp_extensions_); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 dtmf_payload_freq_ = codec.clockrate; | 1931 dtmf_payload_freq_ = codec.clockrate; |
| 1940 } | 1932 } |
| 1941 } | 1933 } |
| 1942 } | 1934 } |
| 1943 | 1935 |
| 1944 // Scan through the list to figure out the codec to use for sending, along | 1936 // Scan through the list to figure out the codec to use for sending, along |
| 1945 // with the proper configuration for VAD, CNG, NACK and Opus-specific | 1937 // with the proper configuration for VAD, CNG, NACK and Opus-specific |
| 1946 // parameters. | 1938 // parameters. |
| 1947 // TODO(solenberg): Refactor this logic once we create AudioEncoders here. | 1939 // TODO(solenberg): Refactor this logic once we create AudioEncoders here. |
| 1948 webrtc::AudioSendStream::Config::SendCodecSpec send_codec_spec; | 1940 webrtc::AudioSendStream::Config::SendCodecSpec send_codec_spec; |
| 1941 webrtc::Call::Config::BitrateConfig bitrate_config; |
| 1949 { | 1942 { |
| 1950 send_codec_spec.nack_enabled = send_codec_spec_.nack_enabled; | 1943 send_codec_spec.nack_enabled = send_codec_spec_.nack_enabled; |
| 1951 | 1944 |
| 1952 // Find send codec (the first non-telephone-event/CN codec). | 1945 // Find send codec (the first non-telephone-event/CN codec). |
| 1953 const AudioCodec* codec = WebRtcVoiceCodecs::GetPreferredCodec( | 1946 const AudioCodec* codec = WebRtcVoiceCodecs::GetPreferredCodec( |
| 1954 codecs, &send_codec_spec.codec_inst); | 1947 codecs, &send_codec_spec.codec_inst); |
| 1955 if (!codec) { | 1948 if (!codec) { |
| 1956 LOG(LS_WARNING) << "Received empty list of codecs."; | 1949 LOG(LS_WARNING) << "Received empty list of codecs."; |
| 1957 return false; | 1950 return false; |
| 1958 } | 1951 } |
| 1959 | 1952 |
| 1960 send_codec_spec.transport_cc_enabled = HasTransportCc(*codec); | 1953 send_codec_spec.transport_cc_enabled = HasTransportCc(*codec); |
| 1961 send_codec_spec.nack_enabled = HasNack(*codec); | 1954 send_codec_spec.nack_enabled = HasNack(*codec); |
| 1962 bitrate_config_ = GetBitrateConfigForCodec(*codec); | 1955 bitrate_config = GetBitrateConfigForCodec(*codec); |
| 1963 | 1956 |
| 1964 // For Opus as the send codec, we are to determine inband FEC, maximum | 1957 // For Opus as the send codec, we are to determine inband FEC, maximum |
| 1965 // playback rate, and opus internal dtx. | 1958 // playback rate, and opus internal dtx. |
| 1966 if (IsCodec(*codec, kOpusCodecName)) { | 1959 if (IsCodec(*codec, kOpusCodecName)) { |
| 1967 GetOpusConfig(*codec, &send_codec_spec.codec_inst, | 1960 GetOpusConfig(*codec, &send_codec_spec.codec_inst, |
| 1968 &send_codec_spec.enable_codec_fec, | 1961 &send_codec_spec.enable_codec_fec, |
| 1969 &send_codec_spec.opus_max_playback_rate, | 1962 &send_codec_spec.opus_max_playback_rate, |
| 1970 &send_codec_spec.enable_opus_dtx, | 1963 &send_codec_spec.enable_opus_dtx, |
| 1971 &send_codec_spec.min_ptime_ms, | 1964 &send_codec_spec.min_ptime_ms, |
| 1972 &send_codec_spec.max_ptime_ms); | 1965 &send_codec_spec.max_ptime_ms); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 | 2021 |
| 2029 if (send_codec_spec_ != send_codec_spec) { | 2022 if (send_codec_spec_ != send_codec_spec) { |
| 2030 send_codec_spec_ = std::move(send_codec_spec); | 2023 send_codec_spec_ = std::move(send_codec_spec); |
| 2031 // Apply new settings to all streams. | 2024 // Apply new settings to all streams. |
| 2032 for (const auto& kv : send_streams_) { | 2025 for (const auto& kv : send_streams_) { |
| 2033 kv.second->RecreateAudioSendStream(send_codec_spec_); | 2026 kv.second->RecreateAudioSendStream(send_codec_spec_); |
| 2034 } | 2027 } |
| 2035 } else { | 2028 } else { |
| 2036 // If the codec isn't changing, set the start bitrate to -1 which means | 2029 // If the codec isn't changing, set the start bitrate to -1 which means |
| 2037 // "unchanged" so that BWE isn't affected. | 2030 // "unchanged" so that BWE isn't affected. |
| 2038 bitrate_config_.start_bitrate_bps = -1; | 2031 bitrate_config.start_bitrate_bps = -1; |
| 2039 } | 2032 } |
| 2033 call_->SetBitrateConfig(bitrate_config); |
| 2040 | 2034 |
| 2041 // Check if the transport cc feedback or NACK status has changed on the | 2035 // Check if the transport cc feedback or NACK status has changed on the |
| 2042 // preferred send codec, and in that case reconfigure all receive streams. | 2036 // preferred send codec, and in that case reconfigure all receive streams. |
| 2043 if (recv_transport_cc_enabled_ != send_codec_spec_.transport_cc_enabled || | 2037 if (recv_transport_cc_enabled_ != send_codec_spec_.transport_cc_enabled || |
| 2044 recv_nack_enabled_ != send_codec_spec_.nack_enabled) { | 2038 recv_nack_enabled_ != send_codec_spec_.nack_enabled) { |
| 2045 LOG(LS_INFO) << "Recreate all the receive streams because the send " | 2039 LOG(LS_INFO) << "Recreate all the receive streams because the send " |
| 2046 "codec has changed."; | 2040 "codec has changed."; |
| 2047 recv_transport_cc_enabled_ = send_codec_spec_.transport_cc_enabled; | 2041 recv_transport_cc_enabled_ = send_codec_spec_.transport_cc_enabled; |
| 2048 recv_nack_enabled_ = send_codec_spec_.nack_enabled; | 2042 recv_nack_enabled_ = send_codec_spec_.nack_enabled; |
| 2049 for (auto& kv : recv_streams_) { | 2043 for (auto& kv : recv_streams_) { |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2660 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 2654 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 2661 const auto it = send_streams_.find(ssrc); | 2655 const auto it = send_streams_.find(ssrc); |
| 2662 if (it != send_streams_.end()) { | 2656 if (it != send_streams_.end()) { |
| 2663 return it->second->channel(); | 2657 return it->second->channel(); |
| 2664 } | 2658 } |
| 2665 return -1; | 2659 return -1; |
| 2666 } | 2660 } |
| 2667 } // namespace cricket | 2661 } // namespace cricket |
| 2668 | 2662 |
| 2669 #endif // HAVE_WEBRTC_VOICE | 2663 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |