root/branches/streaming-rework/src/dice/dice_avdevice.cpp

Revision 404, 5.4 kB (checked in by pieterpalmers, 16 years ago)

- introduce support framework for DICE and Metric Halo
- change probe/discovery code to make adding devices easier
- made conditional compilation effectively work.

./configure now has the following switches:

--enable-bebob build BeBoB support (default=yes)
--enable-motu build Motu support (default=no)
--enable-dice build DICE support (default=no)
--enable-metric-halo build Metric Halo support (note: completely useless)

(default=no)

--enable-rme build RME support (note: completely useless)

(default=no)

--enable-bounce build Bounce device support (default=no)
--enable-all-devices build support for all supported devices (default=no)

these now turn on/off compilation effectively.

Line 
1 /* dice_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_DICE
22 #warning DICE support is currently useless
23
24 #include "dice/dice_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 #include "libstreaming/AmdtpStreamProcessor.h"
40
41 namespace Dice {
42
43 IMPL_DEBUG_MODULE( DiceAvDevice, DiceAvDevice, DEBUG_LEVEL_NORMAL );
44
45 // to define the supported devices
46 static VendorModelEntry supportedDeviceList[] =
47 {
48     {0x00000000, 0x0000, "DICE VENDOR", "XXX"},
49 };
50
51 DiceAvDevice::DiceAvDevice( std::auto_ptr< ConfigRom >( configRom ),
52                     Ieee1394Service& ieee1394service,
53                     int nodeId,
54                     int verboseLevel )
55     : m_configRom( configRom )
56     , m_1394Service( &ieee1394service )
57     , m_model( NULL )
58     , m_nodeId( nodeId )
59     , m_verboseLevel( verboseLevel )
60     , m_id(0)
61     , m_iso_recv_channel ( -1 )
62     , m_iso_send_channel ( -1 )
63    
64 {
65     setDebugLevel( verboseLevel );
66    
67     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Dice::DiceAvDevice (NodeID %d)\n",
68                  nodeId );
69
70 }
71
72 DiceAvDevice::~DiceAvDevice()
73 {
74
75 }
76
77 ConfigRom&
78 DiceAvDevice::getConfigRom() const
79 {
80     return *m_configRom;
81 }
82
83 bool
84 DiceAvDevice::probe( ConfigRom& configRom )
85 {
86     unsigned int vendorId = configRom.getNodeVendorId();
87     unsigned int modelId = configRom.getModelId();
88
89     for ( unsigned int i = 0;
90           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
91           ++i )
92     {
93         if ( ( supportedDeviceList[i].vendor_id == vendorId )
94              && ( supportedDeviceList[i].model_id == modelId )
95            )
96         {
97             return true;
98         }
99     }
100
101     return false;
102 }
103
104 bool
105 DiceAvDevice::discover()
106 {
107     unsigned int vendorId = m_configRom->getNodeVendorId();
108     unsigned int modelId = m_configRom->getModelId();
109
110     for ( unsigned int i = 0;
111           i < ( sizeof( supportedDeviceList )/sizeof( VendorModelEntry ) );
112           ++i )
113     {
114         if ( ( supportedDeviceList[i].vendor_id == vendorId )
115              && ( supportedDeviceList[i].model_id == modelId )
116            )
117         {
118             m_model = &(supportedDeviceList[i]);
119         }
120     }
121
122     if (m_model != NULL) {
123         debugOutput( DEBUG_LEVEL_VERBOSE, "found %s %s\n",
124                 m_model->vendor_name, m_model->model_name);
125         return true;
126     }
127
128     return false;
129 }
130
131 int
132 DiceAvDevice::getSamplingFrequency( ) {
133     return 0;
134 }
135
136 bool
137 DiceAvDevice::setSamplingFrequency( ESamplingFrequency samplingFrequency )
138 {
139
140     return false;
141 }
142
143 bool DiceAvDevice::setId( unsigned int id) {
144     debugOutput( DEBUG_LEVEL_VERBOSE, "Set id to %d...\n", id);
145     m_id=id;
146     return true;
147 }
148
149 void
150 DiceAvDevice::showDevice() const
151 {
152     debugOutput(DEBUG_LEVEL_VERBOSE,
153         "%s %s at node %d\n", m_model->vendor_name, m_model->model_name,
154         m_nodeId);
155 }
156
157 bool
158 DiceAvDevice::prepare() {
159
160     return true;
161 }
162
163 int
164 DiceAvDevice::getStreamCount() {
165     return 0; // one receive, one transmit
166 }
167
168 FreebobStreaming::StreamProcessor *
169 DiceAvDevice::getStreamProcessorByIndex(int i) {
170
171 //    switch (i) {
172 //    case 0:
173 //        return m_receiveProcessor;
174 //    case 1:
175 //        return m_transmitProcessor;
176 //    default:
177 //        return NULL;
178 //    }
179 //    return 0;
180     return NULL;
181 }
182
183 int
184 DiceAvDevice::startStreamByIndex(int i) {
185
186     // NOTE: this assumes that you have two streams
187     switch (i) {
188     case 0:
189         // TODO: do the stuff that is nescessary to make the device
190         // transmit a stream
191
192         // Set the streamprocessor channel to the one obtained by
193         // the connection management
194 //        m_receiveProcessor->setChannel(m_iso_recv_channel);
195
196         break;
197     case 1:
198         // TODO: do the stuff that is nescessary to make the device
199         // receive a stream
200
201         // Set the streamprocessor channel to the one obtained by
202         // the connection management
203 //        m_transmitProcessor->setChannel(m_iso_send_channel);
204
205         break;
206        
207     default: // Invalid stream index
208         return -1;
209     }
210
211     return 0;
212 }
213
214 int
215 DiceAvDevice::stopStreamByIndex(int i) {
216
217     // TODO: connection management: break connection
218     // cfr the start function
219
220     // NOTE: this assumes that you have two streams
221     switch (i) {
222     case 0:
223         break;
224     case 1:
225         break;
226        
227     default: // Invalid stream index
228         return -1;
229     }
230
231     return 0;
232 }
233
234 signed int DiceAvDevice::getIsoRecvChannel(void) {
235     return m_iso_recv_channel;
236 }
237
238 signed int DiceAvDevice::getIsoSendChannel(void) {
239     return m_iso_send_channel;
240 }
241
242 }
243
244 #endif //#ifdef ENABLE_DICE
Note: See TracBrowser for help on using the browser.