Chromium Code Reviews| 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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1415 std::vector<webrtc::RtpExtension> filtered_extensions = | 1415 std::vector<webrtc::RtpExtension> filtered_extensions = |
| 1416 FilterRtpExtensions(params.extensions, | 1416 FilterRtpExtensions(params.extensions, |
| 1417 webrtc::RtpExtension::IsSupportedForAudio, true); | 1417 webrtc::RtpExtension::IsSupportedForAudio, true); |
| 1418 if (send_rtp_extensions_ != filtered_extensions) { | 1418 if (send_rtp_extensions_ != filtered_extensions) { |
| 1419 send_rtp_extensions_.swap(filtered_extensions); | 1419 send_rtp_extensions_.swap(filtered_extensions); |
| 1420 for (auto& it : send_streams_) { | 1420 for (auto& it : send_streams_) { |
| 1421 it.second->RecreateAudioSendStream(send_rtp_extensions_); | 1421 it.second->RecreateAudioSendStream(send_rtp_extensions_); |
| 1422 } | 1422 } |
| 1423 } | 1423 } |
| 1424 | 1424 |
| 1425 if (!SetMaxSendBandwidth(params.max_bandwidth_bps)) { | 1425 if (!SetMaxSendBitrate(params.max_bitrate_bps)) { |
| 1426 return false; | 1426 return false; |
| 1427 } | 1427 } |
| 1428 return SetOptions(params.options); | 1428 return SetOptions(params.options); |
| 1429 } | 1429 } |
| 1430 | 1430 |
| 1431 bool WebRtcVoiceMediaChannel::SetRecvParameters( | 1431 bool WebRtcVoiceMediaChannel::SetRecvParameters( |
| 1432 const AudioRecvParameters& params) { | 1432 const AudioRecvParameters& params) { |
| 1433 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetRecvParameters"); | 1433 TRACE_EVENT0("webrtc", "WebRtcVoiceMediaChannel::SetRecvParameters"); |
| 1434 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1434 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1435 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: " | 1435 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetRecvParameters: " |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1739 << channel; | 1739 << channel; |
| 1740 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( | 1740 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( |
| 1741 channel, send_codec_spec_.opus_max_playback_rate) == -1) { | 1741 channel, send_codec_spec_.opus_max_playback_rate) == -1) { |
| 1742 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, | 1742 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, |
| 1743 send_codec_spec_.opus_max_playback_rate); | 1743 send_codec_spec_.opus_max_playback_rate); |
| 1744 return false; | 1744 return false; |
| 1745 } | 1745 } |
| 1746 } | 1746 } |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 if (send_bitrate_setting_) { | 1749 if (send_bitrate_bps_) { |
| 1750 SetSendBitrateInternal(send_bitrate_bps_); | 1750 SetSendBitrateInternal(send_bitrate_bps_); |
| 1751 } | 1751 } |
| 1752 | 1752 |
| 1753 // Set the CN payloadtype and the VAD status. | 1753 // Set the CN payloadtype and the VAD status. |
| 1754 if (send_codec_spec_.cng_payload_type != -1) { | 1754 if (send_codec_spec_.cng_payload_type != -1) { |
| 1755 // The CN payload type for 8000 Hz clockrate is fixed at 13. | 1755 // The CN payload type for 8000 Hz clockrate is fixed at 13. |
| 1756 if (send_codec_spec_.cng_plfreq != 8000) { | 1756 if (send_codec_spec_.cng_plfreq != 8000) { |
| 1757 webrtc::PayloadFrequencies cn_freq; | 1757 webrtc::PayloadFrequencies cn_freq; |
| 1758 switch (send_codec_spec_.cng_plfreq) { | 1758 switch (send_codec_spec_.cng_plfreq) { |
| 1759 case 16000: | 1759 case 16000: |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2361 } | 2361 } |
| 2362 } | 2362 } |
| 2363 | 2363 |
| 2364 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing(); | 2364 webrtc::AudioProcessing* ap = engine()->voe()->base()->audio_processing(); |
| 2365 if (ap) { | 2365 if (ap) { |
| 2366 ap->set_output_will_be_muted(all_muted); | 2366 ap->set_output_will_be_muted(all_muted); |
| 2367 } | 2367 } |
| 2368 return true; | 2368 return true; |
| 2369 } | 2369 } |
| 2370 | 2370 |
| 2371 // TODO(minyue): SetMaxSendBandwidth() is subject to be renamed to | 2371 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(rtc::Optional<int> bps) { |
| 2372 // SetMaxSendBitrate() in future. | |
| 2373 bool WebRtcVoiceMediaChannel::SetMaxSendBandwidth(int bps) { | |
| 2374 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth."; | 2372 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBandwidth."; |
|
the sun
2016/03/29 11:20:34
Please add:
RTC_DCHECK(worker_thread_checker_.Call
skvlad
2016/03/30 19:40:45
Done.
| |
| 2375 return SetSendBitrateInternal(bps); | 2373 return SetSendBitrateInternal(bps); |
| 2376 } | 2374 } |
| 2377 | 2375 |
| 2378 bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(int bps) { | 2376 bool WebRtcVoiceMediaChannel::SetSendBitrateInternal(rtc::Optional<int> bps) { |
| 2379 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal."; | 2377 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetSendBitrateInternal."; |
| 2380 | 2378 |
| 2381 send_bitrate_setting_ = true; | |
| 2382 send_bitrate_bps_ = bps; | 2379 send_bitrate_bps_ = bps; |
| 2383 | 2380 |
| 2384 if (!HasSendCodec()) { | 2381 if (!HasSendCodec()) { |
| 2385 LOG(LS_INFO) << "The send codec has not been set up yet. " | 2382 LOG(LS_INFO) << "The send codec has not been set up yet. " |
| 2386 << "The send bitrate setting will be applied later."; | 2383 << "The send bitrate setting will be applied later."; |
| 2387 return true; | 2384 return true; |
| 2388 } | 2385 } |
| 2389 | 2386 |
| 2390 // Bitrate is auto by default. | 2387 // Bitrate is auto by default. |
| 2391 // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by | 2388 // TODO(bemasc): Fix this so that if SetMaxSendBandwidth(50) is followed by |
| 2392 // SetMaxSendBandwith(0), the second call removes the previous limit. | 2389 // SetMaxSendBandwith(0), the second call removes the previous limit. |
| 2393 if (bps <= 0) | 2390 if (!bps) |
|
Taylor Brandstetter
2016/03/29 02:26:58
nit: {}s
skvlad
2016/03/30 19:40:44
Done.
| |
| 2394 return true; | 2391 return true; |
| 2395 | 2392 |
| 2396 webrtc::CodecInst codec = send_codec_spec_.codec_inst; | 2393 webrtc::CodecInst codec = send_codec_spec_.codec_inst; |
| 2397 bool is_multi_rate = WebRtcVoiceCodecs::IsCodecMultiRate(codec); | 2394 bool is_multi_rate = WebRtcVoiceCodecs::IsCodecMultiRate(codec); |
| 2398 | 2395 |
| 2399 if (is_multi_rate) { | 2396 if (is_multi_rate) { |
| 2400 // If codec is multi-rate then just set the bitrate. | 2397 // If codec is multi-rate then just set the bitrate. |
| 2401 codec.rate = bps; | 2398 codec.rate = *bps; |
| 2402 for (const auto& ch : send_streams_) { | 2399 for (const auto& ch : send_streams_) { |
| 2403 if (!SetSendCodec(ch.second->channel(), codec)) { | 2400 if (!SetSendCodec(ch.second->channel(), codec)) { |
| 2404 LOG(LS_INFO) << "Failed to set codec " << codec.plname | 2401 LOG(LS_INFO) << "Failed to set codec " << codec.plname |
| 2405 << " to bitrate " << bps << " bps."; | 2402 << " to bitrate " << bps << " bps."; |
| 2406 return false; | 2403 return false; |
| 2407 } | 2404 } |
| 2408 } | 2405 } |
| 2409 return true; | 2406 return true; |
| 2410 } else { | 2407 } else { |
| 2411 // If codec is not multi-rate and |bps| is less than the fixed bitrate | 2408 // If codec is not multi-rate and |bps| is less than the fixed bitrate |
| 2412 // then fail. If codec is not multi-rate and |bps| exceeds or equal the | 2409 // then fail. If codec is not multi-rate and |bps| exceeds or equal the |
| 2413 // fixed bitrate then ignore. | 2410 // fixed bitrate then ignore. |
| 2414 if (bps < codec.rate) { | 2411 if (*bps < codec.rate) { |
| 2415 LOG(LS_INFO) << "Failed to set codec " << codec.plname | 2412 LOG(LS_INFO) << "Failed to set codec " << codec.plname |
| 2416 << " to bitrate " << bps << " bps" | 2413 << " to bitrate " << bps << " bps" |
| 2417 << ", requires at least " << codec.rate << " bps."; | 2414 << ", requires at least " << codec.rate << " bps."; |
| 2418 return false; | 2415 return false; |
| 2419 } | 2416 } |
| 2420 return true; | 2417 return true; |
| 2421 } | 2418 } |
| 2422 } | 2419 } |
| 2423 | 2420 |
| 2424 bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) { | 2421 bool WebRtcVoiceMediaChannel::GetStats(VoiceMediaInfo* info) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2542 } | 2539 } |
| 2543 } else { | 2540 } else { |
| 2544 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2541 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
| 2545 engine()->voe()->base()->StopPlayout(channel); | 2542 engine()->voe()->base()->StopPlayout(channel); |
| 2546 } | 2543 } |
| 2547 return true; | 2544 return true; |
| 2548 } | 2545 } |
| 2549 } // namespace cricket | 2546 } // namespace cricket |
| 2550 | 2547 |
| 2551 #endif // HAVE_WEBRTC_VOICE | 2548 #endif // HAVE_WEBRTC_VOICE |
| OLD | NEW |