Ajout de fonctions de rappel à une application

Une application peut inscrire des fonctions de rappel avec la fenêtre de capture afin qu’elle notifie l’application dans les circonstances suivantes :

  • Le status change
  • Des erreurs se produisent
  • Les images vidéo et les mémoires tampons audio deviennent disponibles
  • L’application doit produire pendant la capture en streaming

L’exemple suivant crée une fenêtre de capture et inscrit des fonctions status, d’erreur, de flux vidéo et de rappel d’images dans la boucle de traitement des messages d’une application. Il inclut également un exemple d’instruction pour désactiver une fonction de rappel. Les exemples suivants montrent des fonctions de rappel de status, d’erreur et de frame 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; 
} 
 

Utilisation de la capture vidéo