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(ULLONG lengthBytes, ULONG lengthFrames, bool IsPesRecording);
54 void setCurrentFrameNumber(ULONG num);
60 void jumpToPercent(double percent);
61 void skipForward(UINT seconds);
62 void skipBackward(UINT seconds);
64 UCHAR getState() { return state; }
65 ULONG getCurrentSeconds();
66 ULONG getLengthSeconds();
68 void call(void*); // for callback interface
70 const static UCHAR S_PLAY = 1;
71 const static UCHAR S_PAUSE_P = 2;
72 const static UCHAR S_PAUSE_I = 3;
73 const static UCHAR S_STOP = 6;
74 const static UCHAR S_JUMP = 7;
78 const static UCHAR CONNECTION_LOST = 1;
79 const static UCHAR STOP_PLAYBACK = 2;
80 const static UCHAR STREAM_END = 3;
83 void switchState(UCHAR newState, ULONG jumpToFrame=0);
86 void doConnectionLost();
87 void restartAtFrame(ULONG newFrame);
88 bool setLengthSeconds();
90 MessageQueue* messageQueue;
91 MessageReceiver* messageReceiver;
102 ULONG lengthSeconds{};
104 std::mutex stateLock;
106 std::thread playerThread;
107 std::mutex playerThreadMutex;
108 std::condition_variable playerThreadCond;
112 ULLONG lengthBytes{};
113 ULONG lengthFrames{};
114 ULONG currentFrameNumber{};
115 static const UINT blockSize{10000};
116 static const UINT startupBlockSize{20000};
127 Play, Pause, FFwd, FBwd, (Stop), [Jump]