8000 Fix crash on windows when camera is busy (#802) · fotiDim/flutter-webrtc@f2d0342 · GitHub
[go: up one dir, main page]

Skip to content

Commit f2d0342

Browse files
authored
Fix crash on windows when camera is busy (flutter-webrtc#802)
Check if capturer is null and do not start video source in that case.
1 parent 2ede8da commit f2d0342

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

common/cpp/src/flutter_media_stream.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ void FlutterMediaStream::GetUserMedia(
3333
}
3434

3535
it = constraints.find(EncodableValue("video"));
36+
params[EncodableValue("videoTracks")] = EncodableValue(EncodableList());
3637
if (it != constraints.end()) {
3738
EncodableValue video = it->second;
3839
if (TypeIs<bool>(video)) {
@@ -41,11 +42,7 @@ void FlutterMediaStream::GetUserMedia(
4142
}
4243
} else if (TypeIs<EncodableMap>(video)) {
4344
GetUserVideo(constraints, stream, params);
44-
} else {
45-
params[EncodableValue("videoTracks")] = EncodableValue(EncodableList());
4645
}
47-
} else {
48-
params[EncodableValue("videoTracks")] = EncodableValue(EncodableList());
4946
}
5047

5148
base_->local_streams_[uuid] = stream;
@@ -220,6 +217,9 @@ void FlutterMediaStream::GetUserVideo(const EncodableMap& constraints,
220217
video_capturer =
221218
base_->video_device_->Create(strNameUTF8, 0, width, height, fps);
222219
}
220+
221+
if (!video_capturer.get()) return;
222+
223223
const char* video_source_label = "video_input";
224224
scoped_refptr<RTCVideoSource> source = base_->factory_->CreateVideoSource(
225225
video_capturer, video_source_label,
Binary file not shown.

0 commit comments

Comments
 (0)
0