/
MPEGaction.h
141 lines (121 loc) · 3.89 KB
/
MPEGaction.h
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
SMPEG - SDL MPEG Player Library
Copyright (C) 1999 Loki Entertainment Software
- Modified by Michel Darricau from eProcess <mdarricau@eprocess.fr> for popcorn -
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* A virtual class to provide basic MPEG playback actions */
#ifndef _MPEGACTION_H_
#define _MPEGACTION_H_
#include "SDL.h"
#include "MPEGfilter.h"
typedef enum {
MPEG_ERROR = -1,
MPEG_STOPPED,
MPEG_PLAYING
} MPEGstatus;
class MPEGaction {
public:
MPEGaction() {
playing = false;
paused = false;
looping = false;
play_time = 0.0;
}
virtual void Loop(bool toggle) {
looping = toggle;
}
virtual double Time(void) { /* Returns the time in seconds since start */
return play_time;
}
virtual void Play(void) = 0;
virtual void Stop(void) = 0;
virtual void Rewind(void) = 0;
virtual void ResetSynchro(double) = 0;
virtual void Skip(float seconds) = 0;
virtual void Pause(void) { /* A toggle action */
if ( paused ) {
paused = false;
Play();
} else {
Stop();
paused = true;
}
}
/* Michel Darricau from eProcess <mdarricau@eprocess.fr> conflict name in popcorn */
virtual MPEGstatus GetStatus(void) = 0;
protected:
bool playing;
bool paused;
bool looping;
double play_time;
bool force_exit;
void ResetPause(void) {
paused = false;
}
};
/* For getting info about the audio portion of the stream */
typedef struct MPEG_AudioInfo {
int mpegversion;
int mode;
int frequency;
int layer;
int bitrate;
int current_frame;
} MPEG_AudioInfo;
/* Audio action class */
class MPEGaudioaction : public MPEGaction {
public:
virtual bool GetAudioInfo(MPEG_AudioInfo *info) {
return(true);
}
virtual void Volume(int vol) = 0;
};
/* Matches the declaration of SDL_UpdateRect() */
typedef void(*MPEG_DisplayCallback)(SDL_Surface* dst, int x, int y,
unsigned int w, unsigned int h);
/* For getting info about the video portion of the stream */
typedef struct MPEG_VideoInfo {
int width;
int height;
int current_frame;
double current_fps;
} MPEG_VideoInfo;
/* Video action class */
class MPEGvideoaction : public MPEGaction {
public:
virtual void SetTimeSource(MPEGaudioaction *source) {
time_source = source;
}
virtual bool GetVideoInfo(MPEG_VideoInfo *info) {
return(false);
}
virtual bool SetDisplay(SDL_Surface *dst, SDL_mutex *lock,
MPEG_DisplayCallback callback) = 0;
virtual void MoveDisplay(int x, int y) = 0;
virtual void ScaleDisplayXY(int w, int h) = 0;
virtual void SetDisplayRegion(int x, int y, int w, int h) = 0;
virtual void RenderFrame(int frame) = 0;
virtual void RenderFinal(SDL_Surface *dst, int x, int y) = 0;
virtual SMPEG_Filter * Filter(SMPEG_Filter * filter) = 0;
protected:
MPEGaudioaction *time_source;
};
/* For getting info about the system portion of the stream */
typedef struct MPEG_SystemInfo {
int total_size;
int current_offset;
double total_time;
double current_time;
} MPEG_SystemInfo;
#endif /* _MPEGACTION_H_ */