/
iptvsignalmonitor.cpp
110 lines (95 loc) · 3.03 KB
/
iptvsignalmonitor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// -*- Mode: c++ -*-
// MythTV headers
#include "iptvsignalmonitor.h"
#include "mpegstreamdata.h"
#include "iptvchannel.h"
#include "mythlogging.h"
#define LOC QString("IPTVSM(%1): ").arg(channel->GetDevice())
/** \brief Initializes signal lock and signal values.
*
* Start() must be called to actually begin continuous
* signal monitoring. The timeout is set to 3 seconds,
* and the signal threshold is initialized to 0%.
*
* \param db_cardnum Recorder number to monitor,
* if this is less than 0, SIGNAL events will not be
* sent to the frontend even if SetNotifyFrontend(true)
* is called.
* \param _channel IPTVChannel for card
* \param _flags Flags to start with
*/
IPTVSignalMonitor::IPTVSignalMonitor(int db_cardnum,
IPTVChannel *_channel,
uint64_t _flags) :
DTVSignalMonitor(db_cardnum, _channel, _flags)
{
LOG(VB_CHANNEL, LOG_INFO, LOC + "ctor");
// TODO init isLocked
bool isLocked = true;
QMutexLocker locker(&statusLock);
signalLock.SetValue((isLocked) ? 1 : 0);
signalStrength.SetValue((isLocked) ? 100 : 0);
}
/** \fn IPTVSignalMonitor::~IPTVSignalMonitor()
* \brief Stops signal monitoring and table monitoring threads.
*/
IPTVSignalMonitor::~IPTVSignalMonitor()
{
LOG(VB_CHANNEL, LOG_INFO, LOC + "dtor");
Stop();
}
IPTVChannel *IPTVSignalMonitor::GetChannel(void)
{
return dynamic_cast<IPTVChannel*>(channel);
}
/** \fn IPTVSignalMonitor::Stop(void)
* \brief Stop signal monitoring and table monitoring threads.
*/
void IPTVSignalMonitor::Stop(void)
{
LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- begin");
SignalMonitor::Stop();
if (GetStreamData())
GetChannel()->SetStreamData(GetStreamData());
m_streamHandlerStarted = false;
LOG(VB_CHANNEL, LOG_INFO, LOC + "Stop() -- end");
}
/** \fn IPTVSignalMonitor::UpdateValues(void)
* \brief Fills in frontend stats and emits status Qt signals.
*
* This is automatically called by run(), after Start()
* has been used to start the signal monitoring thread.
*/
void IPTVSignalMonitor::UpdateValues(void)
{
if (!running || exit)
return;
if (m_streamHandlerStarted)
{
EmitStatus();
if (IsAllGood())
SendMessageAllGood();
// TODO dtv signals...
update_done = true;
return;
}
bool isLocked = false;
{
QMutexLocker locker(&statusLock);
isLocked = signalLock.IsGood();
}
EmitStatus();
if (IsAllGood())
SendMessageAllGood();
// Start table monitoring if we are waiting on any table
// and we have a lock.
if (isLocked && GetStreamData() &&
HasAnyFlag(kDTVSigMon_WaitForPAT | kDTVSigMon_WaitForPMT |
kDTVSigMon_WaitForMGT | kDTVSigMon_WaitForVCT |
kDTVSigMon_WaitForNIT | kDTVSigMon_WaitForSDT))
{
GetChannel()->SetStreamData(GetStreamData());
m_streamHandlerStarted = true;
}
update_done = true;
}