using System; using System.Runtime.InteropServices; namespace NAudio.MediaFoundation { /// /// IMFSourceReader interface /// http://msdn.microsoft.com/en-us/library/windows/desktop/dd374655%28v=vs.85%29.aspx /// [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("70ae66f2-c809-4e4f-8915-bdcb406b7993")] public interface IMFSourceReader { /// /// Queries whether a stream is selected. /// void GetStreamSelection([In] int dwStreamIndex, [Out, MarshalAs(UnmanagedType.Bool)] out bool pSelected); /// /// Selects or deselects one or more streams. /// void SetStreamSelection([In] int dwStreamIndex, [In, MarshalAs(UnmanagedType.Bool)] bool pSelected); /// /// Gets a format that is supported natively by the media source. /// void GetNativeMediaType([In] int dwStreamIndex, [In] int dwMediaTypeIndex, [Out] out IMFMediaType ppMediaType); /// /// Gets the current media type for a stream. /// void GetCurrentMediaType([In] int dwStreamIndex, [Out] out IMFMediaType ppMediaType); /// /// Sets the media type for a stream. /// void SetCurrentMediaType([In] int dwStreamIndex, IntPtr pdwReserved, [In] IMFMediaType pMediaType); /// /// Seeks to a new position in the media source. /// void SetCurrentPosition([In, MarshalAs(UnmanagedType.LPStruct)] Guid guidTimeFormat, [In] IntPtr varPosition); /// /// Reads the next sample from the media source. /// void ReadSample([In] int dwStreamIndex, [In] int dwControlFlags, [Out] out int pdwActualStreamIndex, [Out] out MF_SOURCE_READER_FLAG pdwStreamFlags, [Out] out UInt64 pllTimestamp, [Out] out IMFSample ppSample); /// /// Flushes one or more streams. /// void Flush([In] int dwStreamIndex); /// /// Queries the underlying media source or decoder for an interface. /// void GetServiceForStream([In] int dwStreamIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid guidService, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [Out] out IntPtr ppvObject); /// /// Gets an attribute from the underlying media source. /// [PreserveSig] int GetPresentationAttribute([In] int dwStreamIndex, [In, MarshalAs(UnmanagedType.LPStruct)] Guid guidAttribute, [Out] IntPtr pvarAttribute); } /// /// Contains flags that indicate the status of the IMFSourceReader::ReadSample method /// http://msdn.microsoft.com/en-us/library/windows/desktop/dd375773(v=vs.85).aspx /// [Flags] public enum MF_SOURCE_READER_FLAG { /// /// No Error /// None = 0, /// /// An error occurred. If you receive this flag, do not make any further calls to IMFSourceReader methods. /// MF_SOURCE_READERF_ERROR = 0x00000001, /// /// The source reader reached the end of the stream. /// MF_SOURCE_READERF_ENDOFSTREAM = 0x00000002, /// /// One or more new streams were created /// MF_SOURCE_READERF_NEWSTREAM = 0x00000004, /// /// The native format has changed for one or more streams. The native format is the format delivered by the media source before any decoders are inserted. /// MF_SOURCE_READERF_NATIVEMEDIATYPECHANGED = 0x00000010, /// /// The current media has type changed for one or more streams. To get the current media type, call the IMFSourceReader::GetCurrentMediaType method. /// MF_SOURCE_READERF_CURRENTMEDIATYPECHANGED = 0x00000020, /// /// There is a gap in the stream. This flag corresponds to an MEStreamTick event from the media source. /// MF_SOURCE_READERF_STREAMTICK = 0x00000100, /// /// All transforms inserted by the application have been removed for a particular stream. /// MF_SOURCE_READERF_ALLEFFECTSREMOVED = 0x00000200 } }