在graphstudio中可用的引脚不存在代码 [英] Pins avaiable in graphstudio not there in code

查看:130
本文介绍了在graphstudio中可用的引脚不存在代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用网络摄像头的源过滤器。当我在graphstudio中使用过滤器时,它有两个输出引脚。但是在代码中,对IEnumPins-> next的调用总是返回S_FALSE。
我还寻找另一个可以创建pin的接口,但没有找到这样的东西。

I am using a source filter of a webcam. When I use the filter in graphstudio it has two output pins. However in code the call to IEnumPins->next always returns S_FALSE. I also looked for another interface that could create pins but didn't find such a thing.

如何添加引脚到网络摄像头过滤器?如果他们在graphstudio中可用,他们应该在代码太对了,对吧?

How do I add pins to the webcam filter? If they're available in graphstudio they should be in code too, right?

这里是我的代码..我检查了返回值,如果他们不确定返回。但是除了网络摄像头过滤器没有返回任何pin外,一切似乎都正常工作。

Here is my code.. I checked for return values and returned them if they are not ok. But everything seems to work fine except that the webcam filter doesn't return any pins

CoInitialize(NULL);

    IGraphBuilder* graphBuilder = NULL;
    IMediaControl* mediaControl = NULL;
    IMediaEvent* mediaEvent = NULL;

    HRESULT hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IFilterGraph, (void **)&graphBuilder);

    HANDLE fileHandle = CreateFile(L"D:\\TEMP\\debug1.log", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL);

    graphBuilder->SetLogFile((DWORD_PTR)fileHandle);
    graphBuilder->QueryInterface(IID_IMediaControl, (void **)&mediaControl);
    graphBuilder->QueryInterface(IID_IMediaEvent, (void **)&mediaEvent);

    IBaseFilter* source = NULL;


    static const GUID CLSID_Webcam =
    { 0x17CCA71B, 0xECD7, 0x11D0, { 0xB9, 0x08, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 } };
    hr = CoCreateInstance(CLSID_Webcam, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&source);
    if (FAILED(hr))
        return hr;
    hr = graphBuilder->AddFilter(source, L"logitech");
    if (FAILED(hr))
        return hr;


    IPin* camOut = GetPin(source, PINDIR_OUTPUT);
    ...

GetPin函数使用EnumPins方法查找pin:

The GetPin function uses EnumPins method to find pin:

IPin *GetPin(IBaseFilter *pFilter, PIN_DIRECTION PinDir)
{
    BOOL       bFound = FALSE;
    IEnumPins  *pEnum;
    IPin       *pPin;

    pFilter->EnumPins(&pEnum);
    while (pEnum->Next(1, &pPin, 0) == S_OK)
    {
        PIN_DIRECTION PinDirThis;
        pPin->QueryDirection(&PinDirThis);
        if (bFound = (PinDir == PinDirThis))
            break;
        pPin->Release();
    }
    pEnum->Release();
    return (bFound ? pPin : 0);
}

此外,我不认为这是32/64位问题。我编译到x64和我也使用64位版本的graphstudionext。我还确保网络摄像头过滤器的guid是正确的。 (至少如果你可以信任graphstudionext)

Also, I don't think that this is 32/64bit problem. I compile to x64 and I also used the 64bit version of graphstudionext. And i also made sure that the guid of the webcam filter is correct. (At least if you can trust graphstudionext)

推荐答案

这表明你的代码处理另一个过滤器或有错误否则。通常不要创建引脚,特别是在支持视频设备的源过滤器上。典型的原因是:(a)您正在有效地创建一个不同的过滤器,(b)在您的代码中直接错误,(c)32/64位问题与两个环境中的不同的过滤器。几乎没有什么。仔细检查您的代码,添加调试输出应该可以解决问题。

This is an indication that your code deals with another filter or has bugs otherwise. You normally don't "create" pins, especially on video device backed source filter. Typical reasons are: (a) you are effectively creating a different filter, (b) direct bug in your code, (c) 32/64-bit issue with different filters in the two environments. There can hardly be anything else. Stepping and inspecting your code thoroughly, adding debug output should take you to the solution.

UPDATE。这样的视频捕获设备不能使用 CoCreateInstance 实例化。你必须使用monikers来创建它们。通常通过枚举,如MSDN(包含源代码段)所述:选择捕获设备

UPDATE. Video capture devices like this cannot be instantiated using CoCreateInstance. You have to create them using monikers. typically through enumeration, as described on MSDN (with source code snippet): Selecting a Capture Device.

以下代码不正确,FYI此GUID在SDK中声明为 CLSID_Proxy

The code below is incorrect, FYI this GUID is declared in SDK as CLSID_Proxy.

 static const GUID CLSID_Webcam =
{ 0x17CCA71B, 0xECD7, 0x11D0, { 0xB9, 0x08, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96 } };
hr = CoCreateInstance(CLSID_Webcam, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&source);

这篇关于在graphstudio中可用的引脚不存在代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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