]> git.vomp.tv Git - vompclient.git/blob - player.h
More compiler warning fixes
[vompclient.git] / player.h
1 /*
2     Copyright 2004-2008 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef PLAYER_H
22 #define PLAYER_H
23
24 #include <stdio.h>
25 #include <stdlib.h>
26 #ifndef WIN32
27 #include <sys/time.h>
28 #endif
29 #include <time.h>
30
31 #include "threadsystem.h"
32
33 #include "callback.h"
34 #include "defines.h"
35 #include "vfeed.h"
36 #include "afeed.h"
37 #include "tfeed.h"
38
39 #include "teletextdecodervbiebu.h"
40
41 class MessageQueue;
42 class Audio;
43 class Video;
44 class VDR;
45 class Log;
46 class Demuxer;
47 class OSDReceiver;
48 class DVBSubtitles;
49 class Channel;
50
51 class Player : public Thread_TYPE, public Callback
52 {
53   public:
54     Player(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* osdReceiver);
55     virtual ~Player();
56
57     int init(bool p_isPesRecording,double framespersec);
58     int shutdown();
59     void setStartFrame(ULONG frameNum);
60     void setLengthBytes(ULLONG length);
61     void setLengthFrames(ULONG length);
62     void setAudioChannel(int newChannel, int type, int streamtype);
63     void setSubtitleChannel(int newChannel);
64     bool toggleSubtitles();
65     void turnSubtitlesOn(bool ison); 
66     bool isSubtitlesOn() { return subtitlesShowing; }
67     void tellSubtitlesOSDVisible(bool visible);
68
69     void play();
70     void stop();
71     void pause();
72     void playpause();
73     void fastForward();
74     void fastBackward();
75     void jumpToPercent(double percent);
76     void skipForward(int seconds);
77     void skipBackward(int seconds);
78     void jumpToMark(int mark);
79     void jumpToFrameP(int newFrame);
80
81     UCHAR getState() { return state; }
82     ULONG getCurrentFrameNum();
83     ULONG getLengthFrames();
84     UCHAR getIScanRate() { return ifactor; }
85     bool* getDemuxerMpegAudioChannels();
86     bool* getDemuxerAc3AudioChannels();
87     bool* getDemuxerSubtitleChannels();
88     int *getTeletxtSubtitlePages();
89     int getCurrentAudioChannel();
90     int getCurrentSubtitleChannel();
91     bool isPesRecording() { return is_pesrecording; }
92     Channel *getDemuxerChannel();
93
94    TeletextDecoderVBIEBU * getTeletextDecoder() { return teletext; }
95
96     void call(void*); // for callback interface
97
98     const static UCHAR S_PLAY = 1;
99     const static UCHAR S_PAUSE_P = 2;
100     const static UCHAR S_PAUSE_I = 3;
101     const static UCHAR S_FFWD = 4;
102     const static UCHAR S_FBWD = 5;
103     const static UCHAR S_STOP = 6;
104     const static UCHAR S_JUMP = 7;
105     const static UCHAR S_JUMP_PI = 8; // Jump to Pause_I mode
106
107     // Player events
108
109     // FIXME so far this just duplicates the old system + the wss
110
111     const static UCHAR CONNECTION_LOST = 1;
112     const static UCHAR STOP_PLAYBACK = 2;
113     const static UCHAR STREAM_END = 3;
114     const static UCHAR ASPECT43 = 4;
115     const static UCHAR ASPECT169 = 5;
116
117 #ifdef DEV
118     void test1();
119     void test2();
120 #endif
121
122   protected:
123     void threadMethod();
124     void threadPostStopCleanup();
125
126   private:
127     void switchState(UCHAR newState, ULONG jumpFrame=0);
128
129     void threadFeedPlay();
130     void threadFeedScan();
131     void threadPTSFeedScan();
132
133     void doConnectionLost();
134     void restartAtFrame(ULONG newFrame);
135     void restartAtFramePI(ULONG newFrame);
136
137     bool subtitlesShowing;
138     MessageQueue* messageQueue;
139     void* messageReceiver;
140     OSDReceiver* osdReceiver;
141     Log* logger;
142     Audio* audio;
143     Video* video;
144     Demuxer* demuxer;
145     DVBSubtitles* subtitles;
146     VDR* vdr;
147     VFeed vfeed;
148     AFeed afeed;
149     TFeed tfeed;
150     TeletextDecoderVBIEBU *teletext;
151   
152     
153
154     bool initted;
155     bool startup;
156     bool videoStartup;
157
158     bool is_pesrecording;
159         double fps;
160
161 #ifndef WIN32
162     pthread_mutex_t mutex;
163 #else
164     HANDLE mutex;
165 #endif
166     void lock();
167     void unLock();
168
169     ULLONG lengthBytes;
170     ULONG lengthFrames;
171     ULONG currentFrameNumber;
172     UINT blockSize;
173     UINT startupBlockSize;
174     UCHAR* threadBuffer;
175     UCHAR state;
176     UCHAR ifactor;
177 };
178
179 #endif
180
181
182 /*
183
184 Possible states:
185
186 Play, Pause, FFwd, FBwd, (Stop), [Jump]
187
188                     Possible  Working
189
190 Play   -> PauseP       *         *
191        -> PauseI
192        -> FFwd         *         *
193        -> FBwd         *         *
194        -> Stop         *         *
195        -> Jump         *         *
196        -> Jump_PI      *         *
197
198 PauseP -> Play         *         *
199        -> PauseI
200        -> FFwd         *         *
201        -> FBwd         *         *
202        -> Stop         *         *
203        -> Jump         *         *
204        -> Jump_PI      *         *
205
206 PauseI -> Play         *         *
207        -> PauseP
208        -> FFwd         *         *
209        -> FBwd         *         *
210        -> Stop         *         *
211        -> Jump         *         *
212        -> Jump_PI      *         *
213
214 FFwd   -> Play         *         *
215        -> PauseP
216        -> PauseI       *         *
217        -> FBwd         *         *
218        -> Stop         *         *
219        -> Jump         *         *
220        -> Jump_PI      *         *
221
222 FBwd   -> Play         *         *
223        -> PauseP
224        -> PauseI       *         *
225        -> FFwd         *         *
226        -> Stop         *         *
227        -> Jump         *         *
228        -> Jump_PI      *         *
229
230 Stop   -> Play         *         *
231        -> PauseP
232        -> PauseI
233        -> FFwd
234        -> FBwd
235        -> Jump
236        -> Jump_PI
237
238 */