Skip to content

Commit 119beaa

Browse files
committed
Revert implementation changes in camera_avfoundation
1 parent 8aed9ea commit 119beaa

File tree

10 files changed

+821
-627
lines changed

10 files changed

+821
-627
lines changed

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
## 0.9.19
2-
3-
* Adds lensType in the PlatformCameraDescription
4-
51
## 0.9.18+9
62

73
* Backfills unit tests for `CameraPlugin` class.
@@ -60,7 +56,6 @@
6056

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

6560
## 0.9.17+3
6661

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraPlugin.m

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,6 @@
2121
message:error.localizedDescription
2222
details:error.domain];
2323
}
24-
static void FCPGetLensDirectionAndType(AVCaptureDevice *device,
25-
FCPPlatformCameraLensDirection *lensDirection,
26-
FCPPlatformCameraLensType *lensType) {
27-
switch (device.position) {
28-
case AVCaptureDevicePositionBack:
29-
*lensDirection = FCPPlatformCameraLensDirectionBack;
30-
break;
31-
case AVCaptureDevicePositionFront:
32-
*lensDirection = FCPPlatformCameraLensDirectionFront;
33-
break;
34-
case AVCaptureDevicePositionUnspecified:
35-
*lensDirection = FCPPlatformCameraLensDirectionExternal;
36-
break;
37-
}
38-
39-
if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInWideAngleCamera]) {
40-
*lensType = FCPPlatformCameraLensTypeWide;
41-
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInTelephotoCamera]) {
42-
*lensType = FCPPlatformCameraLensTypeTelephoto;
43-
} else if (@available(iOS 13.0, *)) {
44-
if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInUltraWideCamera]) {
45-
*lensType = FCPPlatformCameraLensTypeUltraWide;
46-
} else if ([device.deviceType isEqualToString:AVCaptureDeviceTypeBuiltInDualWideCamera]) {
47-
*lensType = FCPPlatformCameraLensTypeWide;
48-
} else {
49-
*lensType = FCPPlatformCameraLensTypeUnknown;
50-
}
51-
} else {
52-
*lensType = FCPPlatformCameraLensTypeUnknown;
53-
}
54-
}
5524

5625
@interface CameraPlugin ()
5726
@property(readonly, nonatomic) NSObject<FlutterTextureRegistry> *registry;
@@ -181,12 +150,19 @@ - (void)availableCamerasWithCompletion:
181150
[[NSMutableArray alloc] initWithCapacity:devices.count];
182151
for (NSObject<FLTCaptureDevice> *device in devices) {
183152
FCPPlatformCameraLensDirection lensFacing;
184-
FCPPlatformCameraLensType lensType;
185-
FCPGetLensDirectionAndType(device, &lensFacing, &lensType);
186-
153+
switch (device.position) {
154+
case AVCaptureDevicePositionBack:
155+
lensFacing = FCPPlatformCameraLensDirectionBack;
156+
break;
157+
case AVCaptureDevicePositionFront:
158+
lensFacing = FCPPlatformCameraLensDirectionFront;
159+
break;
160+
case AVCaptureDevicePositionUnspecified:
161+
lensFacing = FCPPlatformCameraLensDirectionExternal;
162+
break;
163+
}
187164
[reply addObject:[FCPPlatformCameraDescription makeWithName:device.uniqueID
188-
lensDirection:lensFacing
189-
lensType:lensType]];
165+
lensDirection:lensFacing]];
190166
}
191167
completion(reply, nil);
192168
});

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/QueueUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
NS_ASSUME_NONNULL_BEGIN
88

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

1212
/// Ensures the given block to be run on the main queue.
1313
/// If caller site is already on the main queue, the block will be run

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/include/camera_avfoundation/messages.g.h

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4-
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
4+
// Autogenerated from Pigeon (v22.4.2), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

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

