@@ -152,7 +152,7 @@ public void onMethodCall(MethodCall call, Result notSafeResult) {
152
152
peerConnectionCreateAnswer (peerConnectionId , new ConstraintsMap (constraints ), result );
153
153
} else if (call .method .equals ("mediaStreamGetTracks" )) {
154
154
String streamId = call .argument ("streamId" );
155
- MediaStream stream = getStreamForId (streamId );
155
+ MediaStream stream = getStreamForId (streamId , "" );
156
156
Map <String , Object > resultMap = new HashMap <>();
157
157
List <Object > audioTracks = new ArrayList <>();
158
158
List <Object > videoTracks = new ArrayList <>();
@@ -298,15 +298,15 @@ public void onMethodCall(MethodCall call, Result notSafeResult) {
298
298
} else if (call .method .equals ("videoRendererSetSrcObject" )) {
299
299
int textureId = call .argument ("textureId" );
300
300
String streamId = call .argument ("streamId" );
301
-
301
+ String peerConnectionId = call . argument ( "peerConnectionId" );
302
302
FlutterRTCVideoRenderer render = renders .get (textureId );
303
303
304
304
if (render == null ) {
305
305
result .error ("FlutterRTCVideoRendererNotFound" , "render [" + textureId + "] not found !" , null );
306
306
return ;
307
307
}
308
308
309
- MediaStream stream = getStreamForId (streamId );
309
+ MediaStream stream = getStreamForId (streamId , peerConnectionId );
310
310
render .setStream (stream );
311
311
result .success (null );
312
312
} else if (call .method .equals ("mediaStreamTrackHasTorch" )) {
@@ -702,7 +702,7 @@ String getNextStreamUUID() {
702
702
703
703
do {
704
704
uuid = UUID .randomUUID ().toString ();
705
- } while (getStreamForId (uuid ) != null );
705
+ } while (getStreamForId (uuid , "" ) != null );
706
706
707
707
return uuid ;
708
708
}
@@ -717,15 +717,20 @@ String getNextTrackUUID() {
717
717
return uuid ;
718
718
}
719
719
720
- MediaStream getStreamForId (String id ) {
720
+ MediaStream getStreamForId (String id , String peerConnectionId ) {
721
721
MediaStream stream = localStreams .get (id );
722
722
723
723
if (stream == null ) {
724
- for ( Map . Entry < String , PeerConnectionObserver > entry : mPeerConnectionObservers . entrySet () ) {
725
- PeerConnectionObserver pco = entry . getValue ( );
724
+ if ( peerConnectionId . length () > 0 ) {
725
+ PeerConnectionObserver pco = mPeerConnectionObservers . get ( peerConnectionId );
726
726
stream = pco .remoteStreams .get (id );
727
- if (stream != null ) {
728
- break ;
727
+ } else {
728
+ for (Map .Entry <String , PeerConnectionObserver > entry : mPeerConnectionObservers .entrySet ()) {
729
+ PeerConnectionObserver pco = entry .getValue ();
730
+ stream = pco .remoteStreams .get (id );
731
+ if (stream != null ) {
732
+ break ;
733
+ }
729
734
}
730
735
}
731
736
}
0 commit comments