]> git.vomp.tv Git - vompclient.git/blob - playerlivetv.h
Updates to new streaming protocol and live tv
[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 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 <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;   // 1 = setChannel, 2 = stop
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 #ifdef DEV
96     void test1();
97     void test2();
98 #endif
99
100   protected:
101     void threadMethod();
102     void threadPostStopCleanup();
103
104   private:
105
106     MessageQueue* messageQueue;
107     void* messageReceiver;
108     Log* logger;
109     Audio* audio;
110     Video* video;
111     DemuxerTS* demuxer;
112     VDR* vdr;
113     VFeed vfeed;
114     AFeed afeed;
115     ChannelList* chanList;
116
117     queue<PLTVInstruction> instructions;
118     queue<StreamChunk> streamChunks;
119     
120     bool initted;
121
122     UCHAR state;
123     const static UCHAR S_STOP = 1;
124     const static UCHAR S_PREBUFFERING = 2;
125     const static UCHAR S_PLAY = 3;
126     void switchState(UCHAR newState);
127
128     bool videoStartup;
129     bool stopNow;
130         
131     void clearStreamChunks();
132     void chunkToDemuxer();
133
134 };
135
136 #endif
137