(devicePtr)!;
+ }
+}
diff --git a/src/Vortice.MediaFoundation/IMFMediaEngineClassFactory.cs b/src/Vortice.MediaFoundation/IMFMediaEngineClassFactory.cs
index 35eee0fb..a60d4d51 100644
--- a/src/Vortice.MediaFoundation/IMFMediaEngineClassFactory.cs
+++ b/src/Vortice.MediaFoundation/IMFMediaEngineClassFactory.cs
@@ -27,7 +27,7 @@ public IMFMediaEngine CreateInstance(
try
{
- attributes.Set(MediaEngineAttributeKeys.Callback, mediaEngineNotifyImpl);
+ attributes.Set(MediaEngineAttributeKeys.Callback.Guid, mediaEngineNotifyImpl);
CreateInstance(createFlags, attributes, out IMFMediaEngine engine).CheckError();
mediaEngineNotifyImpl.MediaEngine = engine;
diff --git a/src/Vortice.MediaFoundation/IMFSourceReader.cs b/src/Vortice.MediaFoundation/IMFSourceReader.cs
new file mode 100644
index 00000000..b32add43
--- /dev/null
+++ b/src/Vortice.MediaFoundation/IMFSourceReader.cs
@@ -0,0 +1,194 @@
+// Copyright (c) Amer Koleci and Contributors.
+// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
+
+using SharpGen.Runtime.Win32;
+
+namespace Vortice.MediaFoundation;
+
+public unsafe partial class IMFSourceReader
+{
+ internal IMFByteStream? _byteStream;
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Gets a format that is supported natively by the media source.
+ ///
+ /// Specifies which stream to query. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
?
+ /// The zero-based index of the media type to retrieve.
+ /// Receives a reference to the interface. The caller must release the interface.
+ ///
+ /// This method queries the underlying media source for its native output format. Potentially, each source stream can produce more than one output format. Use the dwMediaTypeIndex parameter to loop through the available formats. Generally, file sources offer just one format per stream, but capture devices might offer several formats.
The method returns a copy of the media type, so it is safe to modify the object received in the ppMediaType parameter.
To set the output type for a stream, call the method.
This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374661
+ /// HRESULT IMFSourceReader::GetNativeMediaType([In] unsigned int dwStreamIndex,[In] unsigned int dwMediaTypeIndex,[Out] IMFMediaType** ppMediaType)
+ /// IMFSourceReader::GetNativeMediaType
+ public IMFMediaType GetNativeMediaType(SourceReaderIndex readerIndex, int dwMediaTypeIndex)
+ {
+ return GetNativeMediaType((int)readerIndex, dwMediaTypeIndex);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Selects or deselects one or more streams.
+ ///
+ /// The stream to set. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
- 0xFFFFFFFE
| All streams. |
?
+ /// Specify TRUE to select streams or to deselect streams. If a stream is deselected, it will not generate data.
+ /// If this method succeeds, it returns . Otherwise, it returns an error code.
+ ///
+ /// There are two common uses for this method:
- To change the default stream selection. Some media files contain multiple streams of the same type. For example, a file might include audio streams for multiple languages. You can use this method to change which of the streams is selected. To get information about each stream, call or .
- If you will not need data from one of the streams, it is a good idea to deselect that stream. If the stream is selected, the media source might hold onto a queue of unread data, and the queue might grow indefinitely, consuming memory.
For an example of deselecting a stream, see Tutorial: Decoding Audio.
If a stream is deselected, the method returns MF_E_INVALIDREQUEST for that stream. Other methods are valid for deselected streams.
Stream selection does not affect how the source reader loads or unloads decoders in memory. In particular, deselecting a stream does not force the source reader to unload the decoder for that stream.
This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374669
+ /// HRESULT IMFSourceReader::SetStreamSelection([In] unsigned int dwStreamIndex,[In] BOOL fSelected)
+ /// IMFSourceReader::SetStreamSelection
+ public void SetStreamSelection(SourceReaderIndex readerIndex, bool fSelected)
+ {
+ SetStreamSelection((int)readerIndex, fSelected);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Sets the media type for a stream.
This media type defines that format that the Source Reader produces as output. It can differ from the native format provided by the media source. See Remarks for more information.
+ ///
+ /// No documentation.
+ /// No documentation.
+ /// The method returns an . Possible values include, but are not limited to, those in the following table.
Return code | Description |
| The method succeeded. |
- MF_E_INVALIDMEDIATYPE
| At least one decoder was found for the native stream type, but the type specified by pMediaType was rejected. |
- MF_E_INVALIDREQUEST
| One or more sample requests are still pending. |
- MF_E_INVALIDSTREAMNUMBER
| The dwStreamIndex parameter is invalid. |
- MF_E_TOPO_CODEC_NOT_FOUND
| Could not find a decoder for the native stream type. |
?
+ ///
+ /// For each stream, you can set the media type to any of the following:
- One of the native types offered by the media source. To enumerate the native types, call .
- If the native media type is compressed, you can specify a corresponding uncompressed format. The Source Reader will search for a decoder that can decode from the native format to the specified uncompressed format.
The source reader does not support audio resampling. If you need to resample the audio, you can use the Audio Resampler DSP.
If you set the attribute to TRUE when you create the Source Reader, the Source Reader will convert YUV video to RGB-32. This conversion is not optimized for real-time video playback.
This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374667
+ /// HRESULT IMFSourceReader::SetCurrentMediaType([In] unsigned int dwStreamIndex,[In] unsigned int* pdwReserved,[In] IMFMediaType* pMediaType)
+ /// IMFSourceReader::SetCurrentMediaType
+ public void SetCurrentMediaType(SourceReaderIndex readerIndex, IMFMediaType mediaTypeRef)
+ {
+ SetCurrentMediaType((int)readerIndex, mediaTypeRef);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Seeks to a new position in the media source.
+ ///
+ /// The position from which playback will be started. 100-nanosecond units.
+ ///
+ /// The SetCurrentPosition method does not guarantee exact seeking. The accuracy of the seek depends on the media content. If the media content contains a video stream, the SetCurrentPosition method typically seeks to the nearest key frame before the desired position. The distance between key frames depends on several factors, including the encoder implementation, the video content, and the particular encoding settings used to encode the content. The distance between key frame can vary within a single video file (for example, depending on scene complexity).
After seeking, the application should call and advance to the desired position.
This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374668
+ /// HRESULT IMFSourceReader::SetCurrentPosition([In] const GUID& guidTimeFormat,[In] const PROPVARIANT& varPosition)
+ /// IMFSourceReader::SetCurrentPosition
+ public void SetCurrentPosition(long position)
+ {
+ SetCurrentPosition(Guid.Empty, new Variant { Value = position });
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Gets the current media type for a stream.
+ ///
+ /// The stream to query. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
?
+ /// Receives a reference to the interface. The caller must release the interface.
+ ///
+ /// This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374660
+ /// HRESULT IMFSourceReader::GetCurrentMediaType([In] unsigned int dwStreamIndex,[Out] IMFMediaType** ppMediaType)
+ /// IMFSourceReader::GetCurrentMediaType
+ public IMFMediaType GetCurrentMediaType(SourceReaderIndex readerIndex)
+ {
+ return GetCurrentMediaType((int)readerIndex);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Reads the next sample from the media source.
+ ///
+ /// The stream to pull data from. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
- 0xFFFFFFFE
| Get the next available sample, regardless of which stream. |
?
+ /// A bitwise OR of zero or more flags from the enumeration.
+ /// Receives the zero-based index of the stream.
+ /// Receives a bitwise OR of zero or more flags from the enumeration.
+ /// Receives the time stamp of the sample, or the time of the stream event indicated in pdwStreamFlags. The time is given in 100-nanosecond units.
+ /// Receives a reference to the interface or the value null (see Remarks). If this parameter receives a non-null reference, the caller must release the interface.
+ ///
+ /// If the requested stream is not selected, the return code is MF_E_INVALIDREQUEST. See .
This method can complete synchronously or asynchronously. If you provide a callback reference when you create the source reader, the method is asynchronous. Otherwise, the method is synchronous. For more information about setting the callback reference, see .
Asynchronous ModeIn asynchronous mode:
- All of the
[out]
parameters must be null. Otherwise, the method returns E_INVALIDARG. - The method returns immediately.
- When the operation completes, the application's method is called.
- If an error occurs, the method can fail either synchronously or asynchronously. Check the return value of ReadSample, and also check the hrStatus parameter of .
Synchronous ModeIn synchronous mode:
- The pdwStreamFlags and ppSample parameters cannot be null. Otherwise, the method returns E_POINTER.
- The pdwActualStreamIndex and pllTimestamp parameters can be null.
- The method blocks until the next sample is available.
In synchronous mode, if the dwStreamIndex parameter is , you should pass a non-null value for pdwActualStreamIndex, so that you know which stream delivered the sample.
This method can return flags in the pdwStreamFlags parameter without returning a media sample in ppSample. Therefore, the ppSample parameter can receive a null reference even when the method succeeds. For example, when the source reader reaches the end of the stream, it returns the flag in pdwStreamFlags and sets ppSample to null.
If there is a gap in the stream, pdwStreamFlags receives the flag, ppSample is null, and pllTimestamp indicates the time when the gap occurred.
This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374665
+ /// HRESULT IMFSourceReader::ReadSample([In] unsigned int dwStreamIndex,[In] unsigned int dwControlFlags,[Out, Optional] unsigned int* pdwActualStreamIndex,[Out, Optional] unsigned int* pdwStreamFlags,[Out, Optional] longlong* pllTimestamp,[Out, Optional] IMFSample** ppSample)
+ /// IMFSourceReader::ReadSample
+ public IMFSample ReadSample(SourceReaderIndex dwStreamIndex, SourceReaderControlFlag dwControlFlags, out int dwActualStreamIndexRef, out SourceReaderFlag dwStreamFlagsRef, out long llTimestampRef)
+ {
+ return ReadSample((int)dwStreamIndex, dwControlFlags, out dwActualStreamIndexRef, out dwStreamFlagsRef, out llTimestampRef);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Flushes one or more streams.
+ ///
+ /// The stream to flush. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
- 0xFFFFFFFE
| All streams. |
?
+ /// If this method succeeds, it returns . Otherwise, it returns an error code.
+ ///
+ /// The Flush method discards all queued samples and cancels all pending sample requests.
This method can complete either synchronously or asynchronously. If you provide a callback reference when you create the source reader, the method is asynchronous. Otherwise, the method is synchronous. For more information about the setting the callback reference, see .
In synchronous mode, the method blocks until the operation is complete.
In asynchronous mode, the application's method is called when the flush operation completes. While a flush operation is pending, the method returns MF_E_NOTACCEPTING.
Note??In Windows?7, there was a bug in the implementation of this method, which causes OnFlush to be called before the flush operation completes. A hotfix is available that fixes this bug. For more information, see http://support.microsoft.com/kb/979567.
This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374659
+ /// HRESULT IMFSourceReader::Flush([In] unsigned int dwStreamIndex)
+ /// IMFSourceReader::Flush
+ public void Flush(SourceReaderIndex dwStreamIndex)
+ {
+ Flush((int)dwStreamIndex);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Queries the underlying media source or decoder for an interface.
+ ///
+ /// The stream or object to query. If the value is , the method queries the media source. Otherwise, it queries the decoder that is associated with the specified stream. The following values are possible.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
- 0xFFFFFFFF
| The media source. |
?
+ /// A service identifier . If the value is GUID_NULL, the method calls QueryInterface to get the requested interface. Otherwise, the method calls the method. For a list of service identifiers, see Service Interfaces.
+ /// The interface identifier (IID) of the interface being requested.
+ /// Receives a reference to the requested interface. The caller must release the interface.
+ ///
+ /// This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374663
+ /// HRESULT IMFSourceReader::GetServiceForStream([In] unsigned int dwStreamIndex,[In] const GUID& guidService,[In] const GUID& riid,[Out] void** ppvObject)
+ /// IMFSourceReader::GetServiceForStream
+ public nint GetServiceForStream(SourceReaderIndex streamIndex, Guid guidService, Guid riid)
+ {
+ return GetServiceForStream((int)streamIndex, guidService, riid);
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Gets an attribute from the underlying media source.
+ ///
+ /// The stream or object to query. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
- 0xFFFFFFFF
| The media source. |
?
+ /// A that identifies the attribute to retrieve. If the dwStreamIndex parameter equals , guidAttribute can specify one of the following:
- A presentation descriptor attribute. For a list of values, see Presentation Descriptor Attributes.
- . Use this value to get characteristics flags from the media source.
Otherwise, if the dwStreamIndex parameter specifies a stream, guidAttribute specifies a stream descriptor attribute. For a list of values, see Stream Descriptor Attributes.
+ /// a that receives the value of the attribute.
+ ///
+ /// This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374662
+ /// HRESULT IMFSourceReader::GetPresentationAttribute([In] unsigned int dwStreamIndex,[In] const GUID& guidAttribute,[Out] PROPVARIANT* pvarAttribute)
+ /// IMFSourceReader::GetPresentationAttribute
+ public T GetPresentationAttribute(SourceReaderIndex streamIndex, MediaAttributeKey guidAttribute)
+ {
+ Variant variant = GetPresentationAttribute((int)streamIndex, guidAttribute.Guid);
+
+ return (T)Convert.ChangeType(variant.Value, typeof(T));
+ }
+
+ ///
+ /// Applies to: desktop apps | Metro style apps
Gets an attribute from the underlying media source.
+ ///
+ /// The stream or object to query. The value can be any of the following.
Value | Meaning |
- 0?0xFFFFFFFB
| The zero-based index of a stream. |
- 0xFFFFFFFC
| The first video stream. |
- 0xFFFFFFFD
| The first audio stream. |
- 0xFFFFFFFF
| The media source. |
?
+ /// A that identifies the attribute to retrieve. If the dwStreamIndex parameter equals , guidAttribute can specify one of the following:
- A presentation descriptor attribute. For a list of values, see Presentation Descriptor Attributes.
- . Use this value to get characteristics flags from the media source.
Otherwise, if the dwStreamIndex parameter specifies a stream, guidAttribute specifies a stream descriptor attribute. For a list of values, see Stream Descriptor Attributes.
+ /// a that receives the value of the attribute.
+ ///
+ /// This interface is available on Windows?Vista if Platform Update Supplement for Windows?Vista is installed.
+ ///
+ /// dd374662
+ /// HRESULT IMFSourceReader::GetPresentationAttribute([In] unsigned int dwStreamIndex,[In] const GUID& guidAttribute,[Out] PROPVARIANT* pvarAttribute)
+ /// IMFSourceReader::GetPresentationAttribute
+ public Variant GetPresentationAttribute(SourceReaderIndex dwStreamIndex, Guid guidAttribute)
+ {
+ return GetPresentationAttribute((int)dwStreamIndex, guidAttribute);
+ }
+
+ protected override void DisposeCore(nint nativePointer, bool disposing)
+ {
+ base.DisposeCore(nativePointer, disposing);
+
+ if (_byteStream != null)
+ {
+ _byteStream.Dispose();
+ _byteStream = null;
+ }
+ }
+}
diff --git a/src/Vortice.MediaFoundation/IMFSourceReaderCallbackBase.cs b/src/Vortice.MediaFoundation/IMFSourceReaderCallbackBase.cs
new file mode 100644
index 00000000..97a6f38d
--- /dev/null
+++ b/src/Vortice.MediaFoundation/IMFSourceReaderCallbackBase.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Amer Koleci and Contributors.
+// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
+
+using SharpGen.Runtime;
+using SharpGen.Runtime.Win32;
+
+namespace Vortice.MediaFoundation;
+
+public abstract class IMFSourceReaderCallbackBase : CallbackBase, IMFSourceReaderCallback
+{
+ public virtual void OnEvent(SourceReaderIndex streamIndex, IMFMediaEvent @event)
+ {
+
+ }
+
+ public virtual void OnFlush(SourceReaderIndex streamIndex)
+ {
+
+ }
+
+ public virtual void OnReadSample(Result hrStatus,
+ SourceReaderIndex streamIndex,
+ SourceReaderFlag streamFlags, long llTimestamp, IMFSample sample)
+ {
+
+ }
+
+ #region IMFSourceReaderCallback Members
+ void IMFSourceReaderCallback.OnEvent(int streamIndex, IMFMediaEvent @event)
+ {
+ OnEvent((SourceReaderIndex)streamIndex, @event);
+ }
+
+ void IMFSourceReaderCallback.OnFlush(int streamIndex)
+ {
+ OnFlush((SourceReaderIndex)streamIndex);
+ }
+
+ void IMFSourceReaderCallback.OnReadSample(Result hrStatus, int streamIndex, int streamFlags, long timestamp, IMFSample sample)
+ {
+ OnReadSample(hrStatus, (SourceReaderIndex)streamIndex, (SourceReaderFlag)streamFlags, timestamp, sample);
+ }
+ #endregion
+}
diff --git a/src/Vortice.MediaFoundation/MFByteStream.cs b/src/Vortice.MediaFoundation/MFByteStream.cs
index 728ad7d6..75ae6c9b 100644
--- a/src/Vortice.MediaFoundation/MFByteStream.cs
+++ b/src/Vortice.MediaFoundation/MFByteStream.cs
@@ -4,6 +4,7 @@
using System.Runtime.InteropServices;
using SharpGen.Runtime;
using SharpGen.Runtime.Win32;
+using static Vortice.MediaFoundation.MediaFactory;
namespace Vortice.MediaFoundation;
@@ -11,6 +12,7 @@ public unsafe partial class MFByteStream
{
private Stream? _sourceStream;
private readonly bool _disposeStream;
+ private ComStream? _comStream;
private ComStreamProxy? _streamProxy;
///
@@ -24,12 +26,12 @@ public MFByteStream(Stream sourceStream, bool disposeStream = false)
if (PlatformDetection.IsAppContainerProcess)
{
//var randomAccessStream = sourceStream.AsRandomAccessStream();
- //MediaFactory.MFCreateMFByteStreamOnStreamEx(new ComObject(Marshal.GetIUnknownForObject(randomAccessStream)), this);
+ //MFCreateMFByteStreamOnStreamEx(new ComObject(Marshal.GetIUnknownForObject(randomAccessStream)), this);
}
else
{
_streamProxy = new ComStreamProxy(sourceStream);
- MediaFactory.MFCreateMFByteStreamOnStream(_streamProxy, this);
+ MFCreateMFByteStreamOnStream(_streamProxy, this);
}
}
@@ -49,6 +51,18 @@ public MFByteStream(string fileName)
{
}
+ ///
+ /// Instantiates a new instance from a .
+ ///
+ /// hh162754
+ /// HRESULT MFCreateMFByteStreamOnStreamEx([In] IUnknown* punkStream,[Out] IMFByteStream** ppByteStream)
+ /// MFCreateMFByteStreamOnStreamEx
+ public MFByteStream(ComStream sourceStream)
+ {
+ _comStream = sourceStream;
+ MFCreateMFByteStreamOnStream(sourceStream, this);
+ }
+
protected override unsafe void DisposeCore(IntPtr nativePointer, bool disposing)
{
base.DisposeCore(nativePointer, disposing);
@@ -66,6 +80,14 @@ protected override unsafe void DisposeCore(IntPtr nativePointer, bool disposing)
}
}
+ public uint Read(Span bRef, int offset, uint count)
+ {
+ fixed (void* ptr = &bRef[offset])
+ {
+ return Read((IntPtr)ptr, count);
+ }
+ }
+
public uint Read(byte[] bRef, int offset, uint count)
{
fixed (void* ptr = &bRef[offset])
@@ -74,6 +96,14 @@ public uint Read(byte[] bRef, int offset, uint count)
}
}
+ public void BeginRead(Span bRef, int offset, uint count, IMFAsyncCallback callback, object? context = default)
+ {
+ fixed (void* ptr = &bRef[offset])
+ {
+ BeginRead((IntPtr)ptr, count, callback, context != null ? Marshal.GetIUnknownForObject(context) : IntPtr.Zero);
+ }
+ }
+
public void BeginRead(byte[] bRef, int offset, uint count, IMFAsyncCallback callback, object? context = default)
{
fixed (void* ptr = &bRef[offset])
@@ -82,6 +112,14 @@ public void BeginRead(byte[] bRef, int offset, uint count, IMFAsyncCallback call
}
}
+ public uint Write(Span bRef, int offset, uint count)
+ {
+ fixed (void* ptr = &bRef[offset])
+ {
+ return Write((IntPtr)ptr, count);
+ }
+ }
+
public uint Write(byte[] bRef, int offset, uint count)
{
fixed (void* ptr = &bRef[offset])
@@ -90,6 +128,14 @@ public uint Write(byte[] bRef, int offset, uint count)
}
}
+ public void BeginWrite(Span bRef, int offset, uint count, IMFAsyncCallback callback, object? context = default)
+ {
+ fixed (void* ptr = &bRef[offset])
+ {
+ BeginWrite((IntPtr)ptr, count, callback, context != null ? Marshal.GetIUnknownForObject(context) : IntPtr.Zero);
+ }
+ }
+
public void BeginWrite(byte[] bRef, int offset, uint count, IMFAsyncCallback callback, object? context = default)
{
fixed (void* ptr = &bRef[offset])
diff --git a/src/Vortice.MediaFoundation/Mappings.xml b/src/Vortice.MediaFoundation/Mappings.xml
index 146723da..7aa4f7ed 100644
--- a/src/Vortice.MediaFoundation/Mappings.xml
+++ b/src/Vortice.MediaFoundation/Mappings.xml
@@ -32,7 +32,7 @@
-
+
@@ -538,8 +538,8 @@
new System.Guid("$1")
- new System.Guid("$1")
- new System.Guid("$1")
+ new System.Guid("$1")
+ new System.Guid("$1")
new MediaAttributeKey<long>("$1", "DescrambleData")
new MediaAttributeKey<int>("$1", "SampleKeyID")
@@ -606,10 +606,19 @@
StreamRenderingError
SupportedRates
AudioendPointChange
+ IUnknown
+ EndOfStream
+ NewStream
+ NativeMediaTypeChanged
+ CurrentMediaTypeChanged
+ StreamTick
+ AllEffectsRemoved
+ MediaSink
+ NoResolution
+ UpStream
+ DownStream
-
-
@@ -656,7 +665,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -678,6 +696,8 @@
+
+
@@ -689,15 +709,37 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -715,37 +757,39 @@
-
-
-
-
+
+
+
+
+
+
-
-
+
-
+
-
+
-
+
-
-
-
+
+
+
+
-
+
@@ -759,9 +803,21 @@
+
+
+
+
+
+
+
+
-
+
+
+
+
+
@@ -784,7 +840,7 @@
-
+
@@ -803,7 +859,7 @@
-
+
@@ -968,7 +1024,7 @@
-
+
@@ -977,14 +1033,14 @@
-
+
-
+
diff --git a/src/Vortice.MediaFoundation/MediaFactory.cs b/src/Vortice.MediaFoundation/MediaFactory.cs
index 96c04f2a..5baab6ba 100644
--- a/src/Vortice.MediaFoundation/MediaFactory.cs
+++ b/src/Vortice.MediaFoundation/MediaFactory.cs
@@ -219,7 +219,7 @@ public static Result MFGetAttribute2UInt32asUInt64(IMFAttributes attributes, Gui
public static Result MFSetAttribute2UInt32asUInt64(IMFAttributes attributes, Guid guidKey, uint unHigh32, uint unLow32)
{
- return attributes.SetUInt64(guidKey, Pack2UInt32AsUInt64(unHigh32, unLow32));
+ return attributes.Set(guidKey, Pack2UInt32AsUInt64(unHigh32, unLow32));
}
public static Result MFGetAttributeRatio(IMFAttributes attributes, Guid guidKey, out uint numerator, out uint denominator)
@@ -242,6 +242,32 @@ public static Result MFSetAttributeSize(IMFAttributes attributes, Guid guidKey,
return MFSetAttribute2UInt32asUInt64(attributes, guidKey, width, height);
}
+ #region IMFSourceReader
+ public static unsafe IMFSourceReader MFCreateSourceReaderFromByteStream(byte[] buffer, IMFAttributes? attributes = null)
+ {
+ var byteStream = new MFByteStream(new MemoryStream(buffer));
+ IMFSourceReader reader = MFCreateSourceReaderFromByteStream(byteStream, attributes);
+ reader._byteStream = byteStream;
+ return reader;
+ }
+
+ public static unsafe IMFSourceReader MFCreateSourceReaderFromByteStream(Stream buffer, IMFAttributes? attributes = null)
+ {
+ var byteStream = new MFByteStream(buffer);
+ IMFSourceReader reader = MFCreateSourceReaderFromByteStream(byteStream, attributes);
+ reader._byteStream = byteStream;
+ return reader;
+ }
+
+ public static unsafe IMFSourceReader MFCreateSourceReaderFromByteStream(ComStream comStream, IMFAttributes attributes = null)
+ {
+ var byteStream = new MFByteStream(comStream);
+ IMFSourceReader reader = MFCreateSourceReaderFromByteStream(byteStream, attributes);
+ reader._byteStream = byteStream;
+ return reader;
+ }
+ #endregion
+
public static IMFVirtualCamera MFCreateVirtualCamera(
VirtualCameraType type,
VirtualCameraLifetime lifetime,