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