mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-11 10:56:38 +00:00
sendrecv/js: Add an UI for connecting to specified peer id
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-examples/-/merge_requests/28>
This commit is contained in:
parent
9e83c09be6
commit
85aeda42fe
2 changed files with 22 additions and 0 deletions
|
@ -26,6 +26,13 @@
|
||||||
<div><video id="stream" autoplay playsinline>Your browser doesn't support video</video></div>
|
<div><video id="stream" autoplay playsinline>Your browser doesn't support video</video></div>
|
||||||
<div>Status: <span id="status">unknown</span></div>
|
<div>Status: <span id="status">unknown</span></div>
|
||||||
<div><textarea id="text" cols=40 rows=4></textarea></div>
|
<div><textarea id="text" cols=40 rows=4></textarea></div>
|
||||||
|
<br/>
|
||||||
|
<div>
|
||||||
|
<label for="peer-connect">Enter peer id</label>
|
||||||
|
<input id="peer-connect" type="text" name="text">
|
||||||
|
<button onclick="onConnectClicked();">Connect</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>Our id is <b id="peer-id">unknown</b></div>
|
<div>Our id is <b id="peer-id">unknown</b></div>
|
||||||
<br/>
|
<br/>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -25,6 +25,16 @@ var ws_conn;
|
||||||
// Promise for local stream after constraints are approved by the user
|
// Promise for local stream after constraints are approved by the user
|
||||||
var local_stream_promise;
|
var local_stream_promise;
|
||||||
|
|
||||||
|
function onConnectClicked() {
|
||||||
|
var id = document.getElementById("peer-connect").value;
|
||||||
|
if (id == "") {
|
||||||
|
alert("Peer id must be filled out");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ws_conn.send("SESSION " + id);
|
||||||
|
}
|
||||||
|
|
||||||
function getOurId() {
|
function getOurId() {
|
||||||
return Math.floor(Math.random() * (9000 - 10) + 10).toString();
|
return Math.floor(Math.random() * (9000 - 10) + 10).toString();
|
||||||
}
|
}
|
||||||
|
@ -115,6 +125,11 @@ function onServerMessage(event) {
|
||||||
case "HELLO":
|
case "HELLO":
|
||||||
setStatus("Registered with server, waiting for call");
|
setStatus("Registered with server, waiting for call");
|
||||||
return;
|
return;
|
||||||
|
case "SESSION_OK":
|
||||||
|
setStatus("Starting negotiation");
|
||||||
|
if (!peer_connection)
|
||||||
|
createCall(null).then (generateOffer);
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
if (event.data.startsWith("ERROR")) {
|
if (event.data.startsWith("ERROR")) {
|
||||||
handleIncomingError(event.data);
|
handleIncomingError(event.data);
|
||||||
|
|
Loading…
Reference in a new issue