MythTV  master
firewirechannel.cpp
Go to the documentation of this file.
1 
8 #include "mythlogging.h"
9 #include "tv_rec.h"
10 #include "linuxfirewiredevice.h"
11 #if USING_OSX_FIREWIRE
12 #include "darwinfirewiredevice.h"
13 #endif
14 #include "firewirechannel.h"
15 
16 #define LOC QString("FireChan[%1](%2): ").arg(m_inputid).arg(GetDevice())
17 
18 FirewireChannel::FirewireChannel(TVRec *parent, const QString &_videodevice,
19  const FireWireDBOptions &firewire_opts) :
20  DTVChannel(parent),
21  videodevice(_videodevice),
22  fw_opts(firewire_opts),
23  device(nullptr),
24  current_channel(0),
25  isopen(false)
26 {
27  uint64_t guid = string_to_guid(videodevice);
28  uint subunitid = 0; // we only support first tuner on STB...
29 
30 #ifdef USING_LINUX_FIREWIRE
32  guid, subunitid, fw_opts.speed,
34 #endif // USING_LINUX_FIREWIRE
35 
36 #ifdef USING_OSX_FIREWIRE
37  device = new DarwinFirewireDevice(guid, subunitid, fw_opts.speed);
38 #endif // USING_OSX_FIREWIRE
39 }
40 
42 {
43  Close();
44  delete device;
45 }
46 
48 {
49  LOG(VB_CHANNEL, LOG_INFO, LOC + "Open()");
50 
51  if (!device)
52  return false;
53 
54  if (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(fw_opts.model));
68 
69  return false;
70  }
71 
72  if (!device->OpenPort())
73  return false;
74 
75  isopen = true;
76 
77  return true;
78 }
79 
81 {
82  LOG(VB_CHANNEL, LOG_INFO, LOC + "Close()");
83  if (isopen)
84  {
85  device->ClosePort();
86  isopen = false;
87  }
88 }
89 
90 QString FirewireChannel::GetDevice(void) const
91 {
92  return videodevice;
93 }
94 
96 {
97  if (!isopen)
98  {
99  LOG(VB_GENERAL, LOG_ERR, LOC +
100  "SetPowerState() called on closed FirewireChannel.");
101 
102  return false;
103  }
104 
105  return device->SetPowerState(on);
106 }
107 
109 {
110  if (!isopen)
111  {
112  LOG(VB_GENERAL, LOG_ERR, LOC +
113  "GetPowerState() called on closed FirewireChannel.");
114 
116  }
117 
118  return 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 (current_channel)
134  {
135  QString freqid = QString::number(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 (!device->SetChannel(fw_opts.model, 0, channel))
160  return false;
161 
162  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.
QString model
Definition: tv_rec.h:102
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.
unsigned int uint
Definition: compat.h:140
virtual ~FirewireChannel()
uint m_inputid
Definition: channelbase.h:137
bool Retune(void) override
virtual bool IsExternalChannelChangeInUse(void)
VERBOSE_PREAMBLE false
Definition: verbosedefs.h:85
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:150
virtual FirewireDevice::PowerState GetPowerState(void) const
void Close(void) override
Closes the channel changing hardware to use.
FirewireChannel(TVRec *parent, const QString &videodevice, const FireWireDBOptions &firewire_opts)
#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
static bool IsSTBSupported(const QString &model)
virtual bool SetChannel(const QString &panel_model, uint alt_method, uint channel)
FirewireDevice * device
virtual PowerState GetPowerState(void)
virtual bool ClosePort(void)=0
virtual bool OpenPort(void)=0
virtual bool SetPowerState(bool on)
virtual bool InitializeInput(void)
Fills in input map from DB.
FireWireDBOptions fw_opts
virtual bool SetPowerState(bool on)