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
| public func flipCamera() { | |
| sessionQueue.async { [unowned self] in | |
| self.captureSession.beginConfiguration() | |
| guard let currentCaptureInput = self.captureSession.inputs.first as? AVCaptureInput else { return } | |
| self.captureSession.removeInput(currentCaptureInput) | |
| guard let currentCaptureOutput = self.captureSession.outputs.first as? AVCaptureOutput else { return } | |
| self.captureSession.removeOutput(currentCaptureOutput) | |
| self.position = self.position == .front ? .back : .front | |
| self.configureSession() | |
| self.captureSession.commitConfiguration() |
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
| self.position = self.position == .front ? .back : .front | |
| self.configureSession() |
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
| guard let currentCaptureOutput = self.captureSession.outputs.first as? AVCaptureOutput else { return } | |
| self.captureSession.removeOutput(currentCaptureOutput) |
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
| guard let currentCaptureInput = self.captureSession.inputs.first as? AVCaptureInput else { return } | |
| self.captureSession.removeInput(currentCaptureInput) |
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
| public func flipCamera() { | |
| sessionQueue.async { [unowned self] in | |
| self.captureSession.beginConfiguration() | |
| // We're going to do all the changes here | |
| self.captureSession.commitConfiguration() | |
| } | |
| } |
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
| public func flipCamera() { | |
| } |
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
| captureSession.startRunning() |
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
| captureSession.stopRunning() |
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
| import UIKit | |
| import AVFoundation | |
| protocol FrameExtractorDelegate: class { | |
| func captured(image: UIImage) | |
| } | |
| class FrameExtractor: NSObject, AVCaptureVideoDataOutputSampleBufferDelegate { | |
| private let position = AVCaptureDevicePosition.front |
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
| init() { | |
| checkPermission() | |
| sessionQueue.async { [unowned self] in | |
| self.configureSession() | |
| self.captureSession.startRunning() | |
| } | |
| } | |
| // MARK: AVSession configuration | |
| private func checkPermission() { |
NewerOlder