Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6057 in orxonox.OLD


Ignore:
Timestamp:
Dec 12, 2005, 1:07:57 AM (18 years ago)
Author:
hdavid
Message:

branches\avi_play: MediaContainer opens a videofile and prints some information

Location:
branches/avi_play/src
Files:
3 edited

Legend:

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

    r6049 r6057  
    4242  current_frame = 0;
    4343  num_frames = 0;
     44        frames_left = true;
    4445
    4546  if (filename != NULL)
     
    7778SDL_Surface* MediaContainer::getFrame(int frame_number)
    7879{
    79   SDL_Surface* frame;
    80 
    81 
    82   return frame;
     80
    8381}
    8482
    8583SDL_Surface* MediaContainer::getNextFrame()
    8684{
    87   current_frame++;
    88   return this->getFrame(current_frame);
     85        /* get next frame */
     86        if(av_read_frame(format_context, &packet) >= 0)
     87        {
     88                frames_left = true;
     89                current_frame++;
     90                PRINTF(1)("current_frame: %i\n", current_frame);
     91
     92
     93                /* work with the frame */
     94                /* packet -> SDL_Surface */
     95
     96
     97
     98
     99        }
     100        else
     101                frames_left = false;
     102
    89103}
    90104
     
    136150int MediaContainer::getHeight()
    137151{
    138 
     152        return codec_context->height;
    139153}
    140154
    141155int MediaContainer::getWidth()
    142156{
    143 
     157        return codec_context->width;
    144158}
    145159
     
    153167
    154168}
     169
     170bool MediaContainer::framesLeft()
     171{
     172        return frames_left;
     173}
     174
     175void MediaContainer::printMediaInformation()
     176{
     177        PRINTF(1)("========================\n");
     178        PRINTF(1)("========================\n");
     179        PRINTF(1)("=    MEDIACONTAINER    =\n");
     180        PRINTF(1)("========================\n");
     181        PRINTF(1)("========================\n");
     182        PRINTF(1)("=    AVFormatContext   =\n");
     183        PRINTF(1)("========================\n");
     184        PRINTF(1)("filename: %s\n", format_context->filename);
     185        PRINTF(1)("nb_streams: %i\n", format_context->nb_streams);
     186        PRINTF(1)("duration: %fs\n", format_context->duration/1000000.);
     187        PRINTF(1)("file_size: %ikb\n", format_context->file_size/1024);
     188        PRINTF(1)("bit_rate: %ikb/s\n", format_context->bit_rate/1000);
     189        PRINTF(1)("nb_frames: %i\n", format_context->streams[video_stream]->nb_frames);
     190        //PRINTF(1)("r_frame_rate: %ifps\n", format_context->streams[video_stream]->r_frame_rate.num);
     191        PRINTF(1)("========================\n");
     192        PRINTF(1)("=    AVCodecContext    =\n");
     193        PRINTF(1)("========================\n");
     194        PRINTF(1)("width: %i\n", codec_context->width);
     195        PRINTF(1)("height: %i\n", codec_context->height);
     196        PRINTF(1)("========================\n");
     197        PRINTF(1)("=       AVCodec        =\n");
     198        PRINTF(1)("========================\n");
     199        PRINTF(1)("codec name: %s\n", codec->name);
     200        PRINTF(1)("========================\n");
     201        PRINTF(1)("========================\n");
     202}
  • branches/avi_play/src/lib/graphics/importer/media_container.h

    r6003 r6057  
    3232private:
    3333
    34         char* filename;
    3534        int current_frame;
    3635        int num_frames;
     
    4443        int num_bytes;
    4544        int video_stream;
     45        bool frames_left;
    4646
    4747public:
     
    6161        void getStream(/* stream */);
    6262
     63        bool framesLeft();
     64
     65        /* prints some information about the
     66           media file for debug reasons */
     67        void printMediaInformation();
     68
    6369};
    6470
  • branches/avi_play/src/subprojects/importer/importer.cc

    r6049 r6057  
    2828
    2929Model* obj;
     30MediaContainer* movie;
    3031
    3132void Framework::moduleInit(int argc, char** argv)
    3233{
    33   MediaContainer* test2;
    34        
    35   test2 = new MediaContainer(argv[1]); 
    3634
     35  movie = new MediaContainer(argv[1]);
    3736
     37        // print information about the media file
     38        movie->printMediaInformation();
     39
     40/*
    3841  ResourceManager::getInstance()->addImageDir("./");
    3942
     
    5760  lightMan->setAmbientColor(.1,.1,.1);
    5861  (new Light())->setAbsCoor(5.0, 10.0, 40.0);
    59   (new Light())->setAbsCoor(-10, -20, -100);
     62  (new Light())->setAbsCoor(-10, -20, -100);*/
    6063}
    6164
     
    7578void Framework::moduleTick(float dt)
    7679{
    77 
     80        if(movie->framesLeft())
     81                movie->getNextFrame();
    7882}
    7983
    8084void Framework::moduleDraw(void) const
    8185{
    82   obj->draw();
     86  //obj->draw();
    8387
    84   LightManager::getInstance()->draw();
     88  //LightManager::getInstance()->draw();
    8589}
    8690
Note: See TracChangeset for help on using the changeset viewer.