Skip to content

Commit

Permalink
janus.js - renegotiate with external stream (#2604)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmeyerhofer authored May 6, 2021
1 parent 9f95861 commit d167957
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions html/janus.js
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ function Janus(gatewayCallbacks) {
}
// We're now capturing the new stream: check if we're updating or if it's a new thing
var addTracks = false;
if(!config.myStream || !media.update || config.streamExternal) {
if(!config.myStream || !media.update || (config.streamExternal && !media.replaceAudio && !media.replaceVideo)) {
config.myStream = stream;
addTracks = true;
} else {
Expand Down Expand Up @@ -2210,7 +2210,7 @@ function Janus(gatewayCallbacks) {
}
}
// If we're updating, check if we need to remove/replace one of the tracks
if(media.update && !config.streamExternal) {
if(media.update && (!config.streamExternal || (config.streamExternal && (media.replaceAudio || media.replaceVideo)))) {
if(media.removeAudio || media.replaceAudio) {
if(config.myStream && config.myStream.getAudioTracks() && config.myStream.getAudioTracks().length) {
var at = config.myStream.getAudioTracks()[0];
Expand Down Expand Up @@ -2268,12 +2268,10 @@ function Janus(gatewayCallbacks) {
Janus.log("MediaStream provided by the application");
Janus.debug(stream);
// If this is an update, let's check if we need to release the previous stream
if(media.update) {
if(config.myStream && config.myStream !== callbacks.stream && !config.streamExternal) {
// We're replacing a stream we captured ourselves with an external one
Janus.stopAllTracks(config.myStream);
config.myStream = null;
}
if(media.update && config.myStream && config.myStream !== callbacks.stream && !config.streamExternal && !media.replaceAudio && !media.replaceVideo) {
// We're replacing a stream we captured ourselves with an external one
Janus.stopAllTracks(config.myStream);
config.myStream = null;
}
// Skip the getUserMedia part
config.streamExternal = true;
Expand Down

0 comments on commit d167957

Please sign in to comment.