Skip to content

Commit 7b2347e

Browse files
committed
Merge remote-tracking branch 'upstream/main' into handle_deprecated_radio_examples
2 parents 09df509 + e401aeb commit 7b2347e

File tree

33 files changed

+276
-111
lines changed

33 files changed

+276
-111
lines changed

.ci/flutter_master.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7811e8982355a88cb964671bd7d711b3a04540f0
1+
65aca3661b8fa943f801c4b2811af9d1e8e33dbe

packages/camera/camera/test/camera_preview_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class FakeController extends ValueNotifier<CameraValue>
1818
name: '',
1919
lensDirection: CameraLensDirection.back,
2020
sensorOrientation: 0,
21+
lensType: CameraLensType.ultraWide,
2122
);
2223

2324
@override

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.22
2+
3+
* Adds lensType in the PlatformCameraDescription
4+
15
## 0.9.21+4
26

37
* Migrates `updateOrientation` and `setCaptureSessionPreset` methods to Swift.

packages/camera/camera_avfoundation/example/ios/RunnerTests/Mocks/MockCaptureDevice.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MockCaptureDevice: NSObject, FLTCaptureDevice {
3232

3333
var uniqueID = ""
3434
var position = AVCaptureDevice.Position.unspecified
35+
var deviceType = AVCaptureDevice.DeviceType.builtInWideAngleCamera
3536

3637
var activeFormat: FLTCaptureDeviceFormat {
3738
get {

packages/camera/camera_avfoundation/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
# The example app is bundled with the plugin so we use a path dependency on
1515
# the parent directory to use the current plugin's version.
1616
path: ../
17-
camera_platform_interface: ^2.7.0
17+
camera_platform_interface: ^2.10.0
1818
flutter:
1919
sdk: flutter
2020
path_provider: ^2.0.0

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

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,22 +145,12 @@ extension CameraPlugin: FCPCameraApi {
145145
var reply: [FCPPlatformCameraDescription] = []
146146

147147
for device in devices {
148-
var lensFacing: FCPPlatformCameraLensDirection
149-
150-
switch device.position {
151-
case .back:
152-
lensFacing = .back
153-
case .front:
154-
lensFacing = .front
155-
case .unspecified:
156-
lensFacing = .external
157-
@unknown default:
158-
lensFacing = .external
159-
}
160-
148+
let lensFacing = strongSelf.platformLensDirection(for: device)
149+
let lensType = strongSelf.platformLensType(for: device)
161150
let cameraDescription = FCPPlatformCameraDescription.make(
162151
withName: device.uniqueID,
163-
lensDirection: lensFacing
152+
lensDirection: lensFacing,
153+
lensType: lensType
164154
)
165155
reply.append(cameraDescription)
166156
}
@@ -169,6 +159,35 @@ extension CameraPlugin: FCPCameraApi {
169159
}
170160
}
171161

162+
private func platformLensDirection(for device: FLTCaptureDevice) -> FCPPlatformCameraLensDirection
163+
{
164+
switch device.position {
165+
case .back:
166+
return .back
167+
case .front:
168+
return .front
169+
case .unspecified:
170+
return .external
171+
@unknown default:
172+
return .external
173+
}
174+
}
175+
176+
private func platformLensType(for device: FLTCaptureDevice) -> FCPPlatformCameraLensType {
177+
switch device.deviceType {
178+
case .builtInWideAngleCamera:
179+
return .wide
180+
case .builtInTelephotoCamera:
181+
return .telephoto
182+
case .builtInUltraWideCamera:
183+
return .ultraWide
184+
case .builtInDualWideCamera:
185+
return .wide
186+
default:
187+
return .unknown
188+
}
189+
}
190+
172191
public func createCamera(
173192
withName cameraName: String,
174193
settings: FCPPlatformMediaSettings,

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation_objc/FLTCaptureDevice.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ - (AVCaptureDevicePosition)position {
3030
return self.device.position;
3131
}
3232

33+
- (AVCaptureDeviceType)deviceType {
34+
return self.device.deviceType;
35+
}
36+
3337
// Format/Configuration
3438
- (NSObject<FLTCaptureDeviceFormat> *)activeFormat {
3539
return [[FLTDefaultCaptureDeviceFormat alloc] initWithFormat:self.device.activeFormat];

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation_objc/include/camera_avfoundation/FLTCaptureDevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ NS_ASSUME_NONNULL_BEGIN
2424
// Position/Orientation
2525
@property(nonatomic, readonly) AVCaptureDevicePosition position;
2626

27+
// Lens type
28+
@property(nonatomic, readonly) AVCaptureDeviceType deviceType;
29+
2730
// Format/Configuration
2831
@property(nonatomic, retain) NSObject<FLTCaptureDeviceFormat> *activeFormat;
2932
@property(nonatomic, readonly) NSArray<NSObject<FLTCaptureDeviceFormat> *> *formats;

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors
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.4.2), do not edit directly.
4+
// Autogenerated from Pigeon (v22.7.4), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
#import <Foundation/Foundation.h>
@@ -28,6 +28,23 @@ 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+
3148
typedef NS_ENUM(NSUInteger, FCPPlatformDeviceOrientation) {
3249
FCPPlatformDeviceOrientationPortraitUp = 0,
3350
FCPPlatformDeviceOrientationLandscapeLeft = 1,
@@ -124,11 +141,14 @@ typedef NS_ENUM(NSUInteger, FCPPlatformResolutionPreset) {
124141
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
125142
- (instancetype)init NS_UNAVAILABLE;
126143
+ (instancetype)makeWithName:(NSString *)name
127-
lensDirection:(FCPPlatformCameraLensDirection)lensDirection;
144+
lensDirection:(FCPPlatformCameraLensDirection)lensDirection
145+
lensType:(FCPPlatformCameraLensType)lensType;
128146
/// The name of the camera device.
129147
@property(nonatomic, copy) NSString *name;
130148
/// The direction the camera is facing.
131149
@property(nonatomic, assign) FCPPlatformCameraLensDirection lensDirection;
150+
/// The type of the camera lens.
151+
@property(nonatomic, assign) FCPPlatformCameraLensType lensType;
132152
@end
133153

134154
@interface FCPPlatformCameraState : NSObject

packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation_objc/messages.g.m

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2013 The Flutter Authors
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.4.2), do not edit directly.
4+
// Autogenerated from Pigeon (v22.7.4), do not edit directly.
55
// See also: https://pub.dev/packages/pigeon
66

77
#import "./include/camera_avfoundation/messages.g.h"
@@ -49,6 +49,16 @@ - (instancetype)initWithValue:(FCPPlatformCameraLensDirection)value {
4949
}
5050
@end
5151

52+
@implementation FCPPlatformCameraLensTypeBox
53+
- (instancetype)initWithValue:(FCPPlatformCameraLensType)value {
54+
self = [super init];
55+
if (self) {
56+
_value = value;
57+
}
58+
return self;
59+
}
60+
@end
61+
5262
@implementation FCPPlatformDeviceOrientationBox
5363
- (instancetype)initWithValue:(FCPPlatformDeviceOrientation)value {
5464
self = [super init];
@@ -152,10 +162,12 @@ + (nullable FCPPlatformSize *)nullableFromList:(NSArray<id> *)list;
152162

153163
@implementation FCPPlatformCameraDescription
154164
+ (instancetype)makeWithName:(NSString *)name
155-
lensDirection:(FCPPlatformCameraLensDirection)lensDirection {
165+
lensDirection:(FCPPlatformCameraLensDirection)lensDirection
166+
lensType:(FCPPlatformCameraLensType)lensType {
156167
FCPPlatformCameraDescription *pigeonResult = [[FCPPlatformCameraDescription alloc] init];
157168
pigeonResult.name = name;
158169
pigeonResult.lensDirection = lensDirection;
170+
pigeonResult.lensType = lensType;
159171
return pigeonResult;
160172
}
161173
+ (FCPPlatformCameraDescription *)fromList:(NSArray<id> *)list {
@@ -164,6 +176,8 @@ + (FCPPlatformCameraDescription *)fromList:(NSArray<id> *)list {
164176
FCPPlatformCameraLensDirectionBox *boxedFCPPlatformCameraLensDirection =
165177
GetNullableObjectAtIndex(list, 1);
166178
pigeonResult.lensDirection = boxedFCPPlatformCameraLensDirection.value;
179+
FCPPlatformCameraLensTypeBox *boxedFCPPlatformCameraLensType = GetNullableObjectAtIndex(list, 2);
180+
pigeonResult.lensType = boxedFCPPlatformCameraLensType.value;
167181
return pigeonResult;
168182
}
169183
+ (nullable FCPPlatformCameraDescription *)nullableFromList:(NSArray<id> *)list {
@@ -173,6 +187,7 @@ + (nullable FCPPlatformCameraDescription *)nullableFromList:(NSArray<id> *)list
173187
return @[
174188
self.name ?: [NSNull null],
175189
[[FCPPlatformCameraLensDirectionBox alloc] initWithValue:self.lensDirection],
190+
[[FCPPlatformCameraLensTypeBox alloc] initWithValue:self.lensType],
176191
];
177192
}
178193
@end
@@ -315,56 +330,62 @@ - (nullable id)readValueOfType:(UInt8)type {
315330
initWithValue:[enumAsNumber integerValue]];
316331
}
317332
case 130: {
333+
NSNumber *enumAsNumber = [self readValue];
334+
return enumAsNumber == nil
335+
? nil
336+
: [[FCPPlatformCameraLensTypeBox alloc] initWithValue:[enumAsNumber integerValue]];
337+
}
338+
case 131: {
318339
NSNumber *enumAsNumber = [self readValue];
319340
return enumAsNumber == nil ? nil
320341
: [[FCPPlatformDeviceOrientationBox alloc]
321342
initWithValue:[enumAsNumber integerValue]];
322343
}
323-
case 131: {
344+
case 132: {
324345
NSNumber *enumAsNumber = [self readValue];
325346
return enumAsNumber == nil
326347
? nil
327348
: [[FCPPlatformExposureModeBox alloc] initWithValue:[enumAsNumber integerValue]];
328349
}
329-
case 132: {
350+
case 133: {
330351
NSNumber *enumAsNumber = [self readValue];
331352
return enumAsNumber == nil
332353
? nil
333354
: [[FCPPlatformFlashModeBox alloc] initWithValue:[enumAsNumber integerValue]];
334355
}
335-
case 133: {
356+
case 134: {
336357
NSNumber *enumAsNumber = [self readValue];
337358
return enumAsNumber == nil
338359
? nil
339360
: [[FCPPlatformFocusModeBox alloc] initWithValue:[enumAsNumber integerValue]];
340361
}
341-
case 134: {
362+
case 135: {
342363
NSNumber *enumAsNumber = [self readValue];
343364
return enumAsNumber == nil ? nil
344365
: [[FCPPlatformImageFileFormatBox alloc]
345366
initWithValue:[enumAsNumber integerValue]];
346367
}
347-
case 135: {
368+
case 136: {
348369
NSNumber *enumAsNumber = [self readValue];
349370
return enumAsNumber == nil ? nil
350371
: [[FCPPlatformImageFormatGroupBox alloc]
351372
initWithValue:[enumAsNumber integerValue]];
352373
}
353-
case 136: {
374+
case 137: {
354375
NSNumber *enumAsNumber = [self readValue];
355376
return enumAsNumber == nil ? nil
356377
: [[FCPPlatformResolutionPresetBox alloc]
357378
initWithValue:[enumAsNumber integerValue]];
358379
}
359-
case 137:
360-
return [FCPPlatformCameraDescription fromList:[self readValue]];
361380
case 138:
362-
return [FCPPlatformCameraState fromList:[self readValue]];
381+
return [FCPPlatformCameraDescription fromList:[self readValue]];
363382
case 139:
364-
return [FCPPlatformMediaSettings fromList:[self readValue]];
383+
return [FCPPlatformCameraState fromList:[self readValue]];
365384
case 140:
366-
return [FCPPlatformPoint fromList:[self readValue]];
385+
return [FCPPlatformMediaSettings fromList:[self readValue]];
367386
case 141:
387+
return [FCPPlatformPoint fromList:[self readValue]];
388+
case 142:
368389
return [FCPPlatformSize fromList:[self readValue]];
369390
default:
370391
return [super readValueOfType:type];
@@ -380,48 +401,52 @@ - (void)writeValue:(id)value {
380401
FCPPlatformCameraLensDirectionBox *box = (FCPPlatformCameraLensDirectionBox *)value;
381402
[self writeByte:129];
382403
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
404+
} else if ([value isKindOfClass:[FCPPlatformCameraLensTypeBox class]]) {
405+
FCPPlatformCameraLensTypeBox *box = (FCPPlatformCameraLensTypeBox *)value;
406+
[self writeByte:130];
407+
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
383408
} else if ([value isKindOfClass:[FCPPlatformDeviceOrientationBox class]]) {
384409
FCPPlatformDeviceOrientationBox *box = (FCPPlatformDeviceOrientationBox *)value;
385-
[self writeByte:130];
410+
[self writeByte:131];
386411
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
387412
} else if ([value isKindOfClass:[FCPPlatformExposureModeBox class]]) {
388413
FCPPlatformExposureModeBox *box = (FCPPlatformExposureModeBox *)value;
389-
[self writeByte:131];
414+
[self writeByte:132];
390415
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
391416
} else if ([value isKindOfClass:[FCPPlatformFlashModeBox class]]) {
392417
FCPPlatformFlashModeBox *box = (FCPPlatformFlashModeBox *)value;
393-
[self writeByte:132];
418+
[self writeByte:133];
394419
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
395420
} else if ([value isKindOfClass:[FCPPlatformFocusModeBox class]]) {
396421
FCPPlatformFocusModeBox *box = (FCPPlatformFocusModeBox *)value;
397-
[self writeByte:133];
422+
[self writeByte:134];
398423
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
399424
} else if ([value isKindOfClass:[FCPPlatformImageFileFormatBox class]]) {
400425
FCPPlatformImageFileFormatBox *box = (FCPPlatformImageFileFormatBox *)value;
401-
[self writeByte:134];
426+
[self writeByte:135];
402427
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
403428
} else if ([value isKindOfClass:[FCPPlatformImageFormatGroupBox class]]) {
404429
FCPPlatformImageFormatGroupBox *box = (FCPPlatformImageFormatGroupBox *)value;
405-
[self writeByte:135];
430+
[self writeByte:136];
406431
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
407432
} else if ([value isKindOfClass:[FCPPlatformResolutionPresetBox class]]) {
408433
FCPPlatformResolutionPresetBox *box = (FCPPlatformResolutionPresetBox *)value;
409-
[self writeByte:136];
434+
[self writeByte:137];
410435
[self writeValue:(value == nil ? [NSNull null] : [NSNumber numberWithInteger:box.value])];
411436
} else if ([value isKindOfClass:[FCPPlatformCameraDescription class]]) {
412-
[self writeByte:137];
437+
[self writeByte:138];
413438
[self writeValue:[value toList]];
414439
} else if ([value isKindOfClass:[FCPPlatformCameraState class]]) {
415-
[self writeByte:138];
440+
[self writeByte:139];
416441
[self writeValue:[value toList]];
417442
} else if ([value isKindOfClass:[FCPPlatformMediaSettings class]]) {
418-
[self writeByte:139];
443+
[self writeByte:140];
419444
[self writeValue:[value toList]];
420445
} else if ([value isKindOfClass:[FCPPlatformPoint class]]) {
421-
[self writeByte:140];
446+
[self writeByte:141];
422447
[self writeValue:[value toList]];
423448
} else if ([value isKindOfClass:[FCPPlatformSize class]]) {
424-
[self writeByte:141];
449+
[self writeByte:142];
425450
[self writeValue:[value toList]];
426451
} else {
427452
[super writeValue:value];

0 commit comments

Comments
 (0)