This repository was 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
[camera]remove CAS operation and use dispatch queue instead #4973
Merged
fluttergithubbot
merged 4 commits into
flutter:main
from
hellohuanlin:camera_pixel_buffer
Mar 8, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
148f53a
[camera]remove cas operation and use dispatch queue instead
hellohuanlin 249fb9e
address some comments, mostly remove the util class
hellohuanlin f0878e9
[camera]inject capture session for unit test purpose
hellohuanlin 753cbad
[camera]address some nits
hellohuanlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.