示例#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));
        }
示例#2
0
        public static CMSampleBuffer?CreateReady(CMBlockBuffer dataBuffer, CMFormatDescription?formatDescription,
                                                 int samplesCount, CMSampleTimingInfo[]?sampleTimingArray, nuint[]?sampleSizeArray,
                                                 out CMSampleBufferError error)
        {
            if (dataBuffer is null)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentNullException(nameof(dataBuffer));
            }
            if (samplesCount < 0)
            {
                ObjCRuntime.ThrowHelper.ThrowArgumentOutOfRangeException(nameof(samplesCount), "Negative");
            }

            IntPtr buffer;
            var    fdh         = formatDescription.GetHandle();
            var    timingCount = sampleTimingArray is null ? 0 : sampleTimingArray.Length;
            var    sizeCount   = sampleSizeArray is 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));
        }
示例#3
0
		public static CMSampleBuffer CreateWithPacketDescriptions (CMBlockBuffer dataBuffer, CMFormatDescription formatDescription, int samplesCount,
			CMTime sampleTimestamp, AudioStreamPacketDescription[] packetDescriptions, out CMSampleBufferError error)
		{
			if (formatDescription == null)
				throw new ArgumentNullException ("formatDescription");
			if (samplesCount <= 0)
				throw new ArgumentOutOfRangeException ("samplesCount");

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

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

			return new CMSampleBuffer (buffer, true);
		}
示例#4
0
		public static CMSampleBuffer CreateReadyWithImageBuffer (CVImageBuffer imageBuffer, 
			CMFormatDescription formatDescription, CMSampleTimingInfo[] sampleTiming, out CMSampleBufferError error)
		{
			if (imageBuffer == null)
				throw new ArgumentNullException ("imageBuffer");
			if (formatDescription == null)
				throw new ArgumentNullException ("formatDescription");

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

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

			return new CMSampleBuffer (buffer, true);
		}
示例#5
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);
		}
示例#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);
		}
示例#7
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));
        }
示例#8
0
        public static CMSampleBuffer CreateWithPacketDescriptions(CMBlockBuffer dataBuffer, CMFormatDescription formatDescription, int samplesCount,
                                                                  CMTime sampleTimestamp, AudioStreamPacketDescription[] packetDescriptions, out CMSampleBufferError error)
        {
            if (formatDescription == null)
            {
                throw new ArgumentNullException("formatDescription");
            }
            if (samplesCount <= 0)
            {
                throw new ArgumentOutOfRangeException("samplesCount");
            }

            IntPtr buffer;

            error = CMAudioSampleBufferCreateWithPacketDescriptions(IntPtr.Zero,
                                                                    dataBuffer == null ? IntPtr.Zero : dataBuffer.handle,
                                                                    true, IntPtr.Zero, IntPtr.Zero,
                                                                    formatDescription.handle,
                                                                    samplesCount, sampleTimestamp,
                                                                    packetDescriptions,
                                                                    out buffer);

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

            return(new CMSampleBuffer(buffer, true));
        }
示例#9
0
        public static CMSampleBuffer CreateReadyWithImageBuffer(CVImageBuffer imageBuffer,
                                                                CMFormatDescription formatDescription, CMSampleTimingInfo[] sampleTiming, out CMSampleBufferError error)
        {
            if (imageBuffer == null)
            {
                throw new ArgumentNullException("imageBuffer");
            }
            if (formatDescription == null)
            {
                throw new ArgumentNullException("formatDescription");
            }

            IntPtr buffer;

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

            if (error != CMSampleBufferError.None)
                return(null); }
示例#10
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));
 }
示例#11
0
        public static CMSampleBuffer?CreateReadyWithImageBuffer(CVImageBuffer imageBuffer,
                                                                CMFormatDescription formatDescription, ref 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 = CMSampleBufferCreateReadyWithImageBuffer(IntPtr.Zero, imageBuffer.Handle,
                                                             formatDescription.Handle, ref sampleTiming, out buffer);

            if (error != CMSampleBufferError.None)
                return(null); }
示例#12
0
        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));
        }
示例#13
0
        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));
        }
示例#14
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));
        }