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