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(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 }
#define LOC
-*- Mode: c++ -*- CetonSignalMonitor Copyright (c) 2011 Ronald Frazier Copyright (c) 2006 Daniel Kris...
CetonStreamHandler * m_streamHandler
QMutex m_statusLock
CetonChannel * GetCetonChannel(void)
static const uint64_t kDTVSigMon_WaitForPMT
static const uint64_t kDTVSigMon_WaitForPAT
void UpdateValues(void) override
Fills in frontend stats and emits status Qt signals.
bool HasAnyFlag(uint64_t _flags) const
void Stop(void) override
Stop signal monitoring and table monitoring threads.
virtual void RemoveListener(MPEGStreamData *data)
static const uint64_t kDTVSigMon_WaitForVCT
static const uint64_t kDTVSigMon_WaitForMGT
void SetValue(int _value)
static const uint64_t kDTVSigMon_WaitForNIT
virtual void Stop()
Stop signal monitoring thread.
static CetonStreamHandler * Get(const QString &devname, int inputid)
static const uint64_t kSigMon_WaitForSig
ChannelBase * m_channel
volatile bool m_exit
MPEGStreamData * GetStreamData()
Returns the MPEG stream data if it exists.
virtual ~CetonSignalMonitor()
Stops signal monitoring and table monitoring threads.
unsigned int uint
Definition: compat.h:140
void SendMessageAllGood(void)
volatile bool m_running
This class is intended to detect the presence of needed tables.
virtual QString GetDevice(void) const
Returns String representing device, useful for debugging.
Definition: channelbase.h:78
void AddFlags(uint64_t _flags) override
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
bool IsAllGood(void) const override
SignalMonitorValue m_signalStrength
static const uint64_t kDTVSigMon_WaitForSDT
bool IsGood() const
Returns true if the value is equal to the threshold, or on the right side of the threshold (depends o...
void SetThreshold(int _threshold)
SignalMonitorValue m_signalLock
virtual void EmitStatus(void)
static void Return(CetonStreamHandler *&ref, int inputid)
void AddListener(MPEGStreamData *data, bool=false, bool=false, QString output_file=QString()) override