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>
41 * VDR tells me there are around 8.3 "frames" per second in radio recordings.
42 * I don't know where this comes from but things seem to work.
45 class PlayerRadioRec : public Callback
48 PlayerRadioRec(MessageQueue* messageQueue, void* messageReceiver);
49 virtual ~PlayerRadioRec();
51 bool init(ULLONG lengthBytes, ULONG lengthFrames, bool IsPesRecording);
53 void setCurrentFrameNumber(ULONG num);
59 void jumpToPercent(double percent);
60 void skipForward(UINT seconds);
61 void skipBackward(UINT seconds);
63 UCHAR getState() { return state; }
64 ULONG getCurrentSeconds();
65 ULONG getLengthSeconds();
67 void call(void*); // for callback interface
69 const static UCHAR S_PLAY = 1;
70 const static UCHAR S_PAUSE_P = 2;
71 const static UCHAR S_PAUSE_I = 3;
72 const static UCHAR S_STOP = 6;
73 const static UCHAR S_JUMP = 7;
77 const static UCHAR CONNECTION_LOST = 1;
78 const static UCHAR STOP_PLAYBACK = 2;
79 const static UCHAR STREAM_END = 3;
82 void switchState(UCHAR newState, ULONG jumpToFrame=0);
85 void doConnectionLost();
86 void restartAtFrame(ULONG newFrame);
87 bool setLengthSeconds();
89 MessageQueue* messageQueue;
90 void* messageReceiver;
101 ULONG lengthSeconds{};
103 std::mutex stateLock;
105 std::thread playerThread;
106 std::mutex playerThreadMutex;
107 std::condition_variable playerThreadCond;
111 ULLONG lengthBytes{};
112 ULONG lengthFrames{};
113 ULONG currentFrameNumber{};
114 static const UINT blockSize{10000};
115 static const UINT startupBlockSize{20000};
126 Play, Pause, FFwd, FBwd, (Stop), [Jump]