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 
18 SatIPChannel::SatIPChannel(TVRec *parent, QString device) :
19  DTVChannel(parent), m_device(std::move(device))
20 {
22 }
23 
25 {
28 }
29 
30 bool 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);
71  if (m_streamHandler)
72  {
73  if (m_streamData)
74  {
76  }
78  }
79 }
80 
81 bool 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 
97 bool 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 
105 bool SatIPChannel::Tune(const DTVMultiplex &tuning)
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  {
114  SetSIStandard(tuning.m_sistandard);
115  return true;
116  }
117  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Tune failed"));
118  return false;
119 }
DTVMultiplex::m_frequency
uint64_t m_frequency
Definition: dtvmultiplex.h:94
SatIPChannel::EnterPowerSavingMode
bool EnterPowerSavingMode(void) override
Enters power saving mode if the card supports it.
Definition: satipchannel.cpp:92
DTVMultiplex
Definition: dtvmultiplex.h:24
DTVChannel::RegisterForMaster
void RegisterForMaster(const QString &key)
Definition: dtvchannel.cpp:114
DTVChannel::ReturnMasterLock
static void ReturnMasterLock(DTVChannelP &chan)
Definition: dtvchannel.cpp:148
SatIPChannel::SatIPChannel
SatIPChannel(TVRec *parent, QString device)
Definition: satipchannel.cpp:18
SatIPChannel::IsOpen
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: satipchannel.cpp:97
DTVChannel::DeregisterForMaster
void DeregisterForMaster(const QString &key)
Definition: dtvchannel.cpp:121
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
DTVChannel::GetMasterLock
static DTVChannel * GetMasterLock(const QString &key)
Definition: dtvchannel.cpp:136
SatIPChannel::~SatIPChannel
~SatIPChannel(void) override
Definition: satipchannel.cpp:24
SatIPChannel::m_streamData
MPEGStreamData * m_streamData
Definition: satipchannel.h:42
SatIPChannel::IsMaster
bool IsMaster(void) const override
Returns true if this is the first of a number of multi-rec devs.
Definition: satipchannel.cpp:30
satipchannel.h
StreamHandler::RemoveListener
virtual void RemoveListener(MPEGStreamData *data)
Definition: streamhandler.cpp:80
SatIPChannel::Tune
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: satipchannel.cpp:105
satiputils.h
mythlogging.h
SatIPStreamHandler::Return
static void Return(SatIPStreamHandler *&ref, int inputid)
Definition: satipstreamhandler.cpp:63
DTVChannel::SetSIStandard
void SetSIStandard(const QString &si_std)
Sets PSIP table standard: MPEG, DVB, ATSC, or OpenCable.
Definition: dtvchannel.cpp:51
SatIP::toTunerType
static int toTunerType(const QString &deviceid)
Definition: satiputils.cpp:201
DTVTunerType::toString
QString toString() const
Definition: dtvconfparserhelpers.h:154
SatIPChannel::m_streamLock
QMutex m_streamLock
Definition: satipchannel.h:40
mpegtables.h
SatIPChannel::Close
void Close(void) override
Closes the channel changing hardware to use.
Definition: satipchannel.cpp:66
uint
unsigned int uint
Definition: compat.h:81
SatIPStreamHandler::m_satipsrc
int m_satipsrc
Definition: satipstreamhandler.h:57
DTVChannel::m_tunerType
DTVTunerType m_tunerType
Definition: dtvchannel.h:161
std
Definition: mythchrono.h:23
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
DTVMultiplex::m_sistandard
QString m_sistandard
Definition: dtvmultiplex.h:111
tv_rec.h
ChannelBase::GetInputID
virtual int GetInputID(void) const
Definition: channelbase.h:67
SatIPChannel::Open
bool Open(void) override
Opens the channel changing hardware for use.
Definition: satipchannel.cpp:38
SatIPStreamHandler::Get
static SatIPStreamHandler * Get(const QString &devname, int inputid)
Definition: satipstreamhandler.cpp:32
SatIPChannel::m_tuneLock
QMutex m_tuneLock
Definition: satipchannel.h:39
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:33
CardUtil::GetDiSEqCPosition
static QString GetDiSEqCPosition(uint inputid)
Definition: cardutil.h:302
LOC
#define LOC
Definition: satipchannel.cpp:16
SatIPStreamHandler::Tune
bool Tune(const DTVMultiplex &tuning)
Definition: satipstreamhandler.cpp:353
ChannelBase::InitializeInput
virtual bool InitializeInput(void)
Fills in input map from DB.
Definition: channelbase.cpp:548
SatIPChannel::m_streamHandler
SatIPStreamHandler * m_streamHandler
Definition: satipchannel.h:41
SatIPChannel::m_device
QString m_device
Definition: satipchannel.h:38