Skip to content

Commit

Permalink
Fix start with only screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
SelimEmre committed Mar 14, 2021
1 parent 1504e95 commit 72a41a5
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/main/webapp/js/webrtc_adaptor.js
Expand Up @@ -237,7 +237,6 @@ export class WebRTCAdaptor
else{
this.updateAudioTrack(audioStream,streamId,null);
}
this.checkWebSocketConnection();
}
else if(this.publishMode == "screen+camera" ){
if(audioTrack.length > 0 ){
Expand All @@ -256,6 +255,7 @@ export class WebRTCAdaptor
}
this.gotStream(stream);
}
this.checkWebSocketConnection();
}, true)
}
else {
Expand Down Expand Up @@ -792,23 +792,28 @@ export class WebRTCAdaptor
*/
updateLocalAudioStream(stream, onEndedCallback)
{
var audioTrack = this.localStream.getAudioTracks()[0];
var newAudioTrack = stream.getAudioTracks()[0];

if (audioTrack != null)
if (this.localStream != null && this.localStream.getAudioTracks()[0] != null)
{
var audioTrack = this.localStream.getAudioTracks()[0];
this.localStream.removeTrack(audioTrack);
audioTrack.stop();
this.localStream.addTrack(newAudioTrack);
}
else if(this.localStream != null){
this.localStream.addTrack(newAudioTrack);
}
else{
this.localStream = stream;
}


this.localStream.addTrack(newAudioTrack);



if (this.localVideo != null)
{ //it can be null
this.localVideo.srcObject = this.localStream;
}

if (onEndedCallback != null) {
stream.getAudioTracks()[0].onended = function(event) {
onEndedCallback(event);
Expand All @@ -826,11 +831,16 @@ export class WebRTCAdaptor
this.desktopStream.getVideoTracks()[0].stop();
}

if(this.localStream != null){
var newVideoTrack = stream.getVideoTracks()[0];

if(this.localStream != null && this.localStream.getVideoTracks()[0] != null){
var videoTrack = this.localStream.getVideoTracks()[0];
this.localStream.removeTrack(videoTrack);
videoTrack.stop();
this.localStream.addTrack(stream.getVideoTracks()[0]);
this.localStream.addTrack(newVideoTrack);
}
else if(this.localStream != null){
this.localStream.addTrack(newVideoTrack);
}
else{
this.localStream = stream;
Expand Down

0 comments on commit 72a41a5

Please sign in to comment.