File: MPEGsystem.h

package info (click to toggle)
smpeg 0.4.4-8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,892 kB
  • ctags: 1,445
  • sloc: cpp: 14,948; sh: 8,962; ansic: 2,323; asm: 542; makefile: 162
file content (117 lines) | stat: -rw-r--r-- 3,129 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* A class based on the MPEG stream class, used to parse the system stream */
    
/* - Modified by Michel Darricau from eProcess <mdarricau@eprocess.fr>  for popcorn - */

#ifndef _MPEGSYSTEM_H_
#define _MPEGSYSTEM_H_
#define USE_SYSTEM_TIMESTAMP

#include "SDL.h"
#include "SDL_thread.h"
#include "MPEGerror.h"

class MPEGstream;

/* MPEG System library
   by Vivien Chappelier */

/* The system class is necessary for splitting the MPEG stream into */
/* peaces of data that will be sent to the audio or video decoder.  */

class MPEGsystem : public MPEGerror
{
public:
	/* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
    MPEGsystem() {}
    MPEGsystem(SDL_RWops *mpeg_source);
    virtual ~MPEGsystem();

    /* Buffered I/O functions */
    void RequestBuffer();
    bool Wait();
    Uint32 Tell();
    void Rewind();
		/* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
    virtual void Start();
    void Stop();
    bool Eof() const;
		/* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
    virtual bool Seek(int length);
    virtual Uint32 TotalSize();
    virtual double TotalTime();
    virtual double TimeElapsedAudio(int atByte);

    /* Skip "seconds" seconds */
    void Skip(double seconds);

    /* Create all the streams present in the MPEG */
    MPEGstream ** GetStreamList();

    /* Insert a stream in the list */
    void add_stream(MPEGstream * stream);

    /* Search for a stream in the list */
    MPEGstream * get_stream(Uint8 stream_id);

    /* Test if a stream is in the list */
    Uint8 exist_stream(Uint8 stream_id, Uint8 mask);

    /* Reset all the system streams */
    void reset_all_streams();
    
    /* Set eof for all streams */
    void end_all_streams();
    
		/* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
    /* Seek the first header */
    virtual bool seek_first_header();

		/* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
    /* Seek the next header */
    virtual bool seek_next_header();

protected:
    /* Run the loop to fill the stream buffers */
    static bool SystemLoop(MPEGsystem *system);

		/* Michel Darricau from eProcess <mdarricau@eprocess.fr>  need for override in popcorn */
    /* Fill a buffer */
    virtual Uint8 FillBuffer();

    /* Read a new packet */
    virtual void Read();

    /* The system thread which fills the FIFO */
    static int SystemThread(void * udata);

    SDL_RWops *source;

    SDL_Thread * system_thread;
    bool system_thread_running;

    MPEGstream ** stream_list;

    Uint8 * read_buffer;
    Uint8 * pointer;
    int read_size;
    Uint32 read_total;
    Uint32 packet_total;
    int request;
    SDL_semaphore * request_wait;
    SDL_mutex * system_mutex;

    bool endofstream;
    bool errorstream;

    double frametime;
    double stream_timestamp;

#ifdef USE_SYSTEM_TIMESTAMP
    /* Current timestamp for this stream */
    double timestamp;
    double timedrift;
    double skip_timestamp;
#endif
};
#endif