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

Squash: Fix bugs

This commit is contained in:
winlin 2022-01-13 18:26:28 +08:00
parent 4110fb14cb
commit 93aa0eb5ba
25 changed files with 198 additions and 184 deletions

View file

@ -3,24 +3,70 @@
<head>
<title>SRS</title>
<meta charset="utf-8">
<style>
.span6 {
width: 480px;
}
.code {
background-color: rgb(246 248 250);
padding: 8px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
border-radius: 6px;
word-break: normal;
word-wrap: normal;
box-sizing: border-box;
display: block;
white-space: pre;
}
</style>
</head>
<body>
<h3><a href="https://github.com/ossrs/srs">SRS</a> works!</h3>
<p>
Click <a id="en" href="#">here</a> to enter SRS console.<br/>
点击进入<a id="cn" href="#">SRS控制台</a>
</p>
<p>
Click <a href="players/?autostart=true">here</a> to start SRS player.<br/>
点击进入<a href="players/?autostart=true">SRS播放器</a>
</p>
<p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2021</a></p>
<script type="text/javascript">
// http://localhost:8080/console/ng_index.html#/connect?port=1985
// http://localhost:8080/console/ng_index.html#/summaries?port=1985
var en_url = window.location.protocol + "//" + window.location.host + "/console/en_index.html#/summaries?port=1985";
var cn_url = window.location.protocol + "//" + window.location.host + "/console/ng_index.html#/summaries?port=1985";
document.getElementById("en").setAttribute('href', en_url);
document.getElementById("cn").setAttribute('href', cn_url);
</script>
<div>
<h3><a href="https://github.com/ossrs/srs">SRS</a> works!</h3>
<p>
Click <a id="enConsole" href="#">here</a> to enter SRS console.<br/>
点击进入<a id="cnConsole" href="#">SRS控制台</a>
</p>
<p>
Publish stream by <a href="https://ffmpeg.org/download.html">FFmpeg</a> or <a href="https://obsproject.com/download">OBS</a>:<br/>
请使用工具<a href="https://ffmpeg.org/download.html">FFmpeg</a>或者<a href="https://obsproject.com/download">OBS</a>推流到下面地址:
<pre id="url" class="code span6"></pre>
</p>
<p>
Click <a id="enPlayer" href="#">here</a> to start SRS player.<br/>
点击进入<a id="cnPlayer" href="#">SRS播放器</a>
</p>
<p><a href="https://github.com/ossrs/srs">SRS Team &copy; 2022</a></p>
</div>
<script type="text/javascript">
// Build RTMP url.
if (true) {
const rtmpUrl = `rtmp://${window.location.hostname}/live/livestream`;
document.getElementById('url').innerText = rtmpUrl;
}
// Build console url.
if (true) {
// The prefix for default website.
const prefix = `${window.location.protocol}//${window.location.host}`;
// If not 8080, user should proxy to the default port.
const query = parseInt(window.location.port) === 8080 ? `?port=1985` : '';
const enUrl = `${prefix}/console/en_index.html#/summaries${query}`;
const cnUrl = `${prefix}/console/ng_index.html#/summaries${query}`;
document.getElementById("enConsole").setAttribute('href', enUrl);
document.getElementById("cnConsole").setAttribute('href', cnUrl);
}
// The player url.
if (true) {
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=${httpPort}`;
document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`);
document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`);
}
</script>
</body>

View file

@ -24,7 +24,7 @@ function update_nav() {
}
// Special extra params, such as auth_key.
function user_extra_params(query, params) {
function user_extra_params(query, params, rtc) {
var queries = params || [];
for (var key in query.user_query) {
@ -90,6 +90,8 @@ 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=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;
var vhost = (!query.vhost)? window.location.hostname:query.vhost;
@ -104,7 +106,7 @@ function build_default_rtc_url(query) {
if (query.schema && window.location.protocol !== query.schema + ':') {
queries.push('schema=' + query.schema);
}
queries = user_extra_params(query, queries);
queries = user_extra_params(query, queries, true);
var uri = "webrtc://" + server + api + "/" + app + "/" + stream + "?" + queries.join('&');
while (uri.lastIndexOf("?") === uri.length - 1) {

View file

@ -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') {
@ -267,6 +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:80/live/livestream
// or autostart the play:
// webrtc://r.ossrs.net/live/livestream?autostart=true
// or change the app from live to myapp:
@ -413,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') {