Exemple #1
0
        public static CMSampleBuffer CreateReady(CMBlockBuffer dataBuffer, CMFormatDescription formatDescription,
                                                 int samplesCount, CMSampleTimingInfo[] sampleTimingArray, nuint[] sampleSizeArray,
                                                 out CMSampleBufferError error)
        {
            if (dataBuffer == null)
            {
                throw new ArgumentNullException("dataBuffer");
            }
            if (samplesCount < 0)
            {
                throw new ArgumentOutOfRangeException("samplesCount");
            }

            IntPtr buffer;
            var    fdh         = formatDescription == null ? IntPtr.Zero : formatDescription.Handle;
            var    timingCount = sampleTimingArray == null ? 0 : sampleTimingArray.Length;
            var    sizeCount   = sampleSizeArray == null ? 0 : sampleSizeArray.Length;

            error = CMSampleBufferCreateReady(IntPtr.Zero, dataBuffer.handle, fdh, samplesCount, timingCount,
                                              sampleTimingArray, sizeCount, sampleSizeArray, out buffer);

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

            return(new CMSampleBuffer(buffer, true));
        }
        public CMFormatDescription GetFormatDescription()
        {
            var desc       = default(CMFormatDescription);
            var descHandle = CMSampleBufferGetFormatDescription(handle);

            if (descHandle != IntPtr.Zero)
            {
                desc = new CMFormatDescription(descHandle, false);
            }
            return(desc);
        }
Exemple #3
0
 public static CMSampleBuffer CreateReadyWithImageBuffer(CVImageBuffer imageBuffer,
                                                         CMFormatDescription formatDescription, CMSampleTimingInfo[] sampleTiming, out CMSampleBufferError error)
 {
     if (sampleTiming == null)
     {
         throw new ArgumentNullException(nameof(sampleTiming));
     }
     if (sampleTiming.Length != 1)
     {
         throw new ArgumentException("Only a single sample is allowed.", nameof(sampleTiming));
     }
     return(CreateReadyWithImageBuffer(imageBuffer, formatDescription, sampleTiming, out error));
 }
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
        public static CMSampleBuffer CreateReadyWithPacketDescriptions(CMBlockBuffer dataBuffer, CMFormatDescription formatDescription, int samplesCount,
                                                                       CMTime sampleTimestamp, AudioStreamPacketDescription[] packetDescriptions, out CMSampleBufferError error)
        {
            if (dataBuffer == null)
            {
                throw new ArgumentNullException("dataBuffer");
            }
            if (formatDescription == null)
            {
                throw new ArgumentNullException("formatDescription");
            }
            if (samplesCount <= 0)
            {
                throw new ArgumentOutOfRangeException("samplesCount");
            }

            IntPtr buffer;

            error = CMAudioSampleBufferCreateReadyWithPacketDescriptions(IntPtr.Zero, dataBuffer.handle,
                                                                         formatDescription.handle, samplesCount, sampleTimestamp, packetDescriptions, out buffer);

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

            return(new CMSampleBuffer(buffer, true));
        }
        public static CMSampleBuffer?CreateWithPacketDescriptions(CMBlockBuffer?dataBuffer, CMFormatDescription formatDescription, int samplesCount,
                                                                  CMTime sampleTimestamp, AudioStreamPacketDescription[] packetDescriptions, out CMSampleBufferError error)
        {
            if (formatDescription is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(formatDescription));
            }
            if (samplesCount <= 0)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentOutOfRangeException(nameof(samplesCount), "Negative");
            }

            IntPtr buffer;

            error = CMAudioSampleBufferCreateWithPacketDescriptions(IntPtr.Zero,
                                                                    dataBuffer.GetHandle(),
                                                                    true, IntPtr.Zero, IntPtr.Zero,
                                                                    formatDescription.Handle,
                                                                    samplesCount, sampleTimestamp,
                                                                    packetDescriptions,
                                                                    out buffer);

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

            return(new CMSampleBuffer(buffer, true));
        }
        public static CMSampleBuffer?CreateReadyWithPacketDescriptions(CMBlockBuffer dataBuffer, CMFormatDescription formatDescription, int samplesCount,
                                                                       CMTime sampleTimestamp, AudioStreamPacketDescription[]?packetDescriptions, out CMSampleBufferError error)
        {
            if (dataBuffer is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(dataBuffer));
            }
            if (formatDescription is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(formatDescription));
            }
            if (samplesCount <= 0)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentOutOfRangeException(nameof(samplesCount), "smaller than 0");
            }

            error = CMAudioSampleBufferCreateReadyWithPacketDescriptions(IntPtr.Zero, dataBuffer.Handle,
                                                                         formatDescription.Handle, samplesCount, sampleTimestamp, packetDescriptions, out var buffer);

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

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