| Line |   | 
|---|
| 1 | /*! | 
|---|
| 2 |  * @file movie_player.h | 
|---|
| 3 |   *  Manages the media files | 
|---|
| 4 |  | 
|---|
| 5 | */ | 
|---|
| 6 |  | 
|---|
| 7 | #ifndef _MOVIE_PLAYER | 
|---|
| 8 | #define _MOVIE_PLAYER | 
|---|
| 9 |  | 
|---|
| 10 | #include "sdlincl.h" | 
|---|
| 11 |  | 
|---|
| 12 | #ifdef HAVE_AVFORMAT_H | 
|---|
| 13 |   #include <avformat.h> | 
|---|
| 14 | #else | 
|---|
| 15 |   #include <ffmpeg/avformat.h> | 
|---|
| 16 | #endif | 
|---|
| 17 |  | 
|---|
| 18 | #include "glincl.h" | 
|---|
| 19 | #include "texture.h" | 
|---|
| 20 |  | 
|---|
| 21 | // include base_object.h since all classes are derived from this one | 
|---|
| 22 | #include "base_object.h" | 
|---|
| 23 |  | 
|---|
| 24 | // The state of the MoviePlayer | 
|---|
| 25 | typedef enum MP_STATUS { | 
|---|
| 26 |   PLAY, | 
|---|
| 27 |   PAUSE, | 
|---|
| 28 |   STOP | 
|---|
| 29 | }; | 
|---|
| 30 |  | 
|---|
| 31 | class MoviePlayer : public BaseObject | 
|---|
| 32 | { | 
|---|
| 33 |  | 
|---|
| 34 | private: | 
|---|
| 35 |  | 
|---|
| 36 |   AVFormatContext* format_context; | 
|---|
| 37 |   AVCodecContext* codec_context; | 
|---|
| 38 |   AVCodec* codec; | 
|---|
| 39 |   AVFrame* frame; | 
|---|
| 40 |   AVPacket packet; | 
|---|
| 41 |   AVFrame* RGB_frame; | 
|---|
| 42 |  | 
|---|
| 43 |   GLuint texture; | 
|---|
| 44 |   uint8_t* data; | 
|---|
| 45 |   uint8_t* buffer; | 
|---|
| 46 |   int num_bytes; | 
|---|
| 47 |   int video_stream; | 
|---|
| 48 |  | 
|---|
| 49 |   MP_STATUS status; | 
|---|
| 50 |   float timer; | 
|---|
| 51 |   int start_frame; | 
|---|
| 52 |   int actual_frame; | 
|---|
| 53 |   int frame_number; | 
|---|
| 54 |   float fps; | 
|---|
| 55 |   int duration; | 
|---|
| 56 |   bool mediaLoaded; | 
|---|
| 57 |  | 
|---|
| 58 | public: | 
|---|
| 59 |  | 
|---|
| 60 |   MoviePlayer(const std::string& filename = ""); | 
|---|
| 61 |   virtual ~MoviePlayer(); | 
|---|
| 62 |  | 
|---|
| 63 |   bool loadMovie(const std::string& filename); | 
|---|
| 64 |  | 
|---|
| 65 |   void start(float start_time); | 
|---|
| 66 |   void resume(); | 
|---|
| 67 |   void pause(); | 
|---|
| 68 |   void stop(); | 
|---|
| 69 |  | 
|---|
| 70 |   void tick(float dt); | 
|---|
| 71 |   GLuint getTexture(); | 
|---|
| 72 |  | 
|---|
| 73 |   void setFPS(float fps); | 
|---|
| 74 |   float getFPS(); | 
|---|
| 75 |   const MP_STATUS getStatus(); | 
|---|
| 76 |   void printInformation(); | 
|---|
| 77 |  | 
|---|
| 78 | private: | 
|---|
| 79 |  | 
|---|
| 80 |   void getNextFrame(); | 
|---|
| 81 |   void skipFrame(int frames); | 
|---|
| 82 |   bool gotoFrame(int frames); | 
|---|
| 83 |  | 
|---|
| 84 |   void unloadMedia(); | 
|---|
| 85 |  | 
|---|
| 86 | }; | 
|---|
| 87 |  | 
|---|
| 88 | #endif // _MOVIE_PLAYER | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.