Skip to content

Instantly share code, notes, and snippets.

@OneSadCookie
Created November 19, 2015 04:31
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 OneSadCookie/2f3b94d53d31b564d477 to your computer and use it in GitHub Desktop.
Save OneSadCookie/2f3b94d53d31b564d477 to your computer and use it in GitHub Desktop.
import CoreMedia
protocol PixelContainer { }
protocol Source {
typealias PixelContainerType: PixelContainer
func frameAtTime(time: CMTime) -> PixelContainerType?
}
class CaptureSource: Source {
typealias PixelContainerType = CMSampleBuffer
func frameAtTime(time: CMTime) -> PixelContainerType? {
let sample: CMSampleBuffer? = nil
return sample
}
}
class ImageSource: Source {
typealias PixelContainerType = CGImage
func frameAtTime(time: CMTime) -> PixelContainerType? {
let image: CGImage? = nil
return image
}
}
extension CMSampleBuffer: PixelContainer { }
extension CGImage: PixelContainer { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment