Trouble creating my first graph

2013-05-16
2013-08-25
  • hi all, this is first time i try to create a directshow graph and can't understand why it not words. Here the code where i catch and exception "pointer not valid" on
    hr = m_FilterGraph.Connect(iPinPlexOutput, iPinDecoderInput); row.
    Thanks for your support on solve this problem, here it is the code :

    int hr;
    IBaseFilter ibfRenderer = null;
    ISampleGrabber sampGrabber = null;
    //IBaseFilter capFilter = null;
    IPin iPinInFilter = null;
    IPin iPinOutFilter = null;
    IPin iPinInDest = null;
    Type type = null;
    IEnumPins pinEnum;

    // Get the graphbuilder object
    m_FilterGraph = new FilterGraph() as IFilterGraph2;

    // *********
    IBaseFilter sourceFilter;
    hr = m_FilterGraph.AddSourceFilter(FileName, FileName, out sourceFilter);
    IPin iPinSourceFilterOut = DsFindPin.ByDirection(sourceFilter, PinDirection.Output, 0);

    // *********
    type = Type.GetTypeFromCLSID(new Guid("{AFB6C280-2C41-11D3-8A60-0000F81E0E4A}"));
    IBaseFilter filterPlex = (IBaseFilter)Activator.CreateInstance(type);
    hr = m_FilterGraph.AddFilter(filterPlex, "MPEG-2 Demultiplexer");
    DsError.ThrowExceptionForHR(hr);

    IPin iPinPlexInput = DsFindPin.ByDirection((IBaseFilter)filterPlex, PinDirection.Input, 0);
    IPin iPinPlexOutput = DsFindPin.ByDirection((IBaseFilter)filterPlex, PinDirection.Output, 1);// Tried 0, 1 but nothing change
    // Connect Pin
    hr = m_FilterGraph.Connect(iPinSourceFilterOut, iPinPlexInput); // Tried even m_FilterGraph.ConnectDirect...
    DsError.ThrowExceptionForHR(hr);

    // *********
    type = Type.GetTypeFromCLSID(new Guid("{37A4D808-E76C-11D2-935C-00A024E52661}"));
    IBaseFilter filterDecoder = (IBaseFilter)Activator.CreateInstance(type);
    hr = m_FilterGraph.AddFilter(filterDecoder, "ATI MPEG Video Decoder");
    DsError.ThrowExceptionForHR(hr);

    IPin iPinDecoderInput = DsFindPin.ByDirection((IBaseFilter)filterDecoder, PinDirection.Input, 0);
    IPin iPinDecoderOutput = DsFindPin.ByDirection((IBaseFilter)filterDecoder, PinDirection.Output, 0);
    // Connect Pin
    hr = m_FilterGraph.Connect(iPinPlexOutput, iPinDecoderInput); <---- HERE THROW EXCEPTION
    DsError.ThrowExceptionForHR(hr);

    // *********
    type = Type.GetTypeFromCLSID(new Guid("{B87BEB7B-8D29-423F-AE4D-6582C10175AC}"));
    IBaseFilter filterVideoRenderer = (IBaseFilter)Activator.CreateInstance(type);
    hr = m_FilterGraph.AddFilter(filterVideoRenderer, "Video Renderer");
    DsError.ThrowExceptionForHR(hr);

    IPin iPinVideoRendererIn = DsFindPin.ByDirection(filterVideoRenderer, PinDirection.Input, 0);
    hr = m_FilterGraph.Connect(iPinDecoderOutput, iPinVideoRendererIn);
    DsError.ThrowExceptionForHR(hr);

     
  • snarfle
    snarfle
    2013-05-16

    My first guess is that one of m_FilterGraph, iPinPlexOutput, or iPinDecoderInput is NULL.

     
  • Mariam Louis
    Mariam Louis
    2013-08-25

    I have a problem when press on record button in DX Tuner Sample somwtimes video is displayed but without motion as image & sometimes screen continue black & sometimes working properly but the problem happen at first record press

    Please Help urgently