This seems like the way to do it. Thanks!

I may not fully understand the method yet though, let me tell you what I understood so far:

First I have to create a new ByteIOContext struct (ie a new struct for every new file stream I want to load), which is going to represent my open stream for the duration of the playback. Then call init_put_byte() to fill my ByteIOContext with my I/O routines. Finally call av_open_input_stream() instead of av_open_input_file(), and pass it my ByteIOContext. Then everything is the same.

The thing that I'm unsure of is when and how is my custom stream actually opened. The ByteIOContext struct does not contain any function pointers to stream open/close functions, so where do I do that?

Thanks again
Michael



xirexx wrote:
I don't know about URLProtocol, but I achieved the same by implemening my
own read and seek routines. What I did I called init_put_byte (providing my
own read and seek, nil for write). After that jut used av_open_input_stream
instead of av_open_input_file and av_close_input_stream at the very end.


On Tue, Sep 8, 2009 at 10:23 AM, Michael Georgoulopoulos <
[email protected]> wrote:

Hello everyone. This is my first message in the list so I would like to say
a big thanks to the people that created this awesome library!

I am developing a video game (Conspiracies 2 : http://www.anima-ppd.com/)
 in windows/direct3d. My engine needs to have video playback capabilities as
the game mostly consists of videos that are played when the player performs
specific actions. So far I have implemented a simple video player based on
ffmpeg which works perfectly.  My code for opening a video file looks like
this:

bool Video::OpenVideo(const char *video)
{
#define FAIL_EXIT(x) {Info(x);CloseVideo();return false;}
  av_register_all();

  // Open video file
  if (av_open_input_file(&pFormatCtx, video, NULL, 0, NULL))
      FAIL_EXIT("Failed to open video file");

  if (!InitVideoStream()) FAIL_EXIT("Failed to init video stream\n");
  if (!InitCodec()) FAIL_EXIT("Failed to initialize the codec\n");
  if (!InitVideoFrame()) FAIL_EXIT("Failed to initialize video frames\n");

  return true;
#undef FAIL_EXIT
}


This code works fine with real files in the filesystem, but I really need
to set my custom routines for file I/O, because in the retail version of the
game the actual video files will be packed in archives.

So far I have read the faq which says I need to implement a URLProtocol.
Looking at the MPlayer sources I found out how to do this. Seems as simple
as filling a struct with my user I/O routine pointers. But then what? How
can I modify my loading code to actually use that protocol?

Thanks in advance

Michael


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

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


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

Reply via email to