Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. Problem with CROSSBAR in DirectShow

Problem with CROSSBAR in DirectShow

Scheduled Pinned Locked Moved Graphics
helpdata-structuresannouncement
4 Posts 3 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bhanu_8509
    wrote on last edited by
    #1

    Dear All, I am developing an application to preview the video from a Capture device. I have developed the application and it is working fine, but the problem is that it is playing two times correctly but for the third time i got error while connecting with video renderer. Please help me. Code snippet is given below :

    void DialogPlayer::OnBnClickedButton12()
    {
    bool x= CreateVideoGraph();
    }

    BOOL DialogPlayer::CreateVideoGraph()//Creating the graph for video
    {
    hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
    if(FAILED(hr))
    {
    return FALSE;
    }
    if (SUCCEEDED(hr))
    {
    //Create the Capture Graph Builder.
    hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,(void **)&pBuilder);
    if(FAILED(hr))
    {
    return FALSE;
    }
    if (SUCCEEDED(hr))
    {
    hr=pBuilder->SetFiltergraph(pGraph);
    if(FAILED(hr))
    {
    return FALSE;
    }
    }
    }
    hr= pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &(pControl));
    hr=pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &(VideoWindow));
    ICreateDevEnum *pSysDevEnum = NULL;
    hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
    if(FAILED(hr))
    {
    return FALSE;
    }
    IEnumMoniker *pEnumCat = NULL;
    hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
    if (hr == S_OK)
    {
    IMoniker *pMoniker = NULL;
    ULONG cFetched;
    while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
    {
    IPropertyBag *pPropBag;
    hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
    if (SUCCEEDED(hr))
    {
    VARIANT varName;
    VariantInit(&varName);
    hr = pPropBag->Read(L"FriendlyName", &varName, 0);
    BSTR name2=varName.bstrVal;
    if((wcscmp(name2, "Video Capture AV")==0))
    {
    hr=pMoniker->BindToObject(0,0,IID_IBaseFilter, (void**)&(VideoSourceFilter));
    hr=pGraph->AddFilter(VideoSourceFilter,L"Video Source");
    check1=1;
    }
    if(check1==0)
    {
    return FALSE;
    }
    pPropBag->Release();
    }
    pMoniker->Release();
    }
    pEnumCat->Release();
    }
    else
    {
    return FALSE

    T T 2 Replies Last reply
    0
    • B bhanu_8509

      Dear All, I am developing an application to preview the video from a Capture device. I have developed the application and it is working fine, but the problem is that it is playing two times correctly but for the third time i got error while connecting with video renderer. Please help me. Code snippet is given below :

      void DialogPlayer::OnBnClickedButton12()
      {
      bool x= CreateVideoGraph();
      }

      BOOL DialogPlayer::CreateVideoGraph()//Creating the graph for video
      {
      hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
      if(FAILED(hr))
      {
      return FALSE;
      }
      if (SUCCEEDED(hr))
      {
      //Create the Capture Graph Builder.
      hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,(void **)&pBuilder);
      if(FAILED(hr))
      {
      return FALSE;
      }
      if (SUCCEEDED(hr))
      {
      hr=pBuilder->SetFiltergraph(pGraph);
      if(FAILED(hr))
      {
      return FALSE;
      }
      }
      }
      hr= pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &(pControl));
      hr=pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &(VideoWindow));
      ICreateDevEnum *pSysDevEnum = NULL;
      hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
      if(FAILED(hr))
      {
      return FALSE;
      }
      IEnumMoniker *pEnumCat = NULL;
      hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
      if (hr == S_OK)
      {
      IMoniker *pMoniker = NULL;
      ULONG cFetched;
      while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
      {
      IPropertyBag *pPropBag;
      hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
      if (SUCCEEDED(hr))
      {
      VARIANT varName;
      VariantInit(&varName);
      hr = pPropBag->Read(L"FriendlyName", &varName, 0);
      BSTR name2=varName.bstrVal;
      if((wcscmp(name2, "Video Capture AV")==0))
      {
      hr=pMoniker->BindToObject(0,0,IID_IBaseFilter, (void**)&(VideoSourceFilter));
      hr=pGraph->AddFilter(VideoSourceFilter,L"Video Source");
      check1=1;
      }
      if(check1==0)
      {
      return FALSE;
      }
      pPropBag->Release();
      }
      pMoniker->Release();
      }
      pEnumCat->Release();
      }
      else
      {
      return FALSE

      T Offline
      T Offline
      Tim Craig
      wrote on last edited by
      #2

      You didn't say what kind of error you were getting. Is it possible that on one of your previous runs you aborted the program or took a path that didn't close everything? I had a problem with an OpenCV app I wrote that got very unhappy if I exited without properly releasing everything. COM is funny that way. :suss:

      If you don't have the data, you're just another asshole with an opinion.

      1 Reply Last reply
      0
      • B bhanu_8509

        Dear All, I am developing an application to preview the video from a Capture device. I have developed the application and it is working fine, but the problem is that it is playing two times correctly but for the third time i got error while connecting with video renderer. Please help me. Code snippet is given below :

        void DialogPlayer::OnBnClickedButton12()
        {
        bool x= CreateVideoGraph();
        }

        BOOL DialogPlayer::CreateVideoGraph()//Creating the graph for video
        {
        hr = CoCreateInstance(CLSID_FilterGraph, NULL,CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGraph);
        if(FAILED(hr))
        {
        return FALSE;
        }
        if (SUCCEEDED(hr))
        {
        //Create the Capture Graph Builder.
        hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL,CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2,(void **)&pBuilder);
        if(FAILED(hr))
        {
        return FALSE;
        }
        if (SUCCEEDED(hr))
        {
        hr=pBuilder->SetFiltergraph(pGraph);
        if(FAILED(hr))
        {
        return FALSE;
        }
        }
        }
        hr= pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &(pControl));
        hr=pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &(VideoWindow));
        ICreateDevEnum *pSysDevEnum = NULL;
        hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
        if(FAILED(hr))
        {
        return FALSE;
        }
        IEnumMoniker *pEnumCat = NULL;
        hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
        if (hr == S_OK)
        {
        IMoniker *pMoniker = NULL;
        ULONG cFetched;
        while(pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
        {
        IPropertyBag *pPropBag;
        hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag);
        if (SUCCEEDED(hr))
        {
        VARIANT varName;
        VariantInit(&varName);
        hr = pPropBag->Read(L"FriendlyName", &varName, 0);
        BSTR name2=varName.bstrVal;
        if((wcscmp(name2, "Video Capture AV")==0))
        {
        hr=pMoniker->BindToObject(0,0,IID_IBaseFilter, (void**)&(VideoSourceFilter));
        hr=pGraph->AddFilter(VideoSourceFilter,L"Video Source");
        check1=1;
        }
        if(check1==0)
        {
        return FALSE;
        }
        pPropBag->Release();
        }
        pMoniker->Release();
        }
        pEnumCat->Release();
        }
        else
        {
        return FALSE

        T Offline
        T Offline
        tanvon malik
        wrote on last edited by
        #3

        Hi are you releasing the reference count on the

        CrossbarFilter
        IPin *outPin;

        these two interfaces when done.

        tanvon malik http://tanvon.wordpress.com http://DirectShow.wordpress.com DirectShow in URDU language http://groups.yahoo.com/group/tanvon http://www.codeproject.com/script/articles/list_articles.asp?userid=1638055

        B 1 Reply Last reply
        0
        • T tanvon malik

          Hi are you releasing the reference count on the

          CrossbarFilter
          IPin *outPin;

          these two interfaces when done.

          tanvon malik http://tanvon.wordpress.com http://DirectShow.wordpress.com DirectShow in URDU language http://groups.yahoo.com/group/tanvon http://www.codeproject.com/script/articles/list_articles.asp?userid=1638055

          B Offline
          B Offline
          bhanu_8509
          wrote on last edited by
          #4

          I tried releasing everything and nothing happens. Finally I remove all the filters in the graph using IEnuFilters and this works for me. Thanks for your kindness and reply.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups