MythTV master
hdhrstreamhandler.h
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2
3#ifndef HDHRSTREAMHANDLER_H
4#define HDHRSTREAMHANDLER_H
5
6#include <vector>
7
8#include <QString>
9#include <QMutex>
10#include <QMap>
11#include <QRecursiveMutex>
12
14
15#include "DeviceReadBuffer.h"
17#include "mpeg/mpegstreamdata.h"
19
22class HDHRChannel;
24
25// HDHomeRun headers
26#if CONFIG_HDHOMERUN
27#include HDHOMERUN_HEADERFILE
28#else
29struct hdhomerun_device_t { int dummy; };
31#endif
32
33enum HDHRTuneMode : std::uint8_t {
39};
40
41// Note : This class never uses a DRB && always uses a TS reader.
42
43// locking order
44// _pid_lock -> _listener_lock -> _start_stop_lock
45// -> _hdhr_lock
46
48{
49 public:
50 static HDHRStreamHandler *Get(const QString &devname, int inputid,
51 int majorid);
52 static void Return(HDHRStreamHandler * & ref, int inputid);
53
55 bool /*allow_section_reader*/ = false,
56 bool /*needs_drb*/ = false,
57 const QString& output_file = QString()) override // StreamHandler
58 {
59 StreamHandler::AddListener(data, false, false, output_file);
60 }
61
62 void GetTunerStatus(struct hdhomerun_tuner_status_t *status);
63 bool IsConnected(void) const;
64 std::vector<DTVTunerType> GetTunerTypes(void) const { return m_tunerTypes; }
65
66 // Commands
67 bool TuneChannel(const QString &chanid);
68 bool TuneProgram(uint mpeg_prog_num);
69 bool TuneVChannel(const QString &vchn);
70
71 private:
72 explicit HDHRStreamHandler(const QString &device, int inputid, int majorid);
73
74 bool Connect(void);
75
76 QString TunerGet(const QString &name);
77 QString TunerSet(const QString &name, const QString &value);
78
79 bool Open(void);
80 void Close(void);
81
82 void run(void) override; // MThread
83
84 bool UpdateFilters(void) override; // StreamHandler
85
86 private:
89 int m_tuner {-1};
90 std::vector<DTVTunerType> m_tunerTypes;
93
94 mutable QRecursiveMutex m_hdhrLock;
95
96 // for implementing Get & Return
97 static QMutex s_handlersLock;
98 static QMap<int, HDHRStreamHandler*> s_handlers;
99 static QMap<int, uint> s_handlersRefCnt;
100};
101
102#endif // HDHRSTREAMHANDLER_H
This class is intended to detect the presence of needed tables.
Buffers reads from device files.
QRecursiveMutex m_hdhrLock
void GetTunerStatus(struct hdhomerun_tuner_status_t *status)
HDHRTuneMode m_tuneMode
static QMutex s_handlersLock
bool TuneVChannel(const QString &vchn)
hdhomerun_device_t * m_hdhomerunDevice
bool UpdateFilters(void) override
std::vector< DTVTunerType > m_tunerTypes
HDHRStreamHandler(const QString &device, int inputid, int majorid)
bool TuneProgram(uint mpeg_prog_num)
void run(void) override
Reads HDHomeRun socket for tables & data.
static HDHRStreamHandler * Get(const QString &devname, int inputid, int majorid)
std::vector< DTVTunerType > GetTunerTypes(void) const
void AddListener(MPEGStreamData *data, bool=false, bool=false, const QString &output_file=QString()) override
static QMap< int, uint > s_handlersRefCnt
static QMap< int, HDHRStreamHandler * > s_handlers
bool TuneChannel(const QString &chanid)
hdhomerun_device_selector_t * m_deviceSelector
bool IsConnected(void) const
static void Return(HDHRStreamHandler *&ref, int inputid)
QString TunerGet(const QString &name)
QString TunerSet(const QString &name, const QString &value)
Encapsulates data about MPEG stream and emits events for each table.
virtual void AddListener(MPEGStreamData *data, bool allow_section_reader=false, bool needs_buffering=false, const QString &output_file=QString())
unsigned int uint
Definition: freesurround.h:24
HDHRTuneMode
@ hdhrTuneModeNone
@ hdhrTuneModeVChannel
@ hdhrTuneModeFrequency
@ hdhrTuneModeFrequencyPid
@ hdhrTuneModeFrequencyProgram