MythTV  master
firewirechannel.cpp
Go to the documentation of this file.
1 
8 // C/C++ includes
9 #include <utility>
10 
11 #include "mythlogging.h"
12 #include "tv_rec.h"
13 #include "linuxfirewiredevice.h"
14 #if USING_OSX_FIREWIRE
15 #include "darwinfirewiredevice.h"
16 #endif
17 #include "firewirechannel.h"
18 
19 #define LOC QString("FireChan[%1](%2): ").arg(m_inputId).arg(FirewireChannel::GetDevice())
20 
21 FirewireChannel::FirewireChannel(TVRec *parent, QString _videodevice,
22  FireWireDBOptions firewire_opts) :
23  DTVChannel(parent),
24  m_videodevice(std::move(_videodevice)),
25  m_fw_opts(std::move(firewire_opts))
26 {
27  uint64_t guid = string_to_guid(m_videodevice);
28  uint subunitid = 0; // we only support first tuner on STB...
29 
30 #ifdef USING_LINUX_FIREWIRE
32  guid, subunitid, m_fw_opts.m_speed,
34 #endif // USING_LINUX_FIREWIRE
35 
36 #ifdef USING_OSX_FIREWIRE
37  m_device = new DarwinFirewireDevice(guid, subunitid, m_fw_opts.m_speed);
38 #endif // USING_OSX_FIREWIRE
39 }
40 
42 {
44  delete m_device;
45 }
46 
48 {
49  LOG(VB_CHANNEL, LOG_INFO, LOC + "Open()");
50 
51  if (!m_device)
52  return false;
53 
54  if (m_isopen)
55  return true;
56 
57  if (!InitializeInput())
58  return false;
59 
60  if (!m_inputId)
61  return false;
62 
65  {
66  LOG(VB_GENERAL, LOG_ERR, LOC +
67  QString("Model: '%1' is not supported.").arg(m_fw_opts.m_model));
68 
69  return false;
70  }
71 
72  if (!m_device->OpenPort())
73  return false;
74 
75  m_isopen = true;
76 
77  return true;
78 }
79 
81 {
82  LOG(VB_CHANNEL, LOG_INFO, LOC + "Close()");
83  if (m_isopen)
84  {
86  m_isopen = false;
87  }
88 }
89 
90 QString FirewireChannel::GetDevice(void) const
91 {
92  return m_videodevice;
93 }
94 
96 {
97  if (!m_isopen)
98  {
99  LOG(VB_GENERAL, LOG_ERR, LOC +
100  "SetPowerState() called on closed FirewireChannel.");
101 
102  return false;
103  }
104 
105  return m_device->SetPowerState(on);
106 }
107 
109 {
110  if (!m_isopen)
111  {
112  LOG(VB_GENERAL, LOG_ERR, LOC +
113  "GetPowerState() called on closed FirewireChannel.");
114 
116  }
117 
118  return m_device->GetPowerState();
119 }
120 
122 {
123  LOG(VB_CHANNEL, LOG_INFO, LOC + "Retune()");
124 
126  {
127  LOG(VB_GENERAL, LOG_ERR, LOC +
128  "STB is turned off, must be on to retune.");
129 
130  return false;
131  }
132 
133  if (m_current_channel)
134  {
135  QString freqid = QString::number(m_current_channel);
136  return Tune(freqid, 0);
137  }
138 
139  return false;
140 }
141 
142 bool FirewireChannel::Tune(const QString &freqid, int /*finetune*/)
143 {
144  LOG(VB_CHANNEL, LOG_INFO, QString("Tune(%1)").arg(freqid));
145 
146  bool ok = false;
147  uint channel = freqid.toUInt(&ok);
148  if (!ok)
149  return false;
150 
152  {
153  LOG(VB_GENERAL, LOG_WARNING, LOC +
154  "STB is turned off, must be on to set channel.");
155 
156  return true; // signal monitor will call retune later...
157  }
158 
160  return false;
161 
163 
164  return true;
165 }
linuxfirewiredevice.h
channel
QDomElement channel
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:498
FirewireChannel::m_device
FirewireDevice * m_device
Definition: firewirechannel.h:56
FirewireChannel::Open
bool Open(void) override
Opens the channel changing hardware for use.
Definition: firewirechannel.cpp:47
darwinfirewiredevice.h
firewirechannel.h
DarwinFirewireDevice
Definition: darwinfirewiredevice.h:10
arg
arg(title).arg(filename).arg(doDelete))
ChannelBase::m_inputId
uint m_inputId
Definition: channelbase.h:137
FirewireChannel::m_fw_opts
FireWireDBOptions m_fw_opts
Definition: firewirechannel.h:55
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
FireWireDBOptions::m_speed
int m_speed
Definition: tv_rec.h:96
string_to_guid
static uint64_t string_to_guid(const QString &guid)
Definition: avcinfo.h:17
FirewireChannel::m_isopen
bool m_isopen
Definition: firewirechannel.h:58
LinuxFirewireDevice
Definition: linuxfirewiredevice.h:19
FirewireDevice::PowerState
PowerState
Definition: firewiredevice.h:29
mythlogging.h
FirewireChannel::FirewireChannel
FirewireChannel(TVRec *parent, QString videodevice, FireWireDBOptions firewire_opts)
Definition: firewirechannel.cpp:21
FirewireChannel::Close
void Close(void) override
Closes the channel changing hardware to use.
Definition: firewirechannel.cpp:80
FirewireChannel::m_current_channel
uint m_current_channel
Definition: firewirechannel.h:57
FirewireChannel::Retune
bool Retune(void) override
Definition: firewirechannel.cpp:121
FirewireChannel::~FirewireChannel
~FirewireChannel() override
Definition: firewirechannel.cpp:41
ChannelBase::IsExternalChannelChangeInUse
virtual bool IsExternalChannelChangeInUse(void)
Definition: channelbase.cpp:834
FirewireChannel::Tune
bool Tune(const DTVMultiplex &) override
This performs the actual frequency tuning and in some cases input switching.
Definition: firewirechannel.h:32
LinuxFirewireDevice::kConnectionP2P
static const uint kConnectionP2P
Definition: linuxfirewiredevice.h:49
uint
unsigned int uint
Definition: compat.h:140
FirewireChannel::GetPowerState
virtual FirewireDevice::PowerState GetPowerState(void) const
Definition: firewirechannel.cpp:108
FirewireDevice::IsSTBSupported
static bool IsSTBSupported(const QString &model)
Definition: firewiredevice.cpp:484
FirewireChannel::SetPowerState
virtual bool SetPowerState(bool on)
Definition: firewirechannel.cpp:95
FirewireDevice::kAVCPowerQueryFailed
@ kAVCPowerQueryFailed
Definition: firewiredevice.h:34
FirewireChannel::GetDevice
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
Definition: firewirechannel.cpp:90
FireWireDBOptions::m_connection
int m_connection
Definition: tv_rec.h:97
TVRec
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:142
FireWireDBOptions
Definition: tv_rec.h:91
LOC
#define LOC
FirewireChannel Copyright (c) 2005 by Jim Westfall, Dave Abrahams Copyright (c) 2006 by Daniel Kristj...
Definition: firewirechannel.cpp:19
tv_rec.h
FirewireDevice::GetPowerState
virtual PowerState GetPowerState(void)
Definition: firewiredevice.cpp:102
DTVChannel
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
FirewireDevice::SetChannel
virtual bool SetChannel(const QString &panel_model, uint alt_method, uint channel)
Definition: firewiredevice.cpp:148
FirewireDevice::kAVCPowerOff
@ kAVCPowerOff
Definition: firewiredevice.h:32
FirewireDevice::SetPowerState
virtual bool SetPowerState(bool on)
Definition: firewiredevice.cpp:68
ChannelBase::InitializeInput
virtual bool InitializeInput(void)
Fills in input map from DB.
Definition: channelbase.cpp:546
FirewireDevice::ClosePort
virtual bool ClosePort(void)=0
FirewireDevice::OpenPort
virtual bool OpenPort(void)=0
FireWireDBOptions::m_model
QString m_model
Definition: tv_rec.h:98
FirewireChannel::m_videodevice
QString m_videodevice
Definition: firewirechannel.h:54