Search code examples
c++windowsms-media-foundation

"There are no more endpoints available from the endpoint mapper." when creating or activating an IMFMediaSource


Using the Microsoft tutorial on Audio/Video Capture in Media Foundation, I try to create a media source for a video camera. Code below is directly taken from the aforementioned tutorial:

HRESULT CreateVideoCaptureDevice(IMFMediaSource **ppSource)
{
    *ppSource = NULL;

    UINT32 count = 0;

    IMFAttributes *pConfig = NULL;
    IMFActivate **ppDevices = NULL;

    // Create an attribute store to hold the search criteria.
    HRESULT hr = MFCreateAttributes(&pConfig, 1);

    // Request video capture devices.
    if (SUCCEEDED(hr))
    {
        hr = pConfig->SetGUID(
            MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, 
            MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
            );
    }

    // Enumerate the devices,
    if (SUCCEEDED(hr))
    {
        hr = MFEnumDeviceSources(pConfig, &ppDevices, &count);
    }

    // Create a media source for the first device in the list.
    if (SUCCEEDED(hr))
    {
        if (count > 0)
        {
            hr = ppDevices[0]->ActivateObject(IID_PPV_ARGS(ppSource));
        }
        else
        {
            hr = MF_E_NOT_FOUND;
        }
    }

    for (DWORD i = 0; i < count; i++)
    {
        ppDevices[i]->Release();
    }
    CoTaskMemFree(ppDevices);
    return hr;
}

On a specific machine (Windows 10), after executing the ActivateObject method, the result passed to hr is the following error code:

HResult 0x800706d9: "There are no more endpoints available from the endpoint mapper."

Using the alternative method for creating a source, described in the tutorial and using the MFCreateDeviceSource method, gives the same result.

Any video camera devices on this machine give the same result, but the same code on another machine works just fine.

This error code is referenced many times on the web, but always seem to be related to connecting to a printer, joining a domain, or other network stuff. The proposed solutions of changing the firewall settings did not fix my issue.


Solution

  • In my case, the culprit was a disabled service: Windows Camera Frame Server.

    I had to enable it (Automatic startup) through the Services application and start it:

    Windows Camera Frame Server

    After that the error did not occurred again.

    On a related note, I also had to allow applications to access the camera:

    Local Group Policy: Computer Configuration / Administrative Templates / Windows Components / App Privacy

    "Let Windows apps access the camera" must be set to "Not configured".