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

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

Issue 1917193008: Adding getParameters/setParameters APIs to RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: objc compile errors Created 4 years, 7 months 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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 webrtc::RtpExtension::IsSupportedForAudio, false); 1416 webrtc::RtpExtension::IsSupportedForAudio, false);
1417 if (recv_rtp_extensions_ != filtered_extensions) { 1417 if (recv_rtp_extensions_ != filtered_extensions) {
1418 recv_rtp_extensions_.swap(filtered_extensions); 1418 recv_rtp_extensions_.swap(filtered_extensions);
1419 for (auto& it : recv_streams_) { 1419 for (auto& it : recv_streams_) {
1420 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_); 1420 it.second->RecreateAudioReceiveStream(recv_rtp_extensions_);
1421 } 1421 }
1422 } 1422 }
1423 return true; 1423 return true;
1424 } 1424 }
1425 1425
1426 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpParameters( 1426 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpSendParameters(
1427 uint32_t ssrc) const { 1427 uint32_t ssrc) const {
1428 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1428 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1429 auto it = send_streams_.find(ssrc); 1429 auto it = send_streams_.find(ssrc);
1430 if (it == send_streams_.end()) { 1430 if (it == send_streams_.end()) {
1431 LOG(LS_WARNING) << "Attempting to get RTP parameters for stream with ssrc " 1431 LOG(LS_WARNING) << "Attempting to get RTP send parameters for stream "
1432 << ssrc << " which doesn't exist."; 1432 << "with ssrc " << ssrc << " which doesn't exist.";
1433 return webrtc::RtpParameters(); 1433 return webrtc::RtpParameters();
1434 } 1434 }
1435 1435
1436 webrtc::RtpParameters rtp_params = it->second->rtp_parameters(); 1436 webrtc::RtpParameters rtp_params = it->second->rtp_parameters();
1437 // Need to add the common list of codecs to the send stream-specific 1437 // Need to add the common list of codecs to the send stream-specific
1438 // RTP parameters. 1438 // RTP parameters.
1439 for (const AudioCodec& codec : send_codecs_) { 1439 for (const AudioCodec& codec : send_codecs_) {
1440 rtp_params.codecs.push_back(codec.ToCodecParameters()); 1440 rtp_params.codecs.push_back(codec.ToCodecParameters());
1441 } 1441 }
1442 return rtp_params; 1442 return rtp_params;
1443 } 1443 }
1444 1444
1445 bool WebRtcVoiceMediaChannel::SetRtpParameters( 1445 bool WebRtcVoiceMediaChannel::SetRtpSendParameters(
1446 uint32_t ssrc, 1446 uint32_t ssrc,
1447 const webrtc::RtpParameters& parameters) { 1447 const webrtc::RtpParameters& parameters) {
1448 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); 1448 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1449 if (!ValidateRtpParameters(parameters)) { 1449 if (!ValidateRtpParameters(parameters)) {
1450 return false; 1450 return false;
1451 } 1451 }
1452 auto it = send_streams_.find(ssrc); 1452 auto it = send_streams_.find(ssrc);
1453 if (it == send_streams_.end()) { 1453 if (it == send_streams_.end()) {
1454 LOG(LS_WARNING) << "Attempting to set RTP parameters for stream with ssrc " 1454 LOG(LS_WARNING) << "Attempting to set RTP send parameters for stream "
1455 << ssrc << " which doesn't exist."; 1455 << "with ssrc " << ssrc << " which doesn't exist.";
1456 return false; 1456 return false;
1457 } 1457 }
1458 1458
1459 if (!SetChannelParameters(it->second->channel(), parameters)) { 1459 // TODO(deadbeef): Handle setting parameters with a list of codecs in a
1460 LOG(LS_WARNING) << "Failed to set RtpParameters."; 1460 // different order (which should change the send codec).
1461 webrtc::RtpParameters current_parameters = GetRtpSendParameters(ssrc);
1462 if (current_parameters.codecs != parameters.codecs) {
1463 LOG(LS_ERROR) << "Using SetParameters to change the set of codecs "
1464 << "is not currently supported.";
1465 return false;
1466 }
1467
1468 if (!SetChannelSendParameters(it->second->channel(), parameters)) {
1469 LOG(LS_WARNING) << "Failed to set send RtpParameters.";
1461 return false; 1470 return false;
1462 } 1471 }
1463 // Codecs are handled at the WebRtcVoiceMediaChannel level. 1472 // Codecs are handled at the WebRtcVoiceMediaChannel level.
1464 webrtc::RtpParameters reduced_params = parameters; 1473 webrtc::RtpParameters reduced_params = parameters;
1465 reduced_params.codecs.clear(); 1474 reduced_params.codecs.clear();
1466 it->second->SetRtpParameters(reduced_params); 1475 it->second->SetRtpParameters(reduced_params);
1467 return true; 1476 return true;
1468 } 1477 }
1469 1478
1479 webrtc::RtpParameters WebRtcVoiceMediaChannel::GetRtpReceiveParameters(
1480 uint32_t ssrc) const {
1481 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1482 auto it = recv_streams_.find(ssrc);
1483 if (it == recv_streams_.end()) {
1484 LOG(LS_WARNING) << "Attempting to get RTP receive parameters for stream "
1485 << "with ssrc " << ssrc << " which doesn't exist.";
1486 return webrtc::RtpParameters();
1487 }
1488
1489 // TODO(deadbeef): Return stream-specific parameters.
1490 webrtc::RtpParameters rtp_params = CreateRtpParametersWithOneEncoding();
1491 for (const AudioCodec& codec : recv_codecs_) {
1492 rtp_params.codecs.push_back(codec.ToCodecParameters());
1493 }
1494 return rtp_params;
1495 }
1496
1497 bool WebRtcVoiceMediaChannel::SetRtpReceiveParameters(
1498 uint32_t ssrc,
1499 const webrtc::RtpParameters& parameters) {
1500 RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
1501 if (!ValidateRtpParameters(parameters)) {
1502 return false;
1503 }
1504 auto it = recv_streams_.find(ssrc);
1505 if (it == recv_streams_.end()) {
1506 LOG(LS_WARNING) << "Attempting to set RTP receive parameters for stream "
1507 << "with ssrc " << ssrc << " which doesn't exist.";
1508 return false;
1509 }
1510
1511 webrtc::RtpParameters current_parameters = GetRtpReceiveParameters(ssrc);
1512 if (current_parameters != parameters) {
1513 LOG(LS_ERROR) << "Changing the RTP receive parameters is currently "
1514 << "unsupported.";
1515 return false;
1516 }
1517 return true;
1518 }
1519
1470 bool WebRtcVoiceMediaChannel::ValidateRtpParameters( 1520 bool WebRtcVoiceMediaChannel::ValidateRtpParameters(
1471 const webrtc::RtpParameters& rtp_parameters) { 1521 const webrtc::RtpParameters& rtp_parameters) {
1472 if (rtp_parameters.encodings.size() != 1) { 1522 if (rtp_parameters.encodings.size() != 1) {
1473 LOG(LS_ERROR) 1523 LOG(LS_ERROR)
1474 << "Attempted to set RtpParameters without exactly one encoding"; 1524 << "Attempted to set RtpParameters without exactly one encoding";
1475 return false; 1525 return false;
1476 } 1526 }
1477 return true; 1527 return true;
1478 } 1528 }
1479 1529
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate( 1812 if (engine()->voe()->codec()->SetOpusMaxPlaybackRate(
1763 channel, send_codec_spec_.opus_max_playback_rate) == -1) { 1813 channel, send_codec_spec_.opus_max_playback_rate) == -1) {
1764 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel, 1814 LOG_RTCERR2(SetOpusMaxPlaybackRate, channel,
1765 send_codec_spec_.opus_max_playback_rate); 1815 send_codec_spec_.opus_max_playback_rate);
1766 return false; 1816 return false;
1767 } 1817 }
1768 } 1818 }
1769 } 1819 }
1770 // TODO(solenberg): SetMaxSendBitrate() yields another call to SetSendCodec(). 1820 // TODO(solenberg): SetMaxSendBitrate() yields another call to SetSendCodec().
1771 // Check if it is possible to fuse with the previous call in this function. 1821 // Check if it is possible to fuse with the previous call in this function.
1772 SetChannelParameters(channel, rtp_parameters); 1822 SetChannelSendParameters(channel, rtp_parameters);
1773 1823
1774 // Set the CN payloadtype and the VAD status. 1824 // Set the CN payloadtype and the VAD status.
1775 if (send_codec_spec_.cng_payload_type != -1) { 1825 if (send_codec_spec_.cng_payload_type != -1) {
1776 // The CN payload type for 8000 Hz clockrate is fixed at 13. 1826 // The CN payload type for 8000 Hz clockrate is fixed at 13.
1777 if (send_codec_spec_.cng_plfreq != 8000) { 1827 if (send_codec_spec_.cng_plfreq != 8000) {
1778 webrtc::PayloadFrequencies cn_freq; 1828 webrtc::PayloadFrequencies cn_freq;
1779 switch (send_codec_spec_.cng_plfreq) { 1829 switch (send_codec_spec_.cng_plfreq) {
1780 case 16000: 1830 case 16000:
1781 cn_freq = webrtc::kFreq16000Hz; 1831 cn_freq = webrtc::kFreq16000Hz;
1782 break; 1832 break;
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 ap->set_output_will_be_muted(all_muted); 2412 ap->set_output_will_be_muted(all_muted);
2363 } 2413 }
2364 return true; 2414 return true;
2365 } 2415 }
2366 2416
2367 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) { 2417 bool WebRtcVoiceMediaChannel::SetMaxSendBitrate(int bps) {
2368 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBitrate."; 2418 LOG(LS_INFO) << "WebRtcVoiceMediaChannel::SetMaxSendBitrate.";
2369 max_send_bitrate_bps_ = bps; 2419 max_send_bitrate_bps_ = bps;
2370 2420
2371 for (const auto& kv : send_streams_) { 2421 for (const auto& kv : send_streams_) {
2372 if (!SetChannelParameters(kv.second->channel(), 2422 if (!SetChannelSendParameters(kv.second->channel(),
2373 kv.second->rtp_parameters())) { 2423 kv.second->rtp_parameters())) {
2374 return false; 2424 return false;
2375 } 2425 }
2376 } 2426 }
2377 return true; 2427 return true;
2378 } 2428 }
2379 2429
2380 bool WebRtcVoiceMediaChannel::SetChannelParameters( 2430 bool WebRtcVoiceMediaChannel::SetChannelSendParameters(
2381 int channel, 2431 int channel,
2382 const webrtc::RtpParameters& parameters) { 2432 const webrtc::RtpParameters& parameters) {
2383 RTC_CHECK_EQ(1UL, parameters.encodings.size()); 2433 RTC_CHECK_EQ(1UL, parameters.encodings.size());
2384 // TODO(deadbeef): Handle setting parameters with a list of codecs in a 2434 // TODO(deadbeef): Handle setting parameters with a list of codecs in a
2385 // different order (which should change the send codec). 2435 // different order (which should change the send codec).
2386 return SetMaxSendBitrate( 2436 return SetMaxSendBitrate(
2387 channel, MinPositive(max_send_bitrate_bps_, 2437 channel, MinPositive(max_send_bitrate_bps_,
2388 parameters.encodings[0].max_bitrate_bps)); 2438 parameters.encodings[0].max_bitrate_bps));
2389 } 2439 }
2390 2440
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 } 2610 }
2561 } else { 2611 } else {
2562 LOG(LS_INFO) << "Stopping playout for channel #" << channel; 2612 LOG(LS_INFO) << "Stopping playout for channel #" << channel;
2563 engine()->voe()->base()->StopPlayout(channel); 2613 engine()->voe()->base()->StopPlayout(channel);
2564 } 2614 }
2565 return true; 2615 return true;
2566 } 2616 }
2567 } // namespace cricket 2617 } // namespace cricket
2568 2618
2569 #endif // HAVE_WEBRTC_VOICE 2619 #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