MythTV  master
avcinfo.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 // MythTV headers
4 #include "avcinfo.h"
5 #ifndef GUID_ONLY
6 #include "firewiredevice.h"
7 #endif
8 
9 QString guid_to_string(uint64_t guid)
10 {
11  return QString("%1").arg(guid, 16, 16, QLatin1Char('0')).toUpper();
12 }
13 
14 uint64_t string_to_guid(const QString &guid)
15 {
16  return guid.toULongLong(nullptr, 16);
17 }
18 
19 #ifndef GUID_ONLY
21 {
22  memset(m_unit_table, 0xff, sizeof(m_unit_table));
23 }
24 
26  m_port(o.m_port), m_node(o.m_node),
27  m_guid(o.m_guid), m_specid(o.m_specid),
28  m_vendorid(o.m_vendorid), m_modelid(o.m_modelid),
29  m_firmware_revision(o.m_firmware_revision),
30  m_product_name(o.m_product_name)
31 {
32  memcpy(m_unit_table, o.m_unit_table, sizeof(m_unit_table));
33 }
34 
36 {
37  m_port = o.m_port;
38  m_node = o.m_node;
39  m_guid = o.m_guid;
40  m_specid = o.m_specid;
42  m_modelid = o.m_modelid;
45  memcpy(m_unit_table, o.m_unit_table, sizeof(m_unit_table));
46 
47  return *this;
48 }
49 
51 {
52  memset(m_unit_table, 0xff, 32 * sizeof(uint8_t));
53 
54  for (uint i = 0; i < 8; i++)
55  {
56  vector<uint8_t> cmd;
57  vector<uint8_t> ret;
58 
63  cmd.push_back((i<<4) | 0x07);
64  cmd.push_back(0xFF);
65  cmd.push_back(0xFF);
66  cmd.push_back(0xFF);
67  cmd.push_back(0xFF);
68 
69  if (!SendAVCCommand(cmd, ret, -1))
70  return false;
71 
72  if (ret.size() >= 8)
73  {
74  m_unit_table[(i<<2)+0] = ret[4];
75  m_unit_table[(i<<2)+1] = ret[5];
76  m_unit_table[(i<<2)+2] = ret[6];
77  m_unit_table[(i<<2)+3] = ret[7];
78  }
79  }
80 
81  return true;
82 }
83 
84 bool AVCInfo::IsSubunitType(int subunit_type) const
85 {
86  for (uint i = 0; i < 32; i++)
87  {
88  int subunit = m_unit_table[i];
89  if ((subunit != 0xff) &&
90  (subunit & FirewireDevice::kAVCSubunitTypeUnit) == subunit_type)
91  {
92  return true;
93  }
94  }
95 
96  return false;
97 }
98 
99 QString AVCInfo::GetSubunitInfoString(void) const
100 {
101  QString str = "Subunit Types: ";
102 
104  str += "Video Monitor, ";
106  str += "Audio, ";
108  str += "Printer, ";
110  str += "Disk Recorder, ";
112  str += "Tape Recorder, ";
114  str += "Tuner, ";
116  str += "CA, ";
118  str += "Camera, ";
120  str += "Panel, ";
122  str += "Bulletin Board, ";
124  str += "Camera Storage, ";
126  str += "Music, ";
128  str += "Vendor Unique, ";
129 
130  return str;
131 }
132 #endif
AVCInfo()
Definition: avcinfo.cpp:20
uint64_t string_to_guid(const QString &guid)
Definition: avcinfo.cpp:14
int m_port
Definition: avcinfo.h:38
uint m_specid
Definition: avcinfo.h:41
AVCInfo & operator=(const AVCInfo &o)
Definition: avcinfo.cpp:35
QString m_product_name
Definition: avcinfo.h:45
uint8_t m_unit_table[32]
Definition: avcinfo.h:46
bool GetSubunitInfo(void)
Definition: avcinfo.cpp:50
uint m_firmware_revision
Definition: avcinfo.h:44
bool IsSubunitType(int subunit_type) const
Definition: avcinfo.cpp:84
virtual bool SendAVCCommand(const vector< uint8_t > &, vector< uint8_t > &, int)
Definition: avcinfo.h:23
uint m_vendorid
Definition: avcinfo.h:42
QString guid_to_string(uint64_t guid)
Definition: avcinfo.cpp:9
unsigned int uint
Definition: compat.h:140
int m_node
Definition: avcinfo.h:39
QString GetSubunitInfoString(void) const
Definition: avcinfo.cpp:99
uint m_modelid
Definition: avcinfo.h:43
uint64_t m_guid
Definition: avcinfo.h:40