local
parent
cc2c209946
commit
861210c941
|
|
@ -100,35 +100,18 @@ class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
class Entropy {
|
class Entropy {
|
||||||
static preview = null;
|
|
||||||
static localStream = null;
|
|
||||||
static peerConnection = null;
|
static peerConnection = null;
|
||||||
static remote = null;
|
static local = null;
|
||||||
|
|
||||||
static pageReady() {
|
static pageReady() {
|
||||||
|
Entropy.local = new Local("video");
|
||||||
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');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static start(isCaller) {
|
static start(isCaller) {
|
||||||
Entropy.peerConnection = new RTCPeerConnection(Config.peerConnectionConfig);
|
Entropy.peerConnection = new RTCPeerConnection(Config.peerConnectionConfig);
|
||||||
Entropy.peerConnection.onicecandidate = Entropy.gotIceCandidate;
|
Entropy.peerConnection.onicecandidate = Entropy.gotIceCandidate;
|
||||||
Entropy.peerConnection.ontrack = (event) => new Remote('remoteVideo', event.streams[0]);
|
Entropy.peerConnection.ontrack = (event) => new Remote('remoteVideo', event.streams[0]);
|
||||||
Entropy.peerConnection.addStream(Entropy.localStream);
|
Entropy.peerConnection.addStream(Entropy.local.stream);
|
||||||
|
|
||||||
if(isCaller) {
|
if(isCaller) {
|
||||||
Entropy.peerConnection
|
Entropy.peerConnection
|
||||||
|
|
@ -184,9 +167,29 @@ class Entropy {
|
||||||
|
|
||||||
class Local {
|
class Local {
|
||||||
type = null;
|
type = null;
|
||||||
|
stream = null;
|
||||||
|
|
||||||
constructor(type) {
|
constructor(type) {
|
||||||
this.type = 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() {}
|
start() {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue