@@ -1745,7 +1745,7 @@ function Janus(gatewayCallbacks) {
1745
1745
}
1746
1746
// We're now capturing the new stream: check if we're updating or if it's a new thing
1747
1747
var addTracks = false ;
1748
- if ( ! config . myStream || ! media . update || config . streamExternal ) {
1748
+ if ( ! config . myStream || ! media . update || ( config . streamExternal && ! media . replaceAudio && ! media . replaceVideo ) ) {
1749
1749
config . myStream = stream ;
1750
1750
addTracks = true ;
1751
1751
} else {
@@ -2210,7 +2210,7 @@ function Janus(gatewayCallbacks) {
2210
2210
}
2211
2211
}
2212
2212
// 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 ) ) ) ) {
2214
2214
if ( media . removeAudio || media . replaceAudio ) {
2215
2215
if ( config . myStream && config . myStream . getAudioTracks ( ) && config . myStream . getAudioTracks ( ) . length ) {
2216
2216
var at = config . myStream . getAudioTracks ( ) [ 0 ] ;
@@ -2268,12 +2268,10 @@ function Janus(gatewayCallbacks) {
2268
2268
Janus . log ( "MediaStream provided by the application" ) ;
2269
2269
Janus . debug ( stream ) ;
2270
2270
// 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 ;
2277
2275
}
2278
2276
// Skip the getUserMedia part
2279
2277
config . streamExternal = true ;
0 commit comments