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