 @available(iOS 9.0, *)
 open class CameraViewController: UIViewController {
     open weak var delegate: CameraViewControllerDelegate?
-    open var stopSessionWhenDisposed: Bool = false
+    open   var stopSessionWhenDisposed: Bool = false
+    public var configurationQueue: DispatchQueue { return _sessionQueue }
+    /// Sample buffer delegates queue.
+    fileprivate
+    var _sampleBufferDelegates: NSHashTable<AVCaptureVideoDataOutputSampleBufferDelegate> = NSHashTable.weakObjects()
     
     private var _session: AVCaptureSession!
     private var _input  : AVCaptureDeviceInput!

extension CameraViewController {
    public final class DisplayView: CaptureVideoDisplayView {}
}

    
    // MARK: Private.
    
    private func _initSession() throws {
        // Initialize the device input for the session.
        var adevice: AVCaptureDevice!
        if #available(iOS 10.0, *) {
            adevice = AVCaptureDevice.defaultDevice(withDeviceType: .builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: .back)
        } else {
            adevice = AVCaptureDevice.defaultDevice(withMediaType: AVMediaTypeVideo)
        }
        guard let device = adevice else { throw CameraError.initializing(.noneOfCaptureDevice) }
        
        _input = try AVCaptureDeviceInput(device: device)
        // Configure the display out put.
        _displayOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as AnyHashable: kCVPixelFormatType_32BGRA]
        _displayOutput.setSampleBufferDelegate(self, queue: _displayQueue)
        _displayOutput.alwaysDiscardsLateVideoFrames = true
        // Initialize and configure the session of the capture.
        _session = AVCaptureSession()
        if _session.canSetSessionPreset(AVCaptureSessionPresetPhoto) {
            _session.sessionPreset = AVCaptureSessionPresetPhoto
        }
        
    }
    
    private func _configureSession() {
        _sessionQueue.async { [weak self] in autoreleasepool{
            guard let wself = self else { return }
            if wself._session.canAddInput(wself._input) {
                wself._session.addInput(wself._input)
            }
            if wself._session.canAddOutput(wself._output) {
                wself._session.addOutput(wself._output)
            }
            if wself._session.canAddOutput(wself._displayOutput) {
                wself._session.addOutput(wself._displayOutput)
            }
        } }
    }
    
    private func _setupTopBar() {
