func startSession()

in TorchVideo/TorchVideo/CameraController.swift [23:50]


    func startSession() {
        func reportError(error: CameraControllerError) {
            DispatchQueue.main.async {
                if let callback = self.videoCaptureCompletionBlock {
                    callback(nil, error)
                }
            }
        }
        sessionQueue.async {
            do {
                self.captureSession.sessionPreset = .high
                self.captureSession.beginConfiguration()
                try self.configCameraInput()
                try self.configCameraOutput()
                self.captureSession.commitConfiguration()
                self.prepare {
                    if $0, !self.captureSession.isRunning {
                        self.addListeners()
                        self.captureSession.startRunning()
                    } else {
                        reportError(error: .cameraAccessDenied)
                    }
                }
            } catch {
                reportError(error: .cameraConfigError)
            }
        }
    }