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
9 #include "mythlogging.h"
10 #include "mpegtables.h"
11 #include "tv_rec.h"
12 #include "satiputils.h"
13 #include "satipchannel.h"
14 
15 #define LOC QString("SatIPChan[%1]: ").arg(m_inputId)
16 
17 SatIPChannel::SatIPChannel(TVRec *parent, QString device) :
18  DTVChannel(parent), m_device(std::move(device))
19 {
21 }
22 
24 {
27 }
28 
29 bool SatIPChannel::IsMaster(void) const
30 {
32  bool is_master = (master == this);
34  return is_master;
35 }
36 
38 {
39  LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Open(%1)").arg(m_device));
40 
41  if (IsOpen())
42  return true;
43 
44  QMutexLocker locker(&m_tuneLock);
45 
47 
48  LOG(VB_CHANNEL, LOG_DEBUG, LOC + QString("Open(%1) m_tunerType:%2 %3")
49  .arg(m_device).arg(m_tunerType).arg(m_tunerType.toString()));
50 
51  if (!InitializeInput())
52  {
53  LOG(VB_CHANNEL, LOG_ERR, LOC + "InitializeInput() failed");
54  Close();
55  return false;
56  }
57 
59 
60  return true;
61 }
62 
64 {
65  LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Close(%1)").arg(m_device));
66 
67  QMutexLocker locker(&m_streamLock);
68  if (m_streamHandler)
69  {
70  if (m_streamData)
71  {
73  }
75  }
76 }
77 
78 bool SatIPChannel::Tune(const QString &channum)
79 {
80  LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(channum=%1) TODO").arg(channum));
81  if (!IsOpen())
82  {
83  LOG(VB_CHANNEL, LOG_ERR, LOC + "Tune failed, not open");
84  return false;
85  }
86  return false;
87 }
88 
89 bool SatIPChannel::Tune(const DTVMultiplex &tuning)
90 {
91  LOG(VB_CHANNEL, LOG_INFO, LOC + QString("Tune(frequency=%1)").arg(tuning.m_frequency));
92  m_streamHandler->Tune(tuning);
93  return true;
94 }
95 
96 bool SatIPChannel::IsOpen(void) const
97 {
98  QMutexLocker locker(&m_streamLock);
99  return m_streamHandler != nullptr;
100 }
DTVMultiplex::m_frequency
uint64_t m_frequency
Definition: dtvmultiplex.h:94
DTVMultiplex
Definition: dtvmultiplex.h:24
DTVChannel::RegisterForMaster
void RegisterForMaster(const QString &key)
Definition: dtvchannel.cpp:113
DTVChannel::ReturnMasterLock
static void ReturnMasterLock(DTVChannelP &chan)
Definition: dtvchannel.cpp:147
SatIPChannel::SatIPChannel
SatIPChannel(TVRec *parent, QString device)
Definition: satipchannel.cpp:17
SatIPChannel::IsOpen
bool IsOpen(void) const override
Reports whether channel is already open.
Definition: satipchannel.cpp:96
ChannelBase::m_inputId
uint m_inputId
Definition: channelbase.h:137
DTVChannel::DeregisterForMaster
void DeregisterForMaster(const QString &key)
Definition: dtvchannel.cpp:120
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
DTVChannel::GetMasterLock
static DTVChannel * GetMasterLock(const QString &key)
Definition: dtvchannel.cpp:135
SatIPChannel::~SatIPChannel
~SatIPChannel(void) override
Definition: satipchannel.cpp:23
SatIPChannel::m_streamData
MPEGStreamData * m_streamData
Definition: satipchannel.h:41
SatIPChannel::IsMaster
bool IsMaster(void) const override
Returns true if this is the first of a number of multi-rec devs.
Definition: satipchannel.cpp:29
satipchannel.h
StreamHandler::RemoveListener
virtual void RemoveListener(MPEGStreamData *data)
Definition: streamhandler.cpp:78
SatIPChannel::Tune
bool Tune(const DTVMultiplex &tuning) override
This performs the actual frequency tuning and in some cases input switching.
Definition: satipchannel.cpp:89
satiputils.h
mythlogging.h
SatIPStreamHandler::Return
static void Return(SatIPStreamHandler *&ref, int inputid)
Definition: satipstreamhandler.cpp:61
SatIP::toTunerType
static int toTunerType(const QString &deviceid)
Definition: satiputils.cpp:177
DTVTunerType::toString
QString toString() const
Definition: dtvconfparserhelpers.h:154
SatIPChannel::m_streamLock
QMutex m_streamLock
Definition: satipchannel.h:39
mpegtables.h
SatIPChannel::Close
void Close(void) override
Closes the channel changing hardware to use.
Definition: satipchannel.cpp:63
DTVChannel::m_tunerType
DTVTunerType m_tunerType
Definition: dtvchannel.h:162
std
Definition: mythchrono.h:23
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:145
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:37
SatIPStreamHandler::Get
static SatIPStreamHandler * Get(const QString &devname, int inputid)
Definition: satipstreamhandler.cpp:30
SatIPChannel::m_tuneLock
QMutex m_tuneLock
Definition: satipchannel.h:38
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:33
LOC
#define LOC
Definition: satipchannel.cpp:15
SatIPStreamHandler::Tune
bool Tune(const DTVMultiplex &tuning)
Definition: satipstreamhandler.cpp:215
ChannelBase::InitializeInput
virtual bool InitializeInput(void)
Fills in input map from DB.
Definition: channelbase.cpp:541
SatIPChannel::m_streamHandler
SatIPStreamHandler * m_streamHandler
Definition: satipchannel.h:40
SatIPChannel::m_device
QString m_device
Definition: satipchannel.h:37