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 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 webrtc::RtpExtension::IsSupportedForAudio, false); | 1409 webrtc::RtpExtension::IsSupportedForAudio, false); |
1410 if (recv_rtp_extensions_ != filtered_extensions) { | 1410 if (recv_rtp_extensions_ != filtered_extensions) { |
1411 recv_rtp_extensions_.swap(filtered_extensions); | 1411 recv_rtp_extensions_.swap(filtered_extensions); |
1412 for (auto& it : recv_streams_) { | 1412 for (auto& it : recv_streams_) { |
1413 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); | 1413 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); |
1414 } | 1414 } |
1415 } | 1415 } |
1416 return true; | 1416 return true; |
1417 } | 1417 } |
1418 | 1418 |
1419 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpParameters( | 1419 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpSendParameters( |
1420 uint32_t ssrc) const { | 1420 uint32_t ssrc) const { |
1421 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1421 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1422 auto it = send_streams_.find(ssrc); | 1422 auto it = send_streams_.find(ssrc); |
1423 if (it == send_streams_.end()) { | 1423 if (it == send_streams_.end()) { |
1424 LOG(LS_WARNING) << "Attempting to get RTP parameters for stream with ssrc " | 1424 LOG(LS_WARNING) << "Attempting to get RTP send parameters for stream " |
1425 << ssrc << " which doesn't exist."; | 1425 << "with ssrc " << ssrc << " which doesn't exist."; |
1426 return webrtc::RtpParameters(); | 1426 return webrtc::RtpParameters(); |
1427 } | 1427 } |
1428 | 1428 |
1429 webrtc::RtpParameters rtp_params = it->second->rtp_parameters(); | 1429 webrtc::RtpParameters rtp_params = it->second->rtp_parameters(); |
1430 // Need to add the common list of codecs to the send stream-specific | 1430 // Need to add the common list of codecs to the send stream-specific |
1431 // RTP parameters. | 1431 // RTP parameters. |
1432 for (const AudioCodec& codec : send_codecs_) { | 1432 for (const AudioCodec& codec : send_codecs_) { |
1433 rtp_params.codecs.push_back(codec.ToCodecParameters()); | 1433 rtp_params.codecs.push_back(codec.ToCodecParameters()); |
1434 } | 1434 } |
1435 return rtp_params; | 1435 return rtp_params; |
1436 } | 1436 } |
1437 | 1437 |
1438 bool WebRtcVoiceMediaChannel::SetRtpParameters( | 1438 bool WebRtcVoiceMediaChannel::SetRtpSendParameters( |
1439 uint32_t ssrc, | 1439 uint32_t ssrc, |
1440 const webrtc::RtpParameters& parameters) { | 1440 const webrtc::RtpParameters& parameters) { |
1441 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); | 1441 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
1442 if (!ValidateRtpParameters(parameters)) { | 1442 if (!ValidateRtpParameters(parameters)) { |
1443 return false; | 1443 return false; |
1444 } | 1444 } |
1445 auto it = send_streams_.find(ssrc); | 1445 auto it = send_streams_.find(ssrc); |
1446 if (it == send_streams_.end()) { | 1446 if (it == send_streams_.end()) { |
1447 LOG(LS_WARNING) << "Attempting to set RTP parameters for stream with ssrc " | 1447 LOG(LS_WARNING) << "Attempting to set RTP send parameters for stream " |
1448 << ssrc << " which doesn't exist."; | 1448 << "with ssrc " << ssrc << " which doesn't exist."; |
1449 return false; | 1449 return false; |
1450 } | 1450 } |
1451 | 1451 |
1452 if (!SetChannelParameters(it->second->channel(), parameters)) { | 1452 // TODO(deadbeef): Handle setting parameters with a list of codecs in a |
1453 LOG(LS_WARNING) << "Failed to set RtpParameters."; | 1453 // different order (which should change the send codec). |
| 1454 webrtc::RtpParameters current_parameters = GetRtpSendParameters(ssrc); |
| 1455 if (current_parameters.codecs != parameters.codecs) { |
| 1456 LOG(LS_ERROR) << "Using SetParameters to change the set of codecs " |
| 1457 << "is not currently supported."; |
| 1458 return false; |
| 1459 } |
| 1460 |
| 1461 if (!SetChannelSendParameters(it->second->channel(), parameters)) { |
| 1462 LOG(LS_WARNING) << "Failed to set send RtpParameters."; |
1454 return false; | 1463 return false; |
1455 } | 1464 } |
1456 // Codecs are handled at the WebRtcVoiceMediaChannel level. | 1465 // Codecs are handled at the WebRtcVoiceMediaChannel level. |
1457 webrtc::RtpParameters reduced_params = parameters; | 1466 webrtc::RtpParameters reduced_params = parameters; |
1458 reduced_params.codecs.clear(); | 1467 reduced_params.codecs.clear(); |
1459 it->second->set_rtp_parameters(reduced_params); | 1468 it->second->set_rtp_parameters(reduced_params); |
1460 return true; | 1469 return true; |
1461 } | 1470 } |
1462 | 1471 |
| 1472 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters( |
| 1473 uint32_t ssrc) const { |
| 1474 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1475 auto it = recv_streams_.find(ssrc); |
| 1476 if (it == recv_streams_.end()) { |
| 1477 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream " |
| 1478 << "with ssrc " << ssrc << " which doesn't exist."; |
| 1479 return webrtc::RtpParameters(); |
| 1480 } |
| 1481 |
| 1482 // TODO(deadbeef): Return stream-specific parameters. |
| 1483 webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding(); |
| 1484 for (const AudioCodec& codec : recv_codecs_) { |
| 1485 rtp_params.codecs.push_back(codec.ToCodecParameters()); |
| 1486 } |
| 1487 return rtp_params; |
| 1488 } |
| 1489 |
| 1490 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters( |
| 1491 uint32_t ssrc, |
| 1492 const webrtc::RtpParameters& parameters) { |
| 1493 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); |
| 1494 if (!ValidateRtpParameters(parameters)) { |
| 1495 return false; |
| 1496 } |
| 1497 auto it = recv_streams_.find(ssrc); |
| 1498 if (it == recv_streams_.end()) { |
| 1499 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream " |
| 1500 << "with ssrc " << ssrc << " which doesn't exist."; |
| 1501 return false; |
| 1502 } |
| 1503 |
| 1504 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc); |
| 1505 if (current_parameters != parameters) { |
| 1506 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently " |
| 1507 << "unsupported."; |
| 1508 return false; |
| 1509 } |
| 1510 return true; |
| 1511 } |
| 1512 |
1463 bool WebRtcVoiceMediaChannel::ValidateRtpParameters( | 1513 bool WebRtcVoiceMediaChannel::ValidateRtpParameters( |
1464 const webrtc::RtpParameters& rtp_parameters) { | 1514 const webrtc::RtpParameters& rtp_parameters) { |
1465 if (rtp_parameters.encodings.size() != 1) { | 1515 if (rtp_parameters.encodings.size() != 1) { |
1466 LOG(LS_ERROR) | 1516 LOG(LS_ERROR) |
1467 << "Attempted to set RtpParameters without exactly one encoding"; | 1517 << "Attempted to set RtpParameters without exactly one encoding"; |
1468 return false; | 1518 return false; |
1469 } | 1519 } |
1470 return true; | 1520 return true; |
1471 } | 1521 } |
1472 | 1522 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( | 1807 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( |
1758 channel, send_codec_spec_.opus_max_playback_rate) == -1) { | 1808 channel, send_codec_spec_.opus_max_playback_rate) == -1) { |
1759 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, | 1809 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, |
1760 send_codec_spec_.opus_max_playback_rate); | 1810 send_codec_spec_.opus_max_playback_rate); |
1761 return false; | 1811 return false; |
1762 } | 1812 } |
1763 } | 1813 } |
1764 } | 1814 } |
1765 // TODO(solenberg): SetMaxSendBitrate() yields another call to SetSendCodec(). | 1815 // TODO(solenberg): SetMaxSendBitrate() yields another call to SetSendCodec(). |
1766 // Check if it is possible to fuse with the previous call in this function. | 1816 // Check if it is possible to fuse with the previous call in this function. |
1767 SetChannelParameters(channel, rtp_parameters); | 1817 SetChannelSendParameters(channel, rtp_parameters); |
1768 | 1818 |
1769 // Set the CN payloadtype and the VAD status. | 1819 // Set the CN payloadtype and the VAD status. |
1770 if (send_codec_spec_.cng_payload_type != -1) { | 1820 if (send_codec_spec_.cng_payload_type != -1) { |
1771 // The CN payload type for 8000 Hz clockrate is fixed at 13. | 1821 // The CN payload type for 8000 Hz clockrate is fixed at 13. |
1772 if (send_codec_spec_.cng_plfreq != 8000) { | 1822 if (send_codec_spec_.cng_plfreq != 8000) { |
1773 webrtc::PayloadFrequencies cn_freq; | 1823 webrtc::PayloadFrequencies cn_freq; |
1774 switch (send_codec_spec_.cng_plfreq) { | 1824 switch (send_codec_spec_.cng_plfreq) { |
1775 case 16000: | 1825 case 16000: |
1776 cn_freq = webrtc::kFreq16000Hz; | 1826 cn_freq = webrtc::kFreq16000Hz; |
1777 break; | 1827 break; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2396 ap->set_output_will_be_muted(all_muted); | 2446 ap->set_output_will_be_muted(all_muted); |
2397 } | 2447 } |
2398 return true; | 2448 return true; |
2399 } | 2449 } |
2400 | 2450 |
2401 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) { | 2451 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) { |
2402 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBitrate."; | 2452 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBitrate."; |
2403 max_send_bitrate_bps_ = bps; | 2453 max_send_bitrate_bps_ = bps; |
2404 | 2454 |
2405 for (const auto& kv : send_streams_) { | 2455 for (const auto& kv : send_streams_) { |
2406 if (!SetChannelParameters(kv.second->channel(), | 2456 if (!SetChannelSendParameters(kv.second->channel(), |
2407 kv.second->rtp_parameters())) { | 2457 kv.second->rtp_parameters())) { |
2408 return false; | 2458 return false; |
2409 } | 2459 } |
2410 } | 2460 } |
2411 return true; | 2461 return true; |
2412 } | 2462 } |
2413 | 2463 |
2414 bool WebRtcVoiceMediaChannel::SetChannelParameters( | 2464 bool WebRtcVoiceMediaChannel::SetChannelSendParameters( |
2415 int channel, | 2465 int channel, |
2416 const webrtc::RtpParameters& parameters) { | 2466 const webrtc::RtpParameters& parameters) { |
2417 RTC_CHECK_EQ(1UL, parameters.encodings.size()); | 2467 RTC_CHECK_EQ(1UL, parameters.encodings.size()); |
2418 // TODO(deadbeef): Handle setting parameters with a list of codecs in a | 2468 // TODO(deadbeef): Handle setting parameters with a list of codecs in a |
2419 // different order (which should change the send codec). | 2469 // different order (which should change the send codec). |
2420 return SetMaxSendBitrate( | 2470 return SetMaxSendBitrate( |
2421 channel, MinPositive(max_send_bitrate_bps_, | 2471 channel, MinPositive(max_send_bitrate_bps_, |
2422 parameters.encodings[0].max_bitrate_bps)); | 2472 parameters.encodings[0].max_bitrate_bps)); |
2423 } | 2473 } |
2424 | 2474 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 } | 2644 } |
2595 } else { | 2645 } else { |
2596 LOG(LS_INFO) << "Stopping playout for channel #" << channel; | 2646 LOG(LS_INFO) << "Stopping playout for channel #" << channel; |
2597 engine()->voe()->base()->StopPlayout(channel); | 2647 engine()->voe()->base()->StopPlayout(channel); |
2598 } | 2648 } |
2599 return true; | 2649 return true; |
2600 } | 2650 } |
2601 } // namespace cricket | 2651 } // namespace cricket |
2602 | 2652 |
2603 #endif // HAVE_WEBRTC_VOICE | 2653 #endif // HAVE_WEBRTC_VOICE |
OLD | NEW |