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
13#include "libmythbase/mythconfig.h"
15
16#include "DeviceReadBuffer.h"
18#include "mpeg/mpegstreamdata.h"
20
23class HDHRChannel;
25
26// HDHomeRun headers
27#if CONFIG_HDHOMERUN
28#include HDHOMERUN_HEADERFILE
29#else
30struct hdhomerun_device_t { int dummy; };
32#endif
33
34enum HDHRTuneMode : std::uint8_t {
40};
41
42// Note : This class never uses a DRB && always uses a TS reader.
43
44// locking order
45// _pid_lock -> _listener_lock -> _start_stop_lock
46// -> _hdhr_lock
47
49{
50 public:
51 static HDHRStreamHandler *Get(const QString &devname, int inputid,
52 int majorid);
53 static void Return(HDHRStreamHandler * & ref, int inputid);
54
56 bool /*allow_section_reader*/ = false,
57 bool /*needs_drb*/ = false,
58 const QString& output_file = QString()) override // StreamHandler
59 {
60 StreamHandler::AddListener(data, false, false, output_file);
61 }
62
63 void GetTunerStatus(struct hdhomerun_tuner_status_t *status);
64 bool IsConnected(void) const;
65 std::vector<DTVTunerType> GetTunerTypes(void) const { return m_tunerTypes; }
66
67 // Commands
68 bool TuneChannel(const QString &chanid);
69 bool TuneProgram(uint mpeg_prog_num);
70 bool TuneVChannel(const QString &vchn);
71
72 private:
73 explicit HDHRStreamHandler(const QString &device, int inputid, int majorid);
74
75 bool Connect(void);
76
77 QString TunerGet(const QString &name);
78 QString TunerSet(const QString &name, const QString &value);
79
80 bool Open(void);
81 void Close(void);
82
83 void run(void) override; // MThread
84
85 bool UpdateFilters(void) override; // StreamHandler
86
87 private:
90 int m_tuner {-1};
91 std::vector<DTVTunerType> m_tunerTypes;
94
95 mutable QRecursiveMutex m_hdhrLock;
96
97 // for implementing Get & Return
98 static QMutex s_handlersLock;
99 static QMap<int, HDHRStreamHandler*> s_handlers;
100 static QMap<int, uint> s_handlersRefCnt;
101};
102
103#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: compat.h:60
HDHRTuneMode
@ hdhrTuneModeNone
@ hdhrTuneModeVChannel
@ hdhrTuneModeFrequency
@ hdhrTuneModeFrequencyPid
@ hdhrTuneModeFrequencyProgram