local
parent
cc2c209946
commit
861210c941
|
|
@ -100,35 +100,18 @@ class Controller {
|
|||
}
|
||||
|
||||
class Entropy {
|
||||
static preview = null;
|
||||
static localStream = null;
|
||||
static peerConnection = null;
|
||||
static remote = null;
|
||||
static local = null;
|
||||
|
||||
static pageReady() {
|
||||
|
||||
var constraints = {
|
||||
video: true,
|
||||
audio: false,
|
||||
};
|
||||
|
||||
if(navigator.mediaDevices.getUserMedia) {
|
||||
navigator.mediaDevices.getUserMedia(constraints)
|
||||
.then((stream) => {
|
||||
new Preview('preview', stream);
|
||||
Entropy.localStream = stream;
|
||||
})
|
||||
.catch(View.error);
|
||||
} else {
|
||||
alert('Your browser does not support getUserMedia API');
|
||||
}
|
||||
Entropy.local = new Local("video");
|
||||
}
|
||||
|
||||
static start(isCaller) {
|
||||
Entropy.peerConnection = new RTCPeerConnection(Config.peerConnectionConfig);
|
||||
Entropy.peerConnection.onicecandidate = Entropy.gotIceCandidate;
|
||||
Entropy.peerConnection.ontrack = (event) => new Remote('remoteVideo', event.streams[0]);
|
||||
Entropy.peerConnection.addStream(Entropy.localStream);
|
||||
Entropy.peerConnection.addStream(Entropy.local.stream);
|
||||
|
||||
if(isCaller) {
|
||||
Entropy.peerConnection
|
||||
|
|
@ -184,9 +167,29 @@ class Entropy {
|
|||
|
||||
class Local {
|
||||
type = null;
|
||||
stream = null;
|
||||
|
||||
constructor(type) {
|
||||
this.type = type;
|
||||
switch (type) {
|
||||
case "video":
|
||||
case "audio":
|
||||
var constraints = {
|
||||
video: type == "video",
|
||||
audio: type == "audio",
|
||||
};
|
||||
if(!navigator.mediaDevices.getUserMedia) {
|
||||
View.error('Your browser does not support getUserMedia API');
|
||||
}
|
||||
navigator.mediaDevices.getUserMedia(constraints)
|
||||
.then((stream) => {
|
||||
if (type == "video") {
|
||||
new Preview('preview', stream);
|
||||
}
|
||||
this.stream = stream;
|
||||
})
|
||||
.catch(View.error);
|
||||
}
|
||||
}
|
||||
|
||||
start() {}
|
||||
|
|
|
|||
Loading…
Reference in New Issue