ITuner::put_TuneRequest() call ignored

独自空忆成欢 提交于 2019-12-01 11:07:23

I think put_Bandwidth( 8 ) is wrong, it should be a bandwidth in Hz. Anyway, I show you some code I use. Maybe it helps.

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);

You are doing some things in a different order, but I'm not sure if it matters.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!