MediaFoundation can´t find video capture emulator driver. But DirectShow does

孤街醉人 提交于 2019-12-24 02:52:14

问题


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:


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:



来源:https://stackoverflow.com/questions/24612174/mediafoundation-can%c2%b4t-find-video-capture-emulator-driver-but-directshow-does

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!