/// <summary> /// Selects or deselects one or more streams. /// </summary> /// <param name="sourceReader">A valid IMFSourceReader instance.</param></param></param> /// <param name="streamIndex">The stream to set.</param> /// <param name="selected">Specify True to select streams or False to deselect streams. If a stream is deselected, it will not generate data.</param> /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns> public static HResult SetStreamSelection(this IMFSourceReader sourceReader, SourceReaderStreams streamIndex, bool selected) { if (sourceReader == null) { throw new ArgumentNullException("sourceReader"); } return(sourceReader.SetStreamSelection((int)streamIndex, selected)); }
/// <summary> /// Flushes one or more streams. /// </summary> /// <param name="sourceReader">A valid IMFSourceReader instance.</param></param> /// <param name="streamIndex">The streamIndex(s) to flush.</param> /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns> public static HResult Flush(this IMFSourceReader sourceReader, SourceReaderStreams stream) { if (sourceReader == null) { throw new ArgumentNullException("sourceReader"); } return(sourceReader.Flush((int)stream)); }
/// <summary> /// Reads the next sample from the media source. /// </summary> /// <param name="sourceReader">A valid IMFSourceReader instance.</param></param></param> /// <param name="streamIndex">The stream to pull data from.</param> /// <param name="controlFlags">One or more members of the MF_SOURCE_READER_CONTROL_FLAG enumeration.</param> /// <param name="actualStreamIndex">Receives the zero-based index of the stream.</param> /// <param name="streamFlags">Receives one or more members of the MF_SOURCE_READER_FLAG enumeration.</param> /// <param name="timestamp">Receives the time stamp of the sample, or the time of the stream event indicated in <paramref name="streamFlags"/>.</param> /// <param name="sample">Receives an instance of the IMFSample interface or the value null.</param> /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns> public static HResult ReadSample(this IMFSourceReader sourceReader, SourceReaderStreams streamIndex, MF_SOURCE_READER_CONTROL_FLAG controlFlags, out int actualStreamIndex, out MF_SOURCE_READER_FLAG streamFlags, out TimeSpan timestamp, out IMFSample sample) { if (sourceReader == null) { throw new ArgumentNullException("sourceReader"); } long tmp = 0; HResult hr = sourceReader.ReadSample((int)streamIndex, controlFlags, out actualStreamIndex, out streamFlags, out tmp, out sample); timestamp = hr.Succeeded() ? TimeSpan.FromTicks(tmp) : default(TimeSpan); return(hr); }