]> git.vomp.tv Git - vompclient.git/blob - playerlivetv.h
Fix black background for 16:9 live TV on 4:3 screen
[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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef PLAYERLIVETV_H
21 #define PLAYERLIVETV_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 "vfeed.h"
43 #include "afeed.h"
44 #include "tfeed.h"
45 #include "vdr.h"
46
47 #include "teletextdecodervbiebu.h"
48
49 class MessageQueue;
50 class Audio;
51 class Video;
52 class Log;
53 class DemuxerTS;
54 class OSDReceiver;
55 class DVBSubtitles;
56
57 class PlayerLiveTV : public PlayerLive, public Thread_TYPE, public Callback, public StreamReceiver
58 {
59   public:
60     PlayerLiveTV(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* tosdReceiver, ChannelList* chanList);
61     virtual ~PlayerLiveTV();
62
63     virtual int init();
64     virtual int shutdown();
65
66     virtual void go(ULONG index);
67     virtual void setChannel(ULONG index);
68     virtual void stop();
69     virtual void setAudioChannel(int newChannel,int type,int streamtype);
70     virtual void setSubtitleChannel(int newChannel);
71     virtual bool toggleSubtitles();
72     virtual void turnSubtitlesOn(bool ison); 
73     virtual bool isSubtitlesOn() {return subtitlesShowing;};
74     virtual void tellSubtitlesOSDVisible(bool visible);
75
76     virtual bool* getDemuxerMpegAudioChannels();
77     virtual bool* getDemuxerAc3AudioChannels();
78     virtual int getCurrentAudioChannel();
79     virtual int getCurrentSubtitleChannel();
80     virtual int *getTeletxtSubtitlePages();
81
82     TeletextDecoderVBIEBU * getTeletextDecoder(){return teletext;};
83
84     void call(void*); // for callback interface
85
86     virtual void streamReceive(ULONG, void*, ULONG); // stream receiver interface
87     
88     // Player events
89
90     // FIXME so far this just duplicates the old system + the wss
91
92     const static UCHAR CONNECTION_LOST = 1;
93     const static UCHAR STOP_PLAYBACK = 2;
94     const static UCHAR STREAM_END = 3;
95     const static UCHAR ASPECT43 = 4;
96     const static UCHAR ASPECT169 = 5;
97     const static UCHAR PREBUFFERING = 6;
98
99   protected:
100     void threadMethod();
101
102   private:
103     bool subtitlesShowing;
104     MessageQueue* messageQueue;
105     void* messageReceiver;
106     OSDReceiver* osdReceiver;
107     Log* logger;
108     Audio* audio;
109     Video* video;
110     DemuxerTS* demuxer;
111     DVBSubtitles* subtitles;
112     TeletextDecoderVBIEBU *teletext;
113     VDR* vdr;
114     VFeed vfeed;
115     AFeed afeed;
116     TFeed tfeed;
117     ChannelList* chanList;
118     bool firstStart{true};
119
120     std::queue<PLInstruction> instructions;
121     const static UCHAR I_SETCHANNEL = 1;
122     const static UCHAR I_STOP = 2;
123     
124     std::queue<StreamChunk> streamChunks;
125     
126     bool initted;
127
128     UCHAR state;
129     const static UCHAR S_STOP = 1;
130     const static UCHAR S_VIDEOSTARTUP = 2;
131     const static UCHAR S_PREBUFFERING = 3;
132     const static UCHAR S_PLAY = 4;
133     void switchState(UCHAR newState);
134     bool checkError();
135
136     bool videoStartup;
137     bool pendingAudioPlay;
138     bool stopNow;
139     bool h264;
140     int preBufferCount;
141     const static int preBufferAmount = 3;
142
143     void clearStreamChunks();
144     void chunkToDemuxer();
145     void optimizeInstructionQueue();
146 };
147
148 #endif
149