// // SampleHandler.swift // BroadcastExtension // // Copyright © 2018-2019 Twilio. All rights reserved. // import Accelerate import TwilioVideo import ReplayKit // MARK: SampleHandlerDelegate Declaration protocol SampleHandlerDelegate: AnyObject { /** This method delivers the pixel buffer of the current frame seen by the device's camera. */ func didOutput(pixelBuffer: CVPixelBuffer) } class SampleHandler: RPBroadcastSampleHandler { // MARK: SampleHandlerDelegate weak var delegate: SampleHandlerDelegate? func captureOutput(sampleBuffer: CMSampleBuffer) { //emre keypoint // Converts the CMSampleBuffer to a CVPixelBuffer. let pixelBuffer: CVPixelBuffer? = CMSampleBufferGetImageBuffer(sampleBuffer) guard let imagePixelBuffer = pixelBuffer else { return } // Delegates the pixel buffer to the ViewController. delegate?.didOutput(pixelBuffer: imagePixelBuffer) } override func processSampleBuffer(_ sampleBuffer: CMSampleBuffer, with sampleBufferType: RPSampleBufferType) { //emre keypoint switch sampleBufferType { case RPSampleBufferType.video: videoSource?.processFrame(sampleBuffer: sampleBuffer) captureOutput(sampleBuffer: sampleBuffer) break case RPSampleBufferType.audioApp: /* if (SampleHandler.kAudioSampleType == RPSampleBufferType.audioApp) { ExampleCoreAudioDeviceCapturerCallback(audioDevice, sampleBuffer) }*/ break case RPSampleBufferType.audioMic: /* if (SampleHandler.kAudioSampleType == RPSampleBufferType.audioMic) { ExampleCoreAudioDeviceCapturerCallback(audioDevice, sampleBuffer) }*/ break @unknown default: break } } }