From cb9954a1efe7dfb38d0f1fee4643e32b8438e787 Mon Sep 17 00:00:00 2001 From: Christoffer Jansson Date: Thu, 7 Sep 2017 15:58:56 +0200 Subject: [PATCH] fix the video send bitrate params when not specifiying codecs --- package-lock.json | 28 ++++++++++++++-------------- src/web_app/js/sdputils.js | 12 ++++++++++-- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9ab7572ac..656e0f662 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2664,14 +2664,6 @@ } } }, - "string_decoder": { - "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", - "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", - "dev": true, - "requires": { - "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz" - } - }, "string-width": { "version": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", @@ -2682,6 +2674,14 @@ "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz" } }, + "string_decoder": { + "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", + "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", + "dev": true, + "requires": { + "safe-buffer": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz" + } + }, "stringstream": { "version": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", @@ -3183,7 +3183,7 @@ "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "dev": true, "requires": { "fs.realpath": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -4207,11 +4207,6 @@ "integrity": "sha1-kdX1Ew0c75bc+n9yaUUYh0HQnuQ=", "dev": true }, - "string_decoder": { - "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "string-width": { "version": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", @@ -4222,6 +4217,11 @@ "strip-ansi": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz" } }, + "string_decoder": { + "version": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, "strip-ansi": { "version": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", diff --git a/src/web_app/js/sdputils.js b/src/web_app/js/sdputils.js index a3bbb8596..b02e5009b 100644 --- a/src/web_app/js/sdputils.js +++ b/src/web_app/js/sdputils.js @@ -195,8 +195,15 @@ function maybeSetVideoSendInitialBitRate(sdp, params) { trace('Failed to find video m-line'); return sdp; } - - var codec = params.videoRecvCodec; + // Figure out the first codec payload type on the m=video SDP line. + var videoMLine = sdpLines[mLineIndex] + var pattern = new RegExp('m=video\\s\\d+\\s[A-Z\/]+\\s') + var sendPayloadType = videoMLine.split(pattern)[1].split(' ')[0] + var fmtpLine = sdpLines[findLine(sdpLines, 'a=rtpmap', sendPayloadType)] + var codecName = fmtpLine.split('a=rtpmap:' + sendPayloadType)[1].split('/')[0] + + // Use codec from params if specified via URL param, otherwise use from SDP. + var codec = params.videoSendCodec || codecName; sdp = setCodecParam(sdp, codec, 'x-google-min-bitrate', params.videoSendInitialBitrate.toString()); sdp = setCodecParam(sdp, codec, 'x-google-max-bitrate', @@ -205,6 +212,7 @@ function maybeSetVideoSendInitialBitRate(sdp, params) { return sdp; } + function removePayloadTypeFromMline(mLine, payloadType) { mLine = mLine.split(' '); for (var i = 0; i < mLine.length; ++i) {