mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refactor url for rtc player
This commit is contained in:
parent
4c63319b5d
commit
57c23d93c1
3 changed files with 21 additions and 6 deletions
|
@ -58,7 +58,7 @@ function user_extra_params(query, params) {
|
|||
|| key === 'filename' || key === 'host' || key === 'hostname'
|
||||
|| key === 'http_port' || key === 'pathname' || key === 'port'
|
||||
|| key === 'server' || key === 'stream' || key === 'buffer'
|
||||
|| key === 'schema' || key === 'vhost'
|
||||
|| key === 'schema' || key === 'vhost' || key === 'api'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
@ -211,6 +211,7 @@ function build_default_rtc_url(query) {
|
|||
var vhost = (!query.vhost)? window.location.hostname:query.vhost;
|
||||
var app = (!query.app)? "live":query.app;
|
||||
var stream = (!query.stream)? "livestream":query.stream;
|
||||
var api = query.api? ':'+query.api : '';
|
||||
|
||||
// Note that ossrs.net provides only web service,
|
||||
// that is migrating to r.ossrs.net
|
||||
|
@ -227,7 +228,7 @@ function build_default_rtc_url(query) {
|
|||
}
|
||||
queries = user_extra_params(query, queries);
|
||||
|
||||
var uri = "webrtc://" + server + "/" + app + "/" + stream + "?" + queries.join('&');
|
||||
var uri = "webrtc://" + server + api + "/" + app + "/" + stream + "?" + queries.join('&');
|
||||
while (uri.lastIndexOf("?") == uri.length - 1) {
|
||||
uri = uri.substr(0, uri.length - 1);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* depends: jquery1.10
|
||||
* https://gitee.com/winlinvip/codes/rpn0c2ewbomj81augzk4y59
|
||||
* @see: http://blog.csdn.net/win_lin/article/details/17994347
|
||||
* v 1.0.19
|
||||
* v 1.0.20
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -293,7 +293,9 @@ function __fill_query(query_string, obj) {
|
|||
function parse_rtmp_url(rtmp_url) {
|
||||
// @see: http://stackoverflow.com/questions/10469575/how-to-use-location-object-to-parse-url-without-redirecting-the-page-in-javascri
|
||||
var a = document.createElement("a");
|
||||
a.href = rtmp_url.replace("rtmp://", "http://").replace("webrtc://", "http://");
|
||||
a.href = rtmp_url.replace("rtmp://", "http://")
|
||||
.replace("webrtc://", "http://")
|
||||
.replace("rtc://", "http://");
|
||||
|
||||
var vhost = a.hostname;
|
||||
var app = a.pathname.substr(1, a.pathname.lastIndexOf("/") - 1);
|
||||
|
@ -327,7 +329,19 @@ function parse_rtmp_url(rtmp_url) {
|
|||
if (rtmp_url.indexOf("://") > 0) {
|
||||
schema = rtmp_url.substr(0, rtmp_url.indexOf("://"));
|
||||
}
|
||||
var port = (a.port == "")? (schema=="http"?"80":"1935"):a.port;
|
||||
|
||||
var port = a.port;
|
||||
if (!port) {
|
||||
if (schema === 'http') {
|
||||
port = 80;
|
||||
} else if (schema === 'https') {
|
||||
port = 443;
|
||||
} else if (schema === 'rtmp') {
|
||||
port = 1935;
|
||||
} else if (schema === 'webrtc' || schema === 'rtc') {
|
||||
port = 1985;
|
||||
}
|
||||
}
|
||||
|
||||
var ret = {
|
||||
url: rtmp_url,
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
return pc.setLocalDescription(offer).then(function(){ return offer; });
|
||||
}).then(function(offer) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var port = urlObject.user_query.api || 1985;
|
||||
var port = urlObject.port || 1985;
|
||||
|
||||
// @see https://github.com/rtcdn/rtcdn-draft
|
||||
var api = urlObject.user_query.play || '/rtc/v1/play/';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue