mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Add one to one demo for no-localhost
This commit is contained in:
parent
5a611e0c4b
commit
5e6fe49da1
63 changed files with 9837 additions and 18 deletions
2
trunk/3rdparty/signaling/README.md
vendored
2
trunk/3rdparty/signaling/README.md
vendored
|
@ -14,7 +14,7 @@ cd srs/trunk && ./configure && make && ./objs/srs -c conf/rtc.conf
|
|||
Build and run signaling:
|
||||
|
||||
```bash
|
||||
make && ./objs/signaling
|
||||
cd srs/trunk/3rdparty/signaling && make && ./objs/signaling
|
||||
```
|
||||
|
||||
Open the H5 demos:
|
||||
|
|
32
trunk/3rdparty/signaling/www/demos/js/srs.sig.js
vendored
32
trunk/3rdparty/signaling/www/demos/js/srs.sig.js
vendored
|
@ -86,3 +86,35 @@ function SrsRtcSignalingAsync() {
|
|||
|
||||
return self;
|
||||
}
|
||||
|
||||
// Parse params in query string.
|
||||
function SrsRtcSignalingParse(location) {
|
||||
let query = location.href.split('?')[1];
|
||||
query = query? '?' + query : null;
|
||||
|
||||
let wsSchema = location.href.split('wss=')[1];
|
||||
wsSchema = wsSchema? wsSchema.split('&')[0] : (location.protocol === 'http:'? 'ws' : 'wss');
|
||||
|
||||
let wsHost = location.href.split('wsh=')[1];
|
||||
wsHost = wsHost? wsHost.split('&')[0] : location.hostname;
|
||||
|
||||
let wsPort = location.href.split('wsp=')[1];
|
||||
wsPort = wsPort? wsPort.split('&')[0] : location.host.split(':')[1];
|
||||
wsHost = wsPort? wsHost.split(':')[0] + ':' + wsPort : wsHost;
|
||||
|
||||
let host = location.href.split('host=')[1];
|
||||
host = host? host.split('&')[0] : location.hostname;
|
||||
|
||||
let room = location.href.split('room=')[1];
|
||||
|
||||
let display = location.href.split('display=')[1];
|
||||
display = display? display.split('&')[0] : new Date().getTime().toString(16).substr(3);
|
||||
|
||||
let autostart = location.href.split('autostart=')[1];
|
||||
autostart = autostart && autostart.split('&')[0] === 'true';
|
||||
|
||||
return {
|
||||
query: query, wsSchema: wsSchema, wsHost: wsHost, host: host,
|
||||
room: room, display: display, autostart: autostart,
|
||||
};
|
||||
}
|
||||
|
|
28
trunk/3rdparty/signaling/www/demos/one2one.html
vendored
28
trunk/3rdparty/signaling/www/demos/one2one.html
vendored
|
@ -66,6 +66,9 @@
|
|||
var publisher = null;
|
||||
var player = null;
|
||||
$(function(){
|
||||
console.log('?wss=x to specify the websocket schema, ws or wss');
|
||||
console.log('?wsh=x to specify the websocket server ip');
|
||||
console.log('?wsp=x to specify the websocket server port');
|
||||
console.log('?host=x to specify the SRS server');
|
||||
console.log('?room=x to specify the room to join');
|
||||
console.log('?display=x to specify your nick name');
|
||||
|
@ -87,7 +90,7 @@
|
|||
startPlay(host, room, participant.display);
|
||||
});
|
||||
};
|
||||
await sig.connect('ws', window.location.host, room, display);
|
||||
await sig.connect(conf.wsSchema, conf.wsHost, room, display);
|
||||
|
||||
let r0 = await sig.send({action:'join', room:room, display:display});
|
||||
console.log('Signaling: join ok', r0);
|
||||
|
@ -112,7 +115,7 @@
|
|||
};
|
||||
|
||||
var startPublish = function (host, room, display) {
|
||||
var url = 'webrtc://' + host + '/' + room + '/' + display + query;
|
||||
var url = 'webrtc://' + host + '/' + room + '/' + display + conf.query;
|
||||
$('#rtc_media_publisher').show();
|
||||
|
||||
if (publisher) {
|
||||
|
@ -134,7 +137,7 @@
|
|||
};
|
||||
|
||||
var startPlay = function (host, room, display) {
|
||||
var url = 'webrtc://' + host + '/' + room + '/' + display + query;
|
||||
var url = 'webrtc://' + host + '/' + room + '/' + display + conf.query;
|
||||
$('#rtc_media_player').show();
|
||||
|
||||
if (player) {
|
||||
|
@ -162,20 +165,11 @@
|
|||
$("#btn_start").click(startDemo);
|
||||
|
||||
// Pass-by to SRS url.
|
||||
let query = window.location.href.split('?')[1];
|
||||
query = query? '?' + query : null;
|
||||
|
||||
let host = window.location.href.split('host=')[1];
|
||||
$('#txt_host').val(host? host.split('&')[0] : window.location.hostname);
|
||||
|
||||
let room = window.location.href.split('room=')[1];
|
||||
room && $('#txt_room').val(room.split('&')[0]);
|
||||
|
||||
let display = window.location.href.split('display=')[1];
|
||||
$('#txt_display').val(display? display.split('&')[0] : new Date().getTime().toString(16).substr(3));
|
||||
|
||||
let autostart = window.location.href.split('autostart=')[1];
|
||||
if (autostart && autostart.split('&')[0] === 'true') {
|
||||
let conf = SrsRtcSignalingParse(window.location);
|
||||
$('#txt_host').val(conf.host);
|
||||
conf.room && $('#txt_room').val(conf.room);
|
||||
$('#txt_display').val(conf.display);
|
||||
if (conf.autostart) {
|
||||
startDemo();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue