]> git.vomp.tv Git - vompclient-marten.git/blob - player.h
Add auto TCP window size
[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 #include "threadsystem.h"
32
33 #include "callback.h"
34 #include "defines.h"
35 #include "vfeed.h"
36 #include "afeed.h"
37 #include "tfeed.h"
38
39 #include "teletextdecodervbiebu.h"
40
41 class MessageQueue;
42 class Audio;
43 class Video;
44 class VDR;
45 class Log;
46 class Demuxer;
47 class OSDReceiver;
48 class DVBSubtitles;
49 class Channel;
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(bool p_isPesRecording,double framespersec);
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, int streamtype);
63     void setSubtitleChannel(int newChannel);
64     bool toggleSubtitles();
65     void turnSubtitlesOn(bool ison); 
66     bool isSubtitlesOn() { return subtitlesShowing; }
67
68     void play();
69     void stop();
70     void pause();
71     void playpause();
72     void fastForward();
73     void fastBackward();
74     void jumpToPercent(double percent);
75     void skipForward(int seconds);
76     void skipBackward(int seconds);
77     void jumpToMark(int mark);
78     void jumpToFrameP(int newFrame);
79
80     UCHAR getState() { return state; }
81     ULONG getCurrentFrameNum();
82     ULONG getLengthFrames();
83     UCHAR getIScanRate() { return ifactor; }
84     bool* getDemuxerMpegAudioChannels();
85     bool* getDemuxerAc3AudioChannels();
86     bool* getDemuxerSubtitleChannels();
87     int *getTeletxtSubtitlePages();
88     int getCurrentAudioChannel();
89     int getCurrentSubtitleChannel();
90     bool isPesRecording() { return is_pesrecording; }
91     Channel *getDemuxerChannel();
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     void threadPTSFeedScan();
131
132     void doConnectionLost();
133     void restartAtFrame(ULONG newFrame);
134     void restartAtFramePI(ULONG newFrame);
135
136     bool subtitlesShowing;
137     MessageQueue* messageQueue;
138     void* messageReceiver;
139     OSDReceiver* osdReceiver;
140     Log* logger;
141     Audio* audio;
142     Video* video;
143     Demuxer* demuxer;
144     DVBSubtitles* subtitles;
145     VDR* vdr;
146     VFeed vfeed;
147     AFeed afeed;
148     TFeed tfeed;
149     TeletextDecoderVBIEBU *teletext;
150   
151     
152
153     bool initted;
154     bool startup;
155     bool videoStartup;
156
157     bool is_pesrecording;
158         double fps;
159
160 #ifndef WIN32
161     pthread_mutex_t mutex;
162 #else
163     HANDLE mutex;
164 #endif
165     void lock();
166     void unLock();
167
168     ULLONG lengthBytes;
169     ULONG lengthFrames;
170     ULONG currentFrameNumber;
171     UINT blockSize;
172     UINT startupBlockSize;
173     UCHAR* threadBuffer;
174     UCHAR state;
175     UCHAR ifactor;
176 };
177
178 #endif
179
180
181 /*
182
183 Possible states:
184
185 Play, Pause, FFwd, FBwd, (Stop), [Jump]
186
187                     Possible  Working
188
189 Play   -> PauseP       *         *
190        -> PauseI
191        -> FFwd         *         *
192        -> FBwd         *         *
193        -> Stop         *         *
194        -> Jump         *         *
195        -> Jump_PI      *         *
196
197 PauseP -> Play         *         *
198        -> PauseI
199        -> FFwd         *         *
200        -> FBwd         *         *
201        -> Stop         *         *
202        -> Jump         *         *
203        -> Jump_PI      *         *
204
205 PauseI -> Play         *         *
206        -> PauseP
207        -> FFwd         *         *
208        -> FBwd         *         *
209        -> Stop         *         *
210        -> Jump         *         *
211        -> Jump_PI      *         *
212
213 FFwd   -> Play         *         *
214        -> PauseP
215        -> PauseI       *         *
216        -> FBwd         *         *
217        -> Stop         *         *
218        -> Jump         *         *
219        -> Jump_PI      *         *
220
221 FBwd   -> Play         *         *
222        -> PauseP
223        -> PauseI       *         *
224        -> FFwd         *         *
225        -> Stop         *         *
226        -> Jump         *         *
227        -> Jump_PI      *         *
228
229 Stop   -> Play         *         *
230        -> PauseP
231        -> PauseI
232        -> FFwd
233        -> FBwd
234        -> Jump
235        -> Jump_PI
236
237 */