root/branches/streaming-rework/src/iavdevice.h

Revision 435, 7.2 kB (checked in by pieterpalmers, 15 years ago)

src/devicemanager:
- start OSC server for the device manager

src/devicemanager,
src/iavdevice,
src/libieee1394/configrom:
- inherit from OscNode? to become Osc'able

src/bounce,
src/libstreaming/AmdtpStreamProcessor,
src/libstreaming/AmdtpSlaveStreamProcessor:
- fixed bounce device implementation, now working

src/bebob:
- fixed midi bug

General:
- removed 'intermediate XML'
- removed obsolete tests
- removed obsolete files
- removed obsolete API calls

Line 
1 /* iavdevice.h
2  * Copyright (C) 2006 by Daniel Wagner
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 #ifndef IAVDEVICE_H
22 #define IAVDEVICE_H
23
24 #include "libavc/avc_definitions.h"
25 #include "libutil/OptionContainer.h"
26 #include "libosc/OscNode.h"
27
28 class ConfigRom;
29 class Ieee1394Service;
30
31 namespace Streaming {
32     class StreamProcessor;
33 }
34 /*!
35 @brief Base class for device support
36
37  This class should be subclassed to implement freebob support
38  for a specific device.
39
40 */
41 class IAvDevice
42     : public Util::OptionContainer,
43       public OSC::OscNode
44 {
45 public:
46         IAvDevice( std::auto_ptr< ConfigRom >( configRom ),
47                     Ieee1394Service& ieee1394service,
48                     int nodeId );
49        
50         virtual ~IAvDevice() {};
51        
52         /// Returns the ConfigRom object of the device node.
53         ConfigRom& getConfigRom() const;
54        
55         /**
56          * @brief This is called by the DeviceManager to discover & configure the device
57          *
58          * @return true if the device was discovered successfuly
59          */
60         virtual bool discover() = 0;
61        
62         /**
63          * @brief Set the samping frequency
64          * @param samplingFrequency
65          * @return true if successful
66          */
67         virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ) = 0;
68         /**
69          * @brief get the samplingfrequency as an integer
70          * @return the sampling frequency as integer
71          */
72         virtual int getSamplingFrequency( ) = 0;
73        
74     /**
75      * @brief This is called by the device manager to give the device a unique ID.
76      *
77      * The purpose of this is to allow for unique port naming
78      * in case there are multiple identical devices on the bus.
79      * Some audio API's (e.g. jack) don't work properly when the
80      * port names are not unique.
81      *
82      * Say you have two devices having a port named OutputLeft.
83      * This can cause the streaming
84      * part to present two OutputLeft ports to the audio API,
85      * which won't work. This ID will allow you to construct
86      * the port names as 'dev1_OutputLeft' and 'dev2_OutputLeft'
87      *
88      * @note Currently this is a simple integer that is equal to
89      *       the position of the device in the devicemanager's
90      *       device list. Therefore it is dependant on the order
91      *       in which the devices are detected. The side-effect
92      *       of this is that it is dependant on the bus topology
93      *       and history (e.g. busresets etc). This makes that
94      *       these ID's are not fixed to a specific physical device.
95      *       At some point, we will replaced this with a GUID based
96      *       approach, which is tied to a physiscal device and is
97      *       bus & time independant.
98      *
99      * @param id
100      * @return true if successful
101      */
102     bool setId(unsigned int id);
103        
104         /**
105          * @brief Outputs the device configuration to stderr/stdout [debug helper]
106          *
107          * This function prints out a (detailed) description of the
108          * device detected, and its configuration.
109          */
110         virtual void showDevice() const = 0;
111
112         /**
113          * @brief Lock the device
114          *
115          * This is called by the streaming layer before we start manipulating
116          * and/or using the device.
117          *
118          * It should implement the mechanisms provided by the device to
119          * make sure that no other controller claims control of the device.
120          *
121          * @return true if successful, false if not
122          */
123         virtual bool lock() = 0;
124        
125         /**
126          * @brief Unlock the device
127          *
128          * This is called by the streaming layer after we finish manipulating
129          * and/or using the device.
130          *
131          * It should implement the mechanisms provided by the device to
132          * give up exclusive control of the device.
133          *
134          * @return true if successful, false if not
135          */
136         virtual bool unlock() = 0;
137
138         /**
139          * @brief Prepare the device
140          *
141          * This is called by the streaming layer after the configuration
142          * parameters (e.g. sample rate) are set, and before
143          * getStreamProcessor[*] functions are called.
144          *
145          * It should be used to prepare the device's streamprocessors
146          * based upon the device's current configuration. Normally
147          * the streaming layer will not change the device's configuration
148          * after calling this function.
149          *
150          * @return true if successful, false if not
151          */
152         virtual bool prepare() = 0;
153        
154         /**
155          * @brief Returns the number of ISO streams implemented/used by this device
156          *
157          * Most likely this is 2 streams, i.e. one transmit stream and one
158          * receive stream. However there are devices that implement more, for
159          * example BeBoB's implement 4 streams:
160          * - 2 audio streams (1 xmit/1 recv)
161          * - 2 sync streams (1 xmit/1 recv), which are an optional sync source
162          *   for the device.
163          *
164          * @note you have to have a StreamProcessor for every stream. I.e.
165          *       getStreamProcessorByIndex(i) should return a valid StreamProcessor
166          *       for i=0 to i=getStreamCount()-1
167          *
168          * @return number of streams available (both transmit and receive)
169          */
170         virtual int getStreamCount() = 0;
171        
172         /**
173          * @brief Returns the StreamProcessor object for the stream with index i
174          *
175          * @note a streamprocessor returned by getStreamProcessorByIndex(i)
176          *       cannot be the same object as one returned by
177          *       getStreamProcessorByIndex(j) if i isn't equal to j
178          * @note you cannot have two streamprocessors handling the same ISO
179          *       channel (on the same port)
180          *
181          * @param i : Stream index
182          * @pre @ref i smaller than getStreamCount()
183          * @return a StreamProcessor object if successful, NULL otherwise
184          */
185         virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i) = 0;
186        
187         /**
188          * @brief starts the stream with index i
189          *
190          * This function is called by the streaming layer when this stream should
191          * be started, i.e. the device should start sending data or should be prepared to
192          * be ready to receive data.
193          *
194          * It returns the channel number that was assigned for this stream.
195          * Channel allocation should be done using the allocation functions provided by the
196          * Ieee1394Service object that is passed in the constructor.
197          *
198          * @param i : Stream index
199          * @pre @ref i smaller than getStreamCount()
200          * @return true if successful, false if not
201          */
202         virtual bool startStreamByIndex(int i) = 0;
203        
204         /**
205          * @brief stops the stream with index @ref i
206          *
207          * @param i : Stream index
208          * @pre @ref i smaller than getStreamCount()
209          * @return true if successful, false if not
210          */
211         virtual bool stopStreamByIndex(int i) = 0;
212
213     /**
214      * set verbosity level
215      */
216     virtual void setVerboseLevel(int l);
217
218 protected:
219     std::auto_ptr<ConfigRom>( m_pConfigRom );
220     Ieee1394Service*          m_p1394Service;
221     int                       m_verboseLevel;
222     int                       m_nodeId;
223
224     DECLARE_DEBUG_MODULE;
225 };
226
227 #endif
Note: See TracBrowser for help on using the browser.