]> git.vomp.tv Git - vompclient.git/blob - playervideolive.h
Control/main/winmain/util reorg
[vompclient.git] / playervideolive.h
1 /*
2     Copyright 2004-2020 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 PLAYERVIDEOLIVE_H
21 #define PLAYERVIDEOLIVE_H
22
23 #include <mutex>
24 #include <thread>
25 #include <condition_variable>
26
27 #include <queue>
28
29 #include "playerlive.h"
30
31 #include "callback.h"
32 #include "defines.h"
33 #include "vfeed.h"
34 #include "afeed.h"
35 #include "tfeed.h"
36 #include "vdr.h"
37
38 #include "teletextdecodervbiebu.h"
39
40 class MessageQueue;
41 class Audio;
42 class Video;
43 class Log;
44 class DemuxerTS;
45 class OSDReceiver;
46 class DVBSubtitles;
47
48 class PlayerVideoLive : public PlayerLive, public Callback, public StreamReceiver
49 {
50   public:
51     PlayerVideoLive(MessageQueue* messageQueue, void* messageReceiver, OSDReceiver* tosdReceiver, ChannelList* chanList);
52     virtual ~PlayerVideoLive();
53
54     virtual int init();
55     virtual int shutdown();
56
57     virtual void go(ULONG index);
58     virtual void setChannel(ULONG index);
59     virtual void stop();
60     virtual void setAudioChannel(int newChannel,int type,int streamtype);
61     virtual void setSubtitleChannel(int newChannel);
62     virtual bool toggleSubtitles();
63     virtual void turnSubtitlesOn(bool ison); 
64     virtual bool isSubtitlesOn() {return subtitlesShowing;};
65     virtual void tellSubtitlesOSDVisible(bool visible);
66
67     virtual bool* getDemuxerMpegAudioChannels();
68     virtual bool* getDemuxerAc3AudioChannels();
69     virtual int getCurrentAudioChannel();
70     virtual int getCurrentSubtitleChannel();
71     virtual int *getTeletxtSubtitlePages();
72
73     TeletextDecoderVBIEBU * getTeletextDecoder(){return teletext;};
74
75     void call(void*); // for callback interface
76
77     virtual void streamReceive(ULONG, void*, ULONG); // stream receiver interface
78     
79     // Player events
80
81     // FIXME so far this just duplicates the old system + the wss
82
83     const static UCHAR CONNECTION_LOST = 1;
84     const static UCHAR STOP_PLAYBACK = 2;
85     const static UCHAR STREAM_END = 3;
86     const static UCHAR ASPECT43 = 4;
87     const static UCHAR ASPECT169 = 5;
88     const static UCHAR PREBUFFERING = 6;
89
90   private:
91     VFeed vfeed;
92     AFeed afeed;
93     TFeed tfeed;
94     MessageQueue* messageQueue;
95     void* messageReceiver;
96     OSDReceiver* osdReceiver;
97     ChannelList* chanList;
98     Log* logger;
99     Audio* audio;
100     Video* video;
101     DemuxerTS* demuxer;
102     DVBSubtitles* subtitles;
103     TeletextDecoderVBIEBU *teletext;
104     VDR* vdr;
105
106     std::queue<PLInstruction> instructions;
107     const static UCHAR I_SETCHANNEL = 1;
108     const static UCHAR I_STOP = 2;
109
110     std::queue<StreamChunk> streamChunks;
111
112     std::thread playerThread;
113     std::mutex playerThreadMutex;
114     std::condition_variable playerThreadCond;
115     void threadMethod();
116
117     const static UCHAR S_STOP = 1;
118     const static UCHAR S_VIDEOSTARTUP = 2;
119     const static UCHAR S_PREBUFFERING = 3;
120     const static UCHAR S_PLAY = 4;
121     void switchState(UCHAR newState);
122     bool checkError();
123
124     bool initted{};
125     UCHAR state{S_STOP};
126     bool subtitlesShowing{};
127     bool firstStart{true};
128     bool videoStartup{};
129     bool pendingAudioPlay{};
130     bool h264;
131     int preBufferCount;
132     const static int preBufferAmount = 3;
133
134     void clearStreamChunks();
135     void chunkToDemuxer();
136     void optimizeInstructionQueue();
137 };
138
139 #endif
140