ITuner::put_TuneRequest() 调用被忽略

发布于 2024-10-04 10:16:06 字数 1975 浏览 10 评论 0原文

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

这些过滤器是相连的。

除此之外,我还有一个“MPEG-2 解复用器”和一个“BDA MPEG2 传输信息过滤器”,但这两个过滤器没有连接!似乎他们必须在这里才能运行图表。

当我启动图表时,我正在接收 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。

我做错了什么?或者,我是否错过了“调音请求”中的一些重大内容。

(带宽和频率值正确)

I have a DirectShow graph with a "Microsoft DVBT Network Provider", "AVerMedia BDA DVBT Tuner", "AVerMEdia BDA Digital Capture", "Sample Grabber" and "NULL Renderer".

These filters are connected.

Beside that I also have an "MPEG-2 Demultiplexer" and a "BDA MPEG2 Transport Information Filter", but these two filters are NOT connected! It seems like they have to be here in order to run the graph.

When I start the graph, I'm receiving TS data, but no matter what I do, I'm not able to put the tuning request. I can only capture the MUX data from the last tuned frequency with some other application like Windows Media Center.

Here is the code for putting the tune request:

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

This is executed immediately after adding the "Microsoft DVBT Network Provider" filter in the graph.
All "hr" values from the above code are S_OK.

What am I doing wrong? Or, did I miss something big in this "tune request" thing.

(Bandwidth and frequency values are correct)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对风讲故事 2024-10-11 10:16:06

我认为 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);

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文