Unable to use WaitForCompletion() in #include 2019 Community Moderator ElectionDShow Sample Code for playing video does not play the videoWhat is the difference between #include <filename> and #include “filename”?Detecting superfluous #includes in C/C++?Is #pragma once a safe include guard?Displaying the #include hierarchy for a C++ file in Visual Studio#pragma once vs include guards?C/C++ include header file orderCannot open include file 'afxres.h' in VC2010 ExpressWhat is the difference between “Include Directories” and “Additional Include Directories”Unable to launch the IIS Express Web serverWhat is “Service Include” in a csproj file for?

Are small insurances worth it?

Expressing logarithmic equations without logs

Which situations would cause a company to ground or recall a aircraft series?

Are all players supposed to be able to see each others' character sheets?

Dynamic Linkage of LocatorPane and InputField

Why does cron require MTA for logging?

Does "Until when" sound natural for native speakers?

How do we create new idioms and use them in a novel?

Gaining more land

Possible to detect presence of nuclear bomb?

When a wind turbine does not produce enough electricity how does the power company compensate for the loss?

What are some noteworthy "mic-drop" moments in math?

After `ssh` without `-X` to a machine, is it possible to change `$DISPLAY` to make it work like `ssh -X`?

Signed and unsigned numbers

Vocabulary for giving just numbers, not a full answer

Do cubics always have one real root?

Can we track matter through time by looking at different depths in space?

For which categories of spectra is there an explicit description of the fibrant objects via lifting properties?

Is it possible to find 2014 distinct positive integers whose sum is divisible by each of them?

Can't make sense of a paragraph from Lovecraft

Finitely many repeated replacements

Is it safe to abruptly remove Arduino power?

Giving a career talk in my old university, how prominently should I tell students my salary?

The meaning of ‘otherwise’



Unable to use WaitForCompletion() in #include



2019 Community Moderator ElectionDShow Sample Code for playing video does not play the videoWhat is the difference between #include <filename> and #include “filename”?Detecting superfluous #includes in C/C++?Is #pragma once a safe include guard?Displaying the #include hierarchy for a C++ file in Visual Studio#pragma once vs include guards?C/C++ include header file orderCannot open include file 'afxres.h' in VC2010 ExpressWhat is the difference between “Include Directories” and “Additional Include Directories”Unable to launch the IIS Express Web serverWhat is “Service Include” in a csproj file for?










0















I am using Qt patch in visual studio 2008. I am trying to run a video using #include <dshow.h>. I can run video successfully, but on using WaitForCompletion() my video gets hang. here is my code:-



MediaPlayer = new Media(ui.stackedWidget->currentWidget());
connect(ui.stackedWidget->currentWidget(), SIGNAL(videograph()), MediaPlayer,SLOT(HandleGraphEvent()));
MediaPlayer->pMediaControl->Run();
long evCode;
MediaPlayer->g_pEvent1->WaitForCompletion(INFINITE,&evCode);


My header file:-



Media.cpp



#include <dshow.h>
#include <commctrl.h>
#include <commdlg.h>
#include <stdio.h>
#include <tchar.h>
//#include <atlbase.h>

#include "Media.h"
#include <qtconcurrentrun.h>

Media::Media(QWidget *parent)


HRESULT hr;
CoInitialize(NULL);
hr = CoCreateInstance(CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
hr = pVmr->QueryInterface(IID_IVMRFilterConfig, (void**)&pWc);
hr = pWc->SetNumberOfStreams(2);
hr = pVmr->QueryInterface(IID_IVMRMixerBitmap,(void **)&pBitMAp);

if(SUCCEEDED(hr))
RenderPrefs_AllowOffscreen );
pWc->Release();

if(SUCCEEDED(hr))

hr = pVmr->QueryInterface(IID_IVMRWindowlessControl, (void**)&pWl);
if(SUCCEEDED(hr))
hr = pWl->SetVideoClippingWindow(parent->winId());


CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGraph);
pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);

