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