2 Copyright 2004-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 PLAYERRADIOREC_H
21 #define PLAYERRADIOREC_H
25 #include <condition_variable>
37 class MessageReceiver;
42 * VDR tells me there are around 8.3 "frames" per second in radio recordings.
43 * I don't know where this comes from but things seem to work.
46 class PlayerRadioRec : public Callback
49 PlayerRadioRec(MessageQueue* messageQueue, MessageReceiver* messageReceiver);
50 virtual ~PlayerRadioRec();
52 bool init(u8 lengthBytes, u4 lengthFrames, bool IsPesRecording);
54 void setCurrentFrameNumber(u4 num);
60 void jumpToPercent(double percent);
61 void skipForward(u4 seconds);
62 void skipBackward(u4 seconds);
64 u1 getState() { return state; }
65 u4 getCurrentSeconds();
66 u4 getLengthSeconds();
68 void call(void*); // for callback interface
70 const static u1 S_PLAY = 1;
71 const static u1 S_PAUSE_P = 2;
72 const static u1 S_PAUSE_I = 3;
73 const static u1 S_STOP = 6;
74 const static u1 S_JUMP = 7;
78 const static u1 CONNECTION_LOST = 1;
79 const static u1 STOP_PLAYBACK = 2;
80 const static u1 STREAM_END = 3;
83 void switchState(u1 newState, u4 jumpToFrame=0);
86 void doConnectionLost();
87 void restartAtFrame(u4 newFrame);
88 bool setLengthSeconds();
90 MessageQueue* messageQueue;
91 MessageReceiver* messageReceiver;
104 std::mutex stateLock;
106 std::thread playerThread;
107 std::mutex playerThreadMutex;
108 std::condition_variable playerThreadCond;
114 u4 currentFrameNumber{};
115 static const u4 blockSize{10000};
116 static const u4 startupBlockSize{20000};
127 Play, Pause, FFwd, FBwd, (Stop), [Jump]