Chromium Code Reviews| Index: webrtc/media/engine/webrtcvideoengine2.cc | 
| diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc | 
| index c6bdafee5a336666a4fd46f5aab78c0590525105..a3a32fb3504a963f0649ea719d82690dece64d24 100644 | 
| --- a/webrtc/media/engine/webrtcvideoengine2.cc | 
| +++ b/webrtc/media/engine/webrtcvideoengine2.cc | 
| @@ -410,9 +410,8 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoStreams( | 
| } | 
| void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( | 
| - const VideoCodec& codec, | 
| - const VideoOptions& options, | 
| - bool is_screencast) { | 
| + const VideoCodec& codec) { | 
| + bool is_screencast = parameters_.options.is_screencast.value_or(false); | 
| // No automatic resizing when using simulcast or screencast. | 
| bool automatic_resize = | 
| !is_screencast && parameters_.config.rtp.ssrcs.size() == 1; | 
| @@ -423,8 +422,8 @@ void* WebRtcVideoChannel2::WebRtcVideoSendStream::ConfigureVideoEncoderSettings( | 
| denoising = false; | 
| } else { | 
| // Use codec default if video_noise_reduction is unset. | 
| - codec_default_denoising = !options.video_noise_reduction; | 
| - denoising = options.video_noise_reduction.value_or(false); | 
| + codec_default_denoising = !parameters_.options.video_noise_reduction; | 
| + denoising = parameters_.options.video_noise_reduction.value_or(false); | 
| } | 
| if (CodecNamesEq(codec.name, kH264CodecName)) { | 
| @@ -1528,7 +1527,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( | 
| : webrtc::RtcpMode::kCompound; | 
| if (codec_settings) { | 
| - SetCodecAndOptions(*codec_settings, parameters_.options); | 
| + SetCodecAndOptions(*codec_settings); | 
| } | 
| } | 
| @@ -1588,8 +1587,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( | 
| last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; | 
| video_frame.set_render_time_ms(last_frame_timestamp_ms_); | 
| // Reconfigure codec if necessary. | 
| - SetDimensions(video_frame.width(), video_frame.height(), | 
| - capturer_->IsScreencast()); | 
| + SetDimensions(video_frame.width(), video_frame.height()); | 
| last_rotation_ = video_frame.rotation(); | 
| stream_->Input()->IncomingCapturedFrame(video_frame); | 
| @@ -1668,12 +1666,12 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::GetSsrcs() const { | 
| void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( | 
| const VideoOptions& options) { | 
| rtc::CritScope cs(&lock_); | 
| + // TODO(nisse): Use .SetAll method? | 
| + parameters_.options = options; | 
| 
 
pthatcher1
2016/02/20 08:33:00
If you don't, then the options that come from SetV
 
nisse-webrtc
2016/02/22 07:52:34
I'll change to SetAll. I think splitting VideoOpti
 
nisse-webrtc
2016/02/23 13:13:59
Done.
 
 | 
| if (parameters_.codec_settings) { | 
| LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" | 
| << options.ToString(); | 
| - SetCodecAndOptions(*parameters_.codec_settings, options); | 
| - } else { | 
| - parameters_.options = options; | 
| + SetCodecAndOptions(*parameters_.codec_settings); | 
| } | 
| } | 
| @@ -1732,8 +1730,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::DestroyVideoEncoder( | 
| } | 
| void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodecAndOptions( | 
| - const VideoCodecSettings& codec_settings, | 
| - const VideoOptions& options) { | 
| + const VideoCodecSettings& codec_settings) { | 
| parameters_.encoder_config = | 
| CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 
| RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 
| @@ -1765,15 +1762,14 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetCodecAndOptions( | 
| HasNack(codec_settings.codec) ? kNackHistoryMs : 0; | 
| parameters_.config.suspend_below_min_bitrate = | 
| - options.suspend_below_min_bitrate.value_or(false); | 
| + parameters_.options.suspend_below_min_bitrate.value_or(false); | 
| parameters_.codec_settings = | 
| rtc::Optional<WebRtcVideoChannel2::VideoCodecSettings>(codec_settings); | 
| - parameters_.options = options; | 
| LOG(LS_INFO) | 
| << "RecreateWebRtcStream (send) because of SetCodecAndOptions; options=" | 
| - << options.ToString(); | 
| + << parameters_.options.ToString(); | 
| RecreateWebRtcStream(); | 
| if (allocated_encoder_.encoder != new_encoder.encoder) { | 
| DestroyVideoEncoder(&allocated_encoder_); | 
| @@ -1810,21 +1806,20 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSendParameters( | 
| parameters_.conference_mode = *params.conference_mode; | 
| } | 
| // Set codecs and options. | 
| + if (params.options) | 
| + parameters_.options = *params.options; | 
| if (params.codec) { | 
| - SetCodecAndOptions(*params.codec, | 
| - params.options ? *params.options : parameters_.options); | 
| + SetCodecAndOptions(*params.codec); | 
| return; | 
| } else if (params.options) { | 
| // Reconfigure if codecs are already set. | 
| if (parameters_.codec_settings) { | 
| - SetCodecAndOptions(*parameters_.codec_settings, *params.options); | 
| + SetCodecAndOptions(*parameters_.codec_settings); | 
| return; | 
| - } else { | 
| - parameters_.options = *params.options; | 
| } | 
| } | 
| else if (params.conference_mode && parameters_.codec_settings) { | 
| - SetCodecAndOptions(*parameters_.codec_settings, parameters_.options); | 
| + SetCodecAndOptions(*parameters_.codec_settings); | 
| return; | 
| } | 
| if (recreate_stream) { | 
| @@ -1838,7 +1833,8 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 
| const Dimensions& dimensions, | 
| const VideoCodec& codec) const { | 
| webrtc::VideoEncoderConfig encoder_config; | 
| - if (dimensions.is_screencast) { | 
| + bool is_screencast = parameters_.options.is_screencast.value_or(false); | 
| + if (is_screencast) { | 
| encoder_config.min_transmit_bitrate_bps = | 
| 1000 * parameters_.options.screencast_min_bitrate_kbps.value_or(0); | 
| encoder_config.content_type = | 
| @@ -1852,7 +1848,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 
| // Restrict dimensions according to codec max. | 
| int width = dimensions.width; | 
| int height = dimensions.height; | 
| - if (!dimensions.is_screencast) { | 
| + if (!is_screencast) { | 
| if (codec.width < width) | 
| width = codec.width; | 
| if (codec.height < height) | 
| @@ -1867,7 +1863,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 
| // number of negotiated ssrcs. But if the codec is blacklisted for simulcast | 
| // or a screencast, only configure a single stream. | 
| size_t stream_count = parameters_.config.rtp.ssrcs.size(); | 
| - if (IsCodecBlacklistedForSimulcast(codec.name) || dimensions.is_screencast) { | 
| + if (IsCodecBlacklistedForSimulcast(codec.name) || is_screencast) { | 
| stream_count = 1; | 
| } | 
| @@ -1876,7 +1872,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 
| parameters_.max_bitrate_bps, stream_count); | 
| // Conference mode screencast uses 2 temporal layers split at 100kbit. | 
| - if (parameters_.conference_mode && dimensions.is_screencast && | 
| + if (parameters_.conference_mode && is_screencast && | 
| encoder_config.streams.size() == 1) { | 
| ScreenshareLayerConfig config = ScreenshareLayerConfig::GetDefault(); | 
| @@ -1895,20 +1891,16 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig( | 
| void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( | 
| int width, | 
| - int height, | 
| - bool is_screencast) { | 
| + int height) { | 
| if (last_dimensions_.width == width && last_dimensions_.height == height && | 
| - last_dimensions_.is_screencast == is_screencast && | 
| !pending_encoder_reconfiguration_) { | 
| // Configured using the same parameters, do not reconfigure. | 
| return; | 
| } | 
| - LOG(LS_INFO) << "SetDimensions: " << width << "x" << height | 
| - << (is_screencast ? " (screencast)" : " (not screencast)"); | 
| + LOG(LS_INFO) << "SetDimensions: " << width << "x" << height; | 
| last_dimensions_.width = width; | 
| last_dimensions_.height = height; | 
| - last_dimensions_.is_screencast = is_screencast; | 
| RTC_DCHECK(!parameters_.encoder_config.streams.empty()); | 
| @@ -1919,7 +1911,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( | 
| CreateVideoEncoderConfig(last_dimensions_, codec_settings.codec); | 
| encoder_config.encoder_specific_settings = ConfigureVideoEncoderSettings( | 
| - codec_settings.codec, parameters_.options, is_screencast); | 
| + codec_settings.codec); | 
| bool stream_reconfigured = stream_->ReconfigureVideoEncoder(encoder_config); | 
| @@ -2067,11 +2059,12 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::RecreateWebRtcStream() { | 
| } | 
| RTC_CHECK(parameters_.codec_settings); | 
| + RTC_DCHECK_EQ((parameters_.encoder_config.content_type == | 
| + webrtc::VideoEncoderConfig::ContentType::kScreen), | 
| + parameters_.options.is_screencast.value_or(false)) | 
| + << "encoder content type inconsistent with screencast option"; | 
| parameters_.encoder_config.encoder_specific_settings = | 
| - ConfigureVideoEncoderSettings( | 
| - parameters_.codec_settings->codec, parameters_.options, | 
| - parameters_.encoder_config.content_type == | 
| - webrtc::VideoEncoderConfig::ContentType::kScreen); | 
| + ConfigureVideoEncoderSettings(parameters_.codec_settings->codec); | 
| webrtc::VideoSendStream::Config config = parameters_.config; | 
| if (!config.rtp.rtx.ssrcs.empty() && config.rtp.rtx.payload_type == -1) { |