1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

support play hls

This commit is contained in:
winlin 2016-03-19 16:35:13 +08:00
parent 69ec66ee36
commit 46a31f4884
11 changed files with 5321 additions and 53 deletions

View file

@ -61,28 +61,46 @@ function build_default_rtmp_url() {
var app = (query.app == undefined)? "live":query.app;
var stream = (query.stream == undefined)? "demo":query.stream;
if (server == vhost || vhost == "") {
return schema + "://" + server + ":" + port + "/" + app + "/" + stream;
} else {
return schema + "://" + server + ":" + port + "/" + app + "...vhost..." + vhost + "/" + stream;
var queries = [];
if (server != vhost && vhost != "__defaultVhost__") {
queries.push("vhost=" + vhost);
}
if (query.shp_identify) {
queries.push("shp_identify=" + query.shp_identify);
}
var uri = schema + "://" + server + ":" + port + "/" + app + "/" + stream + "?" + queries.join('&');
while (uri.indexOf("?") == uri.length - 1) {
uri = uri.substr(0, uri.length - 1);
}
return uri;
}
// for the chat to init the publish url.
function build_default_publish_rtmp_url() {
var query = parse_query_string();
var schema = (query.schema == undefined)? "rtmp":query.schema;
var server = (query.server == undefined)? window.location.hostname:query.server;
var port = (query.port == undefined)? 1935:query.port;
var vhost = (query.vhost == undefined)? window.location.hostname:query.vhost;
var app = (query.app == undefined)? "live":query.app;
var stream = (query.stream == undefined)? "demo":query.stream;
if (server == vhost || vhost == "") {
return "rtmp://" + server + ":" + port + "/" + app + "/" + stream;
} else {
vhost = srs_get_player_chat_vhost(vhost);
return "rtmp://" + server + ":" + port + "/" + app + "...vhost..." + vhost + "/" + stream;
var queries = [];
if (server != vhost && vhost != "__defaultVhost__") {
queries.push("vhost=" + srs_get_player_chat_vhost(vhost));
}
if (query.shp_identify) {
queries.push("shp_identify=" + query.shp_identify);
}
var uri = schema + "://" + server + ":" + port + "/" + app + "/" + stream + "?" + queries.join('&');
while (uri.indexOf("?") == uri.length - 1) {
uri = uri.substr(0, uri.length - 1);
}
return uri;
}
// for the bandwidth tool to init page
function build_default_bandwidth_rtmp_url() {

View file

@ -5,7 +5,7 @@
* depends: jquery1.10
* https://code.csdn.net/snippets/147103
* @see: http://blog.csdn.net/win_lin/article/details/17994347
* v 1.0.15
* v 1.0.16
*/
/**
@ -243,8 +243,21 @@ function parse_query_string(){
}
}
__fill_query(query_string, obj);
return obj;
}
function __fill_query(query_string, obj) {
// pure user query object.
obj.user_query = {};
if (query_string.length == 0) {
return;
}
// split again for angularjs.
if (query_string.indexOf("?") > 0) {
if (query_string.indexOf("?") >= 0) {
query_string = query_string.split("?")[1];
}
@ -257,7 +270,10 @@ function parse_query_string(){
obj.user_query[query[0]] = query[1];
}
return obj;
// alias domain for vhost.
if (obj.domain) {
obj.vhost = obj.domain;
}
}
/**
@ -277,7 +293,7 @@ function parse_query_string(){
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("?", "...").replace("=", "...");
a.href = rtmp_url.replace("rtmp://", "http://");
var vhost = a.hostname;
var port = (a.port == "")? "1935":a.port;
@ -319,6 +335,7 @@ function parse_rtmp_url(rtmp_url) {
server: a.hostname, port: port,
vhost: vhost, app: app, stream: stream
};
__fill_query(a.search, ret);
return ret;
}