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