Results 1 to 6 of 6

Thread: Using DirectShow and COM objects

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Using DirectShow and COM objects

    I am trying to use Microsofts DirectShow objects inside a QAxWidget. I know there is a queryInterface() for QAxWidgets that I am supposed to use, but how do I add the COM object to that widget? Here is the code for adding the COM object that I have so far, neither works:
    Qt Code:
    1. mpVideoPlayer = new QAxWidget( mpFrame );
    2. //mpVideoPlayer->setControl( "{D1EB6D20-8923-11d0-9D97-00A0C90A43CB}" );
    3. mpVideoPlayer->setGeometry( QRect( 15, 46, 551, 341 ) );
    4. //mpVideoPlayer->queryInterface( IID_IVideoWindow, &pVW );
    To copy to clipboard, switch view to plain text mode 

    Here is the reference code for adding a DirectShow object in a MFC application:
    Qt Code:
    1. USES_CONVERSION;
    2. WCHAR wFile[MAX_PATH];
    3. HRESULT hr;
    4.  
    5. if (!szFile)
    6. return E_POINTER;
    7.  
    8. // Clear open dialog remnants before calling RenderFile()
    9. UpdateWindow(ghApp);
    10.  
    11. // Convert filename to wide character string
    12. wcsncpy(wFile, T2W(szFile), NUMELMS(wFile)-1);
    13. wFile[MAX_PATH-1] = 0;
    14.  
    15. // Get the interface for DirectShow's GraphBuilder
    16. JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
    17. IID_IGraphBuilder, (void **)&pGB));
    18.  
    19. if(SUCCEEDED(hr))
    20. {
    21. // Have the graph builder construct its the appropriate graph automatically
    22. JIF(pGB->RenderFile(wFile, NULL));
    23.  
    24. // QueryInterface for DirectShow interfaces
    25. JIF(pGB->QueryInterface(IID_IMediaControl, (void **)&pMC));
    26. JIF(pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME));
    27. JIF(pGB->QueryInterface(IID_IMediaSeeking, (void **)&pMS));
    28. JIF(pGB->QueryInterface(IID_IMediaPosition, (void **)&pMP));
    29.  
    30. // Query for video interfaces, which may not be relevant for audio files
    31. JIF(pGB->QueryInterface(IID_IVideoWindow, (void **)&pVW));
    32. JIF(pGB->QueryInterface(IID_IBasicVideo, (void **)&pBV));
    33.  
    34. // Query for audio interfaces, which may not be relevant for video-only files
    35. JIF(pGB->QueryInterface(IID_IBasicAudio, (void **)&pBA));
    36.  
    37. // Is this an audio-only file (no video component)?
    38. CheckVisibility();
    39.  
    40. // Have the graph signal event via window callbacks for performance
    41. JIF(pME->SetNotifyWindow((OAHWND)ghApp, WM_GRAPHNOTIFY, 0));
    42.  
    43. if (!g_bAudioOnly)
    44. {
    45. // Setup the video window
    46. JIF(pVW->put_Owner((OAHWND)ghApp));
    47. JIF(pVW->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN));
    48.  
    49. JIF(InitVideoWindow(1, 1));
    50. GetFrameStepInterface();
    51. }
    52. else
    53. {
    54. // Initialize the default player size and enable playback menu items
    55. JIF(InitPlayerWindow());
    56. }
    57.  
    58. // Complete window initialization
    59. ShowWindow(ghApp, SW_SHOWNORMAL);
    60. UpdateWindow(ghApp);
    61. SetForegroundWindow(ghApp);
    62. g_bFullscreen = FALSE;
    63. g_PlaybackRate = 1.0;
    64. UpdateMainTitle();
    65.  
    66. #ifdef REGISTER_FILTERGRAPH
    67. hr = AddGraphToRot(pGB, &g_dwGraphRegister);
    68. if (FAILED(hr))
    69. {
    70. Msg(TEXT("Failed to register filter graph with ROT! hr=0x%x"), hr);
    71. g_dwGraphRegister = 0;
    72. }
    73. #endif
    74.  
    75. // Run the graph to play the media file
    76. JIF(pMC->Run());
    77.  
    78. g_psCurrent=Running;
    79. SetFocus(ghApp);
    80. }
    81.  
    82. return hr;
    To copy to clipboard, switch view to plain text mode 

    This is really bugging me why I cant figure this out. Please help!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using DirectShow and COM objects

    To use queryInterface() you need to generate the definition of the interface from its IDL description.

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Using DirectShow and COM objects

    I am not sure what you mean by IDL description. I am new to using COM objects and relatively new to Qt. So a code example would be greatly appreciated.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using DirectShow and COM objects

    Quote Originally Posted by ToddAtWSU
    I am not sure what you mean by IDL description. I am new to using COM objects and relatively new to Qt.
    IDL is an Interface Description Language. If you don't have the .idl file for the COM object you want to use, you will have to use dynamicCall() method.

  5. #5
    Join Date
    Jan 2006
    Location
    Third rock from the sun
    Posts
    106
    Thanks
    17
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Using DirectShow and COM objects

    I have been following the posts to the DirectShow since I am trying to use the same things in my application. I was looking up the dynamicCall() functionality, but it seems that it is used for controlling the video (such as play, stop, rewind etc) and not for inserting the video into the QAxWidget. How do I setup the QAxWidget to to use a COM object, more specifically, DirectShow. Example code would be very helpful!

    Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using DirectShow and COM objects

    Quote Originally Posted by Rayven
    How do I setup the QAxWidget to to use a COM object, more specifically, DirectShow. Example code would be very helpful!
    You must set the control property.

    http://doc.trolltech.com/4.1/qaxbase.html#control-prop

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.