using System; using System.Runtime.InteropServices; namespace NAudio.Dmo { /// /// DMO Output Data Buffer /// [StructLayout(LayoutKind.Sequential, Pack=8)] public struct DmoOutputDataBuffer : IDisposable { [MarshalAs(UnmanagedType.Interface)] IMediaBuffer pBuffer; DmoOutputDataBufferFlags dwStatus; long rtTimestamp; long referenceTimeDuration; /// /// Creates a new DMO Output Data Buffer structure /// /// Maximum buffer size public DmoOutputDataBuffer(int maxBufferSize) { pBuffer = new MediaBuffer(maxBufferSize); dwStatus = DmoOutputDataBufferFlags.None; rtTimestamp = 0; referenceTimeDuration = 0; } /// /// Dispose /// public void Dispose() { if (pBuffer != null) { ((MediaBuffer)pBuffer).Dispose(); pBuffer = null; GC.SuppressFinalize(this); } } /// /// Media Buffer /// public IMediaBuffer MediaBuffer { get { return pBuffer; } internal set { pBuffer = value; } } /// /// Length of data in buffer /// public int Length { get { return ((MediaBuffer)pBuffer).Length; } } /// /// Status Flags /// public DmoOutputDataBufferFlags StatusFlags { get { return dwStatus; } internal set { dwStatus = value; } } /// /// Timestamp /// public long Timestamp { get { return rtTimestamp; } internal set { rtTimestamp = value; } } /// /// Duration /// public long Duration { get { return referenceTimeDuration; } internal set { referenceTimeDuration = value; } } /// /// Retrives the data in this buffer /// /// Buffer to receive data /// Offset into buffer public void RetrieveData(byte[] data, int offset) { ((MediaBuffer)pBuffer).RetrieveData(data, offset); } /// /// Is more data available /// If true, ProcessOuput should be called again /// public bool MoreDataAvailable { get { return (StatusFlags & DmoOutputDataBufferFlags.Incomplete) == DmoOutputDataBufferFlags.Incomplete; } } } }