Delen via


Callback-functies toevoegen aan een toepassing

Een toepassing kan callback-functies registreren bij het opnamevenster, zodat het de toepassing in de volgende situaties op de hoogte stelt.

  • De status verandert
  • Er treden fouten op
  • Videoframes en audiobuffers worden beschikbaar
  • De toepassing moet opleveren tijdens het vastleggen van streaming

In het volgende voorbeeld wordt een opnamevenster gemaakt en worden de status, fout, videostream en frame callback-functies in de berichtenverwerkingslus van een toepassing geregistreerd. Het bevat ook een voorbeeldinstructie voor het uitschakelen van een callback-functie. In volgende voorbeelden worden eenvoudige status-, fout- en frame callback-functies weergegeven.

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; 
} 
 

Video capture gebruiken