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