Created
April 6, 2017 00:24
-
-
Save hk0i/d832679956945561c56927adbfe1f3a2 to your computer and use it in GitHub Desktop.
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
// MARK: - AVCaptureVideoDataOutputSampleBufferDelegate extension {{{ | |
extension CtsVideoCallView: AVCaptureVideoDataOutputSampleBufferDelegate { | |
func captureOutput(_ captureOutput: AVCaptureOutput!, | |
didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, | |
from: AVCaptureConnection!) { | |
// get image size for preview and resize preview view accordingly | |
let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) | |
let attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, | |
sampleBuffer, kCMAttachmentMode_ShouldPropagate) as! Dictionary | |
let ciImage = CIImage(cvPixelBuffer: imageBuffer, options: attachments) | |
let height = ciImage.cgImage.height | |
let width = ciImage.cgImage.width | |
let localVideoSize = CGSize(width: width, height: height) | |
self.localVideoView.frame.size = localVideoSize | |
} | |
} | |
// }}} AVCaptureVideoDataOutputSampleBufferDelegate extension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment