MythTV  master
cetonsignalmonitor.cpp
Go to the documentation of this file.
1 
8 #include "mythlogging.h"
9 #include "mythdbcon.h"
10 
11 #include "cetonsignalmonitor.h"
12 #include "cetonstreamhandler.h"
13 #include "cetonrecorder.h"
14 #include "cetonchannel.h"
15 
16 #define LOC QString("CetonSigMon[%1](%2): ") \
17  .arg(m_inputid).arg(m_channel->GetDevice())
18 
34  CetonChannel* _channel,
35  bool _release_stream,
36  uint64_t _flags)
37  : DTVSignalMonitor(db_cardnum, _channel, _release_stream, _flags)
38 {
39  LOG(VB_CHANNEL, LOG_INFO, LOC + "ctor");
40 
42 
44 
46 }
47 
52 {
53  LOG(VB_CHANNEL, LOG_INFO, LOC + "dtor");
56 }
57 
62 {
63  LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- begin");
65  if (GetStreamData())
67  m_streamHandlerStarted = false;
68 
69  LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- end");
70 }
71 
73 {
74  return dynamic_cast<CetonChannel*>(m_channel);
75 }
76 
84 {
85  if (!m_running || m_exit)
86  return;
87 
89  {
90  EmitStatus();
91  if (IsAllGood())
93 
94  // TODO dtv signals...
95 
96  m_update_done = true;
97  return;
98  }
99 
100  // cppcheck-suppress variableScope
101  uint sig = 100; // TODO find some way to actually monitor signal level
102 
103  // Set SignalMonitorValues from info from card.
104  bool isLocked = false;
105  {
106  QMutexLocker locker(&m_statusLock);
108  m_signalLock.SetValue(static_cast<int>(true));
109  // TODO add some way to indicate if there is actually a lock
110  isLocked = m_signalLock.IsGood();
111  }
112 
113  EmitStatus();
114  if (IsAllGood())
116 
117  // Start table monitoring if we are waiting on any table
118  // and we have a lock.
119  if (isLocked && GetStreamData() &&
123  {
125  m_streamHandlerStarted = true;
126  }
127 
128  m_update_done = true;
129 }
SignalMonitor::m_update_done
bool m_update_done
Definition: signalmonitor.h:210
DTVSignalMonitor::AddFlags
void AddFlags(uint64_t _flags) override
Definition: dtvsignalmonitor.cpp:143
IPTVStreamHandler::AddListener
void AddListener(MPEGStreamData *data, bool=false, bool=false, QString output_file=QString()) override
Definition: iptvstreamhandler.h:89
CetonSignalMonitor::Stop
void Stop(void) override
Stop signal monitoring and table monitoring threads.
Definition: cetonsignalmonitor.cpp:61
SignalMonitorValue::SetValue
void SetValue(int _value)
Definition: signalmonitorvalue.h:75
SignalMonitorValue::SetThreshold
void SetThreshold(int _threshold)
Definition: signalmonitorvalue.h:85
LOC
#define LOC
-*- Mode: c++ -*- CetonSignalMonitor Copyright (c) 2011 Ronald Frazier Copyright (c) 2006 Daniel Kris...
Definition: cetonsignalmonitor.cpp:16
SignalMonitor::m_channel
ChannelBase * m_channel
Definition: signalmonitor.h:203
SignalMonitor::kDTVSigMon_WaitForMGT
static const uint64_t kDTVSigMon_WaitForMGT
Definition: signalmonitor.h:183
SignalMonitor::m_exit
volatile bool m_exit
Definition: signalmonitor.h:227
mythdbcon.h
DTVSignalMonitor::GetStreamData
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
Definition: dtvsignalmonitor.h:60
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
CetonChannel
Definition: cetonchannel.h:22
SignalMonitor::m_running
volatile bool m_running
Definition: signalmonitor.h:226
SignalMonitor::HasAnyFlag
bool HasAnyFlag(uint64_t _flags) const
Definition: signalmonitor.cpp:268
SignalMonitor::kSigMon_WaitForSig
static const uint64_t kSigMon_WaitForSig
Definition: signalmonitor.h:187
StreamHandler::RemoveListener
virtual void RemoveListener(MPEGStreamData *data)
Definition: streamhandler.cpp:78
cetonchannel.h
SignalMonitor::m_signalStrength
SignalMonitorValue m_signalStrength
Definition: signalmonitor.h:219
mythlogging.h
SignalMonitor::m_inputid
int m_inputid
Definition: signalmonitor.h:205
cetonsignalmonitor.h
SignalMonitor::m_signalLock
SignalMonitorValue m_signalLock
Definition: signalmonitor.h:218
SignalMonitor::SendMessageAllGood
void SendMessageAllGood(void)
Definition: signalmonitor.cpp:453
SignalMonitor::kDTVSigMon_WaitForPMT
static const uint64_t kDTVSigMon_WaitForPMT
Definition: signalmonitor.h:182
SignalMonitor::kDTVSigMon_WaitForPAT
static const uint64_t kDTVSigMon_WaitForPAT
Definition: signalmonitor.h:181
SignalMonitor::kDTVSigMon_WaitForNIT
static const uint64_t kDTVSigMon_WaitForNIT
Definition: signalmonitor.h:185
SignalMonitor::EmitStatus
virtual void EmitStatus(void)
Definition: signalmonitor.cpp:460
SignalMonitor::kDTVSigMon_WaitForSDT
static const uint64_t kDTVSigMon_WaitForSDT
Definition: signalmonitor.h:186
CetonSignalMonitor::GetCetonChannel
CetonChannel * GetCetonChannel(void)
Definition: cetonsignalmonitor.cpp:72
CetonSignalMonitor::m_streamHandler
CetonStreamHandler * m_streamHandler
Definition: cetonsignalmonitor.h:36
cetonstreamhandler.h
uint
unsigned int uint
Definition: compat.h:140
SignalMonitorValue::IsGood
bool IsGood() const
Returns true if the value is equal to the threshold, or on the right side of the threshold (depends o...
Definition: signalmonitorvalue.h:57
cetonrecorder.h
CetonSignalMonitor::CetonSignalMonitor
CetonSignalMonitor(void)
CetonStreamHandler::Return
static void Return(CetonStreamHandler *&ref, int inputid)
Definition: cetonstreamhandler.cpp:70
CetonSignalMonitor::~CetonSignalMonitor
~CetonSignalMonitor() override
Stops signal monitoring and table monitoring threads.
Definition: cetonsignalmonitor.cpp:51
SignalMonitor::m_statusLock
QMutex m_statusLock
Definition: signalmonitor.h:229
CetonStreamHandler::Get
static CetonStreamHandler * Get(const QString &devname, int inputid)
Definition: cetonstreamhandler.cpp:37
DTVSignalMonitor
This class is intended to detect the presence of needed tables.
Definition: dtvsignalmonitor.h:15
CetonSignalMonitor::UpdateValues
void UpdateValues(void) override
Fills in frontend stats and emits status Qt signals.
Definition: cetonsignalmonitor.cpp:83
ChannelBase::GetDevice
virtual QString GetDevice(void) const
Returns String representing device, useful for debugging.
Definition: channelbase.h:78
SignalMonitor::Stop
virtual void Stop()
Stop signal monitoring thread.
Definition: signalmonitor.cpp:292
DTVSignalMonitor::IsAllGood
bool IsAllGood(void) const override
Definition: dtvsignalmonitor.cpp:558
SignalMonitor::kDTVSigMon_WaitForVCT
static const uint64_t kDTVSigMon_WaitForVCT
Definition: signalmonitor.h:184
CetonSignalMonitor::m_streamHandlerStarted
bool m_streamHandlerStarted
Definition: cetonsignalmonitor.h:35