我正在使用Windows 10,并希望从我的电视调谐器USB设备访问视频流。
首先,我尝试使用媒体基础api,经过几次搜索后才知道这个API不支持电视调谐卡。
然后我切换到directshow但枚举视频设备没有列出我的电视调谐器设备。仅列出了我的网络摄像头。我发现我应该使用过滤器&这些操作没有指南。
任何帮助,建议或示例都会有所帮助。
感谢。
ķ
答案 0 :(得分:1)
本周末我正在解决同样的问题:-)。我想制作一个简单的电视调谐器/播放器。直接展示似乎是开发的最后一部分,因为你必须从USB加密狗那里获取数据。
我搜索了很多,但正如你所写,很遗憾几乎没有指南。但是,我想,你可以从MS页面开始 - 微软电视技术: https://msdn.microsoft.com/en-us/library/windows/desktop/dd695086%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 并专注于统一调优模型,它导致Microsoft统一调优模型,其中有一些提示,如何。然而,关于代码和细节的例子,我们已经特别关注......这是基于带有OLE的MFC(我对这项技术很陌生)。
目前,我正在研究部分调优空间,不幸的是,有一些陷阱,作为注册表权限(我还没有解决这个问题)。 之后,你应该了解过滤器和放大器。你写的时候是别针。见https://msdn.microsoft.com/en-us/library/dd377601(v=vs.85).aspx。 不幸的是,我不知道如何为DVB-T创建图表。无论如何,在我的开发。桌面与Win 10 GraphEdit在我打开直接显示过滤器时崩溃(可能与崩溃DVB-T HW的当前SW的原因相同)。我发现有趣的博客与替代图表编辑器: 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 (检查并为我工作)