1 |
/* mh_avdevice.cpp |
---|
2 |
* Copyright (C) 2007 by Pieter Palmers |
---|
3 |
* |
---|
4 |
* This file is part of FreeBob. |
---|
5 |
* |
---|
6 |
* FreeBob is free software; you can redistribute it and/or modify |
---|
7 |
* it under the terms of the GNU General Public License as published by |
---|
8 |
* the Free Software Foundation; either version 2 of the License, or |
---|
9 |
* (at your option) any later version. |
---|
10 |
* FreeBob is distributed in the hope that it will be useful, |
---|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 |
* GNU General Public License for more details. |
---|
14 |
* |
---|
15 |
* You should have received a copy of the GNU General Public License |
---|
16 |
* along with FreeBob; if not, write to the Free Software |
---|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
---|
18 |
* MA 02111-1307 USA. |
---|
19 |
*/ |
---|
20 |
|
---|
21 |
#warning Metric Halo support is currently useless |
---|
22 |
|
---|
23 |
#include "metrichalo/mh_avdevice.h" |
---|
24 |
|
---|
25 |
#include "libieee1394/configrom.h" |
---|
26 |
#include "libieee1394/ieee1394service.h" |
---|
27 |
|
---|
28 |
#include "libavc/avc_definitions.h" |
---|
29 |
|
---|
30 |
#include "debugmodule/debugmodule.h" |
---|
31 |
|
---|
32 |
#include <string> |
---|
33 |
#include <stdint.h> |
---|
34 |
#include <assert.h> |
---|
35 |
#include <netinet/in.h> |
---|
36 |
#include <iostream> |
---|
37 |
#include <sstream> |
---|
38 |
|
---|
39 |
#include <libraw1394/csr.h> |
---|
40 |
|
---|
41 |
namespace MetricHalo { |
---|
42 |
|
---|
43 |
IMPL_DEBUG_MODULE( MHAvDevice, MHAvDevice, DEBUG_LEVEL_NORMAL ); |
---|
44 |
|
---|
45 |
// to define the supported devices |
---|
46 |
static VendorModelEntry supportedDeviceList[] = |
---|
47 |
{ |
---|
48 |
{0x00000000, 0x0000, "Metric Halo", "XXX"}, |
---|
49 |
}; |
---|
50 |
|
---|
51 |
MHAvDevice::MHAvDevice( std::auto_ptr< ConfigRom >( configRom ), |
---|
52 |
Ieee1394Service& ieee1394service, |
---|
53 |
int nodeId, |
---|
54 |
int verboseLevel ) |
---|
55 |
: m_configRom( configRom ) |
---|
56 |
, m_p1394Service( &ieee1394service ) |
---|
57 |
, m_model( NULL ) |
---|
58 |
, m_nodeId( nodeId ) |
---|
59 |
, m_verboseLevel( verboseLevel ) |
---|
60 |
|
---|
61 |
{ |
---|
62 |
setDebugLevel( verboseLevel ); |
---|
63 |
|
---|
64 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n", |
---|
65 |
nodeId ); |
---|
66 |
addOption(Util::OptionContainer::Option("id",std::string("dev?"))); |
---|
67 |
|
---|
68 |
} |
---|
69 |
|
---|
70 |
MHAvDevice::~MHAvDevice() |
---|
71 |
{ |
---|
72 |
|
---|
73 |
} |
---|
74 |
|
---|
75 |
ConfigRom& |
---|
76 |
MHAvDevice::getConfigRom() const |
---|
77 |
{ |
---|
78 |
return *m_configRom; |
---|
79 |
} |
---|
80 |
|
---|
81 |
bool |
---|
82 |
MHAvDevice::probe( ConfigRom& configRom ) |
---|
83 |
{ |
---|
84 |
unsigned int vendorId = configRom.getNodeVendorId(); |
---|
85 |
unsigned int modelId = configRom.getModelId(); |
---|
86 |
|
---|
87 |
for ( unsigned int i = 0; |
---|
88 |
i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); |
---|
89 |
++i ) |
---|
90 |
{ |
---|
91 |
if ( ( supportedDeviceList[i].vendor_id == vendorId ) |
---|
92 |
&& ( supportedDeviceList[i].model_id == modelId ) |
---|
93 |
) |
---|
94 |
{ |
---|
95 |
return true; |
---|
96 |
} |
---|
97 |
} |
---|
98 |
|
---|
99 |
return false; |
---|
100 |
} |
---|
101 |
|
---|
102 |
bool |
---|
103 |
MHAvDevice::discover() |
---|
104 |
{ |
---|
105 |
unsigned int vendorId = m_configRom->getNodeVendorId(); |
---|
106 |
unsigned int modelId = m_configRom->getModelId(); |
---|
107 |
|
---|
108 |
for ( unsigned int i = 0; |
---|
109 |
i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) ); |
---|
110 |
++i ) |
---|
111 |
{ |
---|
112 |
if ( ( supportedDeviceList[i].vendor_id == vendorId ) |
---|
113 |
&& ( supportedDeviceList[i].model_id == modelId ) |
---|
114 |
) |
---|
115 |
{ |
---|
116 |
m_model = &(supportedDeviceList[i]); |
---|
117 |
} |
---|
118 |
} |
---|
119 |
|
---|
120 |
if (m_model != NULL) { |
---|
121 |
debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n", |
---|
122 |
m_model->vendor_name, m_model->model_name); |
---|
123 |
return true; |
---|
124 |
} |
---|
125 |
|
---|
126 |
return false; |
---|
127 |
} |
---|
128 |
|
---|
129 |
int |
---|
130 |
MHAvDevice::getSamplingFrequency( ) { |
---|
131 |
return 0; |
---|
132 |
} |
---|
133 |
|
---|
134 |
bool |
---|
135 |
MHAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency ) |
---|
136 |
{ |
---|
137 |
|
---|
138 |
return false; |
---|
139 |
} |
---|
140 |
|
---|
141 |
bool MHAvDevice::setId( unsigned int id) { |
---|
142 |
// FIXME: decent ID system nescessary |
---|
143 |
std::ostringstream idstr; |
---|
144 |
|
---|
145 |
idstr << "dev" << id; |
---|
146 |
|
---|
147 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %s...\n", idstr.str().c_str()); |
---|
148 |
|
---|
149 |
return setOption("id",idstr.str()); |
---|
150 |
} |
---|
151 |
|
---|
152 |
bool |
---|
153 |
MHAvDevice::lock() { |
---|
154 |
|
---|
155 |
return true; |
---|
156 |
} |
---|
157 |
|
---|
158 |
|
---|
159 |
bool |
---|
160 |
MHAvDevice::unlock() { |
---|
161 |
|
---|
162 |
return true; |
---|
163 |
} |
---|
164 |
|
---|
165 |
void |
---|
166 |
MHAvDevice::showDevice() const |
---|
167 |
{ |
---|
168 |
debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
169 |
"%s %s at node %d\n", m_model->vendor_name, m_model->model_name, |
---|
170 |
m_nodeId); |
---|
171 |
} |
---|
172 |
|
---|
173 |
bool |
---|
174 |
MHAvDevice::prepare() { |
---|
175 |
|
---|
176 |
return true; |
---|
177 |
} |
---|
178 |
|
---|
179 |
int |
---|
180 |
MHAvDevice::getStreamCount() { |
---|
181 |
return 0; |
---|
182 |
} |
---|
183 |
|
---|
184 |
Streaming::StreamProcessor * |
---|
185 |
MHAvDevice::getStreamProcessorByIndex(int i) { |
---|
186 |
|
---|
187 |
return NULL; |
---|
188 |
} |
---|
189 |
|
---|
190 |
bool |
---|
191 |
MHAvDevice::startStreamByIndex(int i) { |
---|
192 |
return false; |
---|
193 |
} |
---|
194 |
|
---|
195 |
bool |
---|
196 |
MHAvDevice::stopStreamByIndex(int i) { |
---|
197 |
return false; |
---|
198 |
} |
---|
199 |
|
---|
200 |
} |
---|