mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 04:58:47 +00:00
sendrecv/js: custom getUserMedia constraints
The html page now contains a text area in which the default constraints will be added and can be edited. Closes https://github.com/centricular/gstwebrtc-demos/issues/11
This commit is contained in:
parent
fe40c70536
commit
7c5fbf1aca
2 changed files with 14 additions and 1 deletions
|
@ -25,5 +25,10 @@
|
|||
<div><video id="stream" autoplay>Your browser doesn't support video</video></div>
|
||||
<div>Status: <span id="status">unknown</span></div>
|
||||
<div>Our id is <b id="peer-id">unknown</b></div>
|
||||
<br/>
|
||||
<div>
|
||||
<div>getUserMedia constraints being used:</div>
|
||||
<div><textarea id="constraints" cols=40 rows=4></textarea></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -15,6 +15,8 @@ var peer_id;
|
|||
// Override with your own STUN servers if you want
|
||||
var rtc_configuration = {iceServers: [{urls: "stun:stun.services.mozilla.com"},
|
||||
{urls: "stun:stun.l.google.com:19302"}]};
|
||||
// The default constraints that will be attempted. Can be overriden by the user.
|
||||
var default_constraints = {video: true, audio: true};
|
||||
|
||||
var connect_attempts = 0;
|
||||
var peer_connection;
|
||||
|
@ -155,7 +157,9 @@ function onServerError(event) {
|
|||
}
|
||||
|
||||
function getLocalStream() {
|
||||
var constraints = {video: true, audio: true};
|
||||
var textarea = document.getElementById('constraints');
|
||||
var constraints = JSON.parse(textarea.value);
|
||||
console.log(JSON.stringify(constraints));
|
||||
|
||||
// Add local stream
|
||||
if (navigator.mediaDevices.getUserMedia) {
|
||||
|
@ -171,6 +175,10 @@ function websocketServerConnect() {
|
|||
setError("Too many connection attempts, aborting. Refresh page to try again");
|
||||
return;
|
||||
}
|
||||
// Populate constraints
|
||||
var textarea = document.getElementById('constraints');
|
||||
if (textarea.value == '')
|
||||
textarea.value = JSON.stringify(default_constraints);
|
||||
// Fetch the peer id to use
|
||||
peer_id = peer_id || getOurId();
|
||||
ws_server = ws_server;
|
||||
|
|
Loading…
Reference in a new issue