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