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

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

Issue 1670153003: Introduce struct MediaConfig, with construction-time settings. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed test nit; use reference. Created 4 years, 10 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2"; 502 LOG(LS_INFO) << "WebRtcVideoEngine2::~WebRtcVideoEngine2";
503 } 503 }
504 504
505 void WebRtcVideoEngine2::Init() { 505 void WebRtcVideoEngine2::Init() {
506 LOG(LS_INFO) << "WebRtcVideoEngine2::Init"; 506 LOG(LS_INFO) << "WebRtcVideoEngine2::Init";
507 initialized_ = true; 507 initialized_ = true;
508 } 508 }
509 509
510 WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel( 510 WebRtcVideoChannel2* WebRtcVideoEngine2::CreateChannel(
511 webrtc::Call* call, 511 webrtc::Call* call,
512 const MediaConfig& config,
512 const VideoOptions& options) { 513 const VideoOptions& options) {
513 RTC_DCHECK(initialized_); 514 RTC_DCHECK(initialized_);
514 LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString(); 515 LOG(LS_INFO) << "CreateChannel. Options: " << options.ToString();
515 return new WebRtcVideoChannel2(call, options, video_codecs_, 516 return new WebRtcVideoChannel2(call, config, options, video_codecs_,
516 external_encoder_factory_, external_decoder_factory_); 517 external_encoder_factory_,
518 external_decoder_factory_);
517 } 519 }
518 520
519 const std::vector<VideoCodec>& WebRtcVideoEngine2::codecs() const { 521 const std::vector<VideoCodec>& WebRtcVideoEngine2::codecs() const {
520 return video_codecs_; 522 return video_codecs_;
521 } 523 }
522 524
523 RtpCapabilities WebRtcVideoEngine2::GetCapabilities() const { 525 RtpCapabilities WebRtcVideoEngine2::GetCapabilities() const {
524 RtpCapabilities capabilities; 526 RtpCapabilities capabilities;
525 capabilities.header_extensions.push_back( 527 capabilities.header_extensions.push_back(
526 RtpHeaderExtension(kRtpTimestampOffsetHeaderExtension, 528 RtpHeaderExtension(kRtpTimestampOffsetHeaderExtension,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 0); 597 0);
596 598
597 AddDefaultFeedbackParams(&codec); 599 AddDefaultFeedbackParams(&codec);
598 supported_codecs.push_back(codec); 600 supported_codecs.push_back(codec);
599 } 601 }
600 return supported_codecs; 602 return supported_codecs;
601 } 603 }
602 604
603 WebRtcVideoChannel2::WebRtcVideoChannel2( 605 WebRtcVideoChannel2::WebRtcVideoChannel2(
604 webrtc::Call* call, 606 webrtc::Call* call,
607 const MediaConfig& config,
605 const VideoOptions& options, 608 const VideoOptions& options,
606 const std::vector<VideoCodec>& recv_codecs, 609 const std::vector<VideoCodec>& recv_codecs,
607 WebRtcVideoEncoderFactory* external_encoder_factory, 610 WebRtcVideoEncoderFactory* external_encoder_factory,
608 WebRtcVideoDecoderFactory* external_decoder_factory) 611 WebRtcVideoDecoderFactory* external_decoder_factory)
609 : call_(call), 612 : VideoMediaChannel(config),
613 call_(call),
610 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), 614 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
615 signal_cpu_adaptation_(config.enable_cpu_overuse_detection),
616 disable_prerenderer_smoothing_(config.disable_prerenderer_smoothing),
611 external_encoder_factory_(external_encoder_factory), 617 external_encoder_factory_(external_encoder_factory),
612 external_decoder_factory_(external_decoder_factory) { 618 external_decoder_factory_(external_decoder_factory) {
613 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 619 RTC_DCHECK(thread_checker_.CalledOnValidThread());
614 SetDefaultOptions();
615 options_.SetAll(options); 620 options_.SetAll(options);
616 if (options_.cpu_overuse_detection)
617 signal_cpu_adaptation_ = *options_.cpu_overuse_detection;
618 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; 621 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
619 sending_ = false; 622 sending_ = false;
620 default_send_ssrc_ = 0; 623 default_send_ssrc_ = 0;
621 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); 624 RTC_DCHECK(ValidateCodecFormats(recv_codecs));
622 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); 625 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs));
623 } 626 }
624 627
625 void WebRtcVideoChannel2::SetDefaultOptions() {
626 options_.cpu_overuse_detection = rtc::Optional<bool>(true);
627 options_.dscp = rtc::Optional<bool>(false);
628 options_.suspend_below_min_bitrate = rtc::Optional<bool>(false);
629 options_.screencast_min_bitrate_kbps = rtc::Optional<int>(0);
630 }
631
632 WebRtcVideoChannel2::~WebRtcVideoChannel2() { 628 WebRtcVideoChannel2::~WebRtcVideoChannel2() {
633 for (auto& kv : send_streams_) 629 for (auto& kv : send_streams_)
634 delete kv.second; 630 delete kv.second;
635 for (auto& kv : receive_streams_) 631 for (auto& kv : receive_streams_)
636 delete kv.second; 632 delete kv.second;
637 } 633 }
638 634
639 bool WebRtcVideoChannel2::CodecIsExternallySupported( 635 bool WebRtcVideoChannel2::CodecIsExternallySupported(
640 const std::string& name) const { 636 const std::string& name) const {
641 if (external_encoder_factory_ == NULL) { 637 if (external_encoder_factory_ == NULL) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 // Handle RTCP mode. 746 // Handle RTCP mode.
751 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) { 747 if (params.rtcp.reduced_size != send_params_.rtcp.reduced_size) {
752 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>( 748 changed_params->rtcp_mode = rtc::Optional<webrtc::RtcpMode>(
753 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize 749 params.rtcp.reduced_size ? webrtc::RtcpMode::kReducedSize
754 : webrtc::RtcpMode::kCompound); 750 : webrtc::RtcpMode::kCompound);
755 } 751 }
756 752
757 return true; 753 return true;
758 } 754 }
759 755
756 rtc::DiffServCodePoint WebRtcVideoChannel2::PreferredDscp() const {
757 return rtc::DSCP_AF41;
758 }
759
760 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { 760 bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) {
761 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters"); 761 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetSendParameters");
762 LOG(LS_INFO) << "SetSendParameters: " << params.ToString(); 762 LOG(LS_INFO) << "SetSendParameters: " << params.ToString();
763 ChangedSendParameters changed_params; 763 ChangedSendParameters changed_params;
764 if (!GetChangedSendParameters(params, &changed_params)) { 764 if (!GetChangedSendParameters(params, &changed_params)) {
765 return false; 765 return false;
766 } 766 }
767 767
768 bool bitrate_config_changed = false; 768 bool bitrate_config_changed = false;
769 769
(...skipping 24 matching lines...) Expand all
794 bitrate_config_.min_bitrate_bps > max_bitrate_bps) { 794 bitrate_config_.min_bitrate_bps > max_bitrate_bps) {
795 bitrate_config_.min_bitrate_bps = max_bitrate_bps; 795 bitrate_config_.min_bitrate_bps = max_bitrate_bps;
796 } 796 }
797 bitrate_config_changed = true; 797 bitrate_config_changed = true;
798 } 798 }
799 799
800 if (bitrate_config_changed) { 800 if (bitrate_config_changed) {
801 call_->SetBitrateConfig(bitrate_config_); 801 call_->SetBitrateConfig(bitrate_config_);
802 } 802 }
803 803
804 if (changed_params.options) { 804 if (changed_params.options)
805 options_.SetAll(*changed_params.options); 805 options_.SetAll(*changed_params.options);
806 {
807 rtc::CritScope lock(&capturer_crit_);
808 if (options_.cpu_overuse_detection) {
809 signal_cpu_adaptation_ = *options_.cpu_overuse_detection;
810 }
811 }
812 rtc::DiffServCodePoint dscp =
813 options_.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT;
814 MediaChannel::SetDscp(dscp);
815 }
816 806
817 { 807 {
818 rtc::CritScope stream_lock(&stream_crit_); 808 rtc::CritScope stream_lock(&stream_crit_);
819 for (auto& kv : send_streams_) { 809 for (auto& kv : send_streams_) {
820 kv.second->SetSendParameters(changed_params); 810 kv.second->SetSendParameters(changed_params);
821 } 811 }
822 if (changed_params.codec) { 812 if (changed_params.codec) {
823 // Update receive feedback parameters from new codec. 813 // Update receive feedback parameters from new codec.
824 LOG(LS_INFO) 814 LOG(LS_INFO)
825 << "SetFeedbackOptions on all the receive streams because the send " 815 << "SetFeedbackOptions on all the receive streams because the send "
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 1121
1132 // Set up A/V sync group based on sync label. 1122 // Set up A/V sync group based on sync label.
1133 config.sync_group = sp.sync_label; 1123 config.sync_group = sp.sync_label;
1134 1124
1135 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false; 1125 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false;
1136 config.rtp.transport_cc = 1126 config.rtp.transport_cc =
1137 send_codec_ ? HasTransportCc(send_codec_->codec) : false; 1127 send_codec_ ? HasTransportCc(send_codec_->codec) : false;
1138 1128
1139 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( 1129 receive_streams_[ssrc] = new WebRtcVideoReceiveStream(
1140 call_, sp, config, external_decoder_factory_, default_stream, 1130 call_, sp, config, external_decoder_factory_, default_stream,
1141 recv_codecs_, options_.disable_prerenderer_smoothing.value_or(false)); 1131 recv_codecs_, disable_prerenderer_smoothing_);
1142 1132
1143 return true; 1133 return true;
1144 } 1134 }
1145 1135
1146 void WebRtcVideoChannel2::ConfigureReceiverRtp( 1136 void WebRtcVideoChannel2::ConfigureReceiverRtp(
1147 webrtc::VideoReceiveStream::Config* config, 1137 webrtc::VideoReceiveStream::Config* config,
1148 const StreamParams& sp) const { 1138 const StreamParams& sp) const {
1149 uint32_t ssrc = sp.first_ssrc(); 1139 uint32_t ssrc = sp.first_ssrc();
1150 1140
1151 config->rtp.remote_ssrc = ssrc; 1141 config->rtp.remote_ssrc = ssrc;
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 "payload type. Ignoring."; 1750 "payload type. Ignoring.";
1761 parameters_.config.rtp.rtx.ssrcs.clear(); 1751 parameters_.config.rtp.rtx.ssrcs.clear();
1762 } else { 1752 } else {
1763 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; 1753 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type;
1764 } 1754 }
1765 } 1755 }
1766 1756
1767 parameters_.config.rtp.nack.rtp_history_ms = 1757 parameters_.config.rtp.nack.rtp_history_ms =
1768 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; 1758 HasNack(codec_settings.codec) ? kNackHistoryMs : 0;
1769 1759
1770 RTC_CHECK(options.suspend_below_min_bitrate);
1771 parameters_.config.suspend_below_min_bitrate = 1760 parameters_.config.suspend_below_min_bitrate =
1772 *options.suspend_below_min_bitrate; 1761 options.suspend_below_min_bitrate.value_or(false);
1773 1762
1774 parameters_.codec_settings = 1763 parameters_.codec_settings =
1775 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); 1764 rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings);
1776 parameters_.options = options; 1765 parameters_.options = options;
1777 1766
1778 LOG(LS_INFO) 1767 LOG(LS_INFO)
1779 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" 1768 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options="
1780 << options.ToString(); 1769 << options.ToString();
1781 RecreateWebRtcStream(); 1770 RecreateWebRtcStream();
1782 if (allocated_encoder_.encoder != new_encoder.encoder) { 1771 if (allocated_encoder_.encoder != new_encoder.encoder) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1828 RecreateWebRtcStream(); 1817 RecreateWebRtcStream();
1829 } 1818 }
1830 } 1819 }
1831 1820
1832 webrtc::VideoEncoderConfig 1821 webrtc::VideoEncoderConfig
1833 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( 1822 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
1834 const Dimensions& dimensions, 1823 const Dimensions& dimensions,
1835 const VideoCodec& codec) const { 1824 const VideoCodec& codec) const {
1836 webrtc::VideoEncoderConfig encoder_config; 1825 webrtc::VideoEncoderConfig encoder_config;
1837 if (dimensions.is_screencast) { 1826 if (dimensions.is_screencast) {
1838 RTC_CHECK(parameters_.options.screencast_min_bitrate_kbps);
1839 encoder_config.min_transmit_bitrate_bps = 1827 encoder_config.min_transmit_bitrate_bps =
1840 *parameters_.options.screencast_min_bitrate_kbps * 1000; 1828 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0);
1841 encoder_config.content_type = 1829 encoder_config.content_type =
1842 webrtc::VideoEncoderConfig::ContentType::kScreen; 1830 webrtc::VideoEncoderConfig::ContentType::kScreen;
1843 } else { 1831 } else {
1844 encoder_config.min_transmit_bitrate_bps = 0; 1832 encoder_config.min_transmit_bitrate_bps = 0;
1845 encoder_config.content_type = 1833 encoder_config.content_type =
1846 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; 1834 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo;
1847 } 1835 }
1848 1836
1849 // Restrict dimensions according to codec max. 1837 // Restrict dimensions according to codec max.
1850 int width = dimensions.width; 1838 int width = dimensions.width;
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2491 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2504 } 2492 }
2505 } 2493 }
2506 2494
2507 return video_codecs; 2495 return video_codecs;
2508 } 2496 }
2509 2497
2510 } // namespace cricket 2498 } // namespace cricket
2511 2499
2512 #endif // HAVE_WEBRTC_VIDEO 2500 #endif // HAVE_WEBRTC_VIDEO
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.h ('k') | webrtc/media/engine/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698