Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.14.0

* Adds `videoOutputPath` support to `VideoCaptureOptions`.

## 2.13.1

* Changes the default implementation of `setJpegImageQuality` to a no-op so that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class MethodChannelCamera extends CameraPlatform {
'cameraId': options.cameraId,
'maxVideoDuration': options.maxDuration?.inMilliseconds,
'enableStream': options.streamCallback != null,
'videoOutputPath': options.videoOutputPath,
});

if (options.streamCallback != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class VideoCaptureOptions {
this.streamCallback,
this.streamOptions,
this.enablePersistentRecording = true,
this.videoOutputPath,
}) : assert(
streamOptions == null || streamCallback != null,
'Must specify streamCallback if providing streamOptions.',
Expand Down Expand Up @@ -52,6 +53,11 @@ class VideoCaptureOptions {
/// Defaults to `true`.
final bool enablePersistentRecording;

/// The path where the video should be saved.
///
/// If null, the platform will generate a temporary path.
final String? videoOutputPath;

@override
bool operator ==(Object other) =>
identical(this, other) ||
Expand All @@ -61,9 +67,16 @@ class VideoCaptureOptions {
maxDuration == other.maxDuration &&
streamCallback == other.streamCallback &&
streamOptions == other.streamOptions &&
enablePersistentRecording == other.enablePersistentRecording;
enablePersistentRecording == other.enablePersistentRecording &&
videoOutputPath == other.videoOutputPath;
Comment thread
Mairramer marked this conversation as resolved.
Resolved

@override
int get hashCode =>
Object.hash(cameraId, maxDuration, streamCallback, streamOptions, enablePersistentRecording);
int get hashCode => Object.hash(
cameraId,
maxDuration,
streamCallback,
streamOptions,
enablePersistentRecording,
videoOutputPath,
);
}
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.13.1
version: 2.14.0

environment:
sdk: ^3.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,33 @@ void main() {
'cameraId': cameraId,
'maxVideoDuration': null,
'enableStream': false,
'videoOutputPath': null,
Comment thread
Mairramer marked this conversation as resolved.
Resolved
},
),
]);
});

test('Should pass videoOutputPath when starting a video recording with options', () async {
// Arrange
final channel = MethodChannelMock(
channelName: 'plugins.flutter.io/camera',
methods: <String, dynamic>{'startVideoRecording': null},
);

// Act
await camera.startVideoCapturing(
VideoCaptureOptions(cameraId, videoOutputPath: 'path/to/video.mp4'),
);

// Assert
expect(channel.log, <Matcher>[
isMethodCall(
'startVideoRecording',
arguments: <String, Object?>{
'cameraId': cameraId,
'maxVideoDuration': null,
'enableStream': false,
'videoOutputPath': 'path/to/video.mp4',
},
),
]);
Expand Down
Loading