11#include <wrl\implements.h>
12#include <wrl\wrappers\corewrappers.h>
13#include <Roerrorapi.h>
24#include <windows.media.h>
25#include <windows.media.mediaproperties.h>
27namespace AWM = ::ABI::Windows::Media;
28namespace AWMMp = ::ABI::Windows::Media::MediaProperties;
29namespace AWFC = ::ABI::Windows::Foundation::Collections;
30namespace MW = ::Microsoft::WRL;
31namespace MWD = ::Microsoft::WRL::Details;
32namespace MWW = ::Microsoft::WRL::Wrappers;
33namespace WMC = ::Windows::Media::Capture;
34namespace WF = ::Windows::Foundation;
35namespace WMMp = ::Windows::Media::MediaProperties;
36namespace WSS = ::Windows::Storage::Streams;
39#define CHK(statement) {HRESULT _hr = (statement); if (FAILED(_hr)) { throw ref new Platform::COMException(_hr); };}
40#define CHKNULL(p) {if ((p) == nullptr) { throw ref new Platform::NullReferenceException(L#p); };}
43#define CHK_RETURN(statement) {hr = (statement); if (FAILED(hr)) { return hr; };}
46template<
typename T,
typename U>
47MW::ComPtr<T>
As(U^ in)
50 CHK(
reinterpret_cast<IInspectable*
>(in)->QueryInterface(IID_PPV_ARGS(&out)));
55template<
typename T,
typename U>
56Microsoft::WRL::ComPtr<T>
As(
const Microsoft::WRL::ComPtr<U>& in)
58 Microsoft::WRL::ComPtr<T> out;
64template<
typename T,
typename U>
65Microsoft::WRL::ComPtr<T>
As(U* in)
67 Microsoft::WRL::ComPtr<T> out;
68 CHK(in->QueryInterface(IID_PPV_ARGS(&out)));
73inline unsigned char*
GetData(_In_ WSS::IBuffer^ buffer)
75 unsigned char* bytes =
nullptr;
76 CHK(As<WSS::IBufferByteAccess>(buffer)->Buffer(&bytes));
85 : _bInitialized(false)
87 CHK(MFStartup(MF_VERSION));
108 ::RoOriginateErrorW(hr, N - 1, str);
118 ::RoOriginateErrorW(hr, 0,
nullptr);
124template <
typename Lambda>
132 catch (Platform::Exception^ e)
136 catch (
const std::bad_alloc&)
138 return E_OUTOFMEMORY;
140 catch (
const std::exception&)
150ref class MediaSample
sealed
153 MW::ComPtr<IMFSample> Sample;
unsigned char * GetData(_In_ WSS::IBuffer^ buffer)
Definition: MFIncludes.h:73
HRESULT OriginateError(__in HRESULT hr, __in wchar_t const (&str)[N])
Definition: MFIncludes.h:104
HRESULT ExceptionBoundary(Lambda &&lambda)
Definition: MFIncludes.h:125
MW::ComPtr< T > As(U^ in)
Definition: MFIncludes.h:47
#define CHK(statement)
Definition: MFIncludes.h:39
Definition: MFIncludes.h:82
AutoMF()
Definition: MFIncludes.h:84
~AutoMF()
Definition: MFIncludes.h:90