2

我有一个带有“Microsoft DVBT Network Provider”、“AVerMedia BDA DVBT Tuner”、“AVerMEdia BDA Digital Capture”、“Sample Grabber”和“NULL Renderer”的 DirectShow 图。

这些过滤器是相连的。

除此之外,我还有一个“MPEG-2 Demultiplexer”和一个“BDA MPEG2 Transport Information Filter”,但这两个过滤器没有连接!似乎他们必须在这里才能运行图表。

当我启动图表时,我正在接收 TS 数据,但无论我做什么,我都无法提出调整请求。我只能使用 Windows Media Center 等其他应用程序从上次调谐频率中捕获 MUX 数据。

这是放置调谐请求的代码:

// creating tuning space

CComPtr<IDVBTuningSpace> pDVBTuningSpace;<br>
hr = pDVBTuningSpace.CoCreateInstance( __uuidof( DVBTuningSpace ) );

WCHAR szFriendlyName[ 64 ] = L"Local DVB-T Digital Antenna";<br> BSTR bstrFriendlyName = SysAllocString( szFriendlyName );

hr = pDVBTuningSpace->put_UniqueName( bstrFriendlyName );<br>
hr = pDVBTuningSpace->put_FriendlyName( bstrFriendlyName );

SysFreeString( bstrFriendlyName );

CComBSTR clsid_dvbt = ("{216C62DF-6D7F-4e9a-8571-05F14EDB766A}");<br>
hr = pDVBTuningSpace->put_NetworkType( clsid_dvbt );<br>
hr = pDVBTuningSpace->put_SystemType( DVB_Terrestrial );<br>


// creating tune request<br>
CComPtr<ITuneRequest> pTuneRequest;

hr = pDVBTuningSpace->CreateTuneRequest( &pTuneRequest );

CComQIPtr<IDVBTuneRequest> pDVBTuneRequest( pTuneRequest );

hr = pDVBTuneRequest->put_ONID( -1 );<br>
hr = pDVBTuneRequest->put_TSID( -1 );<br>
hr = pDVBTuneRequest->put_SID( -1 );

// locator<br>
CComPtr<IDVBTLocator> pDVBTLocator;

hr = pDVBTLocator.CoCreateInstance( __uuidof( DVBTLocator ) );<br>
hr = pDVBTLocator->put_Bandwidth( 8 );<br>
hr = pDVBTLocator->put_CarrierFrequency( 506000 );

hr = pDVBTuneRequest->put_Locator( pDVBTLocator );

CComQIPtr<ITuner> pTuner( pNetworkProvider_ );

hr = pTuner->put_TuneRequest( pDVBTuneRequest );

在图中添加“Microsoft DVBT Network Provider”过滤器后立即执行此操作。
上述代码中的所有“hr”值都是 S_OK。

我究竟做错了什么?或者,我是否错过了这个“调音请求”的一些重要内容。

(带宽和频率值是正确的)

4

1 回答 1

2

我认为put_Bandwidth( 8 )是错误的,它应该是以Hz为单位的带宽。无论如何,我向您展示我使用的一些代码。也许它有帮助。

HRESULT hr;
CComBSTR TuningName;

hr = pDVBTuningSpace2.CoCreateInstance(CLSID_DVBTuningSpace);

hr = pDVBTuningSpace2->put_SystemType(DVB_Terrestrial);

TuningName = L"My DVB-T";
hr = pDVBTuningSpace2->put__NetworkType(CLSID_DVBTNetworkProvider);

CComPtr <IDVBTLocator> pDVBTLocator;
hr = pDVBTLocator.CoCreateInstance(CLSID_DVBTLocator);
hr = pDVBTLocator->put_CarrierFrequency(config->GetFreq());
hr = pDVBTLocator->put_Bandwidth(config->GetSymbolRate());
hr = pDVBTuningSpace2->put_DefaultLocator(pDVBTLocator);

hr = pDVBTuningSpace2->put_UniqueName(TuningName);
hr = pDVBTuningSpace2->put_FriendlyName(TuningName);
hr = pDVBTuningSpace2->put_FrequencyMapping(L"");

CComPtr <ITuningSpaceContainer> pTuningSpaceContainer;
hr = pTuningSpaceContainer.CoCreateInstance(CLSID_SystemTuningSpaces);

VARIANT tiIndex;
hr = pTuningSpaceContainer->Add(pDVBTuningSpace2,&tiIndex);    

if (!SUCCEEDED(hr)) {
    // Get the enumerator for the collection.
    CComPtr<IEnumTuningSpaces> pTuningSpaceEnum;
    hr = pTuningSpaceContainer->get_EnumTuningSpaces(&pTuningSpaceEnum);
    if (SUCCEEDED(hr)) {
        // Loop through the collection.
        CComPtr<ITuningSpace> pTuningSpace;
        //ITuningSpace *pTuningSpace;
        tiIndex.intVal=0;
        while (S_OK == pTuningSpaceEnum->Next(1, &pTuningSpace, NULL)) {
            USES_CONVERSION;
            BSTR Name;

            hr = pTuningSpace->get_UniqueName(&Name);
            if (SUCCEEDED(hr)) {
                if (wcscmp(OLE2W(Name), TuningName) == 0) {
                    hr = pTuningSpaceContainer->put_Item(tiIndex,pDVBTuningSpace2);
                }
                SysFreeString(Name);
            }

            tiIndex.intVal++;
            //pTuningSpace->Release();
            pTuningSpace.Release();
        }
    }
}

CComPtr<ITuneRequest> pTuneRequest;
hr = pDVBTuningSpace2->CreateTuneRequest(&pTuneRequest);

CComQIPtr<IDVBTuneRequest> pDVBTuneRequest(pTuneRequest);
if(pDVBTuneRequest) {

    hr = pDVBTuneRequest->put_SID(config->GetSid());
    hr = pDVBTuneRequest->put_TSID(config->GetTsid());
    hr = pDVBTuneRequest->put_ONID(config->GetOnid());
}

GUID CLSIDNetworkType;
hr = pDVBTuningSpace2->get__NetworkType(&CLSIDNetworkType);

hr = CoCreateInstance(CLSIDNetworkType, NULL, CLSCTX_INPROC_SERVER,
                      IID_IBaseFilter, (void **) &pNetworkProvider);
hr = graph->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);
}

hr = graph->AddFilter(pBdaNetworkTuner,L"BDA Source");
hr = ConnectFilters(pNetworkProvider,pBdaNetworkTuner);
CComPtr<IBaseFilter> pBdaReceiver;
hr = FindDevice(KSCATEGORY_BDA_RECEIVER_COMPONENT, &pBdaReceiver, 0, 0, 0);

hr = graph->AddFilter(pBdaReceiver,L"BDA Receiver");
hr = ConnectFilters(pBdaNetworkTuner,pBdaReceiver);

CComPtr<IBaseFilter> pMpegDemux;
hr = pMpegDemux.CoCreateInstance(CLSID_MPEG2Demultiplexer);
hr = graph->AddFilter(pMpegDemux,L"MPEG Demux");
hr = ConnectFilters(pBdaReceiver,pMpegDemux);

你正在以不同的顺序做一些事情,但我不确定它是否重要。

于 2010-11-25T21:31:25.970 回答