Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6003 in orxonox.OLD for branches/avi_play/src/lib/graphics/importer


Ignore:
Timestamp:
Dec 9, 2005, 6:07:05 PM (19 years ago)
Author:
hdavid
Message:

branches/avi_play: some init stuff

Location:
branches/avi_play/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/avi_play/src/lib/graphics/importer/media_container.cc

    r5975 r6003  
    4040  av_register_all();
    4141
     42        current_frame = 0;
     43        num_frames = 0;
     44
    4245  if (filename != NULL)
    4346    this->loadMedia(filename);
     
    5053MediaContainer::~MediaContainer()
    5154{
     55        //av_free(pFrameRGB);
     56
     57        /* Free the frame */
     58  av_free(frame);
     59
     60  /* Close the codec */
     61  avcodec_close(codec_context);
     62
     63  /* Close the video file */
     64  av_close_input_file(format_context);
    5265
    5366}
    5467
    55 GLuint MediaContainer::getFrame(int frame_number)
     68/*GLuint MediaContainer::getFrame(int frame_number)
    5669{
    5770
     
    6174{
    6275
     76}*/
     77
     78SDL_Surface* MediaContainer::getFrame(int frame_number)
     79{
     80        SDL_Surface* frame;
     81       
     82
     83        return frame;
     84}
     85
     86SDL_Surface* MediaContainer::getNextFrame()
     87{
     88        current_frame++;
     89        return this->getFrame(current_frame);
    6390}
    6491
     
    6895  if (av_open_input_file(&format_context, filename, NULL, 0, NULL) !=0 )
    6996    PRINTF(1)("Could not open %s\n", filename);
     97
     98        /* Retrieve stream information */
     99  if (av_find_stream_info(format_context) < 0)
     100        PRINTF(1)("Could not find stream information in %s\n", filename);
     101
     102  // Dump information about file onto standard error
     103  //dump_format(pFormatCtx, 0, argv[1], false);
     104
     105  /* Find the first video stream and take it */
     106  video_stream = -1;
     107  for(int i = 0; i < format_context->nb_streams; i++)
     108        {
     109                // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
     110                // if(format_context->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO)         
     111        if(format_context->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO)
     112    {
     113        video_stream = i;
     114      break;
     115    }
     116        }
     117 
     118        if(video_stream == -1)
     119        PRINTF(1)("Could not find a video stream in %s\n", filename);
     120
     121        /* Get a pointer to the codec context for the video stream */
     122        // NOTE: different code for the 0.4.9-pre1 release of ffmpeg (tardis)
     123        // codec_context = &format_context->streams[video_stream]->codec;
     124  codec_context = format_context->streams[video_stream]->codec;
     125
     126        /* Find the decoder for the video stream */
     127  codec = avcodec_find_decoder(codec_context->codec_id);
     128  if (codec == NULL)
     129        PRINTF(1)("Could not find codec\n");
     130
     131        /* Open codec */
     132  if (avcodec_open(codec_context, codec) < 0)
     133                PRINTF(1)("Could not open codec\n");
     134
     135       
    70136
    71137}
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r5975 r6003  
    2424using namespace std;
    2525
     26/* Forward Declaration */
     27struct SDL_Surface;
     28
    2629class MediaContainer : public BaseObject
    2730{
     
    3134        char* filename;
    3235        int current_frame;
     36        int num_frames;
    3337
    3438        AVFormatContext* format_context;
     
    4650  ~MediaContainer();
    4751
    48         GLuint getFrame(int frame_number);
    49         GLuint getNextFrame();
     52        //GLuint getFrame(int frame_number);
     53        SDL_Surface* getFrame(int frame_number);
     54        //GLuint getNextFrame();
     55        SDL_Surface* getNextFrame();
    5056        void loadMedia(const char* filename);
    5157       
Note: See TracChangeset for help on using the changeset viewer.