Getting back code in compilable fashion after huge rebase

This commit is contained in:
David Négrier 2020-08-18 00:12:38 +02:00
parent 4b72958193
commit 2e61c2ef62
4 changed files with 35 additions and 37 deletions

View file

@ -11,6 +11,7 @@ interface MediaServiceInterface extends MediaDevices{
}
type UpdatedLocalStreamCallback = (media: MediaStream) => void;
type UpdatedScreenSharingCallback = (media: MediaStream) => void;
// TODO: Split MediaManager in 2 classes: MediaManagerUI (in charge of HTML) and MediaManager (singleton in charge of the camera only)
// TODO: verify that microphone event listeners are not triggered plenty of time NOW (since MediaManager is created many times!!!!)
@ -31,11 +32,10 @@ export class MediaManager {
video: videoConstraint
};
updatedLocalStreamCallBacks : Set<UpdatedLocalStreamCallback> = new Set<UpdatedLocalStreamCallback>();
// TODO: updatedScreenSharingCallBack should have same signature as updatedLocalStreamCallBacks
updatedScreenSharingCallBack : Function;
updatedScreenSharingCallBacks : Set<UpdatedScreenSharingCallback> = new Set<UpdatedScreenSharingCallback>();
constructor(updatedScreenSharingCallBack : Function) {
this.updatedScreenSharingCallBack = updatedScreenSharingCallBack;
constructor() {
this.myCamVideo = this.getElementByIdOrFail<HTMLVideoElement>('myCamVideo');
this.webrtcInAudio = this.getElementByIdOrFail<HTMLAudioElement>('audio-webrtc-in');
@ -69,14 +69,14 @@ export class MediaManager {
//update tracking
});
this.monitorClose = document.getElementById('monitor-close');
this.monitorClose = this.getElementByIdOrFail<HTMLImageElement>('monitor-close');
this.monitorClose.style.display = "block";
this.monitorClose.addEventListener('click', (e: any) => {
e.preventDefault();
this.enabledMonitor();
//update tracking
});
this.monitor = document.getElementById('monitor');
this.monitor = this.getElementByIdOrFail<HTMLImageElement>('monitor');
this.monitor.style.display = "none";
this.monitor.addEventListener('click', (e: any) => {
e.preventDefault();
@ -90,6 +90,11 @@ export class MediaManager {
this.updatedLocalStreamCallBacks.add(callback);
}
onUpdateScreenSharing(callback: UpdatedScreenSharingCallback): void {
this.updatedScreenSharingCallBacks.add(callback);
}
removeUpdateLocalStreamEventListener(callback: UpdatedLocalStreamCallback): void {
this.updatedLocalStreamCallBacks.delete(callback);
}
@ -100,6 +105,12 @@ export class MediaManager {
}
}
private triggerUpdatedScreenSharingCallbacks(stream: MediaStream): void {
for (const callback of this.updatedScreenSharingCallBacks) {
callback(stream);
}
}
activeVisio(){
const gameOverlay = this.getElementByIdOrFail('game-overlay');
gameOverlay.classList.add('active');
@ -156,7 +167,7 @@ export class MediaManager {
this.monitorClose.style.display = "none";
this.monitor.style.display = "block";
this.getScreenMedia().then((stream) => {
this.updatedScreenSharingCallBack(stream);
this.triggerUpdatedScreenSharingCallbacks(stream);
});
}
@ -168,7 +179,7 @@ export class MediaManager {
});
this.localScreenCapture = null;
this.getCamera().then((stream) => {
this.updatedScreenSharingCallBack(stream);
this.triggerUpdatedScreenSharingCallbacks(stream);
});
}