DirectShow筛选器未显示为输入捕获设备 [英] DirectShow filter is not shown as input capture device

查看:140
本文介绍了DirectShow筛选器未显示为输入捕获设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从捕获源过滤器的绝佳示例开始在这里我编写了自己的输入捕获设备可以在Graph Studio Next中正常运行,但在Skype或类似应用程序中未显示为捕获设备(即网络摄像头).

Starting from the great example of Capture Source Filter here I wrote my own input capture device that works fine in Graph Studio Next, but it's not shown as a capture device (i.e. webcam) in application like Skype or similar.

因为我想了解正在发生的事情,所以请您帮助我找出那些应用程序需要显示这样的设备.

Because I want to understand what's happening I ask you to help me to find out what those application need to show such a device.

一些相关代码:

dll.cpp

DEFINE_GUID(CLSID_VirtualCam, 0x8e14549a, 0xdb61, 0x4309, 0xaf, 0xa1, 0x35, 0x78, 0xe9, 0x27, 0xe9, 0x33);

const AMOVIESETUP_MEDIATYPE AMSMediaTypesVideo = 
{
    &MEDIATYPE_Video,
    &MEDIASUBTYPE_NULL
};

const AMOVIESETUP_PIN AMSPinVCam[] =
{
    {
        L"Output",             // Pin string name
        FALSE,                 // Is it rendered
        TRUE,                  // Is it an output
        FALSE,                 // Can we have none
        FALSE,                 // Can we have many
        &CLSID_NULL,           // Connects to filter
        NULL,                  // Connects to pin
        1,                     // Number of types
        &AMSMediaTypesVideo      // Pin Media types
    }
};

const AMOVIESETUP_FILTER AMSFilterVCam =
{
    &CLSID_VirtualCam,  // Filter CLSID
    FILTER_NAME,     // String name
    MERIT_PREFERRED,      // Filter merit
    1,                     // Number pins
    AMSPinVCam             // Pin details
};

CFactoryTemplate g_Templates[] = 
{
    {
        FILTER_NAME,
        &CLSID_VirtualCam,
        CVCam::CreateInstance,
        NULL,
        &AMSFilterVCam
    },
};

Filter.cpp

CVCam::CVCam(LPUNKNOWN lpunk, HRESULT *phr) : CSource(LPCSTR(FILTER_NAME), lpunk, CLSID_VirtualCam)
{
    ASSERT(phr);
    CAutoLock cAutoLock(&m_cStateLock);
    m_paStreams = (CSourceStream **) new CVCamStream*[1];
    m_paStreams[0] = new CVCamStream(phr, this, FILTER_NAME);
}

HRESULT CVCam::QueryInterface(REFIID riid, void **ppv)
{
    if (riid == _uuidof(IAMStreamConfig) || riid == _uuidof(IKsPropertySet))
    {
        HRESULT hr;
        hr = m_paStreams[0]->QueryInterface(riid, ppv);
        if (hr != S_OK) return hr;
    }
    else return CSource::QueryInterface(riid, ppv);

    return S_OK;
}

CVCamStream::CVCamStream(HRESULT *phr, CVCam *pParent, LPCWSTR pPinName) : CSourceStream(LPCSTR(FILTER_NAME),phr, pParent, pPinName), m_pParent(pParent)
{
    hdc = GetDC(NULL);

    Gdiplus::GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    screen_height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
    screen_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);

    GetMediaType(8, &m_mt);
}

CVCamStream::~CVCamStream()
{
    Gdiplus::GdiplusShutdown(gdiplusToken);
    DeleteDC(hdc);
} 

HRESULT CVCamStream::QueryInterface(REFIID riid, void **ppv)
{   
    if(riid == _uuidof(IAMStreamConfig)) *ppv = (IAMStreamConfig*)this;
    else if(riid == _uuidof(IKsPropertySet)) *ppv = (IKsPropertySet*)this;
    else return CSourceStream::QueryInterface(riid, ppv);

    AddRef();
    return S_OK;
}

我省略了与链接的示例完全相同的其他功能,我想配置是在这些功能中完成的.

I omitted the other functions that are pretty the same of the example linked and I guess the configuration is made in these ones.

您是否看到我缺少的任何证据导致过滤器无法识别为视频捕获设备?

Do you see any evidence of my lack that leads the filter to be not recognized as a video capture device?

当然,过滤器已注册(我在DirectShow过滤器管理器中看到了它.)

Of course the filter is registered (I see it in the DirectShow Filter Manager).

推荐答案

不幸的是,您所引用的DirectShow输入设备项目不是旨在将类似摄像机的实现带入任何启用了视频捕获功能的应用程序的API.

The DirectShow input device project you are refering to is not an API which is designed to take your camera-like implementation into any video capture enabled application, unfortunately.

您开发的视频源仅对使用DirectShow API的视频捕获应用程序具有可见性并且与过滤器匹配时才可见.尽管仍然有许多应用程序仍在使用DirectShow,但它们的速度往往会随着时间的推移而缓慢下降.例如,新的Skype未使用DirectShow,而Skype for Business只是前Lync的新名称,这意味着就视频捕获而言,几乎没有与Skype共享的源代码.

The video source you developed will only be visible to application consuming video capture using DirectShow API and having a matching bitness with your filter. Even though quite so many applications out there are still using DirectShow, their rate tends to slowly go down with the time. For example, new Skype is not using DirectShow and Skype for Business is just a new name for former Lync meaning that there is little if any shared source code with Skype in terms of video capture.

我在这篇文章中有更多的技术细节: Virtual DirectShow来源的适用性和图片帖子中应说明您的视频源对哪些应用程序是可见的"(绿色框):

I have more of technical details in this post: Applicability of Virtual DirectShow Sources and the picture from the post should give the idea for which applications your video source is "viisble" (green boxes):

另请参阅:

  • DirectShow Virtual Camera does not appear in the list on some configurations
  • Virtual Driver Cam not recognized by browser

这篇关于DirectShow筛选器未显示为输入捕获设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