2

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)

jimhark
  • 4,938
  • 2
  • 27
  • 28

1 Answers1

2

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.

wimh
  • 15,072
  • 6
  • 47
  • 98
  • 1
    Wimmel, I tried your approach, but the result is exactly the same. :-( I even tried entering badwidth frequency in Hz, although according to http://msdn.microsoft.com/en-us/library/dd693838(VS.85).aspx it should be in MHz. Perhaps applications like Windows Media Center are doing it differently. I wouldn't be surprised. –  Nov 27 '10 at 11:34
  • 1
    @natko For DVB-T I generally use -1 for the bandwidth. For DVB-S I have to use for example 27500000. So the documentation is wrong. In your example you don't specify the ONID, TSID and SID. When I don't enter them I also get no result. You are able to find them using TransEdit (http://www.dvbviewer.com/griga/TransEdit%20E/MainWindow.html) (The onid can be found at www.dvb.org). And you can use graphedit to experiment. You can fully tune in graphedit. – wimh Nov 27 '10 at 12:04
  • Sorry, I was mixing things up. DVB-S uses put_SymbolRate, not put_Bandwidth so that is a different function. – wimh Nov 27 '10 at 12:28
  • Unfortunately, I'm getting nothing when I build the graph in graphedit. There are no properties available on any of the filters od pins. How shoud I tune in graphedit in this case? However, the problem migh be in ONID, TSID and SID. I'll try to find out the values and see what happens. In posted code example I used -1 for all three. I will also try -1 for the badwidth as you suggest and get back with results. –  Nov 27 '10 at 17:00
  • Tried with correct values for ONID, TSID and SID. Nothing... Also tried -1 for the bandwidth - nothing again... groar... –  Nov 27 '10 at 17:14
  • Just tried TransEdit MCC (Demo) 3.3.0.0. It works nice. I'm missing some tuning magic here... –  Nov 27 '10 at 17:44
  • In graphedit when you add the "Microsoft DVBT Network provider" you should be able to choose properties, and select the "Tuning space" and "DVBT Tune Request" tabs. if not, proppage.dll might not be registered. But I remember it took me a lot of time to find out how to tune. It is not easy and the documentation is very limited. – wimh Nov 27 '10 at 17:56
  • I guess I have a problem with unregistered proppage.dll. Meanwhile I tried this approach: http://www.koders.com/cpp/fid26A4B88897C88D24F94AD762C22106504FBE0B18.aspx Of course, it doesn't work... It seems like there is some better and obviously undocumented way. –  Nov 27 '10 at 19:52
  • On my system it is for example located at C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin. You just need to execute regsvr32 proppage.dll. – wimh Nov 27 '10 at 21:00
  • Yes, I know how to register it, but it will not help in solving my issue with tuning. I have to thank you for your time and effort. If you have any new ideas, shoot :-) I'll try anything. –  Nov 28 '10 at 21:24
  • 1
    here's another picture of a graph https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/9a788472-a2e5-41a9-ba6d-d76cccc43140/tv-tuner-what-filters-do-i-need-for-digital-capture-via-directshow?forum=windowsdirectshowdevelopment and I also scrounged up this: https://gist.github.com/rdp/fd781291946fcdd462ce – rogerdpack Jan 22 '15 at 22:57