c++videoms-media-foundationdirect3d9

Some Service interface are not supported in the MFGetService helper function


I'm trying to get a pointer to the IDirect3DSurface9 and I use the the helper function MFGetService and I pass MR_BUFFER_SERVICE to the second parameter.While linking,I received a "unresolved external symbol _MR_BUFFER_SERVICE" error.

I looked up the definition of MR_BUFFER_SERVICE in evr.h and found a macro describing it:

DEFINE_GUID(MR_BUFFER_SERVICE, 
    0xa562248c, 
    0x9ac6, 
    0x4ffc, 
    0x9f, 0xba, 0x3a, 0xf8, 0xf8, 0xad, 0x1a, 0x4d 
);

And then I decided to make this GUID on my own and passed to the MFGetService, but then I get the error code E_NOINTERFACE while debugging.

//Here are the GUID struct I made:
const GUID FAR MR_BUFFER_SERVICE = { 0xa562248c,0x9ac6,0x4ffc, {0x9f, 0xba, 0x3a, 0xf8, 0xf8, 0xad, 0x1a, 0x4d} };

//The main code of getting a pointer to IDirect3DSurface9:
IDirect3DSurface9 *d3dsurface9;
IMFMediaBuffer* pBuffer = NULL;
hr = MFCreateMemoryBuffer(1024 * 10, &pBuffer);
if (FAILED(hr))
{
    MessageBox(NULL, L"fail in creating Media Buffer", NULL, NULL);
}
    hr = MFGetService(pBuffer, MR_BUFFER_SERVICE, 
        IID_PPV_ARGS(&d3dsurface9));
if (FAILED(hr))
{
    MessageBox(NULL, L"failed in getting IDirect3DSurface9", NULL, NULL);
}

Solution

    1. Linker error is to be resolved by additionally linking strmiids.lib
    #pragma comment(lib, "strmiids.lib")
    
    1. MR_BUFFER_SERVICE is not available from generic system memory backed buffers you create by MFCreateMemoryBuffer. This service is only available from buffers which are wrapping respective D3D9 surface, esp. created with MFCreateDXSurfaceBuffer function.

    The details are documented here: DirectX Surface Buffer.