// Run using // // testinterrupt http://192.168.1.5/video.asf // // (assuming that doesn't exist) - to check that the interrupt callback is not being fired #include #include #include static int interrupt_cb(void *ctx) { printf("Interrupt callback called\n"); return 0; } int main(int argc, char *argv[]) { AVFormatContext *pFormatCtx; if(argc < 2) { printf("Please provide a movie file\n"); return -1; } // Register all formats and codecs av_register_all( ); avcodec_register_all(); avformat_network_init(); // Open video file pFormatCtx = avformat_alloc_context( ); pFormatCtx->interrupt_callback.callback = interrupt_cb; pFormatCtx->interrupt_callback.opaque = pFormatCtx; if(avformat_open_input(&pFormatCtx, argv[1], NULL, NULL)!=0) return -1; // Couldn't open file avformat_close_input(pFormatCtx); printf("Exiting\n"); return 0; }