CPPMyth
Library to interoperate with MythTV server
Loading...
Searching...
No Matches
mythrecordingplayback.h
1/*
2 * Copyright (C) 2014 Jean-Luc Barriere
3 *
4 * This Program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This Program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; see the file COPYING. If not, write to
16 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 */
21
22#ifndef MYTHRECORDINGPLAYBACK_H
23#define MYTHRECORDINGPLAYBACK_H
24
25#include "proto/mythprotoplayback.h"
26#include "proto/mythprototransfer.h"
27#include "mythstream.h"
28#include "mytheventhandler.h"
29
30#define MYTH_RECORDING_CHUNK_SIZE 262000
31#define MYTH_RECORDING_CHUNK_MIN 8000
32#define MYTH_RECORDING_CHUNK_MAX 524000
33
34namespace Myth
35{
36
37 class RingBuffer;
38 class RingBufferPacket;
39
40 class RecordingPlayback : private ProtoPlayback, public Stream, private EventSubscriber
41 {
42 public:
43 RecordingPlayback(EventHandler& handler);
44 RecordingPlayback(const std::string& server, unsigned port);
45 ~RecordingPlayback();
46
47 bool Open();
48 void Close();
49 bool IsOpen() { return ProtoPlayback::IsOpen(); }
50 bool OpenTransfer(ProgramPtr recording);
51 void CloseTransfer();
52 bool TransferIsOpen();
53
54 void SetChunk(unsigned size); // to change the size of read chunk
55
56 // Implement Stream
57 int64_t GetSize() const;
58 int Read(void *buffer, unsigned n);
59 int64_t Seek(int64_t offset, WHENCE_t whence);
60 int64_t GetPosition() const;
61
62 // Implement EventSubscriber
63 void HandleBackendMessage(EventMessagePtr msg);
64
65 private:
66 EventHandler m_eventHandler;
67 unsigned m_eventSubscriberId;
68 ProtoTransferPtr m_transfer;
69 ProgramPtr m_recording;
70 volatile bool m_readAhead;
71
72 int _read(void *buffer, unsigned n);
73 int64_t _seek(int64_t offset, WHENCE_t whence);
74 // data buffer
75 unsigned m_chunk; // the size of block to read
76 struct { RingBuffer * rbuf; RingBufferPacket * packet; int consumed; } m_buffer;
77 };
78
79}
80
81#endif /* MYTHRECORDINGPLAYBACK_H */
This is the main namespace that encloses all public classes.
Definition mythcontrol.h:30