Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dad18b9
add lens type info to camera plugin [ios-only]
lenzpaul Mar 6, 2025
a53858b
run pigeon generator
lenzpaul Mar 6, 2025
6b8fa07
Update tests
lenzpaul Mar 6, 2025
e0c743a
updated versions and Changelogs
lenzpaul Mar 6, 2025
78fbe47
adds dependency_overrides for federated plugin PR
lenzpaul Mar 6, 2025
2248a71
Add lens type information to camera plugin tests
lenzpaul Mar 6, 2025
0bbfd07
Add iOS version checks ensuring API availability for camera device types
lenzpaul Mar 6, 2025
5e347d7
Apply formatting fixes
lenzpaul Mar 6, 2025
989a270
created helper function for lens direction and type
lenzpaul Mar 6, 2025
ba8263a
Change lens type enum to only use UltraWide, Wide, and Telephoto
lenzpaul Mar 6, 2025
ae66e57
run pigeon gen and applied flutter_plugin_tools.dart formatting
lenzpaul Mar 6, 2025
ec472d7
Update CHANGELOG and Fix CI errors
lenzpaul Mar 6, 2025
9540ef7
Fix formatting for CI
lenzpaul Mar 6, 2025
5a3db31
Refactor camera lens direction and type handling in CameraPlugin
lenzpaul Mar 6, 2025
39aac3c
Fix documentation for camera lens type descriptions in messages.dart …
lenzpaul Mar 6, 2025
ec7f8f2
run format script
lenzpaul Mar 6, 2025
16f9fc4
Remove unnecessary pubspec changes
lenzpaul Mar 6, 2025
d2404a6
Remove temporary dependency overrides from pubspec.yaml files
lenzpaul Mar 6, 2025
697c023
Remove Runner changes
lenzpaul Mar 6, 2025
8aed9ea
Updates versions and CHANGELOGs. Runs pigeon generator
lenzpaul Mar 6, 2025
119beaa
Revert implementation changes in camera_avfoundation
lenzpaul Mar 6, 2025
e338f6f
Revert changes in camera pkg
lenzpaul Mar 6, 2025
93e2484
Updates CameraDescription tests to add toString and include lensType
lenzpaul Mar 7, 2025
77fe9da
Minor changelog adjustments
stuartmorgan-g Mar 7, 2025
8348878
Merge branch 'main' into camera_package_patch_2
stuartmorgan-g Mar 25, 2025
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
Prev Previous commit
Next Next commit
Revert implementation changes in camera_avfoundation
  • Loading branch information
lenzpaul committed Mar 6, 2025
commit 119beaaa7d58a32740eeb2292cfc56f387b4c38f
5 changes: 0 additions & 5 deletions packages/camera/camera_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## 0.9.19

* Adds lensType in the PlatformCameraDescription

## 0.9.18+9

* Backfills unit tests for `CameraPlugin` class.
Expand Down Expand Up @@ -60,7 +56,6 @@

* Updates Pigeon for non-nullable collection type support.
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
* Adds lensType in the PlatformCameraDescription

## 0.9.17+3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,6 @@
message:error.localizedDescription
details:error.domain];
}
static void FCPGetLensDirectionAndType(AVCaptureDevice *device,
FCPPlatformCameraLensDirection *lensDirection,
FCPPlatformCameraLensType *lensType) {
switch (device.position) {
case AVCaptureDevicePositionBack:
*lensDirection = FCPPlatformCameraLensDirectionBack;
break;
case AVCaptureDevicePositionFront:
*lensDirection = FCPPlatformCameraLensDirectionFront;
break;
case AVCaptureDevicePositionUnspecified:
*lensDirection = FCPPlatformCameraLensDirectionExternal;
break;
}

if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInWideAngleCamera]) {
*lensType = FCPPlatformCameraLensTypeWide;
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInTelephotoCamera]) {
*lensType = FCPPlatformCameraLensTypeTelephoto;
} else if (@available(iOS 13.0, *)) {
if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInUltraWideCamera]) {
*lensType = FCPPlatformCameraLensTypeUltraWide;
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInDualWideCamera]) {
*lensType = FCPPlatformCameraLensTypeWide;
} else {
*lensType = FCPPlatformCameraLensTypeUnknown;
}
} else {
*lensType = FCPPlatformCameraLensTypeUnknown;
}
}

