| 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 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1411 std::vector<webrtc::RtpExtension> filtered_extensions = | 1411 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1412 FilterRtpExtensions(params.extensions, | 1412 FilterRtpExtensions(params.extensions, |
| 1413 webrtc::RtpExtension::IsSupportedForAudio, true); | 1413 webrtc::RtpExtension::IsSupportedForAudio, true); |
| 1414 if (send_rtp_extensions_ != filtered_extensions) { | 1414 if (send_rtp_extensions_ != filtered_extensions) { |
| 1415 send_rtp_extensions_.swap(filtered_extensions); | 1415 send_rtp_extensions_.swap(filtered_extensions); |
| 1416 for (auto& it : send_streams_) { | 1416 for (auto& it : send_streams_) { |
| 1417 it.second->RecreateAudioSendStream(send_rtp_extensions_); | 1417 it.second->RecreateAudioSendStream(send_rtp_extensions_); |
| 1418 } | 1418 } |
| 1419 } | 1419 } |
| 1420 | 1420 |
| 1421 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { | 1421 if (!SetMaxSendBitrate(params.max_bitrate_bps)) { |
| 1422 return false; | 1422 return false; |
| 1423 } | 1423 } |
| 1424 return SetOptions(params.options); | 1424 return SetOptions(params.options); |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 bool WebRtcVoiceMediaChannel::SetRecvParameters( | 1427 bool WebRtcVoiceMediaChannel::SetRecvParameters( |
| 1428 const AudioRecvParameters& params) { | 1428 const AudioRecvParameters& params) { |
| 1429 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetRecvParameters"); | 1429 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetRecvParameters"); |
| 1430 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1430 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1431 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: " | 1431 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: " |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 << channel; | 1735 << channel; |
| 1736 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( | 1736 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( |
| 1737 channel, send_codec_spec_.opus_max_playback_rate) == -1) { | 1737 channel, send_codec_spec_.opus_max_playback_rate) == -1) { |
| 1738 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, | 1738 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, |
| 1739 send_codec_spec_.opus_max_playback_rate); | 1739 send_codec_spec_.opus_max_playback_rate); |
| 1740 return false; | 1740 return false; |
| 1741 } | 1741 } |
| 1742 } | 1742 } |
| 1743 } | 1743 } |
| 1744 | 1744 |
| 1745 if (send_bitrate_setting_) { | 1745 if (send_bitrate_bps_) { |
| 1746 SetSendBitrateInternal(send_bitrate_bps_); | 1746 SetSendBitrateInternal(send_bitrate_bps_); |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 // Set the CN payloadtype and the VAD status. | 1749 // Set the CN payloadtype and the VAD status. |
| 1750 if (send_codec_spec_.cng_payload_type != -1) { | 1750 if (send_codec_spec_.cng_payload_type != -1) { |
| 1751 // The CN payload type for 8000 Hz clockrate is fixed at 13. | 1751 // The CN payload type for 8000 Hz clockrate is fixed at 13. |
| 1752 if (send_codec_spec_.cng_plfreq != 8000) { | 1752 if (send_codec_spec_.cng_plfreq != 8000) { |
| 1753 webrtc::PayloadFrequencies cn_freq; | 1753 webrtc::PayloadFrequencies cn_freq; |
| 1754 switch (send_codec_spec_.cng_plfreq) { | 1754 switch (send_codec_spec_.cng_plfreq) { |
| 1755 case 16000: | 1755 case 16000: |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 } | 2362 } |
| 2363 } | 2363 } |
| 2364 | 2364 |
| 2365 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing(); | 2365 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing(); |
| 2366 if (ap) { | 2366 if (ap) { |
| 2367 ap->set_output_will_be_muted(all_muted); | 2367 ap->set_output_will_be_muted(all_muted); |
| 2368 } | 2368 } |
| 2369 return true; | 2369 return true; |
| 2370 } | 2370 } |
| 2371 | 2371 |
| 2372 // TODO(minyue): SetMaxSendBandwidth() is subject to be renamed to | 2372 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(rtc::Optional<int> bps) { |
| 2373 // SetMaxSendBitrate() in future. | 2373 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 2374 bool WebRtcVoiceMediaChannel::SetMaxSendBandwidth(int bps) { | |
| 2375 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth."; | 2374 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth."; |
| 2376 return SetSendBitrateInternal(bps); | 2375 return SetSendBitrateInternal(bps); |
| 2377 } | 2376 } |
| 2378 | 2377 |
| 2379 bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(int bps) { | 2378 bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(rtc::Optional<int> bps) { |
| 2380 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal."; | 2379 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal."; |
| 2381 | |
| 2382 send_bitrate_setting_ = true; | |
| 2383 send_bitrate_bps_ = bps; | 2380 send_bitrate_bps_ = bps; |
| 2384 | 2381 |
| 2385 if (!HasSendCodec()) { | 2382 if (!HasSendCodec()) { |
| 2386 LOG(LS_INFO) << "The send codec has not been set up yet. " | 2383 LOG(LS_INFO) << "The send codec has not been set up yet. " |
| 2387 << "The send bitrate setting will be applied later."; | 2384 << "The send bitrate setting will be applied later."; |
| 2388 return true; | 2385 return true; |
| 2389 } | 2386 } |
| 2390 | 2387 |
| 2391 // Bitrate is auto by default. | 2388 // Bitrate is auto by default. |
| 2392 // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by | 2389 // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by |
| 2393 // SetMaxSendBandwith(0), the second call removes the previous limit. | 2390 // SetMaxSendBandwith(0), the second call removes the previous limit. |
| 2394 if (bps <= 0) | 2391 if (!bps) { |
| 2395 return true; | 2392 return true; |
| 2393 } |
| 2396 | 2394 |
| 2397 webrtc::CodecInst codec = send_codec_spec_.codec_inst; | 2395 webrtc::CodecInst codec = send_codec_spec_.codec_inst; |
| 2398 bool is_multi_rate = WebRtcVoiceCodecs::IsCodecMultiRate(codec); | 2396 bool is_multi_rate = WebRtcVoiceCodecs::IsCodecMultiRate(codec); |
| 2399 | 2397 |
| 2400 if (is_multi_rate) { | 2398 if (is_multi_rate) { |
| 2401 // If codec is multi-rate then just set the bitrate. | 2399 // If codec is multi-rate then just set the bitrate. |
| 2402 codec.rate = bps; | 2400 codec.rate = *bps; |
| 2403 for (const auto& ch : send_streams_) { | 2401 for (const auto& ch : send_streams_) { |
| 2404 if (!SetSendCodec(ch.second->channel(), codec)) { | 2402 if (!SetSendCodec(ch.second->channel(), codec)) { |
| 2405 LOG(LS_INFO) << "Failed to set codec " << codec.plname | 2403 LOG(LS_INFO) << "Failed to set codec " << codec.plname |
| 2406 << " to bitrate " << bps << " bps."; | 2404 << " to bitrate " << bps << " bps."; |
| 2407 return false; | 2405 return false; |
| 2408 } | 2406 } |
| 2409 } | 2407 } |
| 2410 return true; | 2408 return true; |
| 2411 } else { | 2409 } else { |
| 2412 // If codec is not multi-rate and |bps| is less than the fixed bitrate | 2410 // If codec is not multi-rate and |bps| is less than the fixed bitrate |
| 2413 // then fail. If codec is not multi-rate and |bps| exceeds or equal the | 2411 // then fail. If codec is not multi-rate and |bps| exceeds or equal the |
| 2414 // fixed bitrate then ignore. | 2412 // fixed bitrate then ignore. |
| 2415 if (bps < codec.rate) { | 2413 if (*bps < codec.rate) { |
| 2416 LOG(LS_INFO) << "Failed to set codec " << codec.plname | 2414 LOG(LS_INFO) << "Failed to set codec " << codec.plname |
| 2417 << " to bitrate " << bps << " bps" | 2415 << " to bitrate " << bps << " bps" |
| 2418 << ", requires at least " << codec.rate << " bps."; | 2416 << ", requires at least " << codec.rate << " bps."; |
| 2419 return false; | 2417 return false; |
| 2420 } | 2418 } |
| 2421 return true; | 2419 return true; |
| 2422 } | 2420 } |
| 2423 } | 2421 } |
| 2424 | 2422 |
| 2425 void WebRtcVoiceMediaChannel::OnReadyToSend(bool ready) { | 2423 void WebRtcVoiceMediaChannel::OnReadyToSend(bool ready) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2551 } | 2549 } |
| 2552 } else { | 2550 } else { |
| 2553 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2551 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
| 2554 engine()->voe()->base()->StopPlayout(channel); | 2552 engine()->voe()->base()->StopPlayout(channel); |
| 2555 } | 2553 } |
| 2556 return true; | 2554 return true; |
| 2557 } | 2555 } |
| 2558 } // namespace cricket | 2556 } // namespace cricket |
| 2559 | 2557 |
| 2560 #endif // HAVE_WEBRTC_VOICE | 2558 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |