Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public static CMSampleBuffer?CreateForImageBuffer(CVImageBuffer imageBuffer, bool dataReady, CMVideoFormatDescription formatDescription, CMSampleTimingInfo sampleTiming, out CMSampleBufferError error)
        {
            if (imageBuffer is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(imageBuffer));
            }
            if (formatDescription is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(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));
        }