| Index: webrtc/media/engine/webrtcvideoengine2.cc
|
| diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc
|
| index e34056d905257371b6f9c0db015f38a3bdcf3a85..1dbfe8701cd8bf66ad60bf45f51a94a2ef3ac004 100644
|
| --- a/webrtc/media/engine/webrtcvideoengine2.cc
|
| +++ b/webrtc/media/engine/webrtcvideoengine2.cc
|
| @@ -78,9 +78,9 @@ webrtc::Call::Config::BitrateConfig GetBitrateConfigForCodec(
|
| }
|
| if (codec.GetParam(kCodecParamMaxBitrate, &bitrate_kbps) &&
|
| bitrate_kbps > 0) {
|
| - config.max_bitrate_bps = bitrate_kbps * 1000;
|
| + config.max_bitrate_bps = rtc::Optional<int>(bitrate_kbps * 1000);
|
| } else {
|
| - config.max_bitrate_bps = -1;
|
| + config.max_bitrate_bps = rtc::Optional<int>();
|
| }
|
| return config;
|
| }
|
| @@ -362,7 +362,7 @@ std::vector<webrtc::VideoStream>
|
| WebRtcVideoChannel2::WebRtcVideoSendStream::CreateSimulcastVideoStreams(
|
| const VideoCodec& codec,
|
| const VideoOptions& options,
|
| - int max_bitrate_bps,
|
| + rtc::Optional<int> max_bitrate_bps,
|
| size_t num_streams) {
|
| int max_qp = kDefaultQpMax;
|
| codec.GetParam(kCodecParamMaxQuantization, &max_qp);
|
| @@ -376,11 +376,11 @@ std::vector<webrtc::VideoStream>
|
| WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoStreams(
|
| const VideoCodec& codec,
|
| const VideoOptions& options,
|
| - int max_bitrate_bps,
|
| + rtc::Optional<int> max_bitrate_bps,
|
| size_t num_streams) {
|
| int codec_max_bitrate_kbps;
|
| if (codec.GetParam(kCodecParamMaxBitrate, &codec_max_bitrate_kbps)) {
|
| - max_bitrate_bps = codec_max_bitrate_kbps * 1000;
|
| + max_bitrate_bps = rtc::Optional<int>(codec_max_bitrate_kbps * 1000);
|
| }
|
| if (num_streams != 1) {
|
| return CreateSimulcastVideoStreams(codec, options, max_bitrate_bps,
|
| @@ -388,9 +388,9 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoStreams(
|
| }
|
|
|
| // For unset max bitrates set default bitrate for non-simulcast.
|
| - if (max_bitrate_bps <= 0) {
|
| - max_bitrate_bps =
|
| - GetMaxDefaultVideoBitrateKbps(codec.width, codec.height) * 1000;
|
| + if (!max_bitrate_bps) {
|
| + max_bitrate_bps = rtc::Optional<int>(
|
| + GetMaxDefaultVideoBitrateKbps(codec.width, codec.height) * 1000);
|
| }
|
|
|
| webrtc::VideoStream stream;
|
| @@ -400,7 +400,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoStreams(
|
| codec.framerate != 0 ? codec.framerate : kDefaultVideoMaxFramerate;
|
|
|
| stream.min_bitrate_bps = kMinVideoBitrate * 1000;
|
| - stream.target_bitrate_bps = stream.max_bitrate_bps = max_bitrate_bps;
|
| + stream.target_bitrate_bps = stream.max_bitrate_bps = *max_bitrate_bps;
|
|
|
| int max_qp = kDefaultQpMax;
|
| codec.GetParam(kCodecParamMaxQuantization, &max_qp);
|
| @@ -726,11 +726,9 @@ bool WebRtcVideoChannel2::GetChangedSendParameters(
|
| }
|
|
|
| // Handle max bitrate.
|
| - if (params.max_bandwidth_bps != bitrate_config_.max_bitrate_bps &&
|
| - params.max_bandwidth_bps >= 0) {
|
| - // 0 uncaps max bitrate (-1).
|
| - changed_params->max_bandwidth_bps = rtc::Optional<int>(
|
| - params.max_bandwidth_bps == 0 ? -1 : params.max_bandwidth_bps);
|
| + if (params.max_bitrate_bps != bitrate_config_.max_bitrate_bps) {
|
| + changed_params->max_bandwidth_bps =
|
| + rtc::Optional<rtc::Optional<int>>(params.max_bitrate_bps);
|
| }
|
|
|
| // Handle conference mode.
|
| @@ -783,12 +781,11 @@ bool WebRtcVideoChannel2::SetSendParameters(const VideoSendParameters& params) {
|
| // WebRtcVideoChannel2 (in which case we're good), or per sender (SSRC), in
|
| // which case this should not set a Call::BitrateConfig but rather
|
| // reconfigure all senders.
|
| - int max_bitrate_bps = *changed_params.max_bandwidth_bps;
|
| bitrate_config_.start_bitrate_bps = -1;
|
| - bitrate_config_.max_bitrate_bps = max_bitrate_bps;
|
| - if (max_bitrate_bps > 0 &&
|
| - bitrate_config_.min_bitrate_bps > max_bitrate_bps) {
|
| - bitrate_config_.min_bitrate_bps = max_bitrate_bps;
|
| + bitrate_config_.max_bitrate_bps = *changed_params.max_bandwidth_bps;
|
| + if (bitrate_config_.max_bitrate_bps &&
|
| + (bitrate_config_.min_bitrate_bps > *bitrate_config_.max_bitrate_bps)) {
|
| + bitrate_config_.min_bitrate_bps = *bitrate_config_.max_bitrate_bps;
|
| }
|
| bitrate_config_changed = true;
|
| }
|
| @@ -1457,7 +1454,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::VideoSendStreamParameters::
|
| VideoSendStreamParameters(
|
| const webrtc::VideoSendStream::Config& config,
|
| const VideoOptions& options,
|
| - int max_bitrate_bps,
|
| + rtc::Optional<int> max_bitrate_bps,
|
| const rtc::Optional<VideoCodecSettings>& codec_settings)
|
| : config(config),
|
| options(options),
|
| @@ -1486,7 +1483,7 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream(
|
| const VideoOptions& options,
|
| WebRtcVideoEncoderFactory* external_encoder_factory,
|
| bool enable_cpu_overuse_detection,
|
| - int max_bitrate_bps,
|
| + rtc::Optional<int> max_bitrate_bps,
|
| const rtc::Optional<VideoCodecSettings>& codec_settings,
|
| const std::vector<webrtc::RtpExtension>& rtp_extensions,
|
| // TODO(deadbeef): Don't duplicate information between send_params,
|
| @@ -1845,6 +1842,11 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::ValidateRtpParameters(
|
| << "Attempted to set RtpParameters without exactly one encoding";
|
| return false;
|
| }
|
| + if (rtp_parameters.encodings[0].max_bitrate_bps &&
|
| + (*rtp_parameters.encodings[0].max_bitrate_bps <= 0)) {
|
| + LOG(LS_ERROR) << "Attempted to set a negative bitrate limit";
|
| + return false;
|
| + }
|
| return true;
|
| }
|
|
|
| @@ -1887,8 +1889,8 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig(
|
| stream_count = 1;
|
| }
|
|
|
| - int stream_max_bitrate =
|
| - MinPositive(rtp_parameters_.encodings[0].max_bitrate_bps,
|
| + rtc::Optional<int> stream_max_bitrate =
|
| + OptionalMin(rtp_parameters_.encodings[0].max_bitrate_bps,
|
| parameters_.max_bitrate_bps);
|
| encoder_config.streams = CreateVideoStreams(
|
| clamped_codec, parameters_.options, stream_max_bitrate, stream_count);
|
|
|