CPPMyth
Library to interoperate with MythTV server
Loading...
Searching...
No Matches
mythlivetvplayback.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 MYTHLIVETVPLAYBACK_H
23#define MYTHLIVETVPLAYBACK_H
24
25#include "proto/mythprotorecorder.h"
26#include "proto/mythprototransfer.h"
27#include "proto/mythprotomonitor.h"
28#include "mythstream.h"
29#include "mytheventhandler.h"
30#include "mythtypes.h"
31
32#include <vector>
33
34#define MYTH_LIVETV_CHUNK_SIZE 262000
35#define MYTH_LIVETV_CHUNK_MIN 8000
36#define MYTH_LIVETV_CHUNK_MAX 524000
37
38namespace Myth
39{
40
41 class RingBuffer;
42 class RingBufferPacket;
43
44 class LiveTVPlayback : private ProtoMonitor, public Stream, private EventSubscriber
45 {
46 public:
47 LiveTVPlayback(EventHandler& handler);
48 LiveTVPlayback(const std::string& server, unsigned port);
49 ~LiveTVPlayback();
50
51 bool Open();
52 void Close();
53 bool IsOpen() { return ProtoMonitor::IsOpen(); }
54 void SetTuneDelay(unsigned delay);
55 void SetLimitTuneAttempts(bool limit);
56 bool SpawnLiveTV(const std::string& chanNum, const ChannelList& channels);
57 bool SpawnLiveTV(const ChannelPtr& thisChannel);
58 void StopLiveTV();
59
60 void SetChunk(unsigned size); // to change the size of read chunk
61
62 // Implement Stream
63 int64_t GetSize() const;
64 int Read(void *buffer, unsigned n);
65 int64_t Seek(int64_t offset, WHENCE_t whence);
66 int64_t GetPosition() const;
67
68 bool IsPlaying() const;
69 bool IsLiveRecording() const;
70 bool KeepLiveRecording(bool keep);
71 ProgramPtr GetPlayedProgram() const;
72 time_t GetLiveTimeStart() const;
73 unsigned GetChainedCount() const;
74 ProgramPtr GetChainedProgram(unsigned sequence) const;
75 uint32_t GetCardId() const;
76 SignalStatusPtr GetSignal() const;
77
78 // Implement EventSubscriber
79 void HandleBackendMessage(EventMessagePtr msg);
80
81 private:
82 EventHandler m_eventHandler;
83 unsigned m_eventSubscriberId;
84
85 unsigned m_tuneDelay;
86 bool m_limitTuneAttempts;
87 ProtoRecorderPtr m_recorder;
88 SignalStatusPtr m_signal;
89
90 typedef std::vector<std::pair<ProtoTransferPtr, ProgramPtr> > chained_t;
91 struct {
92 std::string UID;
93 chained_t chained;
94 ProtoTransferPtr currentTransfer;
95 unsigned currentSequence;
96 unsigned lastSequence;
97 volatile bool watch;
98 volatile bool switchOnCreate;
99 } m_chain;
100
101 void InitChain();
102 void ClearChain();
103 bool IsChained(const Program& program);
104 void HandleChainUpdate();
105 bool SwitchChain(unsigned sequence);
106 bool SwitchChainLast();
107
108 typedef std::multimap<unsigned, std::pair<CardInputPtr, ChannelPtr> > preferredCards_t;
109 preferredCards_t FindTunableCardIds(const std::string& chanNum, const ChannelList& channels);
110
111 int _read(void *buffer, unsigned n);
112 int64_t _seek(int64_t offset, WHENCE_t whence);
113 // data buffer
114 unsigned m_chunk; // the size of block to read
115 struct { RingBuffer * rbuf; RingBufferPacket * packet; int consumed; } m_buffer;
116 };
117
118}
119
120#endif /* MYTHLIVETVPLAYBACK_H */
121
This is the main namespace that encloses all public classes.
Definition mythcontrol.h:30