From d54e48e048125aa0c38f65a485eb4e3fae33795e Mon Sep 17 00:00:00 2001 From: Andrew Coutts Date: Wed, 15 Mar 2023 17:46:33 -0400 Subject: [PATCH] camera_platform_interface --- .../camera/camera_platform_interface/CHANGELOG.md | 5 +++++ .../lib/src/events/camera_event.dart | 15 +++++++-------- .../lib/src/types/image_format_group.dart | 8 ++++++++ .../camera/camera_platform_interface/pubspec.yaml | 4 ++-- .../test/types/image_group_test.dart | 1 + 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/camera/camera_platform_interface/CHANGELOG.md b/packages/camera/camera_platform_interface/CHANGELOG.md index 2a7261d3549..e0736cac6a0 100644 --- a/packages/camera/camera_platform_interface/CHANGELOG.md +++ b/packages/camera/camera_platform_interface/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.5.0 + +* Adds NV21 as an image stream format (suitable for Android). +* Aligns Dart and Flutter SDK constraints. + ## 2.4.1 * Updates links for the merge of flutter/plugins into flutter/packages. diff --git a/packages/camera/camera_platform_interface/lib/src/events/camera_event.dart b/packages/camera/camera_platform_interface/lib/src/events/camera_event.dart index a6ace8f9ae7..95f61a97a2c 100644 --- a/packages/camera/camera_platform_interface/lib/src/events/camera_event.dart +++ b/packages/camera/camera_platform_interface/lib/src/events/camera_event.dart @@ -51,14 +51,14 @@ class CameraInitializedEvent extends CameraEvent { /// The `previewWidth` represents the width of the generated preview in pixels. /// The `previewHeight` represents the height of the generated preview in pixels. const CameraInitializedEvent( - int cameraId, + super.cameraId, this.previewWidth, this.previewHeight, this.exposureMode, this.exposurePointSupported, this.focusMode, this.focusPointSupported, - ) : super(cameraId); + ); /// Converts the supplied [Map] to an instance of the [CameraInitializedEvent] /// class. @@ -135,10 +135,10 @@ class CameraResolutionChangedEvent extends CameraEvent { /// The `captureWidth` represents the width of the resulting image in pixels. /// The `captureHeight` represents the height of the resulting image in pixels. const CameraResolutionChangedEvent( - int cameraId, + super.cameraId, this.captureWidth, this.captureHeight, - ) : super(cameraId); + ); /// Converts the supplied [Map] to an instance of the /// [CameraResolutionChangedEvent] class. @@ -178,7 +178,7 @@ class CameraResolutionChangedEvent extends CameraEvent { class CameraClosingEvent extends CameraEvent { /// Build a CameraClosing event triggered from the camera represented by /// `cameraId`. - const CameraClosingEvent(int cameraId) : super(cameraId); + const CameraClosingEvent(super.cameraId); /// Converts the supplied [Map] to an instance of the [CameraClosingEvent] /// class. @@ -211,7 +211,7 @@ class CameraErrorEvent extends CameraEvent { /// `cameraId`. /// /// The `description` represents the error occured on the camera. - const CameraErrorEvent(int cameraId, this.description) : super(cameraId); + const CameraErrorEvent(super.cameraId, this.description); /// Converts the supplied [Map] to an instance of the [CameraErrorEvent] /// class. @@ -248,8 +248,7 @@ class VideoRecordedEvent extends CameraEvent { /// The `file` represents the file of the video. /// The `maxVideoDuration` shows if a maxVideoDuration shows if a maximum /// video duration was set. - const VideoRecordedEvent(int cameraId, this.file, this.maxVideoDuration) - : super(cameraId); + const VideoRecordedEvent(super.cameraId, this.file, this.maxVideoDuration); /// Converts the supplied [Map] to an instance of the [VideoRecordedEvent] /// class. diff --git a/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart b/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart index 8dc69e09f58..9d74f242bae 100644 --- a/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart +++ b/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart @@ -31,6 +31,12 @@ enum ImageFormatGroup { /// On Android, this is `android.graphics.ImageFormat.JPEG`. See /// https://developer.android.com/reference/android/graphics/ImageFormat#JPEG jpeg, + + /// YCrCb format used for images, which uses the NV21 encoding format. + /// + /// On Android, this is `android.graphics.ImageFormat.NV21`. See + /// https://developer.android.com/reference/android/graphics/ImageFormat#NV21 + nv21, } /// Extension on [ImageFormatGroup] to stringify the enum @@ -46,6 +52,8 @@ extension ImageFormatGroupName on ImageFormatGroup { return 'yuv420'; case ImageFormatGroup.jpeg: return 'jpeg'; + case ImageFormatGroup.nv21: + return 'nv21'; case ImageFormatGroup.unknown: return 'unknown'; } diff --git a/packages/camera/camera_platform_interface/pubspec.yaml b/packages/camera/camera_platform_interface/pubspec.yaml index c3869bf599d..a0252860f1e 100644 --- a/packages/camera/camera_platform_interface/pubspec.yaml +++ b/packages/camera/camera_platform_interface/pubspec.yaml @@ -4,10 +4,10 @@ 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.4.1 +version: 2.5.0 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.17.0 <3.0.0" flutter: ">=3.0.0" dependencies: diff --git a/packages/camera/camera_platform_interface/test/types/image_group_test.dart b/packages/camera/camera_platform_interface/test/types/image_group_test.dart index 89585cc1ae3..fd6ce989486 100644 --- a/packages/camera/camera_platform_interface/test/types/image_group_test.dart +++ b/packages/camera/camera_platform_interface/test/types/image_group_test.dart @@ -11,6 +11,7 @@ void main() { expect(ImageFormatGroup.bgra8888.name(), 'bgra8888'); expect(ImageFormatGroup.yuv420.name(), 'yuv420'); expect(ImageFormatGroup.jpeg.name(), 'jpeg'); + expect(ImageFormatGroup.nv21.name(), 'nv21'); expect(ImageFormatGroup.unknown.name(), 'unknown'); }); });