@interface CameraPlugin ()
@property(readonly, nonatomic) NSObject<FlutterTextureRegistry> *registry;
Expand Down Expand Up @@ -181,12 +150,19 @@ - (void)availableCamerasWithCompletion:
[[NSMutableArray alloc] initWithCapacity:devices.count];
for (NSObject<FLTCaptureDevice> *device in devices) {
FCPPlatformCameraLensDirection lensFacing;
FCPPlatformCameraLensType lensType;
FCPGetLensDirectionAndType(device, &lensFacing, &lensType);

switch (device.position) {
case AVCaptureDevicePositionBack:
lensFacing = FCPPlatformCameraLensDirectionBack;
break;
case AVCaptureDevicePositionFront:
lensFacing = FCPPlatformCameraLensDirectionFront;
break;
case AVCaptureDevicePositionUnspecified:
lensFacing = FCPPlatformCameraLensDirectionExternal;
break;
}
[reply addObject:[FCPPlatformCameraDescription makeWithName:device.uniqueID
lensDirection:lensFacing
lensType:lensType]];
lensDirection:lensFacing]];
}
completion(reply, nil);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
NS_ASSUME_NONNULL_BEGIN

/// Queue-specific context data to be associated with the capture session queue.
extern const char *FLTCaptureSessionQueueSpecific;
extern const char* FLTCaptureSessionQueueSpecific;

/// Ensures the given block to be run on the main queue.
/// If caller site is already on the main queue, the block will be run
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 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.
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
// Autogenerated from Pigeon (v22.4.2), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand All @@ -28,23 +28,6 @@ typedef NS_ENUM(NSUInteger, FCPPlatformCameraLensDirection) {
- (instancetype)initWithValue:(FCPPlatformCameraLensDirection)value;
@end

typedef NS_ENUM(NSUInteger, FCPPlatformCameraLensType) {
/// A built-in wide-angle camera device type.
FCPPlatformCameraLensTypeWide = 0,
/// A built-in camera device type with a longer focal length than a wide-angle camera.
FCPPlatformCameraLensTypeTelephoto = 1,
/// A built-in camera device type with a shorter focal length than a wide-angle camera.
FCPPlatformCameraLensTypeUltraWide = 2,
/// Unknown camera device type.
FCPPlatformCameraLensTypeUnknown = 3,
};

/// Wrapper for FCPPlatformCameraLensType to allow for nullability.
@interface FCPPlatformCameraLensTypeBox : NSObject
@property(nonatomic, assign) FCPPlatformCameraLensType value;
- (instancetype)initWithValue:(FCPPlatformCameraLensType)value;
@end

