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 |
#ifdef ENABLE_METRIC_HALO |
---|
22 |
#warning Metric Halo support is currently useless |
---|
23 |
|
---|
24 |
#include "metrichalo/mh_avdevice.h" |
---|
25 |
#include "configrom.h" |
---|
26 |
|
---|
27 |
#include "libfreebobavc/ieee1394service.h" |
---|
28 |
#include "libfreebobavc/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 |
|
---|
37 |
#include <libraw1394/csr.h> |
---|
38 |
|
---|
39 |
namespace MetricHalo { |
---|
40 |
|
---|
41 |
IMPL_DEBUG_MODULE( MHAvDevice, MHAvDevice, DEBUG_LEVEL_NORMAL ); |
---|
42 |
|
---|
43 |
// to define the supported devices |
---|
44 |
static VendorModelEntry supportedDeviceList[] = |
---|
45 |
{ |
---|
46 |
{0x00000000, 0x0000, "Metric Halo", "XXX"}, |
---|
47 |
}; |
---|
48 |
|
---|
49 |
MHAvDevice::MHAvDevice( std::auto_ptr< ConfigRom >( configRom ), |
---|
50 |
Ieee1394Service& ieee1394service, |
---|
51 |
int nodeId, |
---|
52 |
int verboseLevel ) |
---|
53 |
: m_configRom( configRom ) |
---|
54 |
, m_1394Service( &ieee1394service ) |
---|
55 |
, m_model( NULL ) |
---|
56 |
, m_nodeId( nodeId ) |
---|
57 |
, m_verboseLevel( verboseLevel ) |
---|
58 |
, m_id(0) |
---|
59 |
, m_iso_recv_channel ( -1 ) |
---|
60 |
, m_iso_send_channel ( -1 ) |
---|
61 |
|
---|
62 |
{ |
---|
63 |
setDebugLevel( verboseLevel ); |
---|
64 |
|
---|
65 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Created MetricHalo::MHAvDevice (NodeID %d)\n", |
---|
66 |
nodeId ); |
---|
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 |
debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id); |
---|
143 |
m_id=id; |
---|
144 |
return true; |
---|
145 |
} |
---|
146 |
|
---|
147 |
void |
---|
148 |
MHAvDevice::showDevice() const |
---|
149 |
{ |
---|
150 |
debugOutput(DEBUG_LEVEL_VERBOSE, |
---|
151 |
"%s %s at node %d\n", m_model->vendor_name, m_model->model_name, |
---|
152 |
m_nodeId); |
---|
153 |
} |
---|
154 |
|
---|
155 |
bool |
---|
156 |
MHAvDevice::prepare() { |
---|
157 |
|
---|
158 |
return true; |
---|
159 |
} |
---|
160 |
|
---|
161 |
int |
---|
162 |
MHAvDevice::getStreamCount() { |
---|
163 |
return 0; // one receive, one transmit |
---|
164 |
} |
---|
165 |
|
---|
166 |
FreebobStreaming::StreamProcessor * |
---|
167 |
MHAvDevice::getStreamProcessorByIndex(int i) { |
---|
168 |
|
---|
169 |
// switch (i) { |
---|
170 |
// case 0: |
---|
171 |
// return m_receiveProcessor; |
---|
172 |
// case 1: |
---|
173 |
// return m_transmitProcessor; |
---|
174 |
// default: |
---|
175 |
// return NULL; |
---|
176 |
// } |
---|
177 |
// return 0; |
---|
178 |
return NULL; |
---|
179 |
} |
---|
180 |
|
---|
181 |
int |
---|
182 |
MHAvDevice::startStreamByIndex(int i) { |
---|
183 |
|
---|
184 |
// NOTE: this assumes that you have two streams |
---|
185 |
switch (i) { |
---|
186 |
case 0: |
---|
187 |
// TODO: do the stuff that is nescessary to make the device |
---|
188 |
// transmit a stream |
---|
189 |
|
---|
190 |
// Set the streamprocessor channel to the one obtained by |
---|
191 |
// the connection management |
---|
192 |
// m_receiveProcessor->setChannel(m_iso_recv_channel); |
---|
193 |
|
---|
194 |
break; |
---|
195 |
case 1: |
---|
196 |
// TODO: do the stuff that is nescessary to make the device |
---|
197 |
// receive a stream |
---|
198 |
|
---|
199 |
// Set the streamprocessor channel to the one obtained by |
---|
200 |
// the connection management |
---|
201 |
// m_transmitProcessor->setChannel(m_iso_send_channel); |
---|
202 |
|
---|
203 |
break; |
---|
204 |
|
---|
205 |
default: // Invalid stream index |
---|
206 |
return -1; |
---|
207 |
} |
---|
208 |
|
---|
209 |
return 0; |
---|
210 |
} |
---|
211 |
|
---|
212 |
int |
---|
213 |
MHAvDevice::stopStreamByIndex(int i) { |
---|
214 |
|
---|
215 |
// TODO: connection management: break connection |
---|
216 |
// cfr the start function |
---|
217 |
|
---|
218 |
// NOTE: this assumes that you have two streams |
---|
219 |
switch (i) { |
---|
220 |
case 0: |
---|
221 |
break; |
---|
222 |
case 1: |
---|
223 |
break; |
---|
224 |
|
---|
225 |
default: // Invalid stream index |
---|
226 |
return -1; |
---|
227 |
} |
---|
228 |
|
---|
229 |
return 0; |
---|
230 |
} |
---|
231 |
|
---|
232 |
signed int MHAvDevice::getIsoRecvChannel(void) { |
---|
233 |
return m_iso_recv_channel; |
---|
234 |
} |
---|
235 |
|
---|
236 |
signed int MHAvDevice::getIsoSendChannel(void) { |
---|
237 |
return m_iso_send_channel; |
---|
238 |
} |
---|
239 |
|
---|
240 |
} |
---|
241 |
|
---|
242 |
#endif //#ifdef ENABLE_METRIC_HALO |
---|