]> git.vomp.tv Git - vompclient.git/blob - player.h
German 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 #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
42 class MessageQueue;
43 class Audio;
44 class Video;
45 class VDR;
46 class Log;
47 class Demuxer;
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     void jumpToFrameP(int newFrame);
73
74     UCHAR getState() { return state; }
75     ULONG getCurrentFrameNum();
76     ULONG getLengthFrames();
77     UCHAR getIScanRate() { return ifactor; }
78     bool* getDemuxerMpegAudioChannels();
79     bool* getDemuxerAc3AudioChannels();
80     int getCurrentAudioChannel();
81
82     void call(void*); // for callback interface
83
84     const static UCHAR S_PLAY = 1;
85     const static UCHAR S_PAUSE_P = 2;
86     const static UCHAR S_PAUSE_I = 3;
87     const static UCHAR S_FFWD = 4;
88     const static UCHAR S_FBWD = 5;
89     const static UCHAR S_STOP = 6;
90     const static UCHAR S_JUMP = 7;
91     const static UCHAR S_JUMP_PI = 8; // Jump to Pause_I mode
92
93     // Player events
94
95     // FIXME so far this just duplicates the old system + the wss
96
97     const static UCHAR CONNECTION_LOST = 1;
98     const static UCHAR STOP_PLAYBACK = 2;
99     const static UCHAR STREAM_END = 3;
100     const static UCHAR ASPECT43 = 4;
101     const static UCHAR ASPECT169 = 5;
102
103 #ifdef DEV
104     void test1();
105     void test2();
106 #endif
107
108   protected:
109     void threadMethod();
110     void threadPostStopCleanup();
111
112   private:
113     void switchState(UCHAR newState, ULONG jumpFrame=0);
114
115     void threadFeedLive();
116     void threadFeedPlay();
117     void threadFeedScan();
118
119     void doConnectionLost();
120     void restartAtFrame(ULONG newFrame);
121     void restartAtFramePI(ULONG newFrame);
122
123     MessageQueue* messageQueue;
124     void* messageReceiver;
125     Log* logger;
126     Audio* audio;
127     Video* video;
128     Demuxer* demuxer;
129     VDR* vdr;
130     VFeed vfeed;
131     AFeed afeed;
132
133     bool initted;
134     bool startup;
135     bool videoStartup;
136     bool isRecording;
137     bool preBuffering;
138
139 #ifndef WIN32
140     pthread_mutex_t mutex;
141 #else
142   HANDLE mutex;
143 #endif
144     void lock();
145     void unLock();
146
147     ULLONG lengthBytes;
148     ULONG lengthFrames;
149     ULONG currentFrameNumber;
150     UINT blockSize;
151     UINT startupBlockSize;
152     UINT preBufferSize;
153     UCHAR* threadBuffer;
154     UCHAR state;
155     UCHAR ifactor;
156 };
157
158 #endif
159
160
161 /*
162
163 Possible states:
164
165 Play, Pause, FFwd, FBwd, (Stop), [Jump]
166
167                     Possible  Working
168
169 Play   -> PauseP       *         *
170        -> PauseI
171        -> FFwd         *         *
172        -> FBwd         *         *
173        -> Stop         *         *
174        -> Jump         *         *
175        -> Jump_PI      *         *
176
177 PauseP -> Play         *         *
178        -> PauseI
179        -> FFwd         *         *
180        -> FBwd         *         *
181        -> Stop         *         *
182        -> Jump         *         *
183        -> Jump_PI      *         *
184
185 PauseI -> Play         *         *
186        -> PauseP
187        -> FFwd         *         *
188        -> FBwd         *         *
189        -> Stop         *         *
190        -> Jump         *         *
191        -> Jump_PI      *         *
192
193 FFwd   -> Play         *         *
194        -> PauseP
195        -> PauseI       *         *
196        -> FBwd         *         *
197        -> Stop         *         *
198        -> Jump         *         *
199        -> Jump_PI      *         *
200
201 FBwd   -> Play         *         *
202        -> PauseP
203        -> PauseI       *         *
204        -> FFwd         *         *
205        -> Stop         *         *
206        -> Jump         *         *
207        -> Jump_PI      *         *
208
209 Stop   -> Play         *         *
210        -> PauseP
211        -> PauseI
212        -> FFwd
213        -> FBwd
214        -> Jump
215        -> Jump_PI
216
217 */