This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera] Add ability to concurrently record and stream video #6290
Merged
auto-submit
merged 13 commits into
flutter:main
from
adam-harwood:aharwood/enable_stream_and_record
Dec 6, 2022
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
14169ca
Implement interface methods to allow concurrent stream and record
7d07bf9
Fix android test
c4bf172
Format android_camera_test.dart
fdf96d2
Resolve analyze failures
7d94fdb
Fix version bumps
ce20813
Fix MethodChannelCameraTest
3989374
Fix comment on FLTCam
66a90ef
Add tests to confirm can't stream on windows or web
8cd12c1
CHANGELOG updates
416e085
Merge branch 'main' into aharwood/enable_stream_and_record
adam-harwood 9433844
Fix analyze errors
cb0c094
Fix dart analyze warnings for web
3c514d4
Formatted
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,13 +248,25 @@ class AndroidCamera extends CameraPlatform { | |
@override | ||
Future<void> startVideoRecording(int cameraId, | ||
{Duration? maxVideoDuration}) async { | ||
return startVideoCapturing( | ||
VideoCaptureOptions(cameraId, maxDuration: maxVideoDuration)); | ||
} | ||
|
||
@override | ||
Future<void> startVideoCapturing(VideoCaptureOptions options) async { | ||
await _channel.invokeMethod<void>( | ||
'startVideoRecording', | ||
<String, dynamic>{ | ||
'cameraId': cameraId, | ||
'maxVideoDuration': maxVideoDuration?.inMilliseconds, | ||
'cameraId': options.cameraId, | ||
'maxVideoDuration': options.maxDuration?.inMilliseconds, | ||
'enableStream': options.streamCallback != null, | ||
}, | ||
); | ||
|
||
if (options.streamCallback != null) { | ||
_installStreamController().stream.listen(options.streamCallback); | ||
_startStreamListener(); | ||
} | ||
} | ||
|
||
@override | ||
|
@@ -290,13 +302,19 @@ class AndroidCamera extends CameraPlatform { | |
@override | ||
Stream<CameraImageData> onStreamedFrameAvailable(int cameraId, | ||
{CameraImageStreamOptions? options}) { | ||
_installStreamController(onListen: _onFrameStreamListen); | ||
return _frameStreamController!.stream; | ||
} | ||
|
||
StreamController<CameraImageData> _installStreamController( | ||
{Function()? onListen}) { | ||
_frameStreamController = StreamController<CameraImageData>( | ||
onListen: _onFrameStreamListen, | ||
onListen: onListen ?? () {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider https://github.com/flutter/plugins/pull/6290/files#r952963757 here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replied in this comment, I don't think it applies unless I'm misunderstanding something. |
||
onPause: _onFrameStreamPauseResume, | ||
onResume: _onFrameStreamPauseResume, | ||
onCancel: _onFrameStreamCancel, | ||
); | ||
return _frameStreamController!.stream; | ||
return _frameStreamController!; | ||
} | ||
|
||
void _onFrameStreamListen() { | ||
|
@@ -305,6 +323,10 @@ class AndroidCamera extends CameraPlatform { | |
|
||
Future<void> _startPlatformStream() async { | ||
await _channel.invokeMethod<void>('startImageStream'); | ||
_startStreamListener(); | ||
} | ||
|
||
void _startStreamListener() { | ||
const EventChannel cameraEventChannel = | ||
EventChannel('plugins.flutter.io/camera_android/imageStream'); | ||
_platformImageStreamSubscription = | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.