Moderator Control Panel ]

How to get a simple Tv tuning (ATSC) and channel viewing?

How to get a simple Tv tuning (ATSC) and channel viewing?

Postby RNCAlexander » Fri Aug 28, 2020 3:22 am

Hi.
These weeks I have been trying to learn how to develop a small application in visual studio c ++ to be able to tune and visualize channels from the TBS6704 ATSC card.

But to see there is very little information on the subject on the net and microsoft tutorials give very general examples (they omit a lot of previous code that I do not know). That is why I have come to ask for your help with a sample code or guidance to develop a simple ATSC channel display application in c ++.

From what I have investigated, I only have the enumeration of the devices and the one saved in an "IGraphBuilder", I attach the code below:

P.S.: I honestly do not know if the steps I am following are correct, it was what I interpreted with the microsoft documentation.

Code: Select All Code
#include <windows.h>
#include <dshow.h>
#include <ks.h>
#include <ksmedia.h>
#include <bdatypes.h>
#include <Bdamedia.h>


#pragma comment(lib, "strmiids")

int Proceso = 0;


HRESULT EnumerateDevices(REFGUID category, IEnumMoniker** ppEnum)
{
    // Create the System Device Enumerator.

    ICreateDevEnum* pDevEnum;
    HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
        CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum));

    if (SUCCEEDED(hr))
    {
        // Create an enumerator for the category.
        hr = pDevEnum->CreateClassEnumerator(category, ppEnum, 0);
        if (hr == S_FALSE)
        {
            hr = VFW_E_NOT_FOUND;  // The category is empty. Treat as an error.
        }
        pDevEnum->Release();
    }
    return hr;
}

void DisplayDeviceInformation(IEnumMoniker* pEnum, IGraphBuilder* m_pGraph)
{
    IMoniker* pMoniker = NULL;
    ULONG cFetched;
    IBaseFilter* pFilter;

    if (Proceso == 1) {
        pEnum->Next(1, &pMoniker, &cFetched);
        pEnum->Next(1, &pMoniker, &cFetched);
        pEnum->Next(1, &pMoniker, &cFetched);
    }
    else {
        pEnum->Next(1, &pMoniker, &cFetched);
    }



    IPropertyBag* pPropBag;
    HRESULT hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
    if (FAILED(hr))
    {
        pMoniker->Release();

    }

    VARIANT var;
    VariantInit(&var);

    // Get description or friendly name.
    hr = pPropBag->Read(L"Description", &var, 0);
    if (FAILED(hr))
    {
        hr = pPropBag->Read(L"FriendlyName", &var, 0);
    }
    if (SUCCEEDED(hr))
    {
        printf("                                        %S\n", var.bstrVal);
        VariantClear(&var);
    }

    hr = pPropBag->Write(L"FriendlyName", &var);

    // WaveInID applies only to audio capture devices.
    hr = pPropBag->Read(L"WaveInID", &var, 0);
    if (SUCCEEDED(hr))
    {
        printf("WaveIn ID: %d\n", var.lVal);
        VariantClear(&var);
    }

    hr = pPropBag->Read(L"DevicePath", &var, 0);
    if (SUCCEEDED(hr))
    {
        // The device path is not intended for display.
        printf("Device path: %S\n", var.bstrVal);
        VariantClear(&var);
    }



    hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
        (void**)&pFilter);

    if (SUCCEEDED(hr))
    {
        if (Proceso == 0) {
            hr = m_pGraph->AddFilter(pFilter, L"Network ATSC Provider");
            if (SUCCEEDED(hr))
            {
                printf("                        Filtro Red Guardado\n");
                Proceso = Proceso + 1;
            }
        }
        else if (Proceso == 1) {
            hr = m_pGraph->AddFilter(pFilter, L"Sintonizador");
            if (SUCCEEDED(hr))
            {
                printf("                        Filtro Tuner Guardado\n");
                Proceso = Proceso + 1;
            }
        }
        else if (Proceso == 2) {
            hr = m_pGraph->AddFilter(pFilter, L"Captura");
            if (SUCCEEDED(hr))
            {
                printf("                        Filtro Capture Guardado\n");
                Proceso = Proceso + 1;
            }
        }


    }

    pPropBag->Release();
    pMoniker->Release();

}

void main() {


    HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    if (SUCCEEDED(hr))
    {

        IEnumMoniker* pEnum;
        IGraphBuilder* m_pGraph;
        ICaptureGraphBuilder2* pCaptureGraphBuilder2;
        IBaseFilter* pDeviceFilter;
        CoCreateInstance(CLSID_FilterGraph,
            NULL,
            CLSCTX_INPROC,
            IID_IGraphBuilder,
            (LPVOID*)&m_pGraph);

        CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC,
            IID_ICaptureGraphBuilder2,
            (LPVOID*)&pCaptureGraphBuilder2);

        pCaptureGraphBuilder2->SetFiltergraph(m_pGraph);

        hr = EnumerateDevices(KSCATEGORY_BDA_NETWORK_PROVIDER, &pEnum);
        if (SUCCEEDED(hr))
        {
            DisplayDeviceInformation(pEnum, m_pGraph);
            pEnum->Release();
        }
        hr = EnumerateDevices(KSCATEGORY_BDA_NETWORK_TUNER, &pEnum);
        if (SUCCEEDED(hr))
        {
            DisplayDeviceInformation(pEnum, m_pGraph);
            pEnum->Release();
        }
        hr = EnumerateDevices(KSCATEGORY_BDA_RECEIVER_COMPONENT, &pEnum);
        if (SUCCEEDED(hr))
        {
            DisplayDeviceInformation(pEnum, m_pGraph);
            pEnum->Release();
        }
                 // finalize COM
        CoUninitialize();


    }
}


P.S-2: In the same way, if someone could explain the process that the filter graph must follow and how to connect its pins and then tune, I would be very grateful.

Greetings from Mexico.
Using google translator.
RNCAlexander
 
Posts: 1
Joined: Thu Aug 27, 2020 6:14 am

Return to ATSC/ Clear QAM Quad Tuner PCIe Card TBS6704

Who is online

Users browsing this forum: No registered users and 3 guests