Hello...  I have implemented the libavcodec library to inspect buffered data 
from a stream and determine the contents using my own read function. After 
determining the format context, I am able to decode the contents of the stream 
using the same read routine that is subsequently invoked by the av_read_frame 
function. The code is packaged up nicely in a reusable DLL. 

When I instantiate a second instance of the DLL in the same process, I come 
into problems. It appears the libavcodec library uses my same read routine in 
both cases and the second instance never gets past the call to 
av_open_input_stream. Instead, my read routine is invoked during that call 
where in the first instance of the DLL, the read routine is not invoked until 
after the av_find_stream_info call as more data is needed to finish determining 
the format context. 

Is there a way to let the library know that this is a different stream of data 
and that it should be handled as such? 

I've included some sample code of the implementation... 

The following buffer only contains some of the data, the rest is read in from 
my read routine passed to init_put_byte. 

BYTE pDataBuffer[2048]; 
long lSize = 2048; 

AVProbeData pd; 
pd.buf = pDataBuffer; 
pd.buf_size = lSize; 
pd.filename = ""; 

AVInputFormat* pAVInputFormat = av_probe_input_format(&pd, 1); 
if(!pAVInputFormat) 
{ 
return false; 
} 
pAVInputFormat->flags |= AVFMT_NOFILE; 

ByteIOContext ByteIOCtx; 
if(init_put_byte(&ByteIOCtx, pDataBuffer, lSize, 0, this, MyReadFunction, NULL, 
NULL) < 0) 
{ 
return false; 
} 

AVFormatContext* pFormatCtx; 
if(av_open_input_stream(&pFormatCtx, &ByteIOCtx, "", pAVInputFormat, NULL) < 0) 
{ 
return false; 
} 

if(av_find_stream_info(pFormatCtx) < 0) 
{ 
return false; 
} 

The following code later uses my same read function to process the buffer... 

AVPacket packet; 
if(av_read_frame(pFormatCtx, &packet) < 0) 
{ 
return false; 
} 

Do I really need to implement my own URL as seen in other sample code? Is there 
some context data that can be passed with one of the above function calls to 
signal a different data stream is being processed?


Thanks Greatly
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to