| 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 | ObjectListDeclaration(MoviePlayer); |
|---|
| 34 | |
|---|
| 35 | private: |
|---|
| 36 | |
|---|
| 37 | AVFormatContext* format_context; |
|---|
| 38 | AVCodecContext* codec_context; |
|---|
| 39 | AVCodec* codec; |
|---|
| 40 | AVFrame* frame; |
|---|
| 41 | AVPacket packet; |
|---|
| 42 | AVFrame* RGB_frame; |
|---|
| 43 | |
|---|
| 44 | GLuint texture; |
|---|
| 45 | uint8_t* data; |
|---|
| 46 | uint8_t* buffer; |
|---|
| 47 | int num_bytes; |
|---|
| 48 | int video_stream; |
|---|
| 49 | |
|---|
| 50 | MP_STATUS status; |
|---|
| 51 | float timer; |
|---|
| 52 | int start_frame; |
|---|
| 53 | int actual_frame; |
|---|
| 54 | int frame_number; |
|---|
| 55 | float fps; |
|---|
| 56 | int duration; |
|---|
| 57 | bool mediaLoaded; |
|---|
| 58 | |
|---|
| 59 | public: |
|---|
| 60 | |
|---|
| 61 | MoviePlayer(const std::string& filename = ""); |
|---|
| 62 | virtual ~MoviePlayer(); |
|---|
| 63 | |
|---|
| 64 | bool loadMovie(const std::string& filename); |
|---|
| 65 | |
|---|
| 66 | void start(float start_time); |
|---|
| 67 | void resume(); |
|---|
| 68 | void pause(); |
|---|
| 69 | void stop(); |
|---|
| 70 | |
|---|
| 71 | void tick(float dt); |
|---|
| 72 | GLuint getTexture(); |
|---|
| 73 | |
|---|
| 74 | void setFPS(float fps); |
|---|
| 75 | float getFPS(); |
|---|
| 76 | const MP_STATUS getStatus(); |
|---|
| 77 | void printInformation(); |
|---|
| 78 | |
|---|
| 79 | private: |
|---|
| 80 | |
|---|
| 81 | void getNextFrame(); |
|---|
| 82 | void skipFrame(int frames); |
|---|
| 83 | bool gotoFrame(int frames); |
|---|
| 84 | |
|---|
| 85 | void unloadMedia(); |
|---|
| 86 | |
|---|
| 87 | }; |
|---|
| 88 | |
|---|
| 89 | #endif // _MOVIE_PLAYER |
|---|
Note: See
TracBrowser
for help on using the repository browser.