我正在Windows 10上工作,想从我的电视调谐器USB设备访问视频流。

首先,我尝试使用Media Foundation API,经过几次搜索后才知道此API不支持电视调谐器卡。

然后,我已切换到DirectShow,但枚举视频设备未列出我的电视调谐器设备。仅列出了我的网络摄像头。我发现我应该使用过滤器和引脚,但没有有关此操作的指南。

任何帮助,建议或示例都会有所帮助。

谢谢。

ķ

最佳答案

我这个周末要解决同样的问题:-)。我想制作一个简单的电视调谐器/播放器。直接展示似乎是开发的最后一部分,因为您必须从USB加密狗获取数据。

我进行了很多搜索,但正如您所写,很遗憾,几乎没有指南。但是,我认为,您可以从MS页面开始-Microsoft TV Technologies:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd695086%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
并专注于统一调整模型,这会导致Microsoft统一调整模型在其中提供一些提示以及操作方法。但是,关于代码示例和详细信息的措辞不够严格……这是基于MFC的OLE(我对这项技术还很陌生)。

当前,我正在研究Tuning Spaces,不幸的是,由于注册表权限(我尚未解决),存在一些陷阱。
后来,您应该在编写时了解有关过滤器和引脚的知识。参见https://msdn.microsoft.com/en-us/library/dd377601(v=vs.85).aspx
不幸的是,我不知道如何为DVB-T创建图形。无论如何,关于我的开发人员。在Win 10台式机上,当我打开直接显示滤镜时GraphEdit崩溃了(可能是导致DVB-T HW的当前软件崩溃的原因相同)。我发现了带有替代图形编辑器的有趣博客:
https://en.wikipedia.org/wiki/GraphStudio-检查外部链接。较新的GraphStudioNext看起来也很有前途(我还没有尝试过)。

这是我刚刚开始的方法,希望对您有帮助的也对您有所帮助。如果您有更多经验,欢迎任何建议! :-)

我的测试代码(尚未正常工作!)如下。灵感来自ITuner::put_TuneRequest() call ignored

hCo = CoInitializeEx(nullptr, COINIT::COINIT_APARTMENTTHREADED);

