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