int apeg_play_memory_mpg(void *mpeg_data, BITMAP *bmp, int loop, int (*callback)(BITMAP *tempBuffer)) { int ret; Initialize_Decoder(); apeg_stream = apeg_open_memory_stream(mpeg_data, mem_buffer_size); if(!apeg_stream) return APEG_ERROR; if(bmp) clear_to_color(bmp, makecol(0, 0, 0)); if(callback) callback_proc = callback; else callback_proc = default_callback; restart_loop: ret = decode_stream((APEG_LAYER*)apeg_stream, bmp); if(loop && ret == APEG_OK) { apeg_reset_stream(apeg_stream); goto restart_loop; } apeg_close_stream(apeg_stream); apeg_stream = NULL; return ret; }
void VideoManager::loadVideo(char* filename) { FILE* fp = NULL; if ( fopen_s(&fp, filename, "rb") != 0 ) { al_trace("Movie %s is missing.\r\n", filename); return; // do NOT summon error mode for this because the application might in debugging/lite mode } // get the length of the video fseek(fp, 0, SEEK_END); long fsize = ftell(fp); fseek(fp, 0, SEEK_SET); // load the entire video into an unreasonably large memory buffer! videoBuffer = malloc(fsize); fread(videoBuffer, fsize, 1, fp); fclose(fp); // sanity check the buffer contents or else APEG may hang if ( ((char*)videoBuffer)[0] == 'O' && ((char*)videoBuffer)[1] == 'g' && ((char*)videoBuffer)[2] == 'g' && ((char*)videoBuffer)[3] == 'S' ) { cmov = apeg_open_memory_stream(videoBuffer, fsize); } else { al_trace("Video stream did not seem to contain Ogg data.\r\n"); unloadVideo(); } }