How to implement a callback function

Rolf Kalbermatter rolf.kalbermatter at citeng.com
Sun Apr 17 15:43:43 CDT 2005


luis lenders wrote:

As to the title, avicap32 won't implement the callback function, but
your
application will do that. avicap32 only will call it.
 
>Hi , i would like to implement this function:
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multim
ed/htm/_win32_cappreview.asp

Well this function (or rather a macro) is only to enable or disable the
preview
mode. There isn't any callback function I can see here. It is rather
about a preview
of the actual capture data in the capture window itself. You can install
a frame
callback with capSetCallbackOnFrame() and this callback function will be
called
for every frame BEFORE it is diplayed in the preview.

>Here fpProc is a pointer to the preview callback function
>Applications use this to get access to the videodata.
>Right now i already have a preview window.

>If i'm correct it is similar to this
function:http://msdn.microsoft.com/library/default.asp?
>url=/library/en-us/multimed/htm/_win32_capvideostreamcallback.asp

As far as I understand it, the preview callback as you call it is rather
installed
by the capSetCallbackOnFrame() macro and ultimately by the
WM_CAP_SET_CALLBACK_FRAME
message. MSDN doesn't directly specify the actual callback prototype of
this callback,
but it if you search further you can see that the
capVideoStreamCallback() prototype
is both used for the WM_CAP_SET_CALLBACK_FRAME and
WM_CAP_SET_CALLBACK_VIDEOSTREAM
callbacks.

>Here the structure LPVIDEOHDR lpVHdr contains the
>information about the videodata. My question is how
>all of this could be implemented; right now i have :

>case WM_CAP_SET_CALLBACK_FRAME:
 {
 ^^
You can only declare variables in standard C at the beginning of a block
and since
Wine has to be compilable in standard C you need to add curly braces
before you can
declare variables.
>   LPVIDEOHDR lpVideoHdr; //defined in vfw.h
>   typedef LRESULT (CALLBACK * CAPVIDEOCALLBACK)(HWND hwnd, LPVIDEOHDR
lpVideoHdr);
>   CAPVIDEOCALLBACK *framecallback = (CAPVIDEOCALLBACK*)lParam;

You need to store this callback function pointer somewhere in the
capture window.
This could be done by adding the callback pointers to the structure
which holds
all the different runtime parameters for the capture process, such as
the CAPSTATUS,
CAPPARAMS, CAPDRIVERCAPS and probably some more but private data etc
structures.
The pointer to this whole structure will be probably added to the
capture window
as an ATOM or maybe (but probably less preferable) as user data.

>{so what goes here? }

Not much more than what I explained above. The message loop of your
capture window
will then have to check for every incoming frame if frame callback is
set to on
(non-NULL) and in that case call the saved callback pointer with the
actual data.

>So how could i pass the data in lpVideoHdr to the
>application? Any help appreciated  as i'm still quite
>a beginner in this :)

You won't do that in the WM_CAP_SET_CALLBACK_FRAME message handler.
Rather your
message loop will have to do some idle processing, such as generating a
regular
WM_something message in which the external video data is read in and
then all the
necessary processing is done such as passing the captured data to the
frameCallback
if that is enabled, then doing the preview or overlay operation if on,
and after
that pass the data to the videoStreamCallback etc.

But I think your major problem here is not the capSetPreview macro or
rather its
message implementation in the first place, but rather the fact that
avicap32.dll
is basically an empty placeholder in current wine. You will need to
implement
quite something more before you can even worry about capSetPreview().

Rolf Kalbermatter




More information about the wine-devel mailing list