pGraph->QueryInterface(IID_IBasicAudio,(void **)&pAudio);
pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pMediaSeeking );
pGraph->QueryInterface( IID_IMediaPosition, (void **) &pMediaPosition);
hr = pGraph->AddFilter(pVmr, L"Video Mixing Renderer");
g_pEvent->SetNotifyWindow((OAHWND)parent->winId(), WM_GRAPHNOTIFY, 0);
RECT grc;
GetWindowRect(parent->winId(), &grc);
pGraph->RenderFile(L"/FlashDisk/test.mp4", NULL);
long lWidth, lHeight;
hr = pWl->GetNativeVideoSize(&lWidth, &lHeight, NULL, NULL);
if (SUCCEEDED(hr))

SetRect(&g_rcSRc, 0, 0, lWidth, lHeight);
GetWindowRect(parent->winId(), &g_rcDest);
SetRect(&g_rcDest, 0, 0, g_rcDest.right, g_rcDest.bottom);

video_rendered = 1;
pWl->SetVideoPosition(&g_rcSRc, &g_rcDest);


Media::~Media()

CleanUp();


void Media::HandleGraphEvent()

if (g_pEvent == NULL)
return;
long evCode;
LONG_PTR param1, param2;
while (SUCCEEDED(g_pEvent->GetEvent(&evCode, &param1, &param2, 0)))

g_pEvent->FreeEventParams(evCode, param1, param2);
switch (evCode)

case EC_STATE_CHANGE: //ADDED for state change from pause to play to indiacte video paused.
//SetEvent(sync_event);
return;
case EC_COMPLETE: // Fall through.
CleanUp();
return;
case EC_USERABORT: // Fall through.
case EC_ERRORABORT:
CleanUp();
//media.play_next_file();
return;



/*#######################################################################################
CleanUp
#######################################################################################*/
void Media::CleanUp(void)

video_rendered = 0;
g_pEvent->SetNotifyWindow(NULL, 0, 0);
g_pEvent->Release();
g_pEvent = NULL;
pMediaControl->Release();
pAudio->Release();
pGraph->Release();



Media.h



#ifndef MEDIA_H
#define MEDIA_H
//#define max(a,b) (((a) > (b)) ? (a) : (b))
//#define min(a,b) (((a) < (b)) ? (a) : (b))
#include <windef.h>
#include <QObject>
#include <QDebug>
#include <QFile>
#include <QMessageBox>
#include <QTimer>
#include <windows.h>
#include <math.h>
#include <stdlib.h>
#include <Phonon>
#include <dshow.h>
#include <commctrl.h>
#include <commdlg.h>
#include <stdio.h>
#include <tchar.h>
//#include <atlbase.h>
#include <qtconcurrentrun.h>
#pragma comment (lib, "strmiids.lib")
#define WM_GRAPHNOTIFY WM_APP + 1
#define WM_AUDIOGRAPHNOTIFY WM_APP + 2

class Media: public QObject

Q_OBJECT
public:
Media(QWidget *parent);
~Media();
IMediaControl *pMediaControl;
IMediaEventEx *g_pEvent;
IMediaEvent *g_pEvent1;
IVideoWindow *pVidWin;
IVMRMixerBitmap *pBitMAp;
IVMRMixerBitmap *pBitMAp1;
IMediaSeeking *pMediaSeeking;
IMediaPosition *pMediaPosition;
IVMRFilterConfig *pWc;
IBaseFilter *pVmr;
IVMRWindowlessControl *pWl;
RECT g_rcSRc;
RECT g_rcDest;
IBasicAudio *pAudio;
IVMRMixerControl *pVmc;
IGraphBuilder *pGraph;
DWORD width;
unsigned char video_rendered;
void CleanUp(void);
public slots:
void HandleGraphEvent(void);
;


#endif


Please suggest me what i am missing here.










