]> git.vomp.tv Git - vompclient-marten.git/blob - player.h
Windows updates
[vompclient-marten.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 #ifdef WIN32
32 #include "threadwin.h"
33 #else
34 #include "threadp.h"
35 #endif
36
37 #include "callback.h"
38 #include "defines.h"
39 #include "vfeed.h"
40 #include "afeed.h"
41 #include "tfeed.h"
42
43 #include "teletextdecodervbiebu.h"
44
45 class MessageQueue;
46 class Audio;
47 class Video;
48 class VDR;
49 class Log;
50 class Demuxer;
51 class OSDReceiver;
52 class DVBSubtitles;
53
54 class Player : public Thread_TYPE, public Callback
55 {
56   public:
57     Player(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* osdReceiver);
58     virtual ~Player();
59
60     int init();
61     int shutdown();
62     void setStartFrame(ULONG frameNum);
63     void setLengthBytes(ULLONG length);
64     void setLengthFrames(ULONG length);
65     void setAudioChannel(int newChannel, int type);
66     void setSubtitleChannel(int newChannel);
67     bool toggleSubtitles();
68     void turnSubtitlesOn(bool ison); 
69     bool isSubtitlesOn() {return subtitlesShowing;};
70
71     void play();
72     void stop();
73     void pause();
74     void fastForward();
75     void fastBackward();
76     void jumpToPercent(double percent);
77     void skipForward(int seconds);
78     void skipBackward(int seconds);
79     void jumpToMark(int mark);
80     void jumpToFrameP(int newFrame);
81
82     UCHAR getState() { return state; }
83     ULONG getCurrentFrameNum();
84     ULONG getLengthFrames();
85     UCHAR getIScanRate() { return ifactor; }
86     bool* getDemuxerMpegAudioChannels();
87     bool* getDemuxerAc3AudioChannels();
88     bool* getDemuxerSubtitleChannels();
89     int *getTeletxtSubtitlePages();
90     int getCurrentAudioChannel();
91     int getCurrentSubtitleChannel();
92
93    TeletextDecoderVBIEBU * getTeletextDecoder(){return teletext;};
94
95     void call(void*); // for callback interface
96
97     const static UCHAR S_PLAY = 1;
98     const static UCHAR S_PAUSE_P = 2;
99     const static UCHAR S_PAUSE_I = 3;
100     const static UCHAR S_FFWD = 4;
101     const static UCHAR S_FBWD = 5;
102     const static UCHAR S_STOP = 6;
103     const static UCHAR S_JUMP = 7;
104     const static UCHAR S_JUMP_PI = 8; // Jump to Pause_I mode
105
106     // Player events
107
108     // FIXME so far this just duplicates the old system + the wss
109
110     const static UCHAR CONNECTION_LOST = 1;
111     const static UCHAR STOP_PLAYBACK = 2;
112     const static UCHAR STREAM_END = 3;
113     const static UCHAR ASPECT43 = 4;
114     const static UCHAR ASPECT169 = 5;
115
116 #ifdef DEV
117     void test1();
118     void test2();
119 #endif
120
121   protected:
122     void threadMethod();
123     void threadPostStopCleanup();
124
125   private:
126     void switchState(UCHAR newState, ULONG jumpFrame=0);
127
128     void threadFeedPlay();
129     void threadFeedScan();
130
131     void doConnectionLost();
132     void restartAtFrame(ULONG newFrame);
133     void restartAtFramePI(ULONG newFrame);
134
135     bool subtitlesShowing;
136     MessageQueue* messageQueue;
137     void* messageReceiver;
138     OSDReceiver* osdReceiver;
139     Log* logger;
140     Audio* audio;
141     Video* video;
142     Demuxer* demuxer;
143     DVBSubtitles* subtitles;
144     VDR* vdr;
145     VFeed vfeed;
146     AFeed afeed;
147     TFeed tfeed;
148     TeletextDecoderVBIEBU *teletext;
149   
150     
151
152     bool initted;
153     bool startup;
154     bool videoStartup;
155
156 #ifndef WIN32
157     pthread_mutex_t mutex;
158 #else
159     HANDLE mutex;
160 #endif
161     void lock();
162     void unLock();
163
164     ULLONG lengthBytes;
165     ULONG lengthFrames;
166     ULONG currentFrameNumber;
167     UINT blockSize;
168     UINT startupBlockSize;
169     UCHAR* threadBuffer;
170     UCHAR state;
171     UCHAR ifactor;
172 };
173
174 #endif
175
176
177 /*
178
179 Possible states:
180
181 Play, Pause, FFwd, FBwd, (Stop), [Jump]
182
183                     Possible  Working
184
185 Play   -> PauseP       *         *
186        -> PauseI
187        -> FFwd         *         *
188        -> FBwd         *         *
189        -> Stop         *         *
190        -> Jump         *         *
191        -> Jump_PI      *         *
192
193 PauseP -> Play         *         *
194        -> PauseI
195        -> FFwd         *         *
196        -> FBwd         *         *
197        -> Stop         *         *
198        -> Jump         *         *
199        -> Jump_PI      *         *
200
201 PauseI -> Play         *         *
202        -> PauseP
203        -> FFwd         *         *
204        -> FBwd         *         *
205        -> Stop         *         *
206        -> Jump         *         *
207        -> Jump_PI      *         *
208
209 FFwd   -> Play         *         *
210        -> PauseP
211        -> PauseI       *         *
212        -> FBwd         *         *
213        -> Stop         *         *
214        -> Jump         *         *
215        -> Jump_PI      *         *
216
217 FBwd   -> Play         *         *
218        -> PauseP
219        -> PauseI       *         *
220        -> FFwd         *         *
221        -> Stop         *         *
222        -> Jump         *         *
223        -> Jump_PI      *         *
224
225 Stop   -> Play         *         *
226        -> PauseP
227        -> PauseI
228        -> FFwd
229        -> FBwd
230        -> Jump
231        -> Jump_PI
232
233 */