/// <summary> /// Reads the next sample from the media source. /// </summary> /// <param name="streamIndex">Index of the stream.The stream to pull data from. For more information, see <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd374665(v=vs.85).aspx"/>.</param> /// <param name="controlFlags">A bitwise OR of zero or more flags from the <see cref="SourceReaderControlFlags"/> enumeration.</param> /// <param name="actualStreamIndex">Receives the zero-based index of the stream.</param> /// <param name="streamFlags">Receives a bitwise OR of zero or more flags from the <see cref="MFSourceReaderFlags"/> enumeration.</param> /// <param name="timestamp">Receives the time stamp of the sample, or the time of the stream event indicated in <paramref name="streamFlags"/>. The time is given in 100-nanosecond units.</param> /// <returns>The <see cref="MFSample"/> instance or null. If this parameter receives a non-null value, the caller must release the received <see cref="MFSample"/>.</returns> public MFSample ReadSample(int streamIndex, int controlFlags, out int actualStreamIndex, out MFSourceReaderFlags streamFlags, out long timestamp) { MFSample sample; MediaFoundationException.Try(ReadSampleNative(streamIndex, controlFlags, out actualStreamIndex, out streamFlags, out timestamp, out sample), InterfaceName, "ReadSample"); return(sample); }
/// <summary> /// Reads the next sample from the media source. /// </summary> /// <param name="streamIndex">Index of the stream.The stream to pull data from. For more information, see <see href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd374665(v=vs.85).aspx"/>.</param> /// <param name="controlFlags">A bitwise OR of zero or more flags from the <see cref="SourceReaderControlFlags"/> enumeration.</param> /// <param name="actualStreamIndex">Receives the zero-based index of the stream.</param> /// <param name="streamFlags">Receives a bitwise OR of zero or more flags from the <see cref="MFSourceReaderFlags"/> enumeration.</param> /// <param name="timestamp">Receives the time stamp of the sample, or the time of the stream event indicated in <paramref name="streamFlags"/>. The time is given in 100-nanosecond units.</param> /// <param name="sample">Receives the <see cref="MFSample"/> instance or null. If this parameter receives a non-null value, the caller must release the received <see cref="MFSample"/>.</param> /// <returns> /// HRESULT /// </returns> public unsafe int ReadSampleNative(int streamIndex, int controlFlags, out int actualStreamIndex, out MFSourceReaderFlags streamFlags, out long timestamp, out MFSample sample) { IntPtr psample = IntPtr.Zero; fixed(void *ptr0 = &actualStreamIndex, ptr1 = &streamFlags, ptr2 = ×tamp) { int result = InteropCalls.CalliMethodPtr(UnsafeBasePtr, streamIndex, controlFlags, ptr0, ptr1, ptr2, &psample, ((void **)(*(void **)UnsafeBasePtr))[9]); sample = psample == IntPtr.Zero ? null : new MFSample(psample); return(result); } }