31-
typedef NS_ENUM(NSUInteger, FCPPlatformCameraLensType) {
32-
/// A built-in wide-angle camera device type.
33-
FCPPlatformCameraLensTypeWide = 0,
34-
/// A built-in camera device type with a longer focal length than a wide-angle camera.
35-
FCPPlatformCameraLensTypeTelephoto = 1,
36-
/// A built-in camera device type with a shorter focal length than a wide-angle camera.
37-
FCPPlatformCameraLensTypeUltraWide = 2,
38-
/// Unknown camera device type.
39-
FCPPlatformCameraLensTypeUnknown = 3,
40-
};
41-
42-
/// Wrapper for FCPPlatformCameraLensType to allow for nullability.
43-
@interface FCPPlatformCameraLensTypeBox : NSObject
44-
@property(nonatomic, assign) FCPPlatformCameraLensType value;
45-
- (instancetype)initWithValue:(FCPPlatformCameraLensType)value;
46-
@end
47-
4831
typedef NS_ENUM(NSUInteger, FCPPlatformDeviceOrientation) {
4932
FCPPlatformDeviceOrientationPortraitUp = 0,
5033
FCPPlatformDeviceOrientationLandscapeLeft = 1,
@@ -141,79 +124,79 @@ typedef NS_ENUM(NSUInteger, FCPPlatformResolutionPreset) {
141124
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
142125
- (instancetype)init NS_UNAVAILABLE;
143126
+ (instancetype)makeWithName:(NSString *)name
144-
lensDirection:(FCPPlatformCameraLensDirection)lensDirection
145-
lensType:(FCPPlatformCameraLensType)lensType;
127+
lensDirection:(FCPPlatformCameraLensDirection)lensDirection;
146128
/// The name of the camera device.
147-
@property(nonatomic, copy) NSString * name;
129+
@property(nonatomic, copy) NSString *name;
148130
/// The direction the camera is facing.
149131
@property(nonatomic, assign) FCPPlatformCameraLensDirection lensDirection;
150-
/// The type of the camera lens.
151-
@property(nonatomic, assign) FCPPlatformCameraLensType lensType;
152132
@end
153133

154134
@interface FCPPlatformCameraState : NSObject
155135
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
156136
- (instancetype)init NS_UNAVAILABLE;
157137
+ (instancetype)makeWithPreviewSize:(FCPPlatformSize *)previewSize
158-
exposureMode:(FCPPlatformExposureMode)exposureMode
159-
focusMode:(FCPPlatformFocusMode)focusMode
160-
exposurePointSupported:(BOOL )exposurePointSupported
161-
focusPointSupported:(BOOL )focusPointSupported;
138+
exposureMode:(FCPPlatformExposureMode)exposureMode
139+
focusMode:(FCPPlatformFocusMode)focusMode
140+
exposurePointSupported:(BOOL)exposurePointSupported
141+
focusPointSupported:(BOOL)focusPointSupported;
162142
/// The size of the preview, in pixels.
163-
@property(nonatomic, strong) FCPPlatformSize * previewSize;
143+
@property(nonatomic, strong) FCPPlatformSize *previewSize;
164144
/// The default exposure mode
165145
@property(nonatomic, assign) FCPPlatformExposureMode exposureMode;
166146
/// The default focus mode
167147
@property(nonatomic, assign) FCPPlatformFocusMode focusMode;
168148
/// Whether setting exposure points is supported.
169-
@property(nonatomic, assign) BOOL exposurePointSupported;
149+
@property(nonatomic, assign) BOOL exposurePointSupported;
170150
/// Whether setting focus points is supported.
171-
@property(nonatomic, assign) BOOL focusPointSupported;
151+
@property(nonatomic, assign) BOOL focusPointSupported;
172152
@end
173153

174154
@interface FCPPlatformMediaSettings : NSObject
175155
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
176156
- (instancetype)init NS_UNAVAILABLE;
177157
+ (instancetype)makeWithResolutionPreset:(FCPPlatformResolutionPreset)resolutionPreset
178-
framesPerSecond:(nullable NSNumber *)framesPerSecond
179-
videoBitrate:(nullable NSNumber *)videoBitrate
180-
audioBitrate:(nullable NSNumber *)audioBitrate
181-
enableAudio:(BOOL )enableAudio;
158+
framesPerSecond:(nullable NSNumber *)framesPerSecond
159+
videoBitrate:(nullable NSNumber *)videoBitrate
160+
audioBitrate:(nullable NSNumber *)audioBitrate
161+
enableAudio:(BOOL)enableAudio;
182162
@property(nonatomic, assign) FCPPlatformResolutionPreset resolutionPreset;
183-
@property(nonatomic, strong, nullable) NSNumber * framesPerSecond;
184-
@property(nonatomic, strong, nullable) NSNumber * videoBitrate;
185-
@property(nonatomic, strong, nullable) NSNumber * audioBitrate;
186-
@property(nonatomic, assign) BOOL enableAudio;
163+
@property(nonatomic, strong, nullable) NSNumber *framesPerSecond;
164+
@property(nonatomic, strong, nullable) NSNumber *videoBitrate;
165+
@property(nonatomic, strong, nullable) NSNumber *audioBitrate;
166+
@property(nonatomic, assign) BOOL enableAudio;
187167
@end
188168

189169
@interface FCPPlatformPoint : NSObject
190170
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
191171
- (instancetype)init NS_UNAVAILABLE;
192-
+ (instancetype)makeWithX:(double )x
193-
y:(double )y;
194-
@property(nonatomic, assign) double x;
195-
@property(nonatomic, assign) double y;
172+
+ (instancetype)makeWithX:(double)x y:(double)y;
173+
@property(nonatomic, assign) double x;
174+
@property(nonatomic, assign) double y;
196175
@end
197176

198177
@interface FCPPlatformSize : NSObject
199178
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
200179
- (instancetype)init NS_UNAVAILABLE;
201-
+ (instancetype)makeWithWidth:(double )width
202-
height:(double )height;
203-
@property(nonatomic, assign) double width;
204-
@property(nonatomic, assign) double height;
180+
+ (instancetype)makeWithWidth:(double)width height:(double)height;
181+
@property(nonatomic, assign) double width;
182+
@property(nonatomic, assign) double height;
205183
@end
206184

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

210188
@protocol FCPCameraApi
211189
/// Returns the list of available cameras.
212-
- (void)availableCamerasWithCompletion:(void (^)(NSArray<FCPPlatformCameraDescription *> *_Nullable, FlutterError *_Nullable))completion;
190+
- (void)availableCamerasWithCompletion:(void (^)(NSArray<FCPPlatformCameraDescription *> *_Nullable,
191+
FlutterError *_Nullable))completion;
213192
/// Create a new camera with the given settings, and returns its ID.
214-
- (void)createCameraWithName:(NSString *)cameraName settings:(FCPPlatformMediaSettings *)settings completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
193+
- (void)createCameraWithName:(NSString *)cameraName
194+
settings:(FCPPlatformMediaSettings *)settings
195+
completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
215196
/// Initializes the camera with the given ID.
216-
- (void)initializeCamera:(NSInteger)cameraId withImageFormat:(FCPPlatformImageFormatGroup)imageFormat completion:(void (^)(FlutterError *_Nullable))completion;
197+
- (void)initializeCamera:(NSInteger)cameraId
198+
withImageFormat:(FCPPlatformImageFormatGroup)imageFormat
199+
completion:(void (^)(FlutterError *_Nullable))completion;
217200
/// Begins streaming frames from the camera.
218201
- (void)startImageStreamWithCompletion:(void (^)(FlutterError *_Nullable))completion;
219202
/// Stops streaming frames from the camera.
@@ -227,44 +210,53 @@ NSObject<FlutterMessageCodec> *FCPGetMessagesCodec(void);
227210
/// and any associated resources can be cleaned up.
228211
- (void)disposeCamera:(NSInteger)cameraId completion:(void (^)(FlutterError *_Nullable))completion;
229212
/// Locks the camera capture to the current device orientation.
230-
- (void)lockCaptureOrientation:(FCPPlatformDeviceOrientation)orientation completion:(void (^)(FlutterError *_Nullable))completion;
213+
- (void)lockCaptureOrientation:(FCPPlatformDeviceOrientation)orientation
214+
completion:(void (^)(FlutterError *_Nullable))completion;
231215
/// Unlocks camera capture orientation, allowing it to automatically adapt to
232216
/// device orientation.
233217
- (void)unlockCaptureOrientationWithCompletion:(void (^)(FlutterError *_Nullable))completion;
234218
/// Takes a picture with the current settings, and returns the path to the
235219
/// resulting file.
236-
- (void)takePictureWithCompletion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
220+
- (void)takePictureWithCompletion:(void (^)(NSString *_Nullable,
221+
FlutterError *_Nullable))completion;
237222
/// Does any preprocessing necessary before beginning to record video.
238223
- (void)prepareForVideoRecordingWithCompletion:(void (^)(FlutterError *_Nullable))completion;
239224
/// Begins recording video, optionally enabling streaming to Dart at the same
240225
/// time.
241-
- (void)startVideoRecordingWithStreaming:(BOOL)enableStream completion:(void (^)(FlutterError *_Nullable))completion;
226+
- (void)startVideoRecordingWithStreaming:(BOOL)enableStream
227+
completion:(void (^)(FlutterError *_Nullable))completion;
242228
/// Stops recording video, and results the path to the resulting file.
243-
- (void)stopVideoRecordingWithCompletion:(void (^)(NSString *_Nullable, FlutterError *_Nullable))completion;
229+
- (void)stopVideoRecordingWithCompletion:(void (^)(NSString *_Nullable,
230+
FlutterError *_Nullable))completion;
244231
/// Pauses video recording.
245232
- (void)pauseVideoRecordingWithCompletion:(void (^)(FlutterError *_Nullable))completion;
246233
/// Resumes a previously paused video recording.
247234
- (void)resumeVideoRecordingWithCompletion:(void (^)(FlutterError *_Nullable))completion;
248235
/// Switches the camera to the given flash mode.
249-
- (void)setFlashMode:(FCPPlatformFlashMode)mode completion:(void (^)(FlutterError *_Nullable))completion;
236+
- (void)setFlashMode:(FCPPlatformFlashMode)mode
237+
completion:(void (^)(FlutterError *_Nullable))completion;
250238
/// Switches the camera to the given exposure mode.
251-
- (void)setExposureMode:(FCPPlatformExposureMode)mode completion:(void (^)(FlutterError *_Nullable))completion;
239+
- (void)setExposureMode:(FCPPlatformExposureMode)mode
240+
completion:(void (^)(FlutterError *_Nullable))completion;
252241
/// Anchors auto-exposure to the given point in (0,1) coordinate space.
253242
///
254243
/// A null value resets to the default exposure point.
255-
- (void)setExposurePoint:(nullable FCPPlatformPoint *)point completion:(void (^)(FlutterError *_Nullable))completion;
244+
- (void)setExposurePoint:(nullable FCPPlatformPoint *)point
245+
completion:(void (^)(FlutterError *_Nullable))completion;
256246
/// Returns the minimum exposure offset supported by the camera.
257247
- (void)getMinimumExposureOffset:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
258248
/// Returns the maximum exposure offset supported by the camera.
259249
- (void)getMaximumExposureOffset:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
260250
/// Sets the exposure offset manually to the given value.
261251
- (void)setExposureOffset:(double)offset completion:(void (^)(FlutterError *_Nullable))completion;
262252
/// Switches the camera to the given focus mode.
263-
- (void)setFocusMode:(FCPPlatformFocusMode)mode completion:(void (^)(FlutterError *_Nullable))completion;
253+
- (void)setFocusMode:(FCPPlatformFocusMode)mode
254+
completion:(void (^)(FlutterError *_Nullable))completion;
264255
/// Anchors auto-focus to the given point in (0,1) coordinate space.
265256
///
266257
/// A null value resets to the default focus point.
267-
- (void)setFocusPoint:(nullable FCPPlatformPoint *)point completion:(void (^)(FlutterError *_Nullable))completion;
258+
- (void)setFocusPoint:(nullable FCPPlatformPoint *)point
259+
completion:(void (^)(FlutterError *_Nullable))completion;
268260
/// Returns the minimum zoom level supported by the camera.
269261
- (void)getMinimumZoomLevel:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
270262
/// Returns the maximum zoom level supported by the camera.
@@ -278,33 +270,40 @@ NSObject<FlutterMessageCodec> *FCPGetMessagesCodec(void);
278270
/// Changes the camera used while recording video.
279271
///
280272
/// This should only be called while video recording is active.
281-
- (void)updateDescriptionWhileRecordingCameraName:(NSString *)cameraName completion:(void (^)(FlutterError *_Nullable))completion;
273+
- (void)updateDescriptionWhileRecordingCameraName:(NSString *)cameraName
274+
completion:(void (^)(FlutterError *_Nullable))completion;
282275
/// Sets the file format used for taking pictures.
283-
- (void)setImageFileFormat:(FCPPlatformImageFileFormat)format completion:(void (^)(FlutterError *_Nullable))completion;
276+
- (void)setImageFileFormat:(FCPPlatformImageFileFormat)format
277+
completion:(void (^)(FlutterError *_Nullable))completion;
284278
@end
285279

286-
extern void SetUpFCPCameraApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FCPCameraApi> *_Nullable api);
287-
288-
extern void SetUpFCPCameraApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger, NSObject<FCPCameraApi> *_Nullable api, NSString *messageChannelSuffix);
280+
extern void SetUpFCPCameraApi(id<FlutterBinaryMessenger> binaryMessenger,
281+
NSObject<FCPCameraApi> *_Nullable api);
289282

283+
extern void SetUpFCPCameraApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger,
284+
NSObject<FCPCameraApi> *_Nullable api,
285+
NSString *messageChannelSuffix);
290286

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

299-
300297
/// Handler for native callbacks that are tied to a specific camera ID.
301298
///
302299
/// This is intended to be initialized with the camera ID as a suffix.
303300
@interface FCPCameraEventApi : NSObject
304301
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger;
305-
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger messageChannelSuffix:(nullable NSString *)messageChannelSuffix;
302+
- (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)binaryMessenger
303+
messageChannelSuffix:(nullable NSString *)messageChannelSuffix;
306304
/// Called when the camera is inialitized for use.
307-
- (void)initializedWithState:(FCPPlatformCameraState *)initialState completion:(void (^)(FlutterError *_Nullable))completion;
305+
- (void)initializedWithState:(FCPPlatformCameraState *)initialState
306+
completion:(void (^)(FlutterError *_Nullable))completion;
308307
/// Called when an error occurs in the camera.
309308
///
310309
/// This should be used for errors that occur outside of the context of

0 commit comments

Comments
 (0)