2 Copyright 2008-2020 Chris Tallon
4 This file is part of VOMP.
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.
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.
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/>.
20 #ifndef PLAYERRADIOLIVE_H
21 #define PLAYERRADIOLIVE_H
25 #include <condition_variable>
30 #include "playerlive.h"
37 class MessageReceiver;
42 class PlayerRadioLive : public PlayerLive, public Callback, public StreamReceiver
45 PlayerRadioLive(MessageQueue* messageQueue, MessageReceiver* messageReceiver, std::shared_ptr<ChannelList> chanList);
46 virtual ~PlayerRadioLive();
49 virtual int shutdown();
51 virtual void go(u4 index);
52 virtual void setChannel(u4 index);
54 virtual void setAudioChannel(int newChannel, int type,int streamtype);
55 virtual void setSubtitleChannel(int newChannel);
57 virtual bool* getDemuxerMpegAudioChannels();
58 virtual bool* getDemuxerAc3AudioChannels();
59 virtual int getCurrentAudioChannel();
60 virtual int* getTeletxtSubtitlePages();
61 virtual int getCurrentSubtitleChannel();
63 void call(void*); // for callback interface
65 virtual void streamReceive(u4, void*, u4); // stream receiver interface
69 // FIXME so far this just duplicates the old system + the wss
71 const static u1 CONNECTION_LOST = 1;
72 const static u1 STOP_PLAYBACK = 2;
73 const static u1 STREAM_END = 3;
74 const static u1 ASPECT43 = 4;
75 const static u1 ASPECT169 = 5;
76 const static u1 PREBUFFERING = 6;
79 MessageQueue* messageQueue;
80 MessageReceiver* messageReceiver;
86 std::shared_ptr<ChannelList> chanList;
88 std::queue<PLInstruction> instructions;
89 const static u1 I_SETCHANNEL = 1;
90 const static u1 I_STOP = 2;
92 std::queue<StreamChunk> streamChunks;
97 const static u1 S_STOP = 1;
98 const static u1 S_PREBUFFERING = 2;
99 const static u1 S_PLAY = 3;
100 void switchState(u1 newState);
104 const static int preBufferAmount = 3;
106 std::thread playerThread;
107 std::mutex playerThreadMutex;
108 std::condition_variable playerThreadCond;
111 void clearStreamChunks();
112 void chunkToDemuxer();
113 void optimizeInstructionQueue();