Infognition forum
February 08, 2012, 10:27:14 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Last GraphEditPlus version: 1.4.0   Last Video Enhancer version: 1.9.7
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: problems with WTV files rendering.  (Read 840 times)
carXJY
Newbie
*

Karma: +0/-0
Posts: 1


View Profile
« on: May 16, 2011, 10:53:45 PM »

Hi guys,
     I am new to directShow and found GraphEditPlus. I think this product is great. However, I tried to just render a Windows Media Center WTV file and I got a problem.
The WTV file plays very good in GraphEditPlus. When I use the generated C++ code, I got this error:

Building graph...
Pin not found!
Error 80004003: Can't connect StreamBufferSource and PBDA DTFilter 0001

and here is the generated code:
(the only thing I changed was in "hrcheck" function: I changed Tchar* to char*)


#include "stdafx.h"
#include <DShow.h>
#include <atlbase.h>
#include <initguid.h>
#include <dvdmedia.h>

BOOL hrcheck(HRESULT hr, CHAR* errtext)
{
    if (hr >= S_OK)
        return FALSE;
    TCHAR szErr[MAX_ERROR_TEXT_LEN];
    DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
    if (res)
        printf("Error %x: %s\n%s\n",hr, errtext,szErr);
    else
        printf("Error %x: %s\n", hr, errtext);
    return TRUE;
}

//change this macro to fit your style of error handling
#define CHECK_HR(hr, msg) if (hrcheck(hr, msg)) return hr;

CComPtr<IPin> GetPin(IBaseFilter *pFilter, LPCOLESTR pinname)
{
    CComPtr<IEnumPins>  pEnum;
    CComPtr<IPin>       pPin;

    HRESULT hr = pFilter->EnumPins(&pEnum);
    if (hrcheck(hr, "Can't enumerate pins."))
        return NULL;

    while(pEnum->Next(1, &pPin, 0) == S_OK)
    {
        PIN_INFO pinfo;
        pPin->QueryPinInfo(&pinfo);
        BOOL found = !wcsicmp(pinname, pinfo.achName);
        if (pinfo.pFilter) pinfo.pFilter->Release();
        if (found)
            return pPin;
        pPin.Release();
    }
    printf("Pin not found!\n");
    return NULL; 
}

// {C9F5FE02-F851-4EB5-99EE-AD602AF1E619}
DEFINE_GUID(CLSID_StreamBufferSource,
0xC9F5FE02, 0xF851, 0x4EB5, 0x99, 0xEE, 0xAD, 0x60, 0x2A, 0xF1, 0xE6, 0x19); //sbe.dll


// {09144FD6-BB29-11DB-96F1-005056C00008}
DEFINE_GUID(CLSID_PBDADTFilter0001,
0x09144FD6, 0xBB29, 0x11DB, 0x96, 0xF1, 0x00, 0x50, 0x56, 0xC0, 0x00, 0x08); //CPFilters.dll


// {212690FB-83E5-4526-8FD7-74478B7939CD}
DEFINE_GUID(CLSID_MicrosoftDTVDVDVideoDecoder,
0x212690FB, 0x83E5, 0x4526, 0x8F, 0xD7, 0x74, 0x47, 0x8B, 0x79, 0x39, 0xCD); //msmpeg2vdec.dll


// {B87BEB7B-8D29-423F-AE4D-6582C10175AC}
DEFINE_GUID(CLSID_VideoRenderer,
0xB87BEB7B, 0x8D29, 0x423F, 0xAE, 0x4D, 0x65, 0x82, 0xC1, 0x01, 0x75, 0xAC); //quartz.dll




HRESULT BuildGraph(IGraphBuilder *pGraph)
{
    HRESULT hr = S_OK;

    //graph builder
    CComPtr<ICaptureGraphBuilder2> pBuilder;
    hr = pBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder2);
    CHECK_HR(hr, "Can't create Capture Graph Builder");
    hr = pBuilder->SetFiltergraph(pGraph);
    CHECK_HR(hr, "Can't SetFiltergraph");

    //add StreamBufferSource
    CComPtr<IBaseFilter> pStreamBufferSource;
    hr = pStreamBufferSource.CoCreateInstance(CLSID_StreamBufferSource);
    CHECK_HR(hr, "Can't create StreamBufferSource");
    hr = pGraph->AddFilter(pStreamBufferSource, L"StreamBufferSource");
    CHECK_HR(hr, "Can't add StreamBufferSource to graph");


    //add PBDA DTFilter 0001
    CComPtr<IBaseFilter> pPBDADTFilter0001;
    hr = pPBDADTFilter0001.CoCreateInstance(CLSID_PBDADTFilter0001);
    CHECK_HR(hr, "Can't create PBDA DTFilter 0001");
    hr = pGraph->AddFilter(pPBDADTFilter0001, L"PBDA DTFilter 0001");
    CHECK_HR(hr, "Can't add PBDA DTFilter 0001 to graph");


    //connect StreamBufferSource and PBDA DTFilter 0001
    hr = pGraph->ConnectDirect(GetPin(pStreamBufferSource, L"DVR Out - 2"), GetPin(pPBDADTFilter0001, L"In(Enc/Tag)"), NULL);
    CHECK_HR(hr, "Can't connect StreamBufferSource and PBDA DTFilter 0001");


    //add Microsoft DTV-DVD Video Decoder
    CComPtr<IBaseFilter> pMicrosoftDTVDVDVideoDecoder;
    hr = pMicrosoftDTVDVDVideoDecoder.CoCreateInstance(CLSID_MicrosoftDTVDVDVideoDecoder);
    CHECK_HR(hr, "Can't create Microsoft DTV-DVD Video Decoder");
    hr = pGraph->AddFilter(pMicrosoftDTVDVDVideoDecoder, L"Microsoft DTV-DVD Video Decoder");
    CHECK_HR(hr, "Can't add Microsoft DTV-DVD Video Decoder to graph");


    //connect PBDA DTFilter 0001 and Microsoft DTV-DVD Video Decoder
    hr = pGraph->ConnectDirect(GetPin(pPBDADTFilter0001, L"Out"), GetPin(pMicrosoftDTVDVDVideoDecoder, L"Video Input"), NULL);
    CHECK_HR(hr, "Can't connect PBDA DTFilter 0001 and Microsoft DTV-DVD Video Decoder");


    //add Video Renderer
    CComPtr<IBaseFilter> pVideoRenderer;
    hr = pVideoRenderer.CoCreateInstance(CLSID_VideoRenderer);
    CHECK_HR(hr, "Can't create Video Renderer");
    hr = pGraph->AddFilter(pVideoRenderer, L"Video Renderer");
    CHECK_HR(hr, "Can't add Video Renderer to graph");


    //connect Microsoft DTV-DVD Video Decoder and Video Renderer
    hr = pGraph->ConnectDirect(GetPin(pMicrosoftDTVDVDVideoDecoder, L"Video Output 1"), GetPin(pVideoRenderer, L"VMR Input0"), NULL);
    CHECK_HR(hr, "Can't connect Microsoft DTV-DVD Video Decoder and Video Renderer");


    return S_OK;
}

//int _tmain(int argc, _TCHAR* argv[]) //use this line in VS2008
int main(int argc, char* argv[])
{
    CoInitialize(NULL);
    CComPtr<IGraphBuilder> graph;
    graph.CoCreateInstance(CLSID_FilterGraph);

    printf("Building graph...\n");
    HRESULT hr = BuildGraph(graph);
    if (hr==S_OK) {
        printf("Running");
        CComQIPtr<IMediaControl, &IID_IMediaControl> mediaControl(graph);
        hr = mediaControl->Run();
        CHECK_HR(hr, "Can't run the graph");
        CComQIPtr<IMediaEvent, &IID_IMediaEvent> mediaEvent(graph);
        BOOL stop = FALSE;
        MSG msg;
        while(!stop)
        {
            long ev=0, p1=0, p2=0;
            Sleep(500);
            printf(".");
            while(PeekMessage(&msg, NULL, 0,0, PM_REMOVE))
                DispatchMessage(&msg);
            while (mediaEvent->GetEvent(&ev, &p1, &p2, 0)==S_OK)
            {
                if (ev == EC_COMPLETE || ev == EC_USERABORT)
                {
                    printf("Done!\n");
                    stop = TRUE;
                }
                else
                if (ev == EC_ERRORABORT)
                {
                    printf("An error occured: HRESULT=%x\n", p1);
                    mediaControl->Stop();
                    stop = TRUE;
                }
                mediaEvent->FreeEventParams(ev, p1, p2);
            }
        }
    }
    CoUninitialize();
    return 0;
}


Could someone please help? Thanks in advance.

-----------------------------------------------------------------
My system:
--Windows 7 professional
--Microsoft VS 2010
Logged
Dee Mon
Administrator
Hero Member
*****

Karma: +8/-0
Posts: 512



View Profile WWW
« Reply #1 on: May 17, 2011, 11:58:12 AM »

In this code the Stream Buffer Source wasn't told where to get data from.
You should use either IStreamBufferSource::SetStreamSink  (when playing a live stream) or IFileSourceFilter::Load (when playing a file). See
http://msdn.microsoft.com/en-us/library/dd693041%28v=vs.85%29.aspx
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!