Ajout de fonctions de rappel à une application
Une application peut enregistrer des fonctions de rappel avec la fenêtre de capture afin qu’elle envoie une notification à l’application dans les circonstances suivantes :
- L’état change
- Des erreurs se produisent
- Les mémoires tampons audio et les images vidéo deviennent disponibles
- L’application doit se produire pendant la capture en continu
L’exemple suivant crée une fenêtre de capture et enregistre les fonctions d’État, d’erreur, de flux vidéo et de rappel de frame dans la boucle de traitement de message d’une application. Il comprend également un exemple d’instruction pour la désactivation d’une fonction de rappel. Les exemples suivants illustrent des fonctions d’État, d’erreur et de rappel d’image simples.
case WM_CREATE:
{
char achDeviceName[80] ;
char achDeviceVersion[100] ;
char achBuffer[100] ;
WORD wDriverCount = 0 ;
WORD wIndex ;
WORD wError ;
HMENU hMenu ;
// Create a capture window using the capCreateCaptureWindow macro.
ghWndCap = capCreateCaptureWindow((LPSTR)"Capture Window",
WS_CHILD | WS_VISIBLE, 0, 0, 160, 120, (HWND) hWnd, (int) 0);
// Register the error callback function using the
// capSetCallbackOnError macro.
capSetCallbackOnError(ghWndCap, fpErrorCallback);
// Register the status callback function using the
// capSetCallbackOnStatus macro.
capSetCallbackOnStatus(ghWndCap, fpStatusCallback);
// Register the video-stream callback function using the
// capSetCallbackOnVideoStream macro.
capSetCallbackOnVideoStream(ghWndCap, fpVideoCallback);
// Register the frame callback function using the
// capSetCallbackOnFrame macro.
capSetCallbackOnFrame(ghWndCap, fpFrameCallback);
// Connect to a capture driver
break;
}
case WM_CLOSE:
{
// Use the capSetCallbackOnFrame macro to
// disable the frame callback. Similar calls exist for the other
// callback functions.
capSetCallbackOnFrame(ghWndCap, NULL);
break;
}