8000 call `stopCaptureWithCompletionHandler` instead (#748) · samhblee/flutter-webrtc@0225363 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0225363

Browse files
authored
call stopCaptureWithCompletionHandler instead (flutter-webrtc#748)
1 parent fc97839 commit 0225363

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

common/darwin/Classes/FlutterWebRTCPlugin.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,17 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
359359
NSDictionary* argsMap = call.arguments;
360360
NSString* streamId = argsMap[@"streamId"];
361361
RTCMediaStream *stream = self.localStreams[streamId];
362+
BOOL shouldCallResult = YES;
362363
if (stream) {
363364
for (RTCVideoTrack *track in stream.videoTracks) {
364365
[self.localTracks removeObjectForKey:track.trackId];
365366
RTCVideoTrack *videoTrack = (RTCVideoTrack *)track;
366367
RTCVideoSource *source = videoTrack.source;
367368
if(source){
368-
[self.videoCapturer stopCapture];
369+
shouldCallResult = NO;
370+
[self.videoCapturer stopCaptureWithCompletionHandler:^{
371+
result(nil);
372+
}];
369373
self.videoCapturer = nil;
370374
}
371375
}
@@ -374,7 +378,10 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult) result
374378
}
375379
[self.localStreams removeObjectForKey:streamId];
376380
}
377-
result(nil);
381+
if (shouldCallResult) {
382+
// do not call if will be called in stopCapturer above.
383+
result(nil);
384+
}
378385
} else if ([@"mediaStreamTrackSetEnable" isEqualToString:call.method]){
379386
NSDictionary* argsMap = call.arguments;
380387
NSString* trackId = argsMap[@"trackId"];

0 commit comments

Comments
 (0)
0