Hi!

For some reasons I need to implement universal avio proxy, which will support all ffmpeg protocols.
The main goal is to parse all avio_read traffic via some custom function.

So, I create custom context with direct i/o:

  AVIOContext* _ffmpeg_io_context = avio_alloc_context(NULL, 0,
                          0, // writeflag
                          this, //context (opaque)
                          readFunctionWrapper, //read
                          NULL , //write
                          seekFunctionWrapper );//seek
   _ffmpeg_io_context->direct = true;

After I open the original avio:

   AVIOContext*  _origAvio = NULL;
   avio_open2(&_origAvio, _url.c_str(), AVIO_FLAG_READ, NULL, NULL);
_ffmpeg_io_context->seekable = _origAvio->seekable; /// Set to custom avio seekable flags from the original avio

My custom functions looks like this:

   int FFmpegIoProxy::readFunction(uint8_t* buf, int buf_size){
      int res = avio_read(_origAvio, buf, buf_size);
      if (res>0){
         ... do something with buf
      }
      return buf;
   }

   int64_t FFmpegIoProxy::seekFunction(int64_t offset, int whence){
      return avio_seek(_origAvio, offset, whence);
   }

After I open avformat with custom i/o:

  _ffmpeg_format_context = avformat_alloc_context();
  _ffmpeg_format_context->pb=  _ffmpeg_io_context;
  avformat_open_input(&_ffmpeg_format_context, NULL, NULL, NULL);


Local (file://) url works fine, but when I try to open http:// protocol I see messages:

   [http @ 0x4b97c0] HTTP error 416 Requested Range Not Satisfiable

So, really it requesting out-of range data.

Is somebody knows, what is wrong? May be I need to set some more fields of my proxy avio?

--

With best regards, Pavel A. Sokolov
mobile: +7(921)419-1819
skype: pavel_a_sokolov

_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to