Example #1
0
		public static CMSampleBuffer CreateForImageBuffer (CVImageBuffer imageBuffer, bool dataReady, CMVideoFormatDescription formatDescription, CMSampleTimingInfo sampleTiming, out CMSampleBufferError error)
		{
			if (imageBuffer == null)
				throw new ArgumentNullException ("imageBuffer");
			if (formatDescription == null)
				throw new ArgumentNullException ("formatDescription");

			IntPtr buffer;
			error = CMSampleBufferCreateForImageBuffer (IntPtr.Zero,
				imageBuffer.handle, dataReady,
				IntPtr.Zero, IntPtr.Zero,
				formatDescription.handle,
				ref sampleTiming,
				out buffer);

			if (error != CMSampleBufferError.None)
				return null;

			return new CMSampleBuffer (buffer, true);
		}
Example #2
0
		static VTDecompressionSession Create (VTDecompressionOutputCallback outputCallback,
						      CMVideoFormatDescription formatDescription,
						      VTVideoDecoderSpecification decoderSpecification, // hardware acceleration is default behavior on iOS. no opt-in required.
						      NSDictionary destinationImageBufferAttributes,
						      DecompressionOutputCallback cback)
		{	
			if (formatDescription == null)
				throw new ArgumentNullException ("formatDescription");

			var callbackHandle = GCHandle.Alloc (outputCallback);
			var callbackStruct = new VTDecompressionOutputCallbackRecord () {
				Proc = cback,
				DecompressionOutputRefCon = GCHandle.ToIntPtr (callbackHandle)
			};
			IntPtr ret;

			var result = VTDecompressionSessionCreate (IntPtr.Zero, formatDescription.Handle,
				decoderSpecification != null ? decoderSpecification.Dictionary.Handle : IntPtr.Zero,
				destinationImageBufferAttributes != null ? destinationImageBufferAttributes.Handle : IntPtr.Zero,
				ref callbackStruct,
				out ret);

			if (result == VTStatus.Ok && ret != IntPtr.Zero)
				return new VTDecompressionSession (ret, true) {
					callbackHandle = callbackHandle
				};

			callbackHandle.Free ();
			return null;
		}
Example #3
0
		public static VTDecompressionSession Create (CMVideoFormatDescription formatDescription,
			VTVideoDecoderSpecification decoderSpecification = null, // hardware acceleration is default behavior on iOS. no opt-in required.
			NSDictionary destinationImageBufferAttributes = null) // Undocumented options, probably always null
		{
			if (formatDescription == null)
				throw new ArgumentNullException ("formatDescription");

			var callbackStruct = default (VTDecompressionOutputCallbackRecord);

			IntPtr ret;

			var result = VTDecompressionSessionCreate (IntPtr.Zero, formatDescription.Handle,
				decoderSpecification != null ? decoderSpecification.Dictionary.Handle : IntPtr.Zero,
				destinationImageBufferAttributes != null ? destinationImageBufferAttributes.Handle : IntPtr.Zero,
				ref callbackStruct,
				out ret);

			return result == VTStatus.Ok && ret != IntPtr.Zero
				? new VTDecompressionSession (ret, true)
				: null;
		}
Example #4
0
		public static VTDecompressionSession Create (VTDecompressionOutputCallback outputCallback,
							     CMVideoFormatDescription formatDescription,
							     VTVideoDecoderSpecification decoderSpecification, // hardware acceleration is default behavior on iOS. no opt-in required.
							     CVPixelBufferAttributes destinationImageBufferAttributes)
		{
			return Create (outputCallback, formatDescription, decoderSpecification, destinationImageBufferAttributes == null ? null : destinationImageBufferAttributes.Dictionary, static_newDecompressionOutputCallback);
		}
Example #5
0
        public static CMSampleBuffer CreateForImageBuffer(CVImageBuffer imageBuffer, bool dataReady, CMVideoFormatDescription formatDescription, CMSampleTimingInfo sampleTiming, out CMSampleBufferError error)
        {
            if (imageBuffer == null)
            {
                throw new ArgumentNullException("imageBuffer");
            }
            if (formatDescription == null)
            {
                throw new ArgumentNullException("formatDescription");
            }

            IntPtr buffer;

            error = CMSampleBufferCreateForImageBuffer(IntPtr.Zero,
                                                       imageBuffer.handle, dataReady,
                                                       IntPtr.Zero, IntPtr.Zero,
                                                       formatDescription.handle,
                                                       ref sampleTiming,
                                                       out buffer);

            if (error != CMSampleBufferError.None)
            {
                return(null);
            }

            return(new CMSampleBuffer(buffer, true));
        }