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

Revision 412, 6.8 kB (checked in by pieterpalmers, 16 years ago)

- added some documentation
- added a lock()/unlock() to IAvDevice (see header)
- reimplemented test-freebob to the new C++ api
- started with support for AddressRangeMapping?, i.e. response

to reads/writes of the 1394 memory space on the host

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