Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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.3.0

* Adds new capture method for a camera to allow concurrent streaming and recording.

## 2.2.2

* Updates code for `no_leading_underscores_for_local_identifiers` lint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import '../../camera_platform_interface.dart';
import '../method_channel/method_channel_camera.dart';
import '../types/video_capture_options.dart';

/// The interface that implementations of camera must implement.
///
Expand Down Expand Up @@ -131,10 +132,21 @@ abstract class CameraPlatform extends PlatformInterface {
/// meaning the recording will continue until manually stopped.
/// With [maxVideoDuration] set the video is returned in a [VideoRecordedEvent]
/// through the [onVideoRecordedEvent] stream when the set duration is reached.
///
/// This method is deprecated in favour of [startVideoCapturing].
Future<void> startVideoRecording(int cameraId, {Duration? maxVideoDuration}) {
throw UnimplementedError('startVideoRecording() is not implemented.');
}

/// Starts a video recording and/or streaming session.
///
/// Please see [VideoCaptureOptions] for documentation on the
/// configuration options.
Future<void> startVideoCapturing(VideoCaptureOptions options) {
return startVideoRecording(options.cameraId,
maxVideoDuration: options.maxDuration);
}

/// Stops the video recording and returns the file where it was saved.
Future<XFile> stopVideoRecording(int cameraId) {
throw UnimplementedError('stopVideoRecording() is not implemented.');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/foundation.dart';

import 'camera_image_data.dart';

/// Options wrapper for [CameraPlatform.startVideoCapturing] parameters.
@immutable
class VideoCaptureOptions {
/// Constructs a new instance.
const VideoCaptureOptions(
this.cameraId, {
this.maxDuration,
this.streamCallback,
this.streamOptions,
}) : assert(
streamOptions == null || streamCallback != null,
'Must specify streamCallback if providing streamOptions.',
);

/// The ID of the camera to use for capturing.
final int cameraId;

/// The maximum time to perform capturing for.
///
/// By default there is no maximum on the capture time.
final Duration? maxDuration;

/// An optional callback to enable streaming.
///
/// If set, then each image captured by the camera will be
/// passed to this callback.
final Function(CameraImageData image)? streamCallback;

/// Configuration options for streaming.
///
/// Should only be set if a streamCallback is also present.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is true, can you add an assertion to the constructor that verifies this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

final CameraImageStreamOptions? streamOptions;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is VideoCaptureOptions &&
runtimeType == other.runtimeType &&
cameraId == other.cameraId &&
maxDuration == other.maxDuration &&
streamCallback == other.streamCallback &&
streamOptions == other.streamOptions;

@override
int get hashCode =>
Object.hash(cameraId, maxDuration, streamCallback, streamOptions);
}
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/plugins/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.2.2
version: 2.3.0

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down