Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 3 | pmbaty | 1 | /* A class based on the MPEG stream class, used to parse the system stream */ |
| 2 | |||
| 3 | /* - Modified by Michel Darricau from eProcess <mdarricau@eprocess.fr> for popcorn - */ |
||
| 4 | |||
| 5 | #ifndef _MPEGSYSTEM_H_ |
||
| 6 | #define _MPEGSYSTEM_H_ |
||
| 7 | #define USE_SYSTEM_TIMESTAMP |
||
| 8 | |||
| 9 | #include "SDL.h" |
||
| 10 | #include "SDL_thread.h" |
||
| 11 | #include "MPEGerror.h" |
||
| 12 | |||
| 13 | class MPEGstream; |
||
| 14 | |||
| 15 | /* MPEG System library |
||
| 16 | by Vivien Chappelier */ |
||
| 17 | |||
| 18 | /* The system class is necessary for splitting the MPEG stream into */ |
||
| 19 | /* peaces of data that will be sent to the audio or video decoder. */ |
||
| 20 | |||
| 21 | class MPEGsystem : public MPEGerror |
||
| 22 | { |
||
| 23 | public: |
||
| 24 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> need for override in popcorn */ |
||
| 25 | MPEGsystem() {} |
||
| 26 | MPEGsystem(SDL_RWops *mpeg_source); |
||
| 27 | virtual ~MPEGsystem(); |
||
| 28 | |||
| 29 | /* Buffered I/O functions */ |
||
| 30 | void RequestBuffer(); |
||
| 31 | bool Wait(); |
||
| 32 | Uint32 Tell(); |
||
| 33 | void Rewind(); |
||
| 34 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> need for override in popcorn */ |
||
| 35 | virtual void Start(); |
||
| 36 | void Stop(); |
||
| 37 | bool Eof() const; |
||
| 38 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> need for override in popcorn */ |
||
| 39 | virtual bool Seek(int length); |
||
| 40 | virtual Uint32 TotalSize(); |
||
| 41 | virtual double TotalTime(); |
||
| 42 | virtual double TimeElapsedAudio(int atByte); |
||
| 43 | |||
| 44 | /* Skip "seconds" seconds */ |
||
| 45 | void Skip(double seconds); |
||
| 46 | |||
| 47 | /* Create all the streams present in the MPEG */ |
||
| 48 | MPEGstream ** GetStreamList(); |
||
| 49 | |||
| 50 | /* Insert a stream in the list */ |
||
| 51 | void add_stream(MPEGstream * stream); |
||
| 52 | |||
| 53 | /* Search for a stream in the list */ |
||
| 54 | MPEGstream * get_stream(Uint8 stream_id); |
||
| 55 | |||
| 56 | /* Test if a stream is in the list */ |
||
| 57 | Uint8 exist_stream(Uint8 stream_id, Uint8 mask); |
||
| 58 | |||
| 59 | /* Reset all the system streams */ |
||
| 60 | void reset_all_streams(); |
||
| 61 | |||
| 62 | /* Set eof for all streams */ |
||
| 63 | void end_all_streams(); |
||
| 64 | |||
| 65 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> need for override in popcorn */ |
||
| 66 | /* Seek the first header */ |
||
| 67 | virtual bool seek_first_header(); |
||
| 68 | |||
| 69 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> need for override in popcorn */ |
||
| 70 | /* Seek the next header */ |
||
| 71 | virtual bool seek_next_header(); |
||
| 72 | |||
| 73 | protected: |
||
| 74 | /* Run the loop to fill the stream buffers */ |
||
| 75 | static bool SystemLoop(MPEGsystem *system); |
||
| 76 | |||
| 77 | /* Michel Darricau from eProcess <mdarricau@eprocess.fr> need for override in popcorn */ |
||
| 78 | /* Fill a buffer */ |
||
| 79 | virtual Uint8 FillBuffer(); |
||
| 80 | |||
| 81 | /* Read a new packet */ |
||
| 82 | virtual void Read(); |
||
| 83 | |||
| 84 | /* The system thread which fills the FIFO */ |
||
| 85 | static int SystemThread(void * udata); |
||
| 86 | |||
| 87 | SDL_RWops *source; |
||
| 88 | |||
| 89 | SDL_Thread * system_thread; |
||
| 90 | bool system_thread_running; |
||
| 91 | |||
| 92 | MPEGstream ** stream_list; |
||
| 93 | |||
| 94 | Uint8 * read_buffer; |
||
| 95 | Uint8 * pointer; |
||
| 96 | int read_size; |
||
| 97 | Uint32 read_total; |
||
| 98 | Uint32 packet_total; |
||
| 99 | int request; |
||
| 100 | SDL_semaphore * request_wait; |
||
| 101 | SDL_mutex * system_mutex; |
||
| 102 | |||
| 103 | bool endofstream; |
||
| 104 | bool errorstream; |
||
| 105 | |||
| 106 | double frametime; |
||
| 107 | double stream_timestamp; |
||
| 108 | |||
| 109 | #ifdef USE_SYSTEM_TIMESTAMP |
||
| 110 | /* Current timestamp for this stream */ |
||
| 111 | double timestamp; |
||
| 112 | double timedrift; |
||
| 113 | double skip_timestamp; |
||
| 114 | #endif |
||
| 115 | }; |
||
| 116 | #endif |
||
| 117 |