mirror of https://github.com/OpenVidu/openvidu.git
'streamCreated', 'accessAllowed', 'accessDenied' emitted by Publisher
parent
17910bf252
commit
88ff95e24f
File diff suppressed because one or more lines are too long
|
@ -23,7 +23,7 @@ export class Publisher {
|
||||||
constructor(stream: Stream, parentId: string) {
|
constructor(stream: Stream, parentId: string) {
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
|
|
||||||
this.ee.on('camera-access-changed', (event) => {
|
this.stream.addEventListener('camera-access-changed', (event) => {
|
||||||
this.accessAllowed = event.accessAllowed;
|
this.accessAllowed = event.accessAllowed;
|
||||||
if (this.accessAllowed) {
|
if (this.accessAllowed) {
|
||||||
this.ee.emitEvent('accessAllowed');
|
this.ee.emitEvent('accessAllowed');
|
||||||
|
@ -62,8 +62,8 @@ export class Publisher {
|
||||||
element: this.stream.getVideoElement()
|
element: this.stream.getVideoElement()
|
||||||
}]);
|
}]);
|
||||||
} else {
|
} else {
|
||||||
this.stream.addEventListener('video-element-created-by-stream', element => {
|
this.stream.addEventListener('video-element-created-by-stream', (element) => {
|
||||||
console.warn("Publisher emitting videoElementCreated");
|
console.warn('Publisher emitting videoElementCreated');
|
||||||
this.id = element.id;
|
this.id = element.id;
|
||||||
this.ee.emitEvent('videoElementCreated', [{
|
this.ee.emitEvent('videoElementCreated', [{
|
||||||
element: element
|
element: element
|
||||||
|
@ -71,5 +71,33 @@ export class Publisher {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (eventName == 'streamCreated') {
|
||||||
|
if (this.stream.isReady) {
|
||||||
|
this.ee.emitEvent('streamCreated', [{ stream: this.stream }]);
|
||||||
|
} else {
|
||||||
|
this.stream.addEventListener('stream-created-by-publisher', () => {
|
||||||
|
console.warn('Publisher emitting streamCreated');
|
||||||
|
this.ee.emitEvent('streamCreated', [{ stream: this.stream }]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventName == 'accessAllowed') {
|
||||||
|
if (this.stream.accessIsAllowed) {
|
||||||
|
this.ee.emitEvent('accessAllowed');
|
||||||
|
} else {
|
||||||
|
this.stream.addEventListener('access-allowed-by-publisher', () => {
|
||||||
|
this.ee.emitEvent('accessAllowed');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (eventName == 'accessDenied') {
|
||||||
|
if (this.stream.accessIsDenied) {
|
||||||
|
this.ee.emitEvent('accessDenied');
|
||||||
|
} else {
|
||||||
|
this.stream.addEventListener('access-denied-by-publisher', () => {
|
||||||
|
this.ee.emitEvent('accessDenied');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -104,7 +104,9 @@ export class OpenViduInternal {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
getOpenViduServerURL() {
|
||||||
|
return 'https://' + this.wsUri.split("wss://")[1].split("/room")[0];
|
||||||
|
}
|
||||||
|
|
||||||
getRoom() {
|
getRoom() {
|
||||||
return this.session;
|
return this.session;
|
||||||
|
|
|
@ -177,7 +177,7 @@ export class SessionInternal {
|
||||||
this.ee.off(eventName, listener);
|
this.ee.off(eventName, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeEvent(eventName){
|
removeEvent(eventName) {
|
||||||
this.ee.removeEvent(eventName);
|
this.ee.removeEvent(eventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ export class SessionInternal {
|
||||||
this.ee.emitEvent('connectionCreated', [{
|
this.ee.emitEvent('connectionCreated', [{
|
||||||
connection: connection
|
connection: connection
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onParticipantLeft(msg) {
|
onParticipantLeft(msg) {
|
||||||
|
@ -369,7 +369,10 @@ export class SessionInternal {
|
||||||
onLostConnection() {
|
onLostConnection() {
|
||||||
|
|
||||||
if (!this.connected) {
|
if (!this.connected) {
|
||||||
console.warn('Not connected to room, ignoring lost connection notification');
|
console.warn('Not connected to room: if you are not debugging, this is probably a certificate error');
|
||||||
|
if (window.confirm('If you are not debugging, this is probably a certificate error at \"' + this.openVidu.getOpenViduServerURL() + '\"\n\nClick OK to navigate and accept it')) {
|
||||||
|
location.assign(this.openVidu.getOpenViduServerURL());
|
||||||
|
};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ export class Stream {
|
||||||
private videoSrc: string;
|
private videoSrc: string;
|
||||||
private parentId: string;
|
private parentId: string;
|
||||||
public isReady: boolean = false;
|
public isReady: boolean = false;
|
||||||
|
public accessIsAllowed: boolean = false;
|
||||||
|
public accessIsDenied: boolean = false;
|
||||||
|
|
||||||
constructor(private openVidu: OpenViduInternal, private local: boolean, private room: SessionInternal, options: StreamOptions) {
|
constructor(private openVidu: OpenViduInternal, private local: boolean, private room: SessionInternal, options: StreamOptions) {
|
||||||
|
|
||||||
|
@ -276,6 +278,8 @@ export class Stream {
|
||||||
element: this.video
|
element: this.video
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
|
this.ee.emitEvent('stream-created-by-publisher');
|
||||||
|
|
||||||
this.isReady = true;
|
this.isReady = true;
|
||||||
|
|
||||||
return this.video;
|
return this.video;
|
||||||
|
@ -349,24 +353,25 @@ export class Stream {
|
||||||
|
|
||||||
navigator.mediaDevices.getUserMedia(constraints)
|
navigator.mediaDevices.getUserMedia(constraints)
|
||||||
.then(userStream => {
|
.then(userStream => {
|
||||||
|
this.accessIsAllowed = true;
|
||||||
|
this.accessIsDenied = false;
|
||||||
|
this.ee.emitEvent('access-allowed-by-publisher');
|
||||||
|
|
||||||
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
userStream.getAudioTracks()[0].enabled = this.sendAudio;
|
||||||
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
userStream.getVideoTracks()[0].enabled = this.sendVideo;
|
||||||
|
|
||||||
this.wrStream = userStream;
|
this.wrStream = userStream;
|
||||||
this.emitSrcEvent(this.wrStream);
|
this.emitSrcEvent(this.wrStream);
|
||||||
|
|
||||||
this.ee.emitEvent('camera-access-changed', [{
|
|
||||||
accessAllowed: true
|
|
||||||
}]);
|
|
||||||
|
|
||||||
callback(undefined, this);
|
callback(undefined, this);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
this.accessIsDenied = true;
|
||||||
|
this.accessIsAllowed = false;
|
||||||
|
this.ee.emitEvent('access-denied-by-publisher');
|
||||||
|
|
||||||
console.error("Access denied", error);
|
console.error("Access denied", error);
|
||||||
this.ee.emitEvent('camera-access-changed', [{
|
callback(error, this);
|
||||||
accessAllowed: false
|
|
||||||
}]);
|
|
||||||
callback(error, undefined);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue