1

Me again, trying to use directShow. I tried to implement an example from a camera-distributor to read the camera (I would like to get frames in Form of an Byte-Array) and am getting a VFW_E_NOT_IN_GRAPH-Error when trying to connect the pins.

I already searched and now know, that that means, I didn't add a specific Filter to the graphbuilder (or the filter I used isn't compatible?), but I added a Filter and can't see any differences to the sample... however, the sample isn't a project, but only code-scraps, so I think I may have forgotten any initialization...

Could you please take a look at this and tell me whether you find an error? Everything works find without error, just the last hr is filled with 0x8004025F and nothing happens (I made a stop-point within DoRenderSample-method):

    HRESULT hr = S_OK;
    IBaseFilter* pFilter=0;
    hr=CreateKernelFilter(
        CLSID_VideoInputDeviceCategory,
            L"Videology USB-C Camera",
            &pFilter
    );
    CoInitialize(NULL);
//  CComQIPtr<IVideology20K1XX> pKs(pFilter);
    CComQIPtr<IVideologyCommon> pKs( pFilter );
    if(pFilter==0)return;
//  hr=pKs->SetWhiteBalanceMode(wbAuto);

    CBitmapRenderer *m_pSnapshotter = new CBitmapRenderer( _T("Bitmap renderer"), NULL, &hr );

    if( FAILED(hr) )
    {
        ASSERT("Couldn't create bitmap renderer.");
        return;
    }
    m_pSnapshotter->SetCallback( (IBitmapCallback*) this );
    CComQIPtr< IBaseFilter > pGrabBase( m_pSnapshotter );
    IGraphBuilder*  m_pGraphBuilder=0;
     hr = CoCreateInstance(CLSID_FilterGraph, NULL,
    CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&m_pGraphBuilder);
    hr = m_pGraphBuilder->AddFilter( pGrabBase, L"Snapshot" );

    CComPtr<IPin> pOutPin;
    hr= pFilter->FindPin( L"1", &pOutPin );

    CBasePin* pInPin = m_pSnapshotter->GetPin( 0 );
    hr = m_pGraphBuilder->Connect( pOutPin, pInPin );

I hope I didn't forget any important informations... (Using C++-Builder from embarcadero XE2 16 and DirectShow9 from 2005 I think)

Kromster
  • 7,181
  • 7
  • 63
  • 111
Julian
  • 493
  • 4
  • 22

1 Answers1

1

The error code tells you what is wrong. VFW_E_NOT_IN_GRAPH, something is not in graph. You connect two pins, which belong to two filters. One of the filters is not in graph. As you add pGrabBase a few lines above, then the other filter is not in the graph. Add it as well prior to connecting pins.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thank you for your fast answer! So, you say pFilter isn't added nto m_pGraphBuilder yet? SHould I use m_pGraphBuilder->AddFilter( pFilter, L"Snapshot" ); for that? what String do I have to provide there? Or did I misinterpret your help? (And how can I make a new line in comments?^^) – Julian Aug 15 '12 at 11:00
  • Yes you need to add both filters (with the line you wrote above). Any string will do - it's your name for the filter. – Roman R. Aug 15 '12 at 11:04
  • Thanks Again for your answer! Adding hr = m_pGraphBuilder->AddFilter( pFilter, L"Source" ); helped this error... but nothing happens^^ How can I start the whole thing or get frames (most wanted as Byte-Array)? – Julian Aug 15 '12 at 11:07
  • My advice: start with a good sample that works. With such Q you are really in the very beginning on the way, there will be other things before "something start happening". – Roman R. Aug 15 '12 at 11:13
  • Thanks for the advice... I still have some problems finding good samples as many are for previous directshows or they try to render objects... Do you know a working example? The best thing I've found so far would be here: http://stackoverflow.com/questions/1827635/how-to-capture-live-camera-frames-in-rgb-with-directshow?rq=1 – Julian Aug 15 '12 at 11:18
  • There are samples right in Windows SDK. There are more samples in earlier versions of DirectX SDK (2004-2005). There are samples on CodeProject. Most of them are C++ for Visual Studio, Delphi guys use DSPack (not sure if this is more appropriate for C++ Builder development). – Roman R. Aug 15 '12 at 11:21
  • The codeword you need is `SampleCB` (or, `BufferCB`), search for it. You will find a number of samples to grab data. Google uses this approach to capture video in Firefox plugin for GMail. – Roman R. Aug 15 '12 at 11:23