MediaFoundation can´t find video capture emulator

2019-07-20 20:03发布

We are developing a software in which we preview and record an input video source captured from a video-capture card. The preview is implemented with DirectShow and the recording with Media Foundation (it´s an old software slowly upgrading to MediaFoundation)

The problem is with MediaFoundation: it seems to find correctly the video-capture card at our release machine, but not the "screen-capture" video emulator that we use at the testing machines. At the other hand, the DirectShow code finds correctly both, the video-capture device and the screen-capture device emulator.

So, why can´t MediaFoundation find the emulator driver?

Note: The emulator is made in DirectShow... It is VHScrCap

Here is the MediaFoundation code:

HRESULT DeviceList::EnumerateVideoDevices(){
HRESULT hr = S_OK;
IMFAttributes *pAttributes = NULL;

ClearVideo();

// Initialize an attribute store. We will use this to 
// specify the enumeration parameters.

hr = MFCreateAttributes(&pAttributes, 1);

// Ask for source type = video capture devices
if (SUCCEEDED(hr))
{
    hr = pAttributes->SetGUID(
        MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, 
        MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID
        );
}

// Enumerate devices.
if (SUCCEEDED(hr))
{
    hr = MFEnumDeviceSources(pAttributes, &m_ppVideoDevices, &m_cVideoDevices);
}

SafeRelease(&pAttributes);

return hr;

}

At hr = MFEnumDeviceSources(pAttributes, &m_ppVideoDevices, &m_cVideoDevices); no devices are found.

Thanks!

1条回答
叛逆
2楼-- · 2019-07-20 20:32

Media Foundation is not supposed to pick so called "virtual" DirectShow video sources. DirectShow offers video sources through the Video Input category, which includes filters backed by WDM driver devices and then any other filters registered into this category. Media Foundation has its own adapter to expose WDM capture devices, but DirectShow filters are invisible there. Basically you want a separate emulator for Media Foundation.

From MSDN:

Starting in Windows 7, Media Foundation automatically supports audio and video capture devices. For video, the device must provide a kernel streaming (KS) minidriver in the video capture category. Media Foundation uses the PnP path to enumerate the device. For audio, Media Foundation uses the Windows Multimedia Device (MMDevice) API to enumerate audio endpoint devices. If the device meets these criteria, there is no need to implement a custom media source.

However, you might want to implement a custom media source for some other type of device or other live data source. There are only a few differences between a live source and other media sources:

查看更多
登录 后发表回答