share|improve this question


























    0















    I am using Qt patch in visual studio 2008. I am trying to run a video using #include <dshow.h>. I can run video successfully, but on using WaitForCompletion() my video gets hang. here is my code:-



    MediaPlayer = new Media(ui.stackedWidget->currentWidget());
    connect(ui.stackedWidget->currentWidget(), SIGNAL(videograph()), MediaPlayer,SLOT(HandleGraphEvent()));
    MediaPlayer->pMediaControl->Run();
    long evCode;
    MediaPlayer->g_pEvent1->WaitForCompletion(INFINITE,&evCode);


    My header file:-



    Media.cpp



    #include <dshow.h>
    #include <commctrl.h>
    #include <commdlg.h>
    #include <stdio.h>
    #include <tchar.h>
    //#include <atlbase.h>

    #include "Media.h"
    #include <qtconcurrentrun.h>

    Media::Media(QWidget *parent)


    HRESULT hr;
    CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
    hr = pVmr->QueryInterface(IID_IVMRFilterConfig, (void**)&pWc);
    hr = pWc->SetNumberOfStreams(2);
    hr = pVmr->QueryInterface(IID_IVMRMixerBitmap,(void **)&pBitMAp);

    if(SUCCEEDED(hr))
    RenderPrefs_AllowOffscreen );
    pWc->Release();

    if(SUCCEEDED(hr))

    hr = pVmr->QueryInterface(IID_IVMRWindowlessControl, (void**)&pWl);
    if(SUCCEEDED(hr))
    hr = pWl->SetVideoClippingWindow(parent->winId());


    CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGraph);
    pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
    pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);

    pGraph->QueryInterface(IID_IBasicAudio,(void **)&pAudio);
    pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pMediaSeeking );
    pGraph->QueryInterface( IID_IMediaPosition, (void **) &pMediaPosition);
    hr = pGraph->AddFilter(pVmr, L"Video Mixing Renderer");
    g_pEvent->SetNotifyWindow((OAHWND)parent->winId(), WM_GRAPHNOTIFY, 0);
    RECT grc;
    GetWindowRect(parent->winId(), &grc);
    pGraph->RenderFile(L"/FlashDisk/test.mp4", NULL);
    long lWidth, lHeight;
    hr = pWl->GetNativeVideoSize(&lWidth, &lHeight, NULL, NULL);
    if (SUCCEEDED(hr))

    SetRect(&g_rcSRc, 0, 0, lWidth, lHeight);
    GetWindowRect(parent->winId(), &g_rcDest);
    SetRect(&g_rcDest, 0, 0, g_rcDest.right, g_rcDest.bottom);

    video_rendered = 1;
    pWl->SetVideoPosition(&g_rcSRc, &g_rcDest);


    Media::~Media()

    CleanUp();


    void Media::HandleGraphEvent()

    if (g_pEvent == NULL)
    return;
    long evCode;
    LONG_PTR param1, param2;
    while (SUCCEEDED(g_pEvent->GetEvent(&evCode, &param1, &param2, 0)))

    g_pEvent->FreeEventParams(evCode, param1, param2);
    switch (evCode)

    case EC_STATE_CHANGE: //ADDED for state change from pause to play to indiacte video paused.
    //SetEvent(sync_event);
    return;
    case EC_COMPLETE: // Fall through.
    CleanUp();
    return;
    case EC_USERABORT: // Fall through.
    case EC_ERRORABORT:
    CleanUp();
    //media.play_next_file();
    return;



    /*#######################################################################################
    CleanUp
    #######################################################################################*/
    void Media::CleanUp(void)

    video_rendered = 0;
    g_pEvent->SetNotifyWindow(NULL, 0, 0);
    g_pEvent->Release();
    g_pEvent = NULL;
    pMediaControl->Release();
    pAudio->Release();
    pGraph->Release();



    Media.h



    #ifndef MEDIA_H
    #define MEDIA_H
    //#define max(a,b) (((a) > (b)) ? (a) : (b))
    //#define min(a,b) (((a) < (b)) ? (a) : (b))
    #include <windef.h>
    #include <QObject>
    #include <QDebug>
    #include <QFile>
    #include <QMessageBox>
    #include <QTimer>
    #include <windows.h>
    #include <math.h>
    #include <stdlib.h>
    #include <Phonon>
    #include <dshow.h>
    #include <commctrl.h>
    #include <commdlg.h>
    #include <stdio.h>
    #include <tchar.h>
    //#include <atlbase.h>
    #include <qtconcurrentrun.h>
    #pragma comment (lib, "strmiids.lib")
    #define WM_GRAPHNOTIFY WM_APP + 1
    #define WM_AUDIOGRAPHNOTIFY WM_APP + 2

    class Media: public QObject

    Q_OBJECT
    public:
    Media(QWidget *parent);
    ~Media();
    IMediaControl *pMediaControl;
    IMediaEventEx *g_pEvent;
    IMediaEvent *g_pEvent1;
    IVideoWindow *pVidWin;
    IVMRMixerBitmap *pBitMAp;
    IVMRMixerBitmap *pBitMAp1;
    IMediaSeeking *pMediaSeeking;
    IMediaPosition *pMediaPosition;
    IVMRFilterConfig *pWc;
    IBaseFilter *pVmr;
    IVMRWindowlessControl *pWl;
    RECT g_rcSRc;
    RECT g_rcDest;
    IBasicAudio *pAudio;
    IVMRMixerControl *pVmc;
    IGraphBuilder *pGraph;
    DWORD width;
    unsigned char video_rendered;
    void CleanUp(void);
    public slots:
    void HandleGraphEvent(void);
    ;


    #endif


    Please suggest me what i am missing here.










    share|improve this question
























      0












      0








      0








      I am using Qt patch in visual studio 2008. I am trying to run a video using #include <dshow.h>. I can run video successfully, but on using WaitForCompletion() my video gets hang. here is my code:-



      MediaPlayer = new Media(ui.stackedWidget->currentWidget());
      connect(ui.stackedWidget->currentWidget(), SIGNAL(videograph()), MediaPlayer,SLOT(HandleGraphEvent()));
      MediaPlayer->pMediaControl->Run();
      long evCode;
      MediaPlayer->g_pEvent1->WaitForCompletion(INFINITE,&evCode);


      My header file:-



      Media.cpp



      #include <dshow.h>
      #include <commctrl.h>
      #include <commdlg.h>
      #include <stdio.h>
      #include <tchar.h>
      //#include <atlbase.h>

      #include "Media.h"
      #include <qtconcurrentrun.h>

      Media::Media(QWidget *parent)


      HRESULT hr;
      CoInitialize(NULL);
      hr = CoCreateInstance(CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
      hr = pVmr->QueryInterface(IID_IVMRFilterConfig, (void**)&pWc);
      hr = pWc->SetNumberOfStreams(2);
      hr = pVmr->QueryInterface(IID_IVMRMixerBitmap,(void **)&pBitMAp);

      if(SUCCEEDED(hr))
      RenderPrefs_AllowOffscreen );
      pWc->Release();

      if(SUCCEEDED(hr))

      hr = pVmr->QueryInterface(IID_IVMRWindowlessControl, (void**)&pWl);
      if(SUCCEEDED(hr))
      hr = pWl->SetVideoClippingWindow(parent->winId());


      CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGraph);
      pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
      pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);

      pGraph->QueryInterface(IID_IBasicAudio,(void **)&pAudio);
      pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pMediaSeeking );
      pGraph->QueryInterface( IID_IMediaPosition, (void **) &pMediaPosition);
      hr = pGraph->AddFilter(pVmr, L"Video Mixing Renderer");
      g_pEvent->SetNotifyWindow((OAHWND)parent->winId(), WM_GRAPHNOTIFY, 0);
      RECT grc;
      GetWindowRect(parent->winId(), &grc);
      pGraph->RenderFile(L"/FlashDisk/test.mp4", NULL);
      long lWidth, lHeight;
      hr = pWl->GetNativeVideoSize(&lWidth, &lHeight, NULL, NULL);
      if (SUCCEEDED(hr))

      SetRect(&g_rcSRc, 0, 0, lWidth, lHeight);
      GetWindowRect(parent->winId(), &g_rcDest);
      SetRect(&g_rcDest, 0, 0, g_rcDest.right, g_rcDest.bottom);

      video_rendered = 1;
      pWl->SetVideoPosition(&g_rcSRc, &g_rcDest);


      Media::~Media()

      CleanUp();


      void Media::HandleGraphEvent()

      if (g_pEvent == NULL)
      return;
      long evCode;
      LONG_PTR param1, param2;
      while (SUCCEEDED(g_pEvent->GetEvent(&evCode, &param1, &param2, 0)))

      g_pEvent->FreeEventParams(evCode, param1, param2);
      switch (evCode)

      case EC_STATE_CHANGE: //ADDED for state change from pause to play to indiacte video paused.
      //SetEvent(sync_event);
      return;
      case EC_COMPLETE: // Fall through.
      CleanUp();
      return;
      case EC_USERABORT: // Fall through.
      case EC_ERRORABORT:
      CleanUp();
      //media.play_next_file();
      return;



      /*#######################################################################################
      CleanUp
      #######################################################################################*/
      void Media::CleanUp(void)

      video_rendered = 0;
      g_pEvent->SetNotifyWindow(NULL, 0, 0);
      g_pEvent->Release();
      g_pEvent = NULL;
      pMediaControl->Release();
      pAudio->Release();
      pGraph->Release();



      Media.h



      #ifndef MEDIA_H
      #define MEDIA_H
      //#define max(a,b) (((a) > (b)) ? (a) : (b))
      //#define min(a,b) (((a) < (b)) ? (a) : (b))
      #include <windef.h>
      #include <QObject>
      #include <QDebug>
      #include <QFile>
      #include <QMessageBox>
      #include <QTimer>
      #include <windows.h>
      #include <math.h>
      #include <stdlib.h>
      #include <Phonon>
      #include <dshow.h>
      #include <commctrl.h>
      #include <commdlg.h>
      #include <stdio.h>
      #include <tchar.h>
      //#include <atlbase.h>
      #include <qtconcurrentrun.h>
      #pragma comment (lib, "strmiids.lib")
      #define WM_GRAPHNOTIFY WM_APP + 1
      #define WM_AUDIOGRAPHNOTIFY WM_APP + 2

      class Media: public QObject

      Q_OBJECT
      public:
      Media(QWidget *parent);
      ~Media();
      IMediaControl *pMediaControl;
      IMediaEventEx *g_pEvent;
      IMediaEvent *g_pEvent1;
      IVideoWindow *pVidWin;
      IVMRMixerBitmap *pBitMAp;
      IVMRMixerBitmap *pBitMAp1;
      IMediaSeeking *pMediaSeeking;
      IMediaPosition *pMediaPosition;
      IVMRFilterConfig *pWc;
      IBaseFilter *pVmr;
      IVMRWindowlessControl *pWl;
      RECT g_rcSRc;
      RECT g_rcDest;
      IBasicAudio *pAudio;
      IVMRMixerControl *pVmc;
      IGraphBuilder *pGraph;
      DWORD width;
      unsigned char video_rendered;
      void CleanUp(void);
      public slots:
      void HandleGraphEvent(void);
      ;


      #endif


      Please suggest me what i am missing here.










      share|improve this question














      I am using Qt patch in visual studio 2008. I am trying to run a video using #include <dshow.h>. I can run video successfully, but on using WaitForCompletion() my video gets hang. here is my code:-



      MediaPlayer = new Media(ui.stackedWidget->currentWidget());
      connect(ui.stackedWidget->currentWidget(), SIGNAL(videograph()), MediaPlayer,SLOT(HandleGraphEvent()));
      MediaPlayer->pMediaControl->Run();
      long evCode;
      MediaPlayer->g_pEvent1->WaitForCompletion(INFINITE,&evCode);


      My header file:-



      Media.cpp



      #include <dshow.h>
      #include <commctrl.h>
      #include <commdlg.h>
      #include <stdio.h>
      #include <tchar.h>
      //#include <atlbase.h>

      #include "Media.h"
      #include <qtconcurrentrun.h>

      Media::Media(QWidget *parent)


      HRESULT hr;
      CoInitialize(NULL);
      hr = CoCreateInstance(CLSID_VideoMixingRenderer, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVmr);
      hr = pVmr->QueryInterface(IID_IVMRFilterConfig, (void**)&pWc);
      hr = pWc->SetNumberOfStreams(2);
      hr = pVmr->QueryInterface(IID_IVMRMixerBitmap,(void **)&pBitMAp);

      if(SUCCEEDED(hr))
      RenderPrefs_AllowOffscreen );
      pWc->Release();

      if(SUCCEEDED(hr))

      hr = pVmr->QueryInterface(IID_IVMRWindowlessControl, (void**)&pWl);
      if(SUCCEEDED(hr))
      hr = pWl->SetVideoClippingWindow(parent->winId());


      CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&pGraph);
      pGraph->QueryInterface(IID_IMediaControl, (void **)&pMediaControl);
      pGraph->QueryInterface(IID_IMediaEventEx, (void **)&g_pEvent);

      pGraph->QueryInterface(IID_IBasicAudio,(void **)&pAudio);
      pGraph->QueryInterface(IID_IMediaSeeking, (void **)&pMediaSeeking );
      pGraph->QueryInterface( IID_IMediaPosition, (void **) &pMediaPosition);
      hr = pGraph->AddFilter(pVmr, L"Video Mixing Renderer");
      g_pEvent->SetNotifyWindow((OAHWND)parent->winId(), WM_GRAPHNOTIFY, 0);
      RECT grc;
      GetWindowRect(parent->winId(), &grc);
      pGraph->RenderFile(L"/FlashDisk/test.mp4", NULL);
      long lWidth, lHeight;
      hr = pWl->GetNativeVideoSize(&lWidth, &lHeight, NULL, NULL);
      if (SUCCEEDED(hr))

      SetRect(&g_rcSRc, 0, 0, lWidth, lHeight);
      GetWindowRect(parent->winId(), &g_rcDest);
      SetRect(&g_rcDest, 0, 0, g_rcDest.right, g_rcDest.bottom);

      video_rendered = 1;
      pWl->SetVideoPosition(&g_rcSRc, &g_rcDest);


      Media::~Media()

      CleanUp();


      void Media::HandleGraphEvent()

      if (g_pEvent == NULL)
      return;
      long evCode;
      LONG_PTR param1, param2;
      while (SUCCEEDED(g_pEvent->GetEvent(&evCode, &param1, &param2, 0)))

      g_pEvent->FreeEventParams(evCode, param1, param2);
      switch (evCode)

      case EC_STATE_CHANGE: //ADDED for state change from pause to play to indiacte video paused.
      //SetEvent(sync_event);
      return;
      case EC_COMPLETE: // Fall through.
      CleanUp();
      return;
      case EC_USERABORT: // Fall through.
      case EC_ERRORABORT:
      CleanUp();
      //media.play_next_file();
      return;



      /*#######################################################################################
      CleanUp
      #######################################################################################*/
      void Media::CleanUp(void)

      video_rendered = 0;
      g_pEvent->SetNotifyWindow(NULL, 0, 0);
      g_pEvent->Release();
      g_pEvent = NULL;
      pMediaControl->Release();
      pAudio->Release();
      pGraph->Release();



      Media.h



      #ifndef MEDIA_H
      #define MEDIA_H
      //#define max(a,b) (((a) > (b)) ? (a) : (b))
      //#define min(a,b) (((a) < (b)) ? (a) : (b))
      #include <windef.h>
      #include <QObject>
      #include <QDebug>
      #include <QFile>
      #include <QMessageBox>
      #include <QTimer>
      #include <windows.h>
      #include <math.h>
      #include <stdlib.h>
      #include <Phonon>
      #include <dshow.h>
      #include <commctrl.h>
      #include <commdlg.h>
      #include <stdio.h>
      #include <tchar.h>
      //#include <atlbase.h>
      #include <qtconcurrentrun.h>
      #pragma comment (lib, "strmiids.lib")
      #define WM_GRAPHNOTIFY WM_APP + 1
      #define WM_AUDIOGRAPHNOTIFY WM_APP + 2

      class Media: public QObject

      Q_OBJECT
      public:
      Media(QWidget *parent);
      ~Media();
      IMediaControl *pMediaControl;
      IMediaEventEx *g_pEvent;
      IMediaEvent *g_pEvent1;
      IVideoWindow *pVidWin;
      IVMRMixerBitmap *pBitMAp;
      IVMRMixerBitmap *pBitMAp1;
      IMediaSeeking *pMediaSeeking;
      IMediaPosition *pMediaPosition;
      IVMRFilterConfig *pWc;
      IBaseFilter *pVmr;
      IVMRWindowlessControl *pWl;
      RECT g_rcSRc;
      RECT g_rcDest;
      IBasicAudio *pAudio;
      IVMRMixerControl *pVmc;
      IGraphBuilder *pGraph;
      DWORD width;
      unsigned char video_rendered;
      void CleanUp(void);
      public slots:
      void HandleGraphEvent(void);
      ;


      #endif


      Please suggest me what i am missing here.







      c++ visual-studio qt video-streaming directshow






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 4:46









      Tabish SaifullahTabish Saifullah

      330316




      330316






















          1 Answer
          1






          active

          oldest

          votes


















          0














          On a COM STA thread you are responsible to dispatch window messages and WaitForCompletion is a blocking call without a promise to implement message loop.



          See DShow Sample Code for playing video does not play the video




          An easy way to find out if #2 is the problem is placing MessageBox call between Run and WaitForCompletion. MessageBox dispatches messages for you and as long as you keep the box open, video plays as well (or start playing well and keeps playing even after you close the box). Proper solution is to wait and displach messages in the same time (WaitDispatchingMessages, this SO question or similar).




          This applies to your case as well, change to finite timeout, dispatch messages and get back to another wait attempt.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036271%2funable-to-use-waitforcompletion-in-include-dshow-h%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            On a COM STA thread you are responsible to dispatch window messages and WaitForCompletion is a blocking call without a promise to implement message loop.



            See DShow Sample Code for playing video does not play the video




            An easy way to find out if #2 is the problem is placing MessageBox call between Run and WaitForCompletion. MessageBox dispatches messages for you and as long as you keep the box open, video plays as well (or start playing well and keeps playing even after you close the box). Proper solution is to wait and displach messages in the same time (WaitDispatchingMessages, this SO question or similar).




            This applies to your case as well, change to finite timeout, dispatch messages and get back to another wait attempt.






            share|improve this answer



























              0














              On a COM STA thread you are responsible to dispatch window messages and WaitForCompletion is a blocking call without a promise to implement message loop.



              See DShow Sample Code for playing video does not play the video




              An easy way to find out if #2 is the problem is placing MessageBox call between Run and WaitForCompletion. MessageBox dispatches messages for you and as long as you keep the box open, video plays as well (or start playing well and keeps playing even after you close the box). Proper solution is to wait and displach messages in the same time (WaitDispatchingMessages, this SO question or similar).




              This applies to your case as well, change to finite timeout, dispatch messages and get back to another wait attempt.






              share|improve this answer

























                0












                0








                0







                On a COM STA thread you are responsible to dispatch window messages and WaitForCompletion is a blocking call without a promise to implement message loop.



                See DShow Sample Code for playing video does not play the video




                An easy way to find out if #2 is the problem is placing MessageBox call between Run and WaitForCompletion. MessageBox dispatches messages for you and as long as you keep the box open, video plays as well (or start playing well and keeps playing even after you close the box). Proper solution is to wait and displach messages in the same time (WaitDispatchingMessages, this SO question or similar).




                This applies to your case as well, change to finite timeout, dispatch messages and get back to another wait attempt.






                share|improve this answer













                On a COM STA thread you are responsible to dispatch window messages and WaitForCompletion is a blocking call without a promise to implement message loop.



                See DShow Sample Code for playing video does not play the video




                An easy way to find out if #2 is the problem is placing MessageBox call between Run and WaitForCompletion. MessageBox dispatches messages for you and as long as you keep the box open, video plays as well (or start playing well and keeps playing even after you close the box). Proper solution is to wait and displach messages in the same time (WaitDispatchingMessages, this SO question or similar).




                This applies to your case as well, change to finite timeout, dispatch messages and get back to another wait attempt.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 7 at 11:28









                Roman R.Roman R.

                57.3k466109




                57.3k466109





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55036271%2funable-to-use-waitforcompletion-in-include-dshow-h%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme