Merge pull request #566 from thecodingmachine/screanSharing
Fix screen sharing
This commit is contained in:
commit
0f7f42b6f1
@ -209,10 +209,19 @@ export class MediaManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enableCamera() {
|
public enableCamera() {
|
||||||
this.enableCameraStyle();
|
|
||||||
this.constraintsMedia.video = videoConstraint;
|
this.constraintsMedia.video = videoConstraint;
|
||||||
|
|
||||||
this.getCamera().then((stream: MediaStream) => {
|
this.getCamera().then((stream: MediaStream) => {
|
||||||
|
//TODO show error message tooltip upper of camera button
|
||||||
|
//TODO message : please check camera permission of your navigator
|
||||||
|
if(stream.getVideoTracks().length === 0) {
|
||||||
|
throw Error('Video track is empty, please check camera permission of your navigator')
|
||||||
|
}
|
||||||
|
this.enableCameraStyle();
|
||||||
this.triggerUpdatedLocalStreamCallbacks(stream);
|
this.triggerUpdatedLocalStreamCallbacks(stream);
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
this.disableCameraStyle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,11 +237,19 @@ export class MediaManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enableMicrophone() {
|
public enableMicrophone() {
|
||||||
this.enableMicrophoneStyle();
|
|
||||||
this.constraintsMedia.audio = true;
|
this.constraintsMedia.audio = true;
|
||||||
|
|
||||||
this.getCamera().then((stream) => {
|
this.getCamera().then((stream) => {
|
||||||
|
//TODO show error message tooltip upper of camera button
|
||||||
|
//TODO message : please check microphone permission of your navigator
|
||||||
|
if(stream.getAudioTracks().length === 0) {
|
||||||
|
throw Error('Audio track is empty, please check microphone permission of your navigator')
|
||||||
|
}
|
||||||
|
this.enableMicrophoneStyle();
|
||||||
this.triggerUpdatedLocalStreamCallbacks(stream);
|
this.triggerUpdatedLocalStreamCallbacks(stream);
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
this.disableMicrophoneStyle();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,6 +335,9 @@ export class MediaManager {
|
|||||||
const localScreenCapture = this.localScreenCapture;
|
const localScreenCapture = this.localScreenCapture;
|
||||||
this.getCamera().then((stream) => {
|
this.getCamera().then((stream) => {
|
||||||
this.triggerStoppedScreenSharingCallbacks(localScreenCapture);
|
this.triggerStoppedScreenSharingCallbacks(localScreenCapture);
|
||||||
|
}).catch((err) => { //catch error get camera
|
||||||
|
console.error(err);
|
||||||
|
this.triggerStoppedScreenSharingCallbacks(localScreenCapture);
|
||||||
});
|
});
|
||||||
this.localScreenCapture = null;
|
this.localScreenCapture = null;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,14 @@ export class SimplePeer {
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("closeConnection", err)
|
console.error("closeConnection", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if user left discussion, clear array peer connection of sharing
|
||||||
|
if(this.Users.length === 0) {
|
||||||
|
for (const userId of this.PeerScreenSharingConnectionArray.keys()) {
|
||||||
|
this.closeScreenSharingConnection(userId);
|
||||||
|
this.PeerScreenSharingConnectionArray.delete(userId);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -245,9 +253,11 @@ export class SimplePeer {
|
|||||||
// FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray"
|
// FIXME: I don't understand why "Closing connection with" message is displayed TWICE before "Nb users in peerConnectionArray"
|
||||||
// I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel.
|
// I do understand the method closeConnection is called twice, but I don't understand how they manage to run in parallel.
|
||||||
peer.destroy();
|
peer.destroy();
|
||||||
if(!this.PeerScreenSharingConnectionArray.delete(userId)){
|
|
||||||
|
//Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion
|
||||||
|
/*if(!this.PeerScreenSharingConnectionArray.delete(userId)){
|
||||||
throw 'Couln\'t delete peer screen sharing connexion';
|
throw 'Couln\'t delete peer screen sharing connexion';
|
||||||
}
|
}*/
|
||||||
//console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size);
|
//console.log('Nb users in peerConnectionArray '+this.PeerConnectionArray.size);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("closeConnection", err)
|
console.error("closeConnection", err)
|
||||||
@ -301,11 +311,13 @@ export class SimplePeer {
|
|||||||
peer.signal(data.signal);
|
peer.signal(data.signal);
|
||||||
} else {
|
} else {
|
||||||
console.error('Could not find peer whose ID is "'+data.userId+'" in receiveWebrtcScreenSharingSignal');
|
console.error('Could not find peer whose ID is "'+data.userId+'" in receiveWebrtcScreenSharingSignal');
|
||||||
|
console.info('tentative to create new peer connexion');
|
||||||
|
this.sendLocalScreenSharingStreamToUser(data.userId);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`receiveWebrtcSignal => ${data.userId}`, e);
|
console.error(`receiveWebrtcSignal => ${data.userId}`, e);
|
||||||
//force delete and recreate peer connexion
|
//Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion
|
||||||
this.PeerScreenSharingConnectionArray.delete(data.userId);
|
//this.PeerScreenSharingConnectionArray.delete(data.userId);
|
||||||
this.receiveWebrtcScreenSharingSignal(data);
|
this.receiveWebrtcScreenSharingSignal(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -416,8 +428,8 @@ export class SimplePeer {
|
|||||||
|
|
||||||
if (!PeerConnectionScreenSharing.isReceivingScreenSharingStream()) {
|
if (!PeerConnectionScreenSharing.isReceivingScreenSharingStream()) {
|
||||||
PeerConnectionScreenSharing.destroy();
|
PeerConnectionScreenSharing.destroy();
|
||||||
|
//Comment this peer connexion because if we delete and try to reshare screen, the RTCPeerConnection send renegociate event. This array will be remove when user left circle discussion
|
||||||
this.PeerScreenSharingConnectionArray.delete(userId);
|
//this.PeerScreenSharingConnectionArray.delete(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user