if (hCo == S_OK)
{
    IErrorInfo* pIErrorInfo = nullptr;
    HRESULT hr = S_FALSE;

    // Create the SystemTuningSpaces container.
    PQTuningSpaceContainer pTuningSpaceContainer; // PQTuningSpaceContaineris typedef of CComQIPtr<ITuningSpace
    hr = pTuningSpaceContainer.CoCreateInstance(__uuidof(SystemTuningSpaces));
    if (SUCCEEDED(hr))
    {
        // Get the enumerator for the collection.
        CComPtr<IEnumTuningSpaces> pTuningSpaceEnum;
        hr = pTuningSpaceContainer->get_EnumTuningSpaces(&pTuningSpaceEnum);
        if (SUCCEEDED(hr))
        {
            // Loop through the collection.
            PQTuningSpace pTuningSpace;
            while (S_OK == pTuningSpaceEnum->Next(1, &pTuningSpace, nullptr))
            {
                BSTR bstrDVBValue;
                pTuningSpace->get_UniqueName(&bstrDVBValue);
                printf("%S\n", bstrDVBValue);
                pTuningSpace->get_FriendlyName(&bstrDVBValue);
                printf("%S\n", bstrDVBValue);
                pTuningSpace->get_NetworkType(&bstrDVBValue);
                printf("%S\n\n", bstrDVBValue);
                // pTuningSpace points to the next tuning space.
                // You can query this pointer for derived interfaces.
                pTuningSpace.Release();
            }
        }
    }

    PQDVBTuningSpace pDVBTuningSpace;
    WCHAR szDVBNameU[64] = L"DVB-T";
    WCHAR szDVBNameF[64] = L"Local DVB-T Digital Antenna";
    // WCHAR szDVBNetworkType[64] = L"{B2F3A67C-29DA-4C78-8831-091ED509A475}";
    WCHAR szDVBNetworkType[64] = L"{216C62DF-6D7F-4e9a-8571-05F14EDB766A}"; // DVB-T Network type

    hr = pDVBTuningSpace.CoCreateInstance(__uuidof(DVBTuningSpace));
    if (FAILED(hr))
    {
        printf("Failed to create system tuning spaces object.");
        return;
    }

    hr = pDVBTuningSpace->put_SystemType(DVBSystemType::DVB_Terrestrial);
    if (FAILED(hr))
    {
        printf("Failed to put system type of tuning space.");
        return;
    }

    hr = pDVBTuningSpace->put_NetworkType(szDVBNetworkType);
    if (FAILED(hr))
    {
        printf("Failed to put network type of tuning space.");
        return;
    }

    BSTR bstrDVBNetworkType = SysAllocString(szDVBNetworkType);
    hr = pDVBTuningSpace->put_NetworkType(bstrDVBNetworkType);
    SysFreeString(bstrDVBNetworkType);
    if (FAILED(hr))
    {
        printf("Failed to put network type of tuning space.");
        return;
    }

    BSTR bstrDVBName = nullptr;
    bstrDVBName = SysAllocString(szDVBNameU);
    hr = pDVBTuningSpace->put_UniqueName(bstrDVBName);
    SysFreeString(bstrDVBName);

    bstrDVBName = SysAllocString(szDVBNameF);
    hr = pDVBTuningSpace->put_FriendlyName(bstrDVBName);
    SysFreeString(bstrDVBName);

    if (FAILED(hr))
    {
        printf("Failed to put name of tuning space.");
        return;
    }

    PQDVBTLocator pDVBTLocator;
    hr = pDVBTLocator.CoCreateInstance(__uuidof(DVBTLocator));
    hr = pDVBTLocator->put_CarrierFrequency(538000);
    hr = pDVBTLocator->put_Bandwidth(8);
    hr = pDVBTuningSpace->put_DefaultLocator(pDVBTLocator);
    if (FAILED(hr))
    {
        printf("Failed to put locator of tuning space.");
        return;
    }

    VARIANT tiIndex = {};
    //PQTuningSpaceContainer pTuningSpaceContainer;
    //hr = pTuningSpaceContainer.CoCreateInstance(__uuidof(SystemTuningSpaces));
    hr = pTuningSpaceContainer->Add(pDVBTuningSpace, &tiIndex); // #fix needed: registry permissions
    if (hr == HRESULT_FROM_WIN32(ERROR_DUP_NAME))
    {
        CComPtr<IEnumTuningSpaces> pTuningSpaceEnum;
        hr = pTuningSpaceContainer->get_EnumTuningSpaces(&pTuningSpaceEnum);
        if (SUCCEEDED(hr))
        {
            // Loop through the collection.
            PQTuningSpace pTuningSpace;
            tiIndex.intVal = 0;
            while (S_OK == pTuningSpaceEnum->Next(1, &pTuningSpace, nullptr))
            {
                CComBSTR name;
                hr = pTuningSpace->get_UniqueName(&name);
                if (SUCCEEDED(hr))
                {
                    if (name == szDVBNameU)
                    {
                        hr = pTuningSpaceContainer->put_Item(tiIndex, pDVBTuningSpace); // #fix needed: E_INVALIDARG One or more arguments are invalid.
                        break;
                    }
                }

                tiIndex.intVal++;
                pTuningSpace.Release();
            }
        }
    }

    PQTuneRequest pTuneRequest;
    hr = pDVBTuningSpace->CreateTuneRequest(&pTuneRequest);
    if (FAILED(hr))
    {
        printf("Failed to create tune request.");
        return;
    }

    PQDVBTuneRequest pDVBTuneRequest(pTuneRequest);
    if (pDVBTuneRequest)
    {
        hr = pDVBTuneRequest->put_SID(-1);
        hr = pDVBTuneRequest->put_TSID(-1);
        hr = pDVBTuneRequest->put_ONID(-1);
    }

    CComPtr<IGraphBuilder> pGraph;
    hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX::CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);

    CComPtr<IBaseFilter> pNetworkProvider;
    GUID CLSIDNetworkType;
    hr = pDVBTuningSpace->get__NetworkType(&CLSIDNetworkType);
    hr = CoCreateInstance(CLSIDNetworkType, NULL, CLSCTX::CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void **)&pNetworkProvider);
    hr = pGraph->AddFilter(pNetworkProvider, L"Network Provider");

    //// Query for ITuner.
    CComQIPtr<ITuner> pTuner(pNetworkProvider);
    if (pTuner)
    {
        // Submit the tune request to the network provider.
        hr = pTuner->put_TuneRequest(pTuneRequest);
    }

    // TODO: What next???

    CoUninitialize();

编辑:

这可能会有所帮助:
https://github.com/dgis/CodeTV
(检查并为我工作)

关于c++ - 如何访问BDA设备(例如USB电视调谐器卡),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37069301/

10-12 21:34