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;
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 
159  if (!m_device->SetChannel(m_fw_opts.m_model, 0, channel))
160  return false;
161 
162  m_current_channel = channel;
163 
164  return true;
165 }
uint64_t string_to_guid(const QString &guid)
Definition: avcinfo.cpp:14
QString GetDevice(void) const override
Returns String representing device, useful for debugging.
FireWireDBOptions m_fw_opts
static const uint kConnectionP2P
bool Open(void) override
Opens the channel changing hardware for use.
bool Tune(const DTVMultiplex &) override
This performs the actual frequency tuning and in some cases input switching.
virtual ~FirewireChannel()
uint m_inputid
Definition: channelbase.h:137
bool Retune(void) override
virtual bool IsExternalChannelChangeInUse(void)
FirewireDevice * m_device
Class providing a generic interface to digital tuning hardware.
Definition: dtvchannel.h:34
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:141
virtual FirewireDevice::PowerState GetPowerState(void) const
void Close(void) override
Closes the channel changing hardware to use.
unsigned int uint
Definition: compat.h:140
#define LOC
FirewireChannel Copyright (c) 2005 by Jim Westfall, Dave Abrahams Copyright (c) 2006 by Daniel Kristj...
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
FirewireChannel(TVRec *parent, QString videodevice, FireWireDBOptions firewire_opts)
static bool IsSTBSupported(const QString &model)
virtual bool SetChannel(const QString &panel_model, uint alt_method, uint channel)
int m_connection
Definition: tv_rec.h:96
virtual PowerState GetPowerState(void)
virtual bool ClosePort(void)=0
QString m_model
Definition: tv_rec.h:97
virtual bool OpenPort(void)=0
virtual bool SetPowerState(bool on)
virtual bool InitializeInput(void)
Fills in input map from DB.
virtual bool SetPowerState(bool on)