mirror of
https://github.com/ossrs/srs.git
synced 2025-02-14 20:31:56 +00:00
Support api to specify the WebRTC API port. v4.0.225
This commit is contained in:
parent
c6c2e97189
commit
73d0ce1cee
3 changed files with 17 additions and 11 deletions
|
@ -64,7 +64,7 @@
|
|||
const prefix = `players/?schema=${window.location.protocol.replace(':', '')}`;
|
||||
const httpPort = window.location.port || (window.location.protocol === 'http:' ? 80 : 443);
|
||||
// If not 8080, user should proxy both stream and API to the default port.
|
||||
const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}&api_port=${httpPort}`;
|
||||
const query = parseInt(window.location.port) === 8080 ? '' : `&port=${httpPort}&api=${httpPort}`;
|
||||
document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`);
|
||||
document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`);
|
||||
}
|
||||
|
|
|
@ -37,10 +37,6 @@ function user_extra_params(query, params, rtc) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!rtc && key === 'api_port') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (query[key]) {
|
||||
queries.push(key + '=' + query[key]);
|
||||
}
|
||||
|
@ -94,7 +90,7 @@ function build_default_flv_url() {
|
|||
function build_default_rtc_url(query) {
|
||||
// The format for query string to overwrite configs of server.
|
||||
console.log('?eip=x.x.x.x to overwrite candidate. 覆盖服务器candidate(外网IP)配置');
|
||||
console.log('?api_port=x to overwrite WebRTC API(1985).');
|
||||
console.log('?api=x to overwrite WebRTC API(1985).');
|
||||
console.log('?schema=http|https to overwrite WebRTC API protocol.');
|
||||
|
||||
var server = (!query.server)? window.location.hostname:query.server;
|
||||
|
|
|
@ -185,6 +185,12 @@ function SrsRtcPublisherAsync() {
|
|||
|
||||
var port = a.port;
|
||||
if (!port) {
|
||||
// Finger out by webrtc url, if contains http or https port, to overwrite default 1985.
|
||||
if (schema === 'webrtc' && url.indexOf(`webrtc://${a.host}:`) === 0) {
|
||||
port = (url.indexOf(`webrtc://${a.host}:80`) === 0) ? 80 : 443;
|
||||
}
|
||||
|
||||
// Guess by schema.
|
||||
if (schema === 'http') {
|
||||
port = 80;
|
||||
} else if (schema === 'https') {
|
||||
|
@ -210,9 +216,8 @@ function SrsRtcPublisherAsync() {
|
|||
} else if (window.location.href.indexOf('https://') === 0) {
|
||||
ret.port = 443;
|
||||
} else {
|
||||
// Allow use api_port to specify the WebRTC API port.
|
||||
// For WebRTC, SRS use 1985 as default API port.
|
||||
ret.port = ret.user_query.api_port || 1985;
|
||||
ret.port = 1985;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +273,7 @@ function SrsRtcPlayerAsync() {
|
|||
// webrtc://r.ossrs.net/live/livestream
|
||||
// or specifies the API port:
|
||||
// webrtc://r.ossrs.net:11985/live/livestream
|
||||
// webrtc://r.ossrs.net/live/livestream?api_port=11985
|
||||
// webrtc://r.ossrs.net:80/live/livestream
|
||||
// or autostart the play:
|
||||
// webrtc://r.ossrs.net/live/livestream?autostart=true
|
||||
// or change the app from live to myapp:
|
||||
|
@ -415,6 +420,12 @@ function SrsRtcPlayerAsync() {
|
|||
|
||||
var port = a.port;
|
||||
if (!port) {
|
||||
// Finger out by webrtc url, if contains http or https port, to overwrite default 1985.
|
||||
if (schema === 'webrtc' && url.indexOf(`webrtc://${a.host}:`) === 0) {
|
||||
port = (url.indexOf(`webrtc://${a.host}:80`) === 0) ? 80 : 443;
|
||||
}
|
||||
|
||||
// Guess by schema.
|
||||
if (schema === 'http') {
|
||||
port = 80;
|
||||
} else if (schema === 'https') {
|
||||
|
@ -440,9 +451,8 @@ function SrsRtcPlayerAsync() {
|
|||
} else if (window.location.href.indexOf('https://') === 0) {
|
||||
ret.port = 443;
|
||||
} else {
|
||||
// Allow use api_port to specify the WebRTC API port.
|
||||
// For WebRTC, SRS use 1985 as default API port.
|
||||
ret.port = ret.user_query.api_port || 1985;
|
||||
ret.port = 1985;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue