]> git.vomp.tv Git - vompclient.git/blob - playerlivetv.h
Live TV updates
[vompclient.git] / playerlivetv.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 PLAYERLIVETV_H
22 #define PLAYERLIVETV_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 <queue>
32
33 #ifdef WIN32
34 #include "threadwin.h"
35 #else
36 #include "threadp.h"
37 #endif
38
39 #include "callback.h"
40 #include "defines.h"
41 #include "vfeed.h"
42 #include "afeed.h"
43 #include "vdr.h"
44
45 class MessageQueue;
46 class Audio;
47 class Video;
48 class Log;
49 class DemuxerTS;
50
51 struct PLTVInstruction
52 {
53   UCHAR instruction;
54   ULONG channelIndex;
55 };
56
57 struct StreamChunk
58 {
59   void* data;
60   ULONG len;
61 };
62
63 class PlayerLiveTV : public Thread_TYPE, public Callback, public StreamReceiver
64 {
65   public:
66     PlayerLiveTV(MessageQueue* messageQueue, void* messageReceiver, ChannelList* chanList);
67     virtual ~PlayerLiveTV();
68
69     int init();
70     int shutdown();
71
72     void go(ULONG index);
73     void setChannel(ULONG index);
74     void stop();
75     void setAudioChannel(int newChannel);
76
77     bool* getDemuxerMpegAudioChannels();
78     bool* getDemuxerAc3AudioChannels();
79     int getCurrentAudioChannel();
80
81     void call(void*); // for callback interface
82
83     virtual void streamReceive(void*, ULONG); // stream receiver interface
84     
85     // Player events
86
87     // FIXME so far this just duplicates the old system + the wss
88
89     const static UCHAR CONNECTION_LOST = 1;
90     const static UCHAR STOP_PLAYBACK = 2;
91     const static UCHAR STREAM_END = 3;
92     const static UCHAR ASPECT43 = 4;
93     const static UCHAR ASPECT169 = 5;
94
95   protected:
96     void threadMethod();
97     void threadPostStopCleanup() {};
98
99   private:
100     MessageQueue* messageQueue;
101     void* messageReceiver;
102     Log* logger;
103     Audio* audio;
104     Video* video;
105     DemuxerTS* demuxer;
106     VDR* vdr;
107     VFeed vfeed;
108     AFeed afeed;
109     ChannelList* chanList;
110
111     queue<PLTVInstruction> instructions;
112     const static UCHAR I_SETCHANNEL = 1;
113     const static UCHAR I_STOP = 2;
114     
115     queue<StreamChunk> streamChunks;
116     
117     bool initted;
118
119     UCHAR state;
120     const static UCHAR S_STOP = 1;
121     const static UCHAR S_VIDEOSTARTUP = 2;
122     const static UCHAR S_PREBUFFERING = 3;
123     const static UCHAR S_PLAY = 4;
124     void switchState(UCHAR newState);
125
126     bool videoStartup;
127     bool stopNow;
128     int preBufferCount;
129     const static int preBufferAmount = 3;
130
131     void clearStreamChunks();
132     void chunkToDemuxer();
133     void optimizeInstructionQueue();
134 };
135
136 #endif
137