Skip to content

Commit

Permalink
Merge branch 'joewen-CreateByteStream_Support_Windows7'
Browse files Browse the repository at this point in the history
  • Loading branch information
markheath committed Jan 31, 2017
2 parents d557ac4 + 64ebc57 commit eb6b506
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 12 additions & 0 deletions NAudio/MediaFoundation/MediaFoundationHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.InteropServices;
using System.Text;
using NAudio.Wave;
using System.Runtime.InteropServices.ComTypes;

namespace NAudio.MediaFoundation
{
Expand Down Expand Up @@ -143,7 +144,18 @@ public static IMFAttributes CreateAttributes(int initialSize)
public static IMFByteStream CreateByteStream(object stream)
{
IMFByteStream byteStream;
#if NETFX_CORE
MediaFoundationInterop.MFCreateMFByteStreamOnStreamEx(stream, out byteStream);
#else
if (stream is IStream)
{
MediaFoundationInterop.MFCreateMFByteStreamOnStream(stream as IStream, out byteStream);
}
else
{
throw new ArgumentException("Stream must be IStream in desktop apps");
}
#endif
return byteStream;
}

Expand Down
15 changes: 13 additions & 2 deletions NAudio/MediaFoundation/MediaFoundationInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using NAudio.Wave;
using System.Runtime.InteropServices.ComTypes;

namespace NAudio.MediaFoundation
{
Expand Down Expand Up @@ -64,13 +65,23 @@ public static extern void MFCreateSourceReaderFromURL([In, MarshalAs(UnmanagedTy
public static extern void MFCreateSinkWriterFromURL([In, MarshalAs(UnmanagedType.LPWStr)] string pwszOutputURL,
[In] IMFByteStream pByteStream, [In] IMFAttributes pAttributes, [Out] out IMFSinkWriter ppSinkWriter);


#if NETFX_CORE
/// <summary>
/// Creates a Microsoft Media Foundation byte stream that wraps an IRandomAccessStream object.
/// </summary>
[DllImport("mfplat.dll", ExactSpelling = true, PreserveSig = false)]
public static extern void MFCreateMFByteStreamOnStreamEx([MarshalAs(UnmanagedType.IUnknown)] object punkStream, out IMFByteStream ppByteStream);

#if !NETFX_CORE
#else
/// <summary>
/// Creates a Microsoft Media Foundation byte stream that wraps an IRandomAccessStream object.
/// </summary>
[DllImport("mfplat.dll", ExactSpelling = true, PreserveSig = false)]
public static extern void MFCreateMFByteStreamOnStream([In] IStream punkStream, out IMFByteStream ppByteStream);
#endif

#if !NETFX_CORE
/// <summary>
/// Gets a list of Microsoft Media Foundation transforms (MFTs) that match specified search criteria.
/// </summary>
Expand Down Expand Up @@ -100,7 +111,7 @@ internal static extern void MFCreateAttributes(
[Out, MarshalAs(UnmanagedType.Interface)] out IMFAttributes ppMFAttributes,
[In] int cInitialSize);

#if !NETFX_CORE
#if !NETFX_CORE
/// <summary>
/// Gets a list of output formats from an audio encoder.
/// </summary>
Expand Down

0 comments on commit eb6b506

Please sign in to comment.