Exemple #1
0
		static void DecompressionCallback (IntPtr outputCallbackClosure, IntPtr sourceFrame, VTStatus status, 
			VTDecodeInfoFlags infoFlags, IntPtr imageBufferPtr, CMTime presentationTimeStamp, CMTime presentationDuration)
		{
			var gch = GCHandle.FromIntPtr (outputCallbackClosure);
			var func = (VTDecompressionOutputCallback) gch.Target;

			// Apple headers states that the callback should get a CVImageBuffer but it turned out that not all of them are a
			// CVImageBuffer, some can be instances of CVImageBuffer and others can be instances of CVPixelBuffer. So we go one 
			// step further in the inheritance hierarchy and supply the callback a CVPixelBuffer and the callback supplies 
			// to the developer a CVImageBuffer, so the developer can choose when to use one or the other and we mimic
			// what Apple provides on its headers.
			using (var sampleBuffer = new CVPixelBuffer (imageBufferPtr)) {
				func (sourceFrame, status, infoFlags, sampleBuffer, presentationTimeStamp, presentationDuration);
			}
		}
Exemple #2
0
		public VTStatus CopyBlackPixelBuffer (out CVPixelBuffer pixelBuffer)
		{
			if (Handle == IntPtr.Zero)
				throw new ObjectDisposedException ("DecompressionSession");

			IntPtr ret;
			var result = VTDecompressionSessionCopyBlackPixelBuffer (Handle, out ret);
			pixelBuffer = Runtime.GetINativeObject<CVPixelBuffer> (ret, true);
			CFObject.CFRelease (ret);
			return result;
		}