Skip to content

Commit d167957

Browse files
authored
janus.js - renegotiate with external stream (#2604)
1 parent 9f95861 commit d167957

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

html/janus.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ function Janus(gatewayCallbacks) {
17451745
}
17461746
// We're now capturing the new stream: check if we're updating or if it's a new thing
17471747
var addTracks = false;
1748-
if(!config.myStream || !media.update || config.streamExternal) {
1748+
if(!config.myStream || !media.update || (config.streamExternal && !media.replaceAudio && !media.replaceVideo)) {
17491749
config.myStream = stream;
17501750
addTracks = true;
17511751
} else {
@@ -2210,7 +2210,7 @@ function Janus(gatewayCallbacks) {
22102210
}
22112211
}
22122212
// If we're updating, check if we need to remove/replace one of the tracks
2213-
if(media.update && !config.streamExternal) {
2213+
if(media.update && (!config.streamExternal || (config.streamExternal && (media.replaceAudio || media.replaceVideo)))) {
22142214
if(media.removeAudio || media.replaceAudio) {
22152215
if(config.myStream && config.myStream.getAudioTracks() && config.myStream.getAudioTracks().length) {
22162216
var at = config.myStream.getAudioTracks()[0];
@@ -2268,12 +2268,10 @@ function Janus(gatewayCallbacks) {
22682268
Janus.log("MediaStream provided by the application");
22692269
Janus.debug(stream);
22702270
// If this is an update, let's check if we need to release the previous stream
2271-
if(media.update) {
2272-
if(config.myStream && config.myStream !== callbacks.stream && !config.streamExternal) {
2273-
// We're replacing a stream we captured ourselves with an external one
2274-
Janus.stopAllTracks(config.myStream);
2275-
config.myStream = null;
2276-
}
2271+
if(media.update && config.myStream && config.myStream !== callbacks.stream && !config.streamExternal && !media.replaceAudio && !media.replaceVideo) {
2272+
// We're replacing a stream we captured ourselves with an external one
2273+
Janus.stopAllTracks(config.myStream);
2274+
config.myStream = null;
22772275
}
22782276
// Skip the getUserMedia part
22792277
config.streamExternal = true;

0 commit comments

Comments
 (0)