PDA

View Full Version : using setHWND + startLive in a DLL



WK Ho
January 6, 2008, 05:49:23
Hi there

I intended to display the captured image on many of my dialog DLL and after having problem of working on a global grabber object I try to pass the object's pointer from one to another.

CWWHPRWND::CWWHPRWND(CWnd *parent,DShowLib::Grabber *ppGrabber) : CWDialog(parent)
{
pppGrabber=ppGrabber;
...
}

I then operate on the pppGrabber locally such as :

if( pppGrabber->isDevValid() )
{

AfxMessageBox( "The device is still Valid" );

}
else
AfxMessageBox( "The device is NOT Valid" );

Which give me positive result.
However, when I try to do some real stuff like:

if (!pppGrabber->getHWND()) //this one OK
AfxMessageBox( "NO ValidsetWND !" );

xhHwnd=GetSafeHwnd(); // get the current dialog hwnd

if (!(pppGrabber->setHWND(xhHwnd)))
AfxMessageBox( "CANNOT SetHWND !" ); //??this line printed...
pppGrabber->setWindowPosition(5, 70 );
pppGrabber->startLive();

Nothing happen on the display ..The message AfxMessageBox( "CANNOT SetHWND !" ); was executed.

Any idea where I go wrong?

Regards
WK

Stefan Geissler
January 7, 2008, 08:50:04
Hi WK,

Just a question: The live video has been stopped before? I have the suspect, that you try to start the live video of one video capture device twice. This wont work. And if you try this, you will not be able to change the HWND.

Unfortunately you use libraries I do not have (I guess), thus I can not write a sample for you.

WK Ho
January 7, 2008, 09:01:58
Hi there

Before I calling the DLL I perform :
if (mm_Grabber.isLive())
mm_Grabber.suspendLive();

After that I test if it is still valid then run
startLive();

It doesn't work!! However, if I change the above to :
if (mm_Grabber.isLive())
mm_Grabber.stopLive();

ANd then go into the DLL with the passed Grabber object pointer, it can display the image .
The reason that I want to use suspendLive instead as It takes a long time for the display to setup if I have to re-start everything. Any trick to get around. In addition, using prepareLive() doesn't seem to be much of improvement on strating the filter graph. My computer system is quite a fast one with 1G RAM.

WK

Stefan Geissler
January 7, 2008, 09:40:21
Hi WK,

If you called suspend live, the filtergraph and all of its settings will be kept and can't be changed. But I understand your problem about the time stoplive and startlive sequence needs.
At this point of time I have no better idea because of the DirectShow limitations.

The fast and dirty solution would be displaying the images in the frameReady event of the GrabberListener on your own. Then you can change the window handle to display the images in, as wanted. In order to display the live video in a window handle on your own, you would need GDI functions. In the "childview.cpp" of the demoapp it is shown how to display an image buffer in a window handle.

You wont need to call stoplive when you change the window to display the live video in, if you would draw on your own.