typedef NS_ENUM(NSUInteger, FCPPlatformDeviceOrientation) {
FCPPlatformDeviceOrientationPortraitUp = 0,
FCPPlatformDeviceOrientationLandscapeLeft = 1,
Expand Down Expand Up @@ -141,79 +124,79 @@ typedef NS_ENUM(NSUInteger, FCPPlatformResolutionPreset) {
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithName:(NSString *)name
lensDirection:(FCPPlatformCameraLensDirection)lensDirection
lensType:(FCPPlatformCameraLensType)lensType;
lensDirection:(FCPPlatformCameraLensDirection)lensDirection;
/// The name of the camera device.
@property(nonatomic, copy) NSString * name;
@property(nonatomic, copy) NSString *name;
/// The direction the camera is facing.
@property(nonatomic, assign) FCPPlatformCameraLensDirection lensDirection;
/// The type of the camera lens.
@property(nonatomic, assign) FCPPlatformCameraLensType lensType;
@end

@interface FCPPlatformCameraState : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithPreviewSize:(FCPPlatformSize *)previewSize
exposureMode:(FCPPlatformExposureMode)exposureMode
focusMode:(FCPPlatformFocusMode)focusMode
exposurePointSupported:(BOOL )exposurePointSupported
focusPointSupported:(BOOL )focusPointSupported;
exposureMode:(FCPPlatformExposureMode)exposureMode
focusMode:(FCPPlatformFocusMode)focusMode
exposurePointSupported:(BOOL)exposurePointSupported
focusPointSupported:(BOOL)focusPointSupported;
/// The size of the preview, in pixels.
@property(nonatomic, strong) FCPPlatformSize * previewSize;
@property(nonatomic, strong) FCPPlatformSize *previewSize;
/// The default exposure mode
@property(nonatomic, assign) FCPPlatformExposureMode exposureMode;
/// The default focus mode
@property(nonatomic, assign) FCPPlatformFocusMode focusMode;
/// Whether setting exposure points is supported.
@property(nonatomic, assign) BOOL exposurePointSupported;
@property(nonatomic, assign) BOOL exposurePointSupported;
/// Whether setting focus points is supported.
@property(nonatomic, assign) BOOL focusPointSupported;
@property(nonatomic, assign) BOOL focusPointSupported;
@end

@interface FCPPlatformMediaSettings : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithResolutionPreset:(FCPPlatformResolutionPreset)resolutionPreset
framesPerSecond:(nullable NSNumber *)framesPerSecond
videoBitrate:(nullable NSNumber *)videoBitrate
audioBitrate:(nullable NSNumber *)audioBitrate
enableAudio:(BOOL )enableAudio;
framesPerSecond:(nullable NSNumber *)framesPerSecond
videoBitrate:(nullable NSNumber *)videoBitrate
audioBitrate:(nullable NSNumber *)audioBitrate
enableAudio:(BOOL)enableAudio;
@property(nonatomic, assign) FCPPlatformResolutionPreset resolutionPreset;
@property(nonatomic, strong, nullable) NSNumber * framesPerSecond;
@property(nonatomic, strong, nullable) NSNumber * videoBitrate;
@property(nonatomic, strong, nullable) NSNumber * audioBitrate;
@property(nonatomic, assign) BOOL enableAudio;
@property(nonatomic, strong, nullable) NSNumber *framesPerSecond;
@property(nonatomic, strong, nullable) NSNumber *videoBitrate;
@property(nonatomic, strong, nullable) NSNumber *audioBitrate;
@property(nonatomic, assign) BOOL enableAudio;
@end

@interface FCPPlatformPoint : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithX:(double )x
y:(double )y;
@property(nonatomic, assign) double x;
@property(nonatomic, assign) double y;
+ (instancetype)makeWithX:(double)x y:(double)y;
@property(nonatomic, assign) double x;
@property(nonatomic, assign) double y;
@end

@interface FCPPlatformSize : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithWidth:(double )width
height:(double )height;
@property(nonatomic, assign) double width;
@property(nonatomic, assign) double height;
+ (instancetype)makeWithWidth:(double)width height:(double)height;
@property(nonatomic, assign) double width;
@property(nonatomic, assign) double height;
@end

/// The codec used by all APIs.
NSObject<FlutterMessageCodec> *FCPGetMessagesCodec(void);

@protocol FCPCameraApi
/// Returns the list of available cameras.
- (void)availableCamerasWithCompletion:(void (^)(NSArray<FCPPlatformCameraDescription *> *_Nullable, FlutterError *_Nullable))completion;
- (void)availableCamerasWithCompletion:(void (^)(NSArray<FCPPlatformCameraDescription *> *_Nullable,
FlutterError *_Nullable))completion;
/// Create a new camera with the given settings, and returns its ID.
- (void)createCameraWithName:(NSString *)cameraName settings:(FCPPlatformMediaSettings *)settings completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
- (void)createCameraWithName:(NSString *)cameraName
settings:(FCPPlatformMediaSettings *)settings
completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
/// Initializes the camera with the given ID.
- (void)initializeCamera:(NSInteger)cameraId withImageFormat:(FCPPlatformImageFormatGroup)imageFormat completion:(void (^)(FlutterError *_Nullable))completion;
- (void)initializeCamera:(NSInteger)cameraId
withImageFormat:(FCPPlatformImageFormatGroup)imageFormat
completion:(void (^)(FlutterError *_Nullable))completion;
/// Begins streaming frames from the camera.
- (void)startImageStreamWithCompletion:(void (^)(FlutterError *_Nullable))completion;
/// Stops streaming frames from the camera.
Expand All @@ -227,44 +210,53 @@ NSObject<FlutterMessageCodec> *FCPGetMessagesCodec(void);
/// and any associated resources can be cleaned up.
- (void)disposeCamera:(NSInteger)cameraId completion:(void (^)(FlutterError *_Nullable))completion;
/// Locks the camera capture to the current device orientation.
- (void)lockCaptureOrientation:(FCPPlatformDeviceOrientation)orientation completion:(void (^)(FlutterError *_Nullable))completion;
- (void)lockCaptureOrientation:(FCPPlatformDeviceOrientation)orientation
completion:(void (^)(FlutterError *_Nullable))completion;
/// Unlocks camera capture orientation, allowing it to automatically adapt to
/// device orientation.
- (void)unlockCaptureOrientationWithCompletion:(void (^)(FlutterError *_Nullable))completion;
/// Takes a picture with the current settings, and returns the path to the
/// resulting file.
- (void)takePictureWithCompletion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
- (void)takePictureWithCompletion:(void (^)(NSString *_Nullable,
FlutterError *_Nullable))completion;
/// Does any preprocessing necessary before beginning to record video.
- (void)prepareForVideoRecordingWithCompletion:(void (^)(FlutterError *_Nullable))completion;
/// Begins recording video, optionally enabling streaming to Dart at the same
/// time.
- (void)startVideoRecordingWithStreaming:(BOOL)enableStream completion:(void (^)(FlutterError *_Nullable))completion;
- (void)startVideoRecordingWithStreaming:(BOOL)enableStream
completion:(void (^)(FlutterError *_Nullable))completion;
/// Stops recording video, and results the path to the resulting file.
- (void)stopVideoRecordingWithCompletion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
- (void)stopVideoRecordingWithCompletion:(void (^)(NSString *_Nullable,
FlutterError *_Nullable))completion;
/// Pauses video recording.
- (void)pauseVideoRecordingWithCompletion:(void (^)(FlutterError *_Nullable))completion;
/// Resumes a previously paused video recording.
- (void)resumeVideoRecordingWithCompletion:(void (^)(FlutterError *_Nullable))completion;
/// Switches the camera to the given flash mode.
- (void)setFlashMode:(FCPPlatformFlashMode)mode completion:(void (^)(FlutterError *_Nullable))completion;
- (void)setFlashMode:(FCPPlatformFlashMode)mode
completion:(void (^)(FlutterError *_Nullable))completion;
/// Switches the camera to the given exposure mode.
- (void)setExposureMode:(FCPPlatformExposureMode)mode completion:(void (^)(FlutterError *_Nullable))completion;
- (void)setExposureMode:(FCPPlatformExposureMode)mode
completion:(void (^)(FlutterError *_Nullable))completion;
/// Anchors auto-exposure to the given point in (0,1) coordinate space.
///
/// A null value resets to the default exposure point.
- (void)setExposurePoint:(nullable FCPPlatformPoint *)point completion:(void (^)(FlutterError *_Nullable))completion;
- (void)setExposurePoint:(nullable FCPPlatformPoint *)point
completion:(void (^)(FlutterError *_Nullable))completion;
/// Returns the minimum exposure offset supported by the camera.
- (void)getMinimumExposureOffset:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
/// Returns the maximum exposure offset supported by the camera.
- (void)getMaximumExposureOffset:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
/// Sets the exposure offset manually to the given value.
- (void)setExposureOffset:(double)offset completion:(void (^)(FlutterError *_Nullable))completion;
/// Switches the camera to the given focus mode.
- (void)setFocusMode:(FCPPlatformFocusMode)mode completion:(void (^)(FlutterError *_Nullable))completion;
- (void)setFocusMode:(FCPPlatformFocusMode)mode
completion:(void (^)(FlutterError *_Nullable))completion;
/// Anchors auto-focus to the given point in (0,1) coordinate space.
///
/// A null value resets to the default focus point.
- (void)setFocusPoint:(nullable FCPPlatformPoint *)point completion:(void (^)(FlutterError *_Nullable))completion;
- (void)setFocusPoint:(nullable FCPPlatformPoint *)point
completion:(void (^)(FlutterError *_Nullable))completion;
/// Returns the minimum zoom level supported by the camera.
- (void)getMinimumZoomLevel:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
/// Returns the maximum zoom level supported by the camera.
Expand All @@ -278,33 +270,40 @@ NSObject<FlutterMessageCodec> *FCPGetMessagesCodec(void);
/// Changes the camera used while recording video.
///
/// This should only be called while video recording is active.
- (void)updateDescriptionWhileRecordingCameraName:(NSString *)cameraName completion:(void (^)(FlutterError *_Nullable))completion;
- (void)updateDescriptionWhileRecordingCameraName:(NSString *)cameraName
completion:(void (^)(FlutterError *_Nullable))completion;
/// Sets the file format used for taking pictures.
- (void)setImageFileFormat:(FCPPlatformImageFileFormat)format completion:(void (^)(FlutterError *_Nullable))completion;
- (void)setImageFileFormat:(FCPPlatformImageFileFormat)format
completion:(void (^)(FlutterError *_Nullable))completion;
@end

extern void SetUpFCPCameraApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FCPCameraApi> *_Nullable api);

extern void SetUpFCPCameraApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FCPCameraApi> *_Nullable api, NSString *messageChannelSuffix);
extern void SetUpFCPCameraApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FCPCameraApi> *_Nullable api);

extern void SetUpFCPCameraApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FCPCameraApi> *_Nullable api,
NSString *messageChannelSuffix);

/// Handler for native callbacks that are not tied to a specific camera ID.
@interface FCPCameraGlobalEventApi : NSObject
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger messageChannelSuffix:(nullable NSString *)messageChannelSuffix;
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger
messageChannelSuffix:(nullable NSString *)messageChannelSuffix;
/// Called when the device's physical orientation changes.
- (void)deviceOrientationChangedOrientation:(FCPPlatformDeviceOrientation)orientation completion:(void (^)(FlutterError *_Nullable))completion;
- (void)deviceOrientationChangedOrientation:(FCPPlatformDeviceOrientation)orientation
completion:(void (^)(FlutterError *_Nullable))completion;
@end


/// Handler for native callbacks that are tied to a specific camera ID.
///
/// This is intended to be initialized with the camera ID as a suffix.
@interface FCPCameraEventApi : NSObject
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger messageChannelSuffix:(nullable NSString *)messageChannelSuffix;
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger
messageChannelSuffix:(nullable NSString *)messageChannelSuffix;
/// Called when the camera is inialitized for use.
- (void)initializedWithState:(FCPPlatformCameraState *)initialState completion:(void (^)(FlutterError *_Nullable))completion;
- (void)initializedWithState:(FCPPlatformCameraState *)initialState
completion:(void (^)(FlutterError *_Nullable))completion;
/// Called when an error occurs in the camera.
///
/// This should be used for errors that occur outside of the context of
Expand Down
Loading