| Line | |
|---|
| 1 | /*! |
|---|
| 2 | * @file recorder.h |
|---|
| 3 | * |
|---|
| 4 | */ |
|---|
| 5 | |
|---|
| 6 | #ifndef _RECORDER_H |
|---|
| 7 | #define _RECORDER_H |
|---|
| 8 | |
|---|
| 9 | #include "sdlincl.h" |
|---|
| 10 | |
|---|
| 11 | #ifdef HAVE_AVFORMAT_H |
|---|
| 12 | #include <avformat.h> |
|---|
| 13 | #else |
|---|
| 14 | #include <ffmpeg/avformat.h> |
|---|
| 15 | #endif |
|---|
| 16 | |
|---|
| 17 | #include "glincl.h" |
|---|
| 18 | #include "world_entity.h" |
|---|
| 19 | |
|---|
| 20 | class Recorder : public WorldEntity |
|---|
| 21 | { |
|---|
| 22 | private: |
|---|
| 23 | AVFrame* picture; |
|---|
| 24 | uint8_t* buffer; |
|---|
| 25 | int frame_count; |
|---|
| 26 | int buffer_size; |
|---|
| 27 | |
|---|
| 28 | AVOutputFormat* output_format; |
|---|
| 29 | AVFormatContext* format_context; |
|---|
| 30 | AVCodecContext* codec_context; |
|---|
| 31 | AVCodec *codec; |
|---|
| 32 | AVStream* video_stream; |
|---|
| 33 | AVPacket packet; |
|---|
| 34 | double video_pts; |
|---|
| 35 | |
|---|
| 36 | uint8_t *picture_buf; |
|---|
| 37 | int size; |
|---|
| 38 | |
|---|
| 39 | int height; |
|---|
| 40 | int width; |
|---|
| 41 | float time; |
|---|
| 42 | |
|---|
| 43 | float stream_duration; |
|---|
| 44 | float stream_frame_rate; |
|---|
| 45 | int stream_nb_frames; |
|---|
| 46 | |
|---|
| 47 | AVFrame* RGB_frame; |
|---|
| 48 | public: |
|---|
| 49 | Recorder (const TiXmlElement* root = NULL); |
|---|
| 50 | ~Recorder (); |
|---|
| 51 | |
|---|
| 52 | virtual void draw () const; |
|---|
| 53 | virtual void tick (float dt); |
|---|
| 54 | |
|---|
| 55 | virtual void loadParams(const TiXmlElement* root); |
|---|
| 56 | |
|---|
| 57 | private: |
|---|
| 58 | void initVideo(const char* filename); |
|---|
| 59 | void addVideoStream(); |
|---|
| 60 | void openVideo(); |
|---|
| 61 | void closeVideo(); |
|---|
| 62 | void allocPicture(); |
|---|
| 63 | void writeVideoFrame(); |
|---|
| 64 | void fillYuvImage(); |
|---|
| 65 | |
|---|
| 66 | void setStreamDuration(float duration); |
|---|
| 67 | void setFPS(float fps); |
|---|
| 68 | }; |
|---|
| 69 | |
|---|
| 70 | #endif /* _RECORDER_H */ |
|---|
Note: See
TracBrowser
for help on using the repository browser.