1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef WMF_H_ 8 #define WMF_H_ 9 10 #include <windows.h> 11 #include <mfapi.h> 12 #include <mfidl.h> 13 #include <mfreadwrite.h> 14 #include <mfobjects.h> 15 #include <ks.h> 16 #include <stdio.h> 17 #include <mferror.h> 18 #include <propvarutil.h> 19 #include <wmcodecdsp.h> 20 #include <d3d9.h> 21 #include <dxva2api.h> 22 #include <wmcodecdsp.h> 23 #include <codecapi.h> 24 25 // The Windows headers helpfully declare min and max macros, which don't 26 // compile in the presence of std::min and std::max and unified builds. 27 // So undef them here. 28 #ifdef min 29 # undef min 30 #endif 31 #ifdef max 32 # undef max 33 #endif 34 35 // Some SDK versions don't define the AAC decoder CLSID. 36 #ifndef CLSID_CMSAACDecMFT 37 extern "C" const CLSID CLSID_CMSAACDecMFT; 38 # define WMF_MUST_DEFINE_AAC_MFT_CLSID 39 #endif 40 41 namespace mozilla { 42 namespace wmf { 43 44 // If successful, loads all required WMF DLLs and calls the WMF MFStartup() 45 // function. This delegates the WMF MFStartup() call to the MTA thread if 46 // the current thread is not MTA. This is to ensure we always interact with 47 // WMF from threads with the same COM compartment model. 48 HRESULT MFStartup(); 49 50 // Calls the WMF MFShutdown() function. Call this once for every time 51 // wmf::MFStartup() succeeds. Note: does not unload the WMF DLLs loaded by 52 // MFStartup(); leaves them in memory to save I/O at next MFStartup() call. 53 // This delegates the WMF MFShutdown() call to the MTA thread if the current 54 // thread is not MTA. This is to ensure we always interact with 55 // WMF from threads with the same COM compartment model. 56 HRESULT MFShutdown(); 57 58 // All functions below are wrappers around the corresponding WMF function, 59 // and automatically locate and call the corresponding function in the WMF DLLs. 60 61 HRESULT MFCreateMediaType(IMFMediaType** aOutMFType); 62 63 HRESULT MFGetStrideForBitmapInfoHeader(DWORD aFormat, DWORD aWidth, 64 LONG* aOutStride); 65 66 HRESULT MFGetService(IUnknown* punkObject, REFGUID guidService, REFIID riid, 67 LPVOID* ppvObject); 68 69 HRESULT DXVA2CreateDirect3DDeviceManager9( 70 UINT* pResetToken, IDirect3DDeviceManager9** ppDXVAManager); 71 72 HRESULT MFCreateDXGIDeviceManager(UINT* pResetToken, 73 IMFDXGIDeviceManager** ppDXVAManager); 74 75 HRESULT MFCreateSample(IMFSample** ppIMFSample); 76 77 HRESULT MFCreateAlignedMemoryBuffer(DWORD cbMaxLength, DWORD fAlignmentFlags, 78 IMFMediaBuffer** ppBuffer); 79 80 HRESULT MFCreateDXGISurfaceBuffer(REFIID riid, IUnknown* punkSurface, 81 UINT uSubresourceIndex, 82 BOOL fButtomUpWhenLinear, 83 IMFMediaBuffer** ppBuffer); 84 85 } // end namespace wmf 86 } // end namespace mozilla 87 88 #endif 89