我正在windows 10上工作,我想从我的电视调谐器usb设备上访问视频流。
首先,我尝试使用媒体基础api,经过几次搜索后,我知道这个API不支持电视调谐器卡。
然后我切换到directshow,但是枚举视频设备没有列出我的电视调谐器设备。只有我的摄像头被列出来了。我发现我应该使用过滤器和引脚,但是没有这样的操作指南。
任何帮助、建议或榜样都是有帮助的。
谢谢。
K
发布于 2016-07-18 00:08:49
我这个周末要解决同样的问题:-)。我想做一个简单的电视调谐器/播放器。直接显示似乎是开发的最后一部分,因为你必须从USB接口获取数据。
我搜索了很多,但正如你所写的,不幸的是,几乎没有导游。但是,我认为,您可以从MS Microsoft技术:https://msdn.microsoft.com/en-us/library/windows/desktop/dd695086%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396开始,重点关注统一调优模型,这将导致,其中有一些提示,如何。然而,对于代码和细节的例子,漂亮的闭上了嘴.这是基于MFC与OLE (我是相当新的这项技术)。
目前,我正在处理部分调优空间,不幸的是,存在一些缺陷,比如注册表权限(我还没有解决这个问题)。稍后,当你写作时,你应该对过滤器和引脚有一个了解。见https://msdn.microsoft.com/en-us/library/dd377601(v=vs.85).aspx。不幸的是,我不知道如何为DVB-T创建一个图形。不管怎么说,在我的手机上。桌面与Win 10,GraphEdit是崩溃时,我打开直接显示过滤器(可能是相同的原因是崩溃电流西南的DVB- the )。我发现有趣的博客与替代图形编辑器:https://en.wikipedia.org/wiki/GraphStudio -检查外部链接。新的GraphStudioNext看起来也很有希望(我还没试过这个)。
这就是我刚刚开始的方式,希望这能帮到你,如果你还感兴趣的话。如果您有更多的经验,欢迎您提出任何建议!:
我的测试代码(还没有正常工作!)是在咆哮。受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 (检查并为我工作)
https://stackoverflow.com/questions/37069301
复制相似问题