Skip to content

Instantly share code, notes, and snippets.

@standinga
Created December 15, 2020 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save standinga/0e2ef3111f08a0e270b75349b7a7dd8d to your computer and use it in GitHub Desktop.
Save standinga/0e2ef3111f08a0e270b75349b7a7dd8d to your computer and use it in GitHub Desktop.
H264Coder.swift initial
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