-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove strong reference retain cycle from camera preview view mo…
…del (#135)
- Loading branch information
1 parent
83ac755
commit 930462b
Showing
2 changed files
with
36 additions
and
12 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Sources/FaceLiveness/Views/GetReadyPage/CameraPreviewOutputSampleBufferDelegate.swift
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,28 @@ | ||
// | ||
// Copyright Amazon.com Inc. or its affiliates. | ||
// All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import AVFoundation | ||
import CoreImage | ||
|
||
class CameraPreviewOutputSampleBufferDelegate: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate { | ||
|
||
let updateBufferHandler: ((CVImageBuffer) -> Void) | ||
|
||
init(_ updateBufferHandler: @escaping (CVImageBuffer) -> Void) { | ||
self.updateBufferHandler = updateBufferHandler | ||
} | ||
|
||
func captureOutput( | ||
_ output: AVCaptureOutput, | ||
didOutput sampleBuffer: CMSampleBuffer, | ||
from connection: AVCaptureConnection | ||
) { | ||
if let buffer = sampleBuffer.imageBuffer { | ||
updateBufferHandler(buffer) | ||
} | ||
} | ||
} |
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