Continue screen sharing

This commit is contained in:
Gregoire Parant 2020-06-08 22:52:25 +02:00
parent 81c030392f
commit fe739f4f08
3 changed files with 51 additions and 5 deletions

View file

@ -34,6 +34,8 @@
</div>-->
</div>
</div>
<div id="activeScreenSharing" class="active-screen-sharing active">
</div>
<audio id="audio-webrtc-in">
<source src="/resources/objects/webrtc-in.mp3" type="audio/mp3">
</audio>

View file

@ -152,4 +152,34 @@ video{
top: calc(48px - 37px);
left: calc(48px - 41px);
position: relative;
}
/*SCREEN SHARING*/
.active-screen-sharing video{
transform: scaleX(1);
}
.active-screen-sharing .screen-sharing-video-container video:hover{
width: 50%;
}
.active-screen-sharing .screen-sharing-video-container video{
position: absolute;
width: 25%;
height: auto;
left: 0;
top: 0;
transition: all 0.2s ease;
}
.active-screen-sharing .screen-sharing-video-container video:nth-child(1){
/*this is for camera of user*/
top: 0%;
}
.active-screen-sharing .screen-sharing-video-container video:nth-child(2){
top: 25%;
}
.active-screen-sharing .screen-sharing-video-container video:nth-child(3){
top: 50%;
}
.active-screen-sharing .screen-sharing-video-container video:nth-child(4) {
top: 75%;
}

View file

@ -248,13 +248,21 @@ export class SimplePeer {
*/
private addMedia (userId : any = null) {
try {
let localStream: MediaStream | null = this.MediaManager.localStream;
let localScreenCapture: MediaStream | null = this.MediaManager.localScreenCapture;
let PeerConnection = this.PeerConnectionArray.get(userId);
if (!PeerConnection) {
throw new Error('While adding media, cannot find user with ID ' + userId);
}
if(userId.indexOf("screenSharing") > -1 && this.MediaManager.localScreenCapture){
for (const track of this.MediaManager.localScreenCapture.getTracks()) {
PeerConnection.addTrack(track, this.MediaManager.localScreenCapture);
}
return;
}
let localStream: MediaStream | null = this.MediaManager.localStream;
let localScreenCapture: MediaStream | null = this.MediaManager.localScreenCapture;
PeerConnection.write(new Buffer(JSON.stringify(Object.assign(this.MediaManager.constraintsMedia, {screen: localScreenCapture !== null}))));
if(!localStream){
@ -280,15 +288,21 @@ export class SimplePeer {
if (this.MediaManager.localScreenCapture) {
let screenSharingUser: UserSimplePeerInterface = {
userId: `screenSharing-${this.Connection.userId}`,
name: 'screenSharing',
initiator: true
};
let PeerConnectionScreenSharing = this.createPeerConnection(screenSharingUser);
if (!PeerConnectionScreenSharing) {
return;
}
for (const track of this.MediaManager.localScreenCapture.getTracks()) {
PeerConnectionScreenSharing.addTrack(track, this.MediaManager.localScreenCapture);
try {
for (const track of this.MediaManager.localScreenCapture.getTracks()) {
PeerConnectionScreenSharing.addTrack(track, this.MediaManager.localScreenCapture);
}
}catch (e) {
console.error("updatedScreenSharing => ", e);
}
this.MediaManager.addStreamRemoteVideo(screenSharingUser.userId, this.MediaManager.localScreenCapture);
} else {
if (!this.PeerConnectionArray.has(`screenSharing-${this.Connection.userId}`)) {
return;