MythTV master
satipchannel.cpp
Go to the documentation of this file.
1// C++ includes
2#include <utility>
3
4// Qt includes
5#include <QMutexLocker>
6#include <QString>
7
8// MythTV includes
10
11#include "mpeg/mpegtables.h"
12#include "satipchannel.h"
13#include "satiputils.h"
14#include "tv_rec.h"
15
16#define LOC QString("SatIPChan[%1]: ").arg(m_inputId)
17
18SatIPChannel::SatIPChannel(TVRec *parent, QString device) :
19 DTVChannel(parent), m_device(std::move(device))
20{
22}
23
25{
28}
29
30bool SatIPChannel::IsMaster(void) const
31{
33 bool is_master = (master == this);
35 return is_master;
36}
37
39{
40 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Open(%1)").arg(m_device));
41
42 if (IsOpen())
43 {
44 return true;
45 }
46
47 QMutexLocker locker(&m_tuneLock);
48
50
51 LOG(VB_CHANNEL, LOG_DEBUG, LOC + QString("Open(%1) m_tunerType:%2 %3")
52 .arg(m_device).arg(m_tunerType).arg(m_tunerType.toString()));
53
54 if (!InitializeInput())
55 {
56 LOG(VB_CHANNEL, LOG_ERR, LOC + "InitializeInput() failed");
57 Close();
58 return false;
59 }
60
62
63 return true;
64}
65
67{
68 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Close(%1)").arg(m_device));
69
70 QMutexLocker locker(&m_streamLock);
72 {
73 if (m_streamData)
74 {
76 }
78 }
79}
80
81bool SatIPChannel::Tune(const QString &channum)
82{
83 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(channum=%1) TODO").arg(channum));
84 if (!IsOpen())
85 {
86 LOG(VB_CHANNEL, LOG_ERR, LOC + "Tune failed, not open");
87 return false;
88 }
89 return false;
90}
91
93{
94 return true;
95}
96
97bool SatIPChannel::IsOpen(void) const
98{
99 QMutexLocker locker(&m_streamLock);
100 bool result = m_streamHandler != nullptr;
101 LOG(VB_CHANNEL, LOG_DEBUG, LOC + QString("IsOpen:%1").arg(result));
102 return result;
103}
104
106{
107 uint satipsrc = CardUtil::GetDiSEqCPosition(GetInputID()).toUInt();
108 satipsrc = std::clamp(satipsrc, 1U, 255U);
109 LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune freq=%1,src=%2").arg(tuning.m_frequency).arg(satipsrc));
110
111 m_streamHandler->m_satipsrc = satipsrc;
112 if (m_streamHandler->Tune(tuning))
113 {
115 return true;
116 }
117 LOG(VB_GENERAL, LOG_ERR, LOC + QString("Tune failed"));
118 return false;
119}
static QString GetDiSEqCPosition(uint inputid)
Definition: cardutil.h:302
virtual int GetInputID(void) const
Definition: channelbase.h:67
virtual bool InitializeInput(void)
Fills in input map from DB.
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
static void ReturnMasterLock(DTVChannelP &chan)
Definition: dtvchannel.cpp:148
void DeregisterForMaster(const QString &key)
Definition: dtvchannel.cpp:121
DTVTunerType m_tunerType
Definition: dtvchannel.h:161
void SetSIStandard(const QString &si_std)
Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
Definition: dtvchannel.cpp:51
static DTVChannel * GetMasterLock(const QString &key)
Definition: dtvchannel.cpp:136
void RegisterForMaster(const QString &key)
Definition: dtvchannel.cpp:114
uint64_t m_frequency
Definition: dtvmultiplex.h:94
QString m_sistandard
Definition: dtvmultiplex.h:111
QString toString() const
bool IsOpen(void) const override
Reports whether channel is already open.
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
bool Open(void) override
Opens the channel changing hardware for use.
void Close(void) override
Closes the channel changing hardware to use.
QMutex m_streamLock
Definition: satipchannel.h:40
bool IsMaster(void) const override
Returns true if this is the first of a number of multi-rec devs.
QString m_device
Definition: satipchannel.h:38
bool EnterPowerSavingMode(void) override
Enters power saving mode if the card supports it.
SatIPStreamHandler * m_streamHandler
Definition: satipchannel.h:41
~SatIPChannel(void) override
SatIPChannel(TVRec *parent, QString device)
MPEGStreamData * m_streamData
Definition: satipchannel.h:42
QMutex m_tuneLock
Definition: satipchannel.h:39
static SatIPStreamHandler * Get(const QString &devname, int inputid)
bool Tune(const DTVMultiplex &tuning)
static void Return(SatIPStreamHandler *&ref, int inputid)
static int toTunerType(const QString &deviceid)
Definition: satiputils.cpp:203
virtual void RemoveListener(MPEGStreamData *data)
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:143
unsigned int uint
Definition: freesurround.h:24
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
STL namespace.
static eu8 clamp(eu8 value, eu8 low, eu8 high)
Definition: pxsup2dast.c:206
#define LOC