Created
December 15, 2020 00:00
-
-
Save standinga/0e2ef3111f08a0e270b75349b7a7dd8d to your computer and use it in GitHub Desktop.
H264Coder.swift initial
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 AVFoundation | |
import VideoToolbox | |
class H264Coder { | |
var session: VTCompressionSession? | |
let outputCallback: VTCompressionOutputCallback = { refcon, sourceFrameRefCon, status, infoFlags, sampleBuffer in | |
guard let refcon = refcon, | |
status == noErr, | |
let sampleBuffer = sampleBuffer else { | |
print("H264Coder outputCallback sampleBuffer NIUL or status: \(status)") | |
return | |
} | |
let encoder: H264Coder = Unmanaged<H264Coder>.fromOpaque(refcon).takeUnretainedValue() | |
encoder.didEncodeFrame(frame: sampleBuffer) | |
} | |
func didEncodeFrame(frame: CMSampleBuffer) { | |
print ("Received encoded frame in delegate...") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment