-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[camera] Fixed a crash when streaming on iOS #4520
Changes from 1 commit
29beaa7
aec0f93
0d9f61a
7cff775
5d1fb56
7c0fa9e
3056e17
1a48ffc
4cb5d6e
27957a1
97d16c7
1382d62
46d9df0
84dc53d
3ed1e94
9a3e627
6191e3a
e732d7b
b69ea0f
e9beb1f
74d9d85
6b81e1a
96f8edb
1167112
24871c6
7635469
376bbfa
f276bd0
f69aed6
9653345
661cf49
8e334bf
7b8d74f
ab233fa
830d5ad
095faf3
e185988
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,6 +241,58 @@ void main() { | |
| skip: !Platform.isAndroid, | ||
| ); | ||
|
|
||
| /// Start streaming with specifying the ImageFormatGroup. | ||
| Future<CameraImage> startStreaming(List<CameraDescription> cameras, | ||
| ImageFormatGroup? imageFormatGroup) async { | ||
| final CameraController controller = CameraController( | ||
| cameras.first, | ||
| ResolutionPreset.low, | ||
| enableAudio: false, | ||
| imageFormatGroup: imageFormatGroup, | ||
| ); | ||
|
|
||
| await controller.initialize(); | ||
| final _completer = Completer<CameraImage>(); | ||
|
|
||
| await controller.startImageStream((CameraImage image) { | ||
| if (!_completer.isCompleted) { | ||
| Future(() async { | ||
| await controller.stopImageStream(); | ||
| await controller.dispose(); | ||
| }).then((value) { | ||
| _completer.complete(image); | ||
| }); | ||
| } | ||
| }); | ||
| return _completer.future; | ||
| } | ||
|
|
||
| testWidgets( | ||
| 'iOS image streaming with imageFormatGroup', | ||
| (WidgetTester tester) async { | ||
| final List<CameraDescription> cameras = await availableCameras(); | ||
| if (cameras.isEmpty) { | ||
| return; | ||
| } | ||
|
|
||
| var _image = await startStreaming(cameras, null); | ||
| expect(_image, isNotNull); | ||
| expect(_image.format.group, ImageFormatGroup.bgra8888); | ||
| expect(_image.planes.length, 1); | ||
|
|
||
| _image = await startStreaming(cameras, ImageFormatGroup.yuv420); | ||
| expect(_image, isNotNull); | ||
| expect(_image.format.group, ImageFormatGroup.yuv420); | ||
| expect(_image.planes.length, 2); | ||
|
|
||
| _image = await startStreaming(cameras, ImageFormatGroup.bgra8888); | ||
| expect(_image, isNotNull); | ||
| expect(_image.format.group, ImageFormatGroup.bgra8888); | ||
| expect(_image.planes.length, 1); | ||
| }, | ||
| skip: !Platform.isIOS, | ||
| ); | ||
|
|
||
| testWidgets( | ||
| 'Image streaming persistence test on iOS', | ||
|
||
| (WidgetTester tester) async { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a version bump; please see the link in the PR checklist to discussion of versioning in this respository.