OStreamVideoDecoder::OStreamVideoDecoder( unsigned int io_buf_size, ostream_decoding_type decoding_type, int fps /* = 25 */, PixelFormat opencv_pix_fmt /*= PIX_FMT_BGR24*/) : _internal_buffer_size( io_buf_size ), _decoding_type( decoding_type ), _fps( fps ), _opencv_pix_fmt( opencv_pix_fmt ) { _initialized = false; sws_ctx = NULL; _opencv_ready_frame = NULL; if ( io_buf_size <= 1 ) { // DEBUG_PRINT ("io_buf_size is wrong\n."); return; } // allocate the internal buffer _internal_buffer = new unsigned char[_internal_buffer_size]; if ( decoder_initialize () == true ) { _initialized = true; } }
unsigned long callc fennec_plugin_open(unsigned long otype, unsigned long osize, const string odata) { int found = 0; unsigned long i; unsigned long last_count; unsigned long j; while(plugin_busy)sys_pass(); plugin_busy = 1; if(otype == fennec_input_open_file || otype == fennec_input_open_internet_stream) { /* search for an empty player */ for(i=0; i<pstreams_count; i++) { if(!pstreams[i].initialized) { found = 1; break; } } if(found) { /* there's an empty player, id - 'i' */ pstreams[i].initialized = 1; j = i; }else{ /* should reallocate some memory */ last_count = pstreams_count; if(pstreams_count >= plugin_player_max) { /* we've reached to the maximum, sorry can't load more */ plugin_busy = 0; return 0; } pstreams_count += plugin_player_add; if(pstreams_count > plugin_player_max)pstreams_count = plugin_player_max; pstreams = (struct plugin_stream*) sys_mem_realloc(pstreams, pstreams_count * sizeof(struct plugin_stream)); for(i=last_count; i<pstreams_count; i++) { pstreams[i].initialized = 0; } j = last_count + 1; pstreams[j].initialized = 1; } /* now do the loading stuff */ decoder_initialize(j); if(decoder_openfile(j, odata) == 1) { plugin_busy = 0; return j; }else{ plugin_busy = 0; return -1; } return j; } plugin_busy = 0; return -1; }