From a9b5d65ca747aa59f1ec9993703e56d9d466db87 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 12 Aug 2018 11:52:18 +0800 Subject: [PATCH] For #1202, Support auth_key param for srs player --- trunk/research/players/js/srs.page.js | 25 ++++++++++++++++++++++--- trunk/research/players/srs_player.html | 5 +++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/trunk/research/players/js/srs.page.js b/trunk/research/players/js/srs.page.js index 3e458c8d2..6a3132741 100755 --- a/trunk/research/players/js/srs.page.js +++ b/trunk/research/players/js/srs.page.js @@ -44,6 +44,27 @@ function update_nav() { $("#nav_vlc").attr("href", "vlc.html" + window.location.search); } +// Special extra params, such as auth_key. +function user_extra_params(query, params) { + var queries = params || []; + var server = (query.server == undefined)? window.location.hostname:query.server; + var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost; + + for (var key in query.user_query) { + if (key == 'app' || key == 'autostart' || key == 'dir' + || key == 'filename' || key == 'host' || key == 'hostname' + || key == 'http_port' || key == 'pathname' || key == 'port' + || key == 'server' || key == 'stream' || key == 'buffer' + || key == 'schema' || key == 'vhost' + ) { + continue; + } + queries.push(key + '=' + query[key]); + } + + return queries; +} + /** @param server the ip of server. default to window.location.hostname @param vhost the vhost of rtmp. default to window.location.hostname @@ -65,9 +86,7 @@ function build_default_rtmp_url() { if (server != vhost && vhost != "__defaultVhost__") { queries.push("vhost=" + vhost); } - if (query.shp_identify) { - queries.push("shp_identify=" + query.shp_identify); - } + queries = user_extra_params(query, queries); var uri = schema + "://" + server + ":" + port + "/" + app + "/" + stream + "?" + queries.join('&'); while (uri.indexOf("?") == uri.length - 1) { diff --git a/trunk/research/players/srs_player.html b/trunk/research/players/srs_player.html index 3598b9c6a..757fc0d7d 100755 --- a/trunk/research/players/srs_player.html +++ b/trunk/research/players/srs_player.html @@ -643,6 +643,11 @@ if (query.buffer) { url += "&buffer=" + query.buffer; } + + var queries = user_extra_params(query); + if (queries && queries.length) { + url += '&' + queries.join('&'); + } $("#player_url").text($("#txt_url").val()).attr("href", url); $("#link_server").text(rtmp.server);