This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[camera]remove CAS operation and use dispatch queue instead (#4973)
- Loading branch information
1 parent
b906ea5
commit 4e1c90e
Showing
12 changed files
with
166 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/camera/camera/example/ios/RunnerTests/CameraTestUtils.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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 camera; | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/// Creates an `FLTCam` that runs its capture session operations on a given queue. | ||
/// @param captureSessionQueue the capture session queue | ||
/// @return an FLTCam object. | ||
extern FLTCam *FLTCreateCamWithCaptureSessionQueue(dispatch_queue_t captureSessionQueue); | ||
|
||
/// Creates a test sample buffer. | ||
/// @return a test sample buffer. | ||
extern CMSampleBufferRef FLTCreateTestSampleBuffer(void); | ||
|
||
NS_ASSUME_NONNULL_END |
44 changes: 44 additions & 0 deletions
44
packages/camera/camera/example/ios/RunnerTests/CameraTestUtils.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// 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 "CameraTestUtils.h" | ||
#import <OCMock/OCMock.h> | ||
@import AVFoundation; | ||
|
||
FLTCam *FLTCreateCamWithCaptureSessionQueue(dispatch_queue_t captureSessionQueue) { | ||
id inputMock = OCMClassMock([AVCaptureDeviceInput class]); | ||
OCMStub([inputMock deviceInputWithDevice:[OCMArg any] error:[OCMArg setTo:nil]]) | ||
.andReturn(inputMock); | ||
|
||
id sessionMock = OCMClassMock([AVCaptureSession class]); | ||
OCMStub([sessionMock addInputWithNoConnections:[OCMArg any]]); // no-op | ||
OCMStub([sessionMock canSetSessionPreset:[OCMArg any]]).andReturn(YES); | ||
|
||
return [[FLTCam alloc] initWithCameraName:@"camera" | ||
resolutionPreset:@"medium" | ||
enableAudio:true | ||
orientation:UIDeviceOrientationPortrait | ||
captureSession:sessionMock | ||
captureSessionQueue:captureSessionQueue | ||
error:nil]; | ||
} | ||
|
||
CMSampleBufferRef FLTCreateTestSampleBuffer(void) { | ||
CVPixelBufferRef pixelBuffer; | ||
CVPixelBufferCreate(kCFAllocatorDefault, 100, 100, kCVPixelFormatType_32BGRA, NULL, &pixelBuffer); | ||
|
||
CMFormatDescriptionRef formatDescription; | ||
CMVideoFormatDescriptionCreateForImageBuffer(kCFAllocatorDefault, pixelBuffer, | ||
&formatDescription); | ||
|
||
CMSampleTimingInfo timingInfo = {CMTimeMake(1, 44100), kCMTimeZero, kCMTimeInvalid}; | ||
|
||
CMSampleBufferRef sampleBuffer; | ||
CMSampleBufferCreateReadyWithImageBuffer(kCFAllocatorDefault, pixelBuffer, formatDescription, | ||
&timingInfo, &sampleBuffer); | ||
|
||
CFRelease(pixelBuffer); | ||
CFRelease(formatDescription); | ||
return sampleBuffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.