Chromium Code Reviews| Index: talk/media/webrtc/webrtcvideoengine2.cc |
| diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc |
| index e6bd294bc74e70f392cdd9f8a2486f8bf352a1fb..2f88457326c928f8c733ea833a0f8927dddec301 100644 |
| --- a/talk/media/webrtc/webrtcvideoengine2.cc |
| +++ b/talk/media/webrtc/webrtcvideoengine2.cc |
| @@ -622,21 +622,19 @@ WebRtcVideoChannel2::WebRtcVideoChannel2( |
| external_encoder_factory_(external_encoder_factory), |
| external_decoder_factory_(external_decoder_factory) { |
| RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| - SetDefaultOptions(); |
| - options_.SetAll(options); |
| - if (options_.cpu_overuse_detection) |
| - signal_cpu_adaptation_ = *options_.cpu_overuse_detection; |
| + |
| + signal_cpu_adaptation_ = options.cpu_overuse_detection.value_or(true); |
| rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
| sending_ = false; |
| default_send_ssrc_ = 0; |
| SetRecvCodecs(recv_codecs); |
| } |
| -void WebRtcVideoChannel2::SetDefaultOptions() { |
| - options_.cpu_overuse_detection = rtc::Optional<bool>(true); |
| - options_.dscp = rtc::Optional<bool>(false); |
| - options_.suspend_below_min_bitrate = rtc::Optional<bool>(false); |
| - options_.screencast_min_bitrate = rtc::Optional<int>(0); |
| +void WebRtcVideoChannel2::SetDefaultOptions(VideoOptions *options) { |
| + options->cpu_overuse_detection = rtc::Optional<bool>(true); |
| + options->dscp = rtc::Optional<bool>(false); |
| + options->suspend_below_min_bitrate = rtc::Optional<bool>(false); |
| + options->screencast_min_bitrate = rtc::Optional<int>(0); |
| } |
| WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
| @@ -717,10 +715,10 @@ bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) { |
| // instead of 4 times. |
| if (!SetSendCodecs(params.codecs) || |
| !SetSendRtpHeaderExtensions(params.extensions) || |
| - !SetMaxSendBandwidth(params.max_bandwidth_bps) || |
| - !SetOptions(params.options)) { |
| + !SetMaxSendBandwidth(params.max_bandwidth_bps)) { |
| return false; |
| } |
| + SetSharedOptions(params.options); |
| if (send_params_.rtcp.reduced_size != params.rtcp.reduced_size) { |
| rtc::CritScope stream_lock(&stream_crit_); |
| for (auto& kv : send_streams_) { |
| @@ -923,7 +921,7 @@ bool WebRtcVideoChannel2::SetVideoSend(uint32_t ssrc, bool enable, |
| return false; |
| } |
| if (enable && options) { |
| - return SetOptions(*options); |
| + return SetOptions(ssrc, *options); |
| } else { |
| return true; |
| } |
| @@ -968,8 +966,12 @@ bool WebRtcVideoChannel2::AddSendStream(const StreamParams& sp) { |
| webrtc::VideoSendStream::Config config(this); |
| config.overuse_callback = this; |
| + // Initial options |
| + VideoOptions options; |
| + SetDefaultOptions(&options); |
| + |
| WebRtcVideoSendStream* stream = new WebRtcVideoSendStream( |
| - call_, sp, config, external_encoder_factory_, options_, |
| + call_, sp, config, external_encoder_factory_, options, |
| bitrate_config_.max_bitrate_bps, send_codec_, send_rtp_extensions_, |
| send_params_); |
| @@ -1099,7 +1101,12 @@ bool WebRtcVideoChannel2::AddRecvStream(const StreamParams& sp, |
| receive_streams_[ssrc] = new WebRtcVideoReceiveStream( |
| call_, sp, config, external_decoder_factory_, default_stream, |
| - recv_codecs_, options_.disable_prerenderer_smoothing.value_or(false)); |
| + recv_codecs_, |
| + // TODO(nisse): Used to pass |
|
pbos-webrtc
2016/01/28 14:55:44
This should be const on construction, this needs t
|
| + // options_.disable_prerenderer_smoothing.value_or(false), |
| + // unclear if it needs to be configurable here, but there's no |
| + // other method to change it. |
| + false); |
| return true; |
| } |
| @@ -1466,29 +1473,29 @@ bool WebRtcVideoChannel2::SetMaxSendBandwidth(int max_bitrate_bps) { |
| return true; |
| } |
| -bool WebRtcVideoChannel2::SetOptions(const VideoOptions& options) { |
| - TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); |
| - LOG(LS_INFO) << "SetOptions: " << options.ToString(); |
| - VideoOptions old_options = options_; |
| - options_.SetAll(options); |
| - if (options_ == old_options) { |
| - // No new options to set. |
| - return true; |
| - } |
| +void WebRtcVideoChannel2::SetSharedOptions(const VideoOptions& options) { |
| { |
| rtc::CritScope lock(&capturer_crit_); |
| - if (options_.cpu_overuse_detection) |
| - signal_cpu_adaptation_ = *options_.cpu_overuse_detection; |
| + if (options.cpu_overuse_detection) |
| + signal_cpu_adaptation_ = *options.cpu_overuse_detection; |
| } |
| rtc::DiffServCodePoint dscp = |
| - options_.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; |
| + options.dscp.value_or(false) ? rtc::DSCP_AF41 : rtc::DSCP_DEFAULT; |
| MediaChannel::SetDscp(dscp); |
| +} |
| + |
| +bool WebRtcVideoChannel2::SetOptions(uint32_t ssrc, |
| + const VideoOptions& options) { |
| + TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::SetOptions"); |
| + LOG(LS_INFO) << "SetOptions: ssrc " << ssrc << ": " << options.ToString(); |
| + SetSharedOptions(options); |
| + |
| rtc::CritScope stream_lock(&stream_crit_); |
| - for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it = |
| - send_streams_.begin(); |
| - it != send_streams_.end(); ++it) { |
| - it->second->SetOptions(options_); |
| + if (send_streams_.find(ssrc) == send_streams_.end()) { |
| + return false; |
| } |
| + send_streams_[ssrc]->SetOptions(options); |
| + |
| return true; |
| } |
| @@ -1808,6 +1815,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetApplyRotation( |
| void WebRtcVideoChannel2::WebRtcVideoSendStream::SetOptions( |
| const VideoOptions& options) { |
| + |
| rtc::CritScope cs(&lock_); |
| if (parameters_.codec_settings) { |
| LOG(LS_INFO) << "SetCodecAndOptions because of SetOptions; options=" |