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

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

Issue 1430433004: Replace rtc::cricket::Settable with rtc::Maybe (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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 * libjingle 2 * libjingle
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // No automatic resizing when using simulcast or screencast. 482 // No automatic resizing when using simulcast or screencast.
483 bool automatic_resize = 483 bool automatic_resize =
484 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; 484 !is_screencast && parameters_.config.rtp.ssrcs.size() == 1;
485 bool frame_dropping = !is_screencast; 485 bool frame_dropping = !is_screencast;
486 bool denoising; 486 bool denoising;
487 bool codec_default_denoising = false; 487 bool codec_default_denoising = false;
488 if (is_screencast) { 488 if (is_screencast) {
489 denoising = false; 489 denoising = false;
490 } else { 490 } else {
491 // Use codec default if video_noise_reduction is unset. 491 // Use codec default if video_noise_reduction is unset.
492 codec_default_denoising = !options.video_noise_reduction.Get(&denoising); 492 codec_default_denoising = !options.video_noise_reduction;
493 denoising = options.video_noise_reduction.value_or(false);
493 } 494 }
494 495
495 if (CodecNamesEq(codec.name, kVp8CodecName)) { 496 if (CodecNamesEq(codec.name, kVp8CodecName)) {
496 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); 497 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings();
497 encoder_settings_.vp8.automaticResizeOn = automatic_resize; 498 encoder_settings_.vp8.automaticResizeOn = automatic_resize;
498 // VP8 denoising is enabled by default. 499 // VP8 denoising is enabled by default.
499 encoder_settings_.vp8.denoisingOn = 500 encoder_settings_.vp8.denoisingOn =
500 codec_default_denoising ? true : denoising; 501 codec_default_denoising ? true : denoising;
501 encoder_settings_.vp8.frameDroppingOn = frame_dropping; 502 encoder_settings_.vp8.frameDroppingOn = frame_dropping;
502 return &encoder_settings_.vp8; 503 return &encoder_settings_.vp8;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 const std::vector<VideoCodec>& recv_codecs, 771 const std::vector<VideoCodec>& recv_codecs,
771 WebRtcVideoEncoderFactory* external_encoder_factory, 772 WebRtcVideoEncoderFactory* external_encoder_factory,
772 WebRtcVideoDecoderFactory* external_decoder_factory) 773 WebRtcVideoDecoderFactory* external_decoder_factory)
773 : call_(call), 774 : call_(call),
774 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), 775 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_),
775 external_encoder_factory_(external_encoder_factory), 776 external_encoder_factory_(external_encoder_factory),
776 external_decoder_factory_(external_decoder_factory) { 777 external_decoder_factory_(external_decoder_factory) {
777 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 778 RTC_DCHECK(thread_checker_.CalledOnValidThread());
778 SetDefaultOptions(); 779 SetDefaultOptions();
779 options_.SetAll(options); 780 options_.SetAll(options);
780 options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_); 781 if (options_.cpu_overuse_detection)
782 signal_cpu_adaptation_ = *options_.cpu_overuse_detection;
781 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; 783 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc;
782 sending_ = false; 784 sending_ = false;
783 default_send_ssrc_ = 0; 785 default_send_ssrc_ = 0;
784 SetRecvCodecs(recv_codecs); 786 SetRecvCodecs(recv_codecs);
785 } 787 }
786 788
787 void WebRtcVideoChannel2::SetDefaultOptions() { 789 void WebRtcVideoChannel2::SetDefaultOptions() {
788 options_.cpu_overuse_detection.Set(true); 790 options_.cpu_overuse_detection = rtc::Maybe<bool>(true);
789 options_.dscp.Set(false); 791 options_.dscp = rtc::Maybe<bool>(false);
790 options_.suspend_below_min_bitrate.Set(false); 792 options_.suspend_below_min_bitrate = rtc::Maybe<bool>(false);
791 options_.screencast_min_bitrate.Set(0); 793 options_.screencast_min_bitrate = rtc::Maybe<int>(0);
792 } 794 }
793 795
794 WebRtcVideoChannel2::~WebRtcVideoChannel2() { 796 WebRtcVideoChannel2::~WebRtcVideoChannel2() {
795 for (auto& kv : send_streams_) 797 for (auto& kv : send_streams_)
796 delete kv.second; 798 delete kv.second;
797 for (auto& kv : receive_streams_) 799 for (auto& kv : receive_streams_)
798 delete kv.second; 800 delete kv.second;
799 } 801 }
800 802
801 bool WebRtcVideoChannel2::CodecIsExternallySupported( 803 bool WebRtcVideoChannel2::CodecIsExternallySupported(
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 const std::vector<VideoCodecSettings> supported_codecs = 947 const std::vector<VideoCodecSettings> supported_codecs =
946 FilterSupportedCodecs(MapCodecs(codecs)); 948 FilterSupportedCodecs(MapCodecs(codecs));
947 949
948 if (supported_codecs.empty()) { 950 if (supported_codecs.empty()) {
949 LOG(LS_ERROR) << "No video codecs supported."; 951 LOG(LS_ERROR) << "No video codecs supported.";
950 return false; 952 return false;
951 } 953 }
952 954
953 LOG(LS_INFO) << "Using codec: " << supported_codecs.front().codec.ToString(); 955 LOG(LS_INFO) << "Using codec: " << supported_codecs.front().codec.ToString();
954 956
955 VideoCodecSettings old_codec; 957 if (send_codec_ && supported_codecs.front() == *send_codec_) {
956 if (send_codec_.Get(&old_codec) && supported_codecs.front() == old_codec) {
957 LOG(LS_INFO) << "Ignore call to SetSendCodecs because first supported " 958 LOG(LS_INFO) << "Ignore call to SetSendCodecs because first supported "
958 "codec hasn't changed."; 959 "codec hasn't changed.";
959 // Using same codec, avoid reconfiguring. 960 // Using same codec, avoid reconfiguring.
960 return true; 961 return true;
961 } 962 }
962 963
963 send_codec_.Set(supported_codecs.front()); 964 send_codec_ = rtc::Maybe<WebRtcVideoChannel2::VideoCodecSettings>(
965 supported_codecs.front());
964 966
965 rtc::CritScope stream_lock(&stream_crit_); 967 rtc::CritScope stream_lock(&stream_crit_);
966 LOG(LS_INFO) << "Change the send codec because SetSendCodecs has a different " 968 LOG(LS_INFO) << "Change the send codec because SetSendCodecs has a different "
967 "first supported codec."; 969 "first supported codec.";
968 for (auto& kv : send_streams_) { 970 for (auto& kv : send_streams_) {
969 RTC_DCHECK(kv.second != nullptr); 971 RTC_DCHECK(kv.second != nullptr);
970 kv.second->SetCodec(supported_codecs.front()); 972 kv.second->SetCodec(supported_codecs.front());
971 } 973 }
972 LOG(LS_INFO) << "SetNackAndRemb on all the receive streams because the send " 974 LOG(LS_INFO) << "SetNackAndRemb on all the receive streams because the send "
973 "codec has changed."; 975 "codec has changed.";
(...skipping 25 matching lines...) Expand all
999 bitrate_config_.max_bitrate_bps = bitrate_kbps * 1000; 1001 bitrate_config_.max_bitrate_bps = bitrate_kbps * 1000;
1000 } else { 1002 } else {
1001 bitrate_config_.max_bitrate_bps = -1; 1003 bitrate_config_.max_bitrate_bps = -1;
1002 } 1004 }
1003 call_->SetBitrateConfig(bitrate_config_); 1005 call_->SetBitrateConfig(bitrate_config_);
1004 1006
1005 return true; 1007 return true;
1006 } 1008 }
1007 1009
1008 bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) { 1010 bool WebRtcVideoChannel2::GetSendCodec(VideoCodec* codec) {
1009 VideoCodecSettings codec_settings; 1011 if (!send_codec_) {
1010 if (!send_codec_.Get(&codec_settings)) {
1011 LOG(LS_VERBOSE) << "GetSendCodec: No send codec set."; 1012 LOG(LS_VERBOSE) << "GetSendCodec: No send codec set.";
1012 return false; 1013 return false;
1013 } 1014 }
1014 *codec = codec_settings.codec; 1015 *codec = send_codec_->codec;
1015 return true; 1016 return true;
1016 } 1017 }
1017 1018
1018 bool WebRtcVideoChannel2::SetSendStreamFormat(uint32_t ssrc, 1019 bool WebRtcVideoChannel2::SetSendStreamFormat(uint32_t ssrc,
1019 const VideoFormat& format) { 1020 const VideoFormat& format) {
1020 LOG(LS_VERBOSE) << "SetSendStreamFormat:" << ssrc << " -> " 1021 LOG(LS_VERBOSE) << "SetSendStreamFormat:" << ssrc << " -> "
1021 << format.ToString(); 1022 << format.ToString();
1022 rtc::CritScope stream_lock(&stream_crit_); 1023 rtc::CritScope stream_lock(&stream_crit_);
1023 if (send_streams_.find(ssrc) == send_streams_.end()) { 1024 if (send_streams_.find(ssrc) == send_streams_.end()) {
1024 return false; 1025 return false;
1025 } 1026 }
1026 return send_streams_[ssrc]->SetVideoFormat(format); 1027 return send_streams_[ssrc]->SetVideoFormat(format);
1027 } 1028 }
1028 1029
1029 bool WebRtcVideoChannel2::SetSend(bool send) { 1030 bool WebRtcVideoChannel2::SetSend(bool send) {
1030 LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false"); 1031 LOG(LS_VERBOSE) << "SetSend: " << (send ? "true" : "false");
1031 if (send && !send_codec_.IsSet()) { 1032 if (send && !send_codec_) {
1032 LOG(LS_ERROR) << "SetSend(true) called before setting codec."; 1033 LOG(LS_ERROR) << "SetSend(true) called before setting codec.";
1033 return false; 1034 return false;
1034 } 1035 }
1035 if (send) { 1036 if (send) {
1036 StartAllSendStreams(); 1037 StartAllSendStreams();
1037 } else { 1038 } else {
1038 StopAllSendStreams(); 1039 StopAllSendStreams();
1039 } 1040 }
1040 sending_ = send; 1041 sending_ = send;
1041 return true; 1042 return true;
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 1218
1218 for (uint32_t used_ssrc : sp.ssrcs) 1219 for (uint32_t used_ssrc : sp.ssrcs)
1219 receive_ssrcs_.insert(used_ssrc); 1220 receive_ssrcs_.insert(used_ssrc);
1220 1221
1221 webrtc::VideoReceiveStream::Config config(this); 1222 webrtc::VideoReceiveStream::Config config(this);
1222 ConfigureReceiverRtp(&config, sp); 1223 ConfigureReceiverRtp(&config, sp);
1223 1224
1224 // Set up A/V sync group based on sync label. 1225 // Set up A/V sync group based on sync label.
1225 config.sync_group = sp.sync_label; 1226 config.sync_group = sp.sync_label;
1226 1227
1227 config.rtp.remb = false; 1228 config.rtp.remb = send_codec_ ? HasRemb(send_codec_->codec) : false;
1228 VideoCodecSettings send_codec;
1229 if (send_codec_.Get(&send_codec)) {
1230 config.rtp.remb = HasRemb(send_codec.codec);
1231 }
1232 1229
1233 receive_streams_[ssrc] = new WebRtcVideoReceiveStream( 1230 receive_streams_[ssrc] = new WebRtcVideoReceiveStream(
1234 call_, sp, config, external_decoder_factory_, default_stream, 1231 call_, sp, config, external_decoder_factory_, default_stream,
1235 recv_codecs_); 1232 recv_codecs_);
1236 1233
1237 return true; 1234 return true;
1238 } 1235 }
1239 1236
1240 void WebRtcVideoChannel2::ConfigureReceiverRtp( 1237 void WebRtcVideoChannel2::ConfigureReceiverRtp(
1241 webrtc::VideoReceiveStream::Config* config, 1238 webrtc::VideoReceiveStream::Config* config,
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); 1602 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions");
1606 LOG(LS_INFO) << "SetOptions: " << options.ToString(); 1603 LOG(LS_INFO) << "SetOptions: " << options.ToString();
1607 VideoOptions old_options = options_; 1604 VideoOptions old_options = options_;
1608 options_.SetAll(options); 1605 options_.SetAll(options);
1609 if (options_ == old_options) { 1606 if (options_ == old_options) {
1610 // No new options to set. 1607 // No new options to set.
1611 return true; 1608 return true;
1612 } 1609 }
1613 { 1610 {
1614 rtc::CritScope lock(&capturer_crit_); 1611 rtc::CritScope lock(&capturer_crit_);
1615 options_.cpu_overuse_detection.Get(&signal_cpu_adaptation_); 1612 if (options_.cpu_overuse_detection)
1613 signal_cpu_adaptation_ = *options_.cpu_overuse_detection;
1616 } 1614 }
1617 rtc::DiffServCodePoint dscp = options_.dscp.GetWithDefaultIfUnset(false) 1615 rtc::DiffServCodePoint dscp =
1618 ? rtc::DSCP_AF41 1616 options_.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT;
1619 : rtc::DSCP_DEFAULT;
1620 MediaChannel::SetDscp(dscp); 1617 MediaChannel::SetDscp(dscp);
1621 rtc::CritScope stream_lock(&stream_crit_); 1618 rtc::CritScope stream_lock(&stream_crit_);
1622 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it = 1619 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it =
1623 send_streams_.begin(); 1620 send_streams_.begin();
1624 it != send_streams_.end(); ++it) { 1621 it != send_streams_.end(); ++it) {
1625 it->second->SetOptions(options_); 1622 it->second->SetOptions(options_);
1626 } 1623 }
1627 return true; 1624 return true;
1628 } 1625 }
1629 1626
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 it != send_streams_.end(); ++it) { 1698 it != send_streams_.end(); ++it) {
1702 it->second->Stop(); 1699 it->second->Stop();
1703 } 1700 }
1704 } 1701 }
1705 1702
1706 WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters:: 1703 WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters::
1707 VideoSendStreamParameters( 1704 VideoSendStreamParameters(
1708 const webrtc::VideoSendStream::Config& config, 1705 const webrtc::VideoSendStream::Config& config,
1709 const VideoOptions& options, 1706 const VideoOptions& options,
1710 int max_bitrate_bps, 1707 int max_bitrate_bps,
1711 const Settable<VideoCodecSettings>& codec_settings) 1708 const rtc::Maybe<VideoCodecSettings>& codec_settings)
1712 : config(config), 1709 : config(config),
1713 options(options), 1710 options(options),
1714 max_bitrate_bps(max_bitrate_bps), 1711 max_bitrate_bps(max_bitrate_bps),
1715 codec_settings(codec_settings) { 1712 codec_settings(codec_settings) {}
1716 }
1717 1713
1718 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder( 1714 WebRtcVideoChannel2::WebRtcVideoSendStream::AllocatedEncoder::AllocatedEncoder(
1719 webrtc::VideoEncoder* encoder, 1715 webrtc::VideoEncoder* encoder,
1720 webrtc::VideoCodecType type, 1716 webrtc::VideoCodecType type,
1721 bool external) 1717 bool external)
1722 : encoder(encoder), 1718 : encoder(encoder),
1723 external_encoder(nullptr), 1719 external_encoder(nullptr),
1724 type(type), 1720 type(type),
1725 external(external) { 1721 external(external) {
1726 if (external) { 1722 if (external) {
1727 external_encoder = encoder; 1723 external_encoder = encoder;
1728 this->encoder = 1724 this->encoder =
1729 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder); 1725 new webrtc::VideoEncoderSoftwareFallbackWrapper(type, encoder);
1730 } 1726 }
1731 } 1727 }
1732 1728
1733 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( 1729 WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
1734 webrtc::Call* call, 1730 webrtc::Call* call,
1735 const StreamParams& sp, 1731 const StreamParams& sp,
1736 const webrtc::VideoSendStream::Config& config, 1732 const webrtc::VideoSendStream::Config& config,
1737 WebRtcVideoEncoderFactory* external_encoder_factory, 1733 WebRtcVideoEncoderFactory* external_encoder_factory,
1738 const VideoOptions& options, 1734 const VideoOptions& options,
1739 int max_bitrate_bps, 1735 int max_bitrate_bps,
1740 const Settable<VideoCodecSettings>& codec_settings, 1736 const rtc::Maybe<VideoCodecSettings>& codec_settings,
1741 const std::vector<webrtc::RtpExtension>& rtp_extensions) 1737 const std::vector<webrtc::RtpExtension>& rtp_extensions)
1742 : ssrcs_(sp.ssrcs), 1738 : ssrcs_(sp.ssrcs),
1743 ssrc_groups_(sp.ssrc_groups), 1739 ssrc_groups_(sp.ssrc_groups),
1744 call_(call), 1740 call_(call),
1745 external_encoder_factory_(external_encoder_factory), 1741 external_encoder_factory_(external_encoder_factory),
1746 stream_(NULL), 1742 stream_(NULL),
1747 parameters_(config, options, max_bitrate_bps, codec_settings), 1743 parameters_(config, options, max_bitrate_bps, codec_settings),
1748 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false), 1744 allocated_encoder_(NULL, webrtc::kVideoCodecUnknown, false),
1749 capturer_(NULL), 1745 capturer_(NULL),
1750 sending_(false), 1746 sending_(false),
1751 muted_(false), 1747 muted_(false),
1752 old_adapt_changes_(0), 1748 old_adapt_changes_(0),
1753 first_frame_timestamp_ms_(0), 1749 first_frame_timestamp_ms_(0),
1754 last_frame_timestamp_ms_(0) { 1750 last_frame_timestamp_ms_(0) {
1755 parameters_.config.rtp.max_packet_size = kVideoMtu; 1751 parameters_.config.rtp.max_packet_size = kVideoMtu;
1756 1752
1757 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs); 1753 sp.GetPrimarySsrcs(&parameters_.config.rtp.ssrcs);
1758 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs, 1754 sp.GetFidSsrcs(parameters_.config.rtp.ssrcs,
1759 &parameters_.config.rtp.rtx.ssrcs); 1755 &parameters_.config.rtp.rtx.ssrcs);
1760 parameters_.config.rtp.c_name = sp.cname; 1756 parameters_.config.rtp.c_name = sp.cname;
1761 parameters_.config.rtp.extensions = rtp_extensions; 1757 parameters_.config.rtp.extensions = rtp_extensions;
1762 1758
1763 VideoCodecSettings params; 1759 if (codec_settings) {
1764 if (codec_settings.Get(&params)) { 1760 SetCodec(*codec_settings);
1765 SetCodec(params);
1766 } 1761 }
1767 } 1762 }
1768 1763
1769 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { 1764 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() {
1770 DisconnectCapturer(); 1765 DisconnectCapturer();
1771 if (stream_ != NULL) { 1766 if (stream_ != NULL) {
1772 call_->DestroyVideoSendStream(stream_); 1767 call_->DestroyVideoSendStream(stream_);
1773 } 1768 }
1774 DestroyVideoEncoder(&allocated_encoder_); 1769 DestroyVideoEncoder(&allocated_encoder_);
1775 } 1770 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 rtc::CritScope cs(&lock_); 1928 rtc::CritScope cs(&lock_);
1934 if (capturer_ == NULL) 1929 if (capturer_ == NULL)
1935 return; 1930 return;
1936 1931
1937 capturer_->SetApplyRotation(apply_rotation); 1932 capturer_->SetApplyRotation(apply_rotation);
1938 } 1933 }
1939 1934
1940 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( 1935 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions(
1941 const VideoOptions& options) { 1936 const VideoOptions& options) {
1942 rtc::CritScope cs(&lock_); 1937 rtc::CritScope cs(&lock_);
1943 VideoCodecSettings codec_settings; 1938 if (parameters_.codec_settings) {
1944 if (parameters_.codec_settings.Get(&codec_settings)) {
1945 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" 1939 LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options="
1946 << options.ToString(); 1940 << options.ToString();
1947 SetCodecAndOptions(codec_settings, options); 1941 SetCodecAndOptions(*parameters_.codec_settings, options);
1948 } else { 1942 } else {
1949 parameters_.options = options; 1943 parameters_.options = options;
1950 } 1944 }
1951 } 1945 }
1952 1946
1953 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec( 1947 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodec(
1954 const VideoCodecSettings& codec_settings) { 1948 const VideoCodecSettings& codec_settings) {
1955 rtc::CritScope cs(&lock_); 1949 rtc::CritScope cs(&lock_);
1956 LOG(LS_INFO) << "SetCodecAndOptions because of SetCodec."; 1950 LOG(LS_INFO) << "SetCodecAndOptions because of SetCodec.";
1957 SetCodecAndOptions(codec_settings, parameters_.options); 1951 SetCodecAndOptions(codec_settings, parameters_.options);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 "payload type. Ignoring."; 2036 "payload type. Ignoring.";
2043 parameters_.config.rtp.rtx.ssrcs.clear(); 2037 parameters_.config.rtp.rtx.ssrcs.clear();
2044 } else { 2038 } else {
2045 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type; 2039 parameters_.config.rtp.rtx.payload_type = codec_settings.rtx_payload_type;
2046 } 2040 }
2047 } 2041 }
2048 2042
2049 parameters_.config.rtp.nack.rtp_history_ms = 2043 parameters_.config.rtp.nack.rtp_history_ms =
2050 HasNack(codec_settings.codec) ? kNackHistoryMs : 0; 2044 HasNack(codec_settings.codec) ? kNackHistoryMs : 0;
2051 2045
2052 options.suspend_below_min_bitrate.Get( 2046 RTC_CHECK(options.suspend_below_min_bitrate);
2053 &parameters_.config.suspend_below_min_bitrate); 2047 parameters_.config.suspend_below_min_bitrate =
2048 *options.suspend_below_min_bitrate;
2054 2049
2055 parameters_.codec_settings.Set(codec_settings); 2050 parameters_.codec_settings =
2051 rtc::Maybe<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings);
2056 parameters_.options = options; 2052 parameters_.options = options;
2057 2053
2058 LOG(LS_INFO) 2054 LOG(LS_INFO)
2059 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" 2055 << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options="
2060 << options.ToString(); 2056 << options.ToString();
2061 RecreateWebRtcStream(); 2057 RecreateWebRtcStream();
2062 if (allocated_encoder_.encoder != new_encoder.encoder) { 2058 if (allocated_encoder_.encoder != new_encoder.encoder) {
2063 DestroyVideoEncoder(&allocated_encoder_); 2059 DestroyVideoEncoder(&allocated_encoder_);
2064 allocated_encoder_ = new_encoder; 2060 allocated_encoder_ = new_encoder;
2065 } 2061 }
2066 } 2062 }
2067 2063
2068 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions( 2064 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetRtpExtensions(
2069 const std::vector<webrtc::RtpExtension>& rtp_extensions) { 2065 const std::vector<webrtc::RtpExtension>& rtp_extensions) {
2070 rtc::CritScope cs(&lock_); 2066 rtc::CritScope cs(&lock_);
2071 parameters_.config.rtp.extensions = rtp_extensions; 2067 parameters_.config.rtp.extensions = rtp_extensions;
2072 if (stream_ != nullptr) { 2068 if (stream_ != nullptr) {
2073 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions"; 2069 LOG(LS_INFO) << "RecreateWebRtcStream (send) because of SetRtpExtensions";
2074 RecreateWebRtcStream(); 2070 RecreateWebRtcStream();
2075 } 2071 }
2076 } 2072 }
2077 2073
2078 webrtc::VideoEncoderConfig 2074 webrtc::VideoEncoderConfig
2079 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( 2075 WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
2080 const Dimensions& dimensions, 2076 const Dimensions& dimensions,
2081 const VideoCodec& codec) const { 2077 const VideoCodec& codec) const {
2082 webrtc::VideoEncoderConfig encoder_config; 2078 webrtc::VideoEncoderConfig encoder_config;
2083 if (dimensions.is_screencast) { 2079 if (dimensions.is_screencast) {
2084 int screencast_min_bitrate_kbps; 2080 RTC_CHECK(parameters_.options.screencast_min_bitrate);
2085 parameters_.options.screencast_min_bitrate.Get(
2086 &screencast_min_bitrate_kbps);
2087 encoder_config.min_transmit_bitrate_bps = 2081 encoder_config.min_transmit_bitrate_bps =
2088 screencast_min_bitrate_kbps * 1000; 2082 *parameters_.options.screencast_min_bitrate * 1000;
2089 encoder_config.content_type = 2083 encoder_config.content_type =
2090 webrtc::VideoEncoderConfig::ContentType::kScreen; 2084 webrtc::VideoEncoderConfig::ContentType::kScreen;
2091 } else { 2085 } else {
2092 encoder_config.min_transmit_bitrate_bps = 0; 2086 encoder_config.min_transmit_bitrate_bps = 0;
2093 encoder_config.content_type = 2087 encoder_config.content_type =
2094 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo; 2088 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo;
2095 } 2089 }
2096 2090
2097 // Restrict dimensions according to codec max. 2091 // Restrict dimensions according to codec max.
2098 int width = dimensions.width; 2092 int width = dimensions.width;
(...skipping 15 matching lines...) Expand all
2114 size_t stream_count = parameters_.config.rtp.ssrcs.size(); 2108 size_t stream_count = parameters_.config.rtp.ssrcs.size();
2115 if (IsCodecBlacklistedForSimulcast(codec.name) || dimensions.is_screencast) { 2109 if (IsCodecBlacklistedForSimulcast(codec.name) || dimensions.is_screencast) {
2116 stream_count = 1; 2110 stream_count = 1;
2117 } 2111 }
2118 2112
2119 encoder_config.streams = 2113 encoder_config.streams =
2120 CreateVideoStreams(clamped_codec, parameters_.options, 2114 CreateVideoStreams(clamped_codec, parameters_.options,
2121 parameters_.max_bitrate_bps, stream_count); 2115 parameters_.max_bitrate_bps, stream_count);
2122 2116
2123 // Conference mode screencast uses 2 temporal layers split at 100kbit. 2117 // Conference mode screencast uses 2 temporal layers split at 100kbit.
2124 if (parameters_.options.conference_mode.GetWithDefaultIfUnset(false) && 2118 if (parameters_.options.conference_mode.value_or(false) &&
2125 dimensions.is_screencast && encoder_config.streams.size() == 1) { 2119 dimensions.is_screencast && encoder_config.streams.size() == 1) {
2126 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); 2120 ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault();
2127 2121
2128 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked 2122 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked
2129 // on the VideoCodec struct as target and max bitrates, respectively. 2123 // on the VideoCodec struct as target and max bitrates, respectively.
2130 // See eg. webrtc::VP8EncoderImpl::SetRates(). 2124 // See eg. webrtc::VP8EncoderImpl::SetRates().
2131 encoder_config.streams[0].target_bitrate_bps = 2125 encoder_config.streams[0].target_bitrate_bps =
2132 config.tl0_bitrate_kbps * 1000; 2126 config.tl0_bitrate_kbps * 1000;
2133 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; 2127 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000;
2134 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); 2128 encoder_config.streams[0].temporal_layer_thresholds_bps.clear();
(...skipping 14 matching lines...) Expand all
2149 } 2143 }
2150 LOG(LS_INFO) << "SetDimensions: " << width << "x" << height 2144 LOG(LS_INFO) << "SetDimensions: " << width << "x" << height
2151 << (is_screencast ? " (screencast)" : " (not screencast)"); 2145 << (is_screencast ? " (screencast)" : " (not screencast)");
2152 2146
2153 last_dimensions_.width = width; 2147 last_dimensions_.width = width;
2154 last_dimensions_.height = height; 2148 last_dimensions_.height = height;
2155 last_dimensions_.is_screencast = is_screencast; 2149 last_dimensions_.is_screencast = is_screencast;
2156 2150
2157 RTC_DCHECK(!parameters_.encoder_config.streams.empty()); 2151 RTC_DCHECK(!parameters_.encoder_config.streams.empty());
2158 2152
2159 VideoCodecSettings codec_settings; 2153 RTC_CHECK(parameters_.codec_settings);
2160 parameters_.codec_settings.Get(&codec_settings); 2154 VideoCodecSettings codec_settings = *parameters_.codec_settings;
2161 2155
2162 webrtc::VideoEncoderConfig encoder_config = 2156 webrtc::VideoEncoderConfig encoder_config =
2163 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); 2157 CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec);
2164 2158
2165 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( 2159 encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings(
2166 codec_settings.codec, parameters_.options, is_screencast); 2160 codec_settings.codec, parameters_.options, is_screencast);
2167 2161
2168 bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config); 2162 bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config);
2169 2163
2170 encoder_config.encoder_specific_settings = NULL; 2164 encoder_config.encoder_specific_settings = NULL;
(...skipping 24 matching lines...) Expand all
2195 2189
2196 VideoSenderInfo 2190 VideoSenderInfo
2197 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() { 2191 WebRtcVideoChannel2::WebRtcVideoSendStream::GetVideoSenderInfo() {
2198 VideoSenderInfo info; 2192 VideoSenderInfo info;
2199 webrtc::VideoSendStream::Stats stats; 2193 webrtc::VideoSendStream::Stats stats;
2200 { 2194 {
2201 rtc::CritScope cs(&lock_); 2195 rtc::CritScope cs(&lock_);
2202 for (uint32_t ssrc : parameters_.config.rtp.ssrcs) 2196 for (uint32_t ssrc : parameters_.config.rtp.ssrcs)
2203 info.add_ssrc(ssrc); 2197 info.add_ssrc(ssrc);
2204 2198
2205 VideoCodecSettings codec_settings; 2199 if (parameters_.codec_settings)
2206 if (parameters_.codec_settings.Get(&codec_settings)) 2200 info.codec_name = parameters_.codec_settings->codec.name;
2207 info.codec_name = codec_settings.codec.name;
2208 for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) { 2201 for (size_t i = 0; i < parameters_.encoder_config.streams.size(); ++i) {
2209 if (i == parameters_.encoder_config.streams.size() - 1) { 2202 if (i == parameters_.encoder_config.streams.size() - 1) {
2210 info.preferred_bitrate += 2203 info.preferred_bitrate +=
2211 parameters_.encoder_config.streams[i].max_bitrate_bps; 2204 parameters_.encoder_config.streams[i].max_bitrate_bps;
2212 } else { 2205 } else {
2213 info.preferred_bitrate += 2206 info.preferred_bitrate +=
2214 parameters_.encoder_config.streams[i].target_bitrate_bps; 2207 parameters_.encoder_config.streams[i].target_bitrate_bps;
2215 } 2208 }
2216 } 2209 }
2217 2210
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 int width = last_dimensions_.width; 2302 int width = last_dimensions_.width;
2310 last_dimensions_.width = 0; 2303 last_dimensions_.width = 0;
2311 SetDimensions(width, last_dimensions_.height, last_dimensions_.is_screencast); 2304 SetDimensions(width, last_dimensions_.height, last_dimensions_.is_screencast);
2312 } 2305 }
2313 2306
2314 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { 2307 void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() {
2315 if (stream_ != NULL) { 2308 if (stream_ != NULL) {
2316 call_->DestroyVideoSendStream(stream_); 2309 call_->DestroyVideoSendStream(stream_);
2317 } 2310 }
2318 2311
2319 VideoCodecSettings codec_settings; 2312 RTC_CHECK(parameters_.codec_settings);
2320 parameters_.codec_settings.Get(&codec_settings);
2321 parameters_.encoder_config.encoder_specific_settings = 2313 parameters_.encoder_config.encoder_specific_settings =
2322 ConfigureVideoEncoderSettings( 2314 ConfigureVideoEncoderSettings(
2323 codec_settings.codec, parameters_.options, 2315 parameters_.codec_settings->codec, parameters_.options,
2324 parameters_.encoder_config.content_type == 2316 parameters_.encoder_config.content_type ==
2325 webrtc::VideoEncoderConfig::ContentType::kScreen); 2317 webrtc::VideoEncoderConfig::ContentType::kScreen);
2326 2318
2327 webrtc::VideoSendStream::Config config = parameters_.config; 2319 webrtc::VideoSendStream::Config config = parameters_.config;
2328 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { 2320 if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) {
2329 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX " 2321 LOG(LS_WARNING) << "RTX SSRCs configured but there's no configured RTX "
2330 "payload type the set codec. Ignoring RTX."; 2322 "payload type the set codec. Ignoring RTX.";
2331 config.rtp.rtx.ssrcs.clear(); 2323 config.rtp.rtx.ssrcs.clear();
2332 } 2324 }
2333 stream_ = call_->CreateVideoSendStream(config, parameters_.encoder_config); 2325 stream_ = call_->CreateVideoSendStream(config, parameters_.encoder_config);
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
2751 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2743 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2752 } 2744 }
2753 } 2745 }
2754 2746
2755 return video_codecs; 2747 return video_codecs;
2756 } 2748 }
2757 2749
2758 } // namespace cricket 2750 } // namespace cricket
2759 2751
2760 #endif // HAVE_WEBRTC_VIDEO 2752 #endif // HAVE_WEBRTC_VIDEO
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.h ('k') | talk/media/webrtc/webrtcvideoengine2_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698