Exemple #1
0
        public unsafe CMSampleTimingInfo [] GetSampleTimingInfo(out OSStatus status)
        {
            nint count;

            status = 0;

            if (handle == IntPtr.Zero)
            {
                return(null);
            }

            if ((status = CMSampleBufferGetSampleTimingInfoArray(handle, 0, null, out count)) != 0)
            {
                return(null);
            }

            CMSampleTimingInfo [] pInfo = new CMSampleTimingInfo [count];

            if (count == 0)
            {
                return(pInfo);

                fixed(CMSampleTimingInfo *info = pInfo)
                if ((status = CMSampleBufferGetSampleTimingInfoArray(handle, count, info, out count)) != 0)
                {
                    return(null);
                }

                return(pInfo);
        }
        public unsafe CMSampleTimingInfo []? GetSampleTimingInfo(out OSStatus status)
        {
            nint count;

            status = default(OSStatus);

            if (Handle == IntPtr.Zero)
            {
                return(null);
            }

            status = CMSampleBufferGetSampleTimingInfoArray(Handle, 0, null, out count);
            if (status != (OSStatus)0)
            {
                return(null);
            }

            CMSampleTimingInfo [] pInfo = new CMSampleTimingInfo [count];

            if (count == 0)
            {
                return(pInfo);

                fixed(CMSampleTimingInfo *info = pInfo)
                {
                    status = CMSampleBufferGetSampleTimingInfoArray(Handle, count, info, out count);
                    if (status != (OSStatus)0)
                    {
                        return(null);
                    }
                }

                return(pInfo);
        }
Exemple #3
0
 static extern /* OSStatus */ CMSampleBufferError CMSampleBufferCreateForImageBuffer(
     /* CFAllocatorRef */ IntPtr allocator,
     /* CVImageBufferRef */ IntPtr imageBuffer,
     /* Boolean */ [MarshalAs(UnmanagedType.I1)] bool dataReady,
     /* CMSampleBufferMakeDataReadyCallback */ IntPtr makeDataReadyCallback,
     /* void* */ IntPtr makeDataReadyRefcon,
     /* CMVideoFormatDescriptionRef */ IntPtr formatDescription,
     /* const CMSampleTimingInfo* */ ref CMSampleTimingInfo sampleTiming,
     /* CMSampleBufferRef* */ out IntPtr bufOut
     );
Exemple #4
0
        public static CMSampleBuffer CreateReadyWithImageBuffer(CVImageBuffer imageBuffer,
                                                                CMFormatDescription formatDescription, ref CMSampleTimingInfo sampleTiming, out CMSampleBufferError error)
        {
            if (imageBuffer == null)
            {
                throw new ArgumentNullException(nameof(imageBuffer));
            }
            if (formatDescription == null)
            {
                throw new ArgumentNullException(nameof(formatDescription));
            }

            IntPtr buffer;

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

            if (error != CMSampleBufferError.None)
                return(null); }
Exemple #5
0
 extern static /* OSStatus */ CMSampleBufferError CMSampleBufferCreateReadyWithImageBuffer(
     /* CFAllocatorRef */ IntPtr allocator,
     /* CVImageBufferRef */ IntPtr imageBuffer,
     /* CMFormatDescriptionRef */ IntPtr formatDescription,              // not null
     /* const CMSampleTimingInfo * CM_NONNULL */ ref CMSampleTimingInfo sampleTiming,
     /* CMSampleBufferRef* */ out IntPtr sBufOut);
Exemple #6
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));
        }
        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));
        }