]> git.vomp.tv Git - vompclient.git/blob - playerradio.h
Compile fix for MVP re: location change of hmsf
[vompclient.git] / playerradio.h
1 /*
2     Copyright 2004-2006 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 PLAYERRADIO_H
22 #define PLAYERRADIO_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 "afeed.h"
36
37 class Log;
38 class Audio;
39 class Video;
40 class Demuxer;
41 class VDR;
42 class MessageQueue;
43
44 class PlayerRadio : public Thread_TYPE, public Callback
45 {
46   public:
47     PlayerRadio(MessageQueue* messageQueue, void* messageReceiver);
48     virtual ~PlayerRadio();
49
50     int init(ULLONG lengthBytes, ULONG lengthPackets, bool IsPesRecording);
51     int shutdown();
52     void setStartBytes(ULLONG startBytes);
53
54     void play();
55     void stop();
56     void pause();
57     void playpause();
58     void jumpToPercent(double percent);
59     void skipForward(UINT seconds);
60     void skipBackward(UINT seconds);
61
62     UCHAR getState() { return state; }
63     ULONG getCurrentSeconds();
64     ULONG getLengthSeconds();
65
66     void call(void*); // for callback interface
67
68     const static UCHAR S_PLAY = 1;
69     const static UCHAR S_PAUSE_P = 2;
70     const static UCHAR S_STOP = 6;
71     const static UCHAR S_JUMP = 7;
72
73     // Player events
74
75     const static UCHAR CONNECTION_LOST = 1;
76     const static UCHAR STOP_PLAYBACK = 2;
77     const static UCHAR STREAM_END = 3;
78
79   protected:
80     void threadMethod();
81     void threadPostStopCleanup();
82
83   private:
84     void switchState(UCHAR newState, ULONG jumpPacket=0);
85
86     void threadFeedPlay();
87     void threadFeedScan();
88
89     void doConnectionLost();
90     void restartAtPacket(ULONG newPacket);
91     bool setLengthSeconds();
92
93     MessageQueue* messageQueue;
94     void* messageReceiver;
95     Log* logger;
96     Audio* audio;
97     Demuxer* demuxer;
98     VDR* vdr;
99     AFeed afeed;
100
101     bool initted;
102     bool startup;
103
104     ULLONG startPTS;
105     ULONG lengthSeconds;
106
107 #ifndef WIN32
108     pthread_mutex_t mutex;
109 #else
110     HANDLE mutex;
111 #endif
112     void lock();
113     void unLock();
114
115     ULLONG lengthBytes;
116     ULLONG streamPos;
117     ULONG lengthPackets;
118     ULONG currentPacketNumber;
119     UINT blockSize;
120     UINT startupBlockSize;
121     UCHAR* threadBuffer;
122     UCHAR state;
123 };
124
125 #endif
126
127
128 /*
129
130 Possible states:
131
132 Play, Pause, FFwd, FBwd, (Stop), [Jump]
133
134                     Possible  Working
135
136 Play   -> PauseP       *         *
137        -> Stop         *         *
138        -> Jump         *         *
139
140 PauseP -> Play         *         *
141        -> Stop         *         *
142        -> Jump         *         *
143
144 PauseI -> Play         *         *
145        -> PauseP
146        -> Stop         *         *
147        -> Jump         *         *
148
149 Stop   -> Play         *         *
150        -> PauseP
151        -> Jump
152
153 Jump   -> Play
154        -> PauseP
155        -> Stop
156
157 */