public static CMBlockBuffer CreateContiguous(CMBlockBuffer sourceBuffer, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error) { if (sourceBuffer == null) { throw new ArgumentNullException("sourceBuffer"); } IntPtr buffer; if (customBlockSource == null) { error = CMBlockBufferCreateContiguous(IntPtr.Zero, sourceBuffer.handle, IntPtr.Zero, IntPtr.Zero, offsetToData, dataLength, flags, out buffer); } else { error = CMBlockBufferCreateContiguous(IntPtr.Zero, sourceBuffer.handle, IntPtr.Zero, ref customBlockSource.Cblock, offsetToData, dataLength, flags, out buffer); } if (error != CMBlockBufferError.None) { return(null); } var block = new CMBlockBuffer(buffer, true); block.customAllocator = customBlockSource; return(block); }
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 CMBlockBuffer FromMemoryBlock(IntPtr memoryBlock, nuint blockLength, CMCustomBlockAllocator customBlockSource, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error) { var blockAllocator = memoryBlock == IntPtr.Zero ? IntPtr.Zero : CFAllocator.Null.Handle; IntPtr buffer; if (customBlockSource == null) { error = CMBlockBufferCreateWithMemoryBlock(IntPtr.Zero, memoryBlock, blockLength, blockAllocator, IntPtr.Zero, offsetToData, dataLength, flags, out buffer); } else { error = CMBlockBufferCreateWithMemoryBlock(IntPtr.Zero, memoryBlock, blockLength, blockAllocator, ref customBlockSource.Cblock, offsetToData, dataLength, flags, out buffer); } if (error != CMBlockBufferError.None) { return(null); } var block = new CMBlockBuffer(buffer, true); block.customAllocator = customBlockSource; return(block); }
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 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)); }
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)); }
public int /*CMSampleBufferError*/ SetDataBuffer(CMBlockBuffer dataBuffer) { var dataBufferHandle = IntPtr.Zero; if (dataBuffer != null) { dataBufferHandle = dataBuffer.handle; } return((int)CMSampleBufferSetDataBuffer(handle, dataBufferHandle)); }
public CMBlockBufferError AppendBuffer(CMBlockBuffer targetBuffer, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags) { if (Handle == IntPtr.Zero) { throw new ObjectDisposedException("BlockBuffer"); } // From docs targetBuffer must not be null unless the PermitEmptyReference flag is set if (!flags.HasFlag(CMBlockBufferFlags.PermitEmptyReference)) { if (targetBuffer == null) { throw new ArgumentNullException("targetBuffer"); } } return(CMBlockBufferAppendBufferReference(Handle, targetBuffer == null ? IntPtr.Zero : targetBuffer.handle, offsetToData, dataLength, flags)); }
public static CMBlockBuffer FromBuffer(CMBlockBuffer targetBuffer, nuint offsetToData, nuint dataLength, CMBlockBufferFlags flags, out CMBlockBufferError error) { // From docs targetBuffer must not be null unless the PermitEmptyReference flag is set if (!flags.HasFlag(CMBlockBufferFlags.PermitEmptyReference)) { if (targetBuffer == null) { throw new ArgumentNullException("targetBuffer"); } } IntPtr buffer; error = CMBlockBufferCreateWithBufferReference(IntPtr.Zero, targetBuffer == null ? IntPtr.Zero : targetBuffer.handle, offsetToData, dataLength, flags, out buffer); if (error != CMBlockBufferError.None) { return(null); } return(new CMBlockBuffer(buffer, true)); }
public CMSampleBufferError SetDataBuffer(CMBlockBuffer dataBuffer) { var dataBufferHandle = dataBuffer == null ? IntPtr.Zero : dataBuffer.handle; return(CMSampleBufferSetDataBuffer(handle, dataBufferHandle)); }
public CMSampleBufferError SetDataBuffer(CMBlockBuffer dataBuffer) { return(CMSampleBufferSetDataBuffer(Handle, dataBuffer.GetHandle())); }