From 1c7d48d431e098ba42fa6bd9f1cfe69a703edee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85sa=20Persson?= Date: Tue, 8 Sep 2015 09:21:43 +0200 Subject: [PATCH] Let max default bitrate depend on resolution when configuring one video stream (was previously always 2Mbps). Is now set to: <= 320x240: 600kbps <= 640x480: 1.7Mbps <= 960x540: 2Mbps > 960x540: 2.5Mbps For QVGA and VGA, the qp was around 10 at the selected thresholds when running some tests. The change in qp declined above the selected bitrates. BUG= R=mflodman@webrtc.org, pbos@webrtc.org, stefan@webrtc.org Review URL: https://codereview.webrtc.org/1297373003 . Cr-Commit-Position: refs/heads/master@{#9878} --- talk/media/webrtc/webrtcvideoengine2.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc index 5957329ae3..bc303cd98a 100644 --- a/talk/media/webrtc/webrtcvideoengine2.cc +++ b/talk/media/webrtc/webrtcvideoengine2.cc @@ -309,13 +309,25 @@ bool IsCodecBlacklistedForSimulcast(const std::string& codec_name) { return CodecNamesEq(codec_name, kH264CodecName); } +// The selected thresholds for QVGA and VGA corresponded to a QP around 10. +// The change in QP declined above the selected bitrates. +static int GetMaxDefaultVideoBitrateKbps(int width, int height) { + if (width * height <= 320 * 240) { + return 600; + } else if (width * height <= 640 * 480) { + return 1700; + } else if (width * height <= 960 * 540) { + return 2000; + } else { + return 2500; + } +} } // namespace // Constants defined in talk/media/webrtc/constants.h // TODO(pbos): Move these to a separate constants.cc file. const int kMinVideoBitrate = 30; const int kStartVideoBitrate = 300; -const int kMaxVideoBitrate = 2000; const int kVideoMtu = 1200; const int kVideoRtpBufferSize = 65536; @@ -449,8 +461,10 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoStreams( } // For unset max bitrates set default bitrate for non-simulcast. - if (max_bitrate_bps <= 0) - max_bitrate_bps = kMaxVideoBitrate * 1000; + if (max_bitrate_bps <= 0) { + max_bitrate_bps = + GetMaxDefaultVideoBitrateKbps(codec.width, codec.height) * 1000; + } webrtc::VideoStream stream; stream.width = codec.width;