root/branches/streaming-rework/src/bebob/bebob_avdevice.h

Revision 404, 6.5 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 /* bebob_avdevice.h
2  * Copyright (C) 2005,06,07 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 #ifdef ENABLE_BEBOB
22
23 #ifndef BEBOB_AVDEVICE_H
24 #define BEBOB_AVDEVICE_H
25
26 #include <stdint.h>
27
28 #include "debugmodule/debugmodule.h"
29 #include "libfreebobavc/avc_definitions.h"
30 #include "libfreebobavc/avc_extended_cmd_generic.h"
31 #include "libfreebob/xmlparser.h"
32
33 #include "bebob/bebob_avplug.h"
34 #include "bebob/bebob_avdevice_subunit.h"
35
36 #include "libstreaming/AmdtpStreamProcessor.h"
37 #include "libstreaming/AmdtpPort.h"
38 #include "libstreaming/AmdtpPortInfo.h"
39
40 #include "libutil/serialize.h"
41
42 #include "iavdevice.h"
43
44 #include <sstream>
45
46 class ConfigRom;
47 class Ieee1394Service;
48 class SubunitPlugSpecificDataPlugAddress;
49
50 namespace BeBoB {
51
52 struct VendorModelEntry {
53     unsigned int vendor_id;
54     unsigned int model_id;
55     char *vendor_name;
56     char *model_name;
57 };
58
59 class AvDevice : public IAvDevice {
60 public:
61     AvDevice( std::auto_ptr<ConfigRom>( configRom ),
62               Ieee1394Service& ieee1394Service,
63               int nodeId,
64               int verboseLevel );
65     virtual ~AvDevice();
66
67     static bool probe( ConfigRom& configRom );
68     virtual bool discover();
69     virtual ConfigRom& getConfigRom() const;
70
71     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
72     virtual int getSamplingFrequency( );
73
74     virtual int getStreamCount();
75     virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i);
76
77     virtual bool prepare();
78
79     virtual int startStreamByIndex(int i);
80     virtual int stopStreamByIndex(int i);
81
82     virtual bool addXmlDescription( xmlNodePtr deviceNode );
83     virtual void showDevice() const;
84     virtual bool setId(unsigned int id);
85
86     Ieee1394Service& get1394Service()
87         { return *m_p1394Service; }
88
89     AvPlugManager& getPlugManager()
90         { return *m_pPlugManager; }
91
92     struct SyncInfo {
93         SyncInfo( AvPlug& source,
94                   AvPlug& destination,
95                   std::string description )
96             : m_source( &source )
97             , m_destination( &destination )
98             , m_description( description )
99             {}
100         SyncInfo()
101             : m_source( 0 )
102             , m_destination( 0 )
103             , m_description( "" )
104             {}
105         AvPlug*     m_source;
106         AvPlug*     m_destination;
107         std::string m_description;
108     };
109
110     typedef std::vector<SyncInfo> SyncInfoVector;
111     const SyncInfoVector& getSyncInfos() const
112         { return m_syncInfos; }
113     const SyncInfo* getActiveSyncInfo() const
114         { return m_activeSyncInfo; }
115     bool setActiveSync( const SyncInfo& syncInfo );
116
117     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
118     static AvDevice* deserialize( Glib::ustring basePath,
119                                   Util::IODeserialize& deser,
120                                   Ieee1394Service& ieee1394Service );
121
122 protected:
123     AvDevice();
124
125     bool enumerateSubUnits();
126
127     bool discoverPlugs();
128     bool discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection,
129                            plug_id_t plugMaxId );
130     bool discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection,
131                                 plug_id_t plugMaxId );
132     bool discoverPlugConnections();
133     bool discoverSyncModes();
134     bool discoverSubUnitsPlugConnections();
135
136     AvDeviceSubunit* getSubunit( subunit_type_t subunitType,
137                                  subunit_id_t subunitId ) const;
138
139     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
140     AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const;
141
142     AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection );
143
144     AvPlug* getPlugById( AvPlugVector& plugs,
145                          AvPlug::EAvPlugDirection plugDireciton,
146                          int id );
147     AvPlugVector getPlugsByType( AvPlugVector& plugs,
148                  AvPlug::EAvPlugDirection plugDirection,
149                  AvPlug::EAvPlugType type);
150
151     bool addPlugToProcessor( AvPlug& plug, FreebobStreaming::StreamProcessor *processor,
152                              FreebobStreaming::AmdtpAudioPort::E_Direction direction);
153
154     bool setSamplingFrequencyPlug( AvPlug& plug,
155                                    AvPlug::EAvPlugDirection direction,
156                                    ESamplingFrequency samplingFrequency );
157
158     void showAvPlugs( AvPlugVector& plugs ) const;
159
160     bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs,
161                                            AvPlugVector& prhs,
162                                            std::string syncDescription );
163
164     static bool serializeSyncInfoVector( Glib::ustring basePath,
165                                          Util::IOSerialize& ser,
166                                          const SyncInfoVector& vec );
167     static bool deserializeSyncInfoVector( Glib::ustring basePath,
168                                            Util::IODeserialize& deser,
169                                            AvDevice& avDevice,
170                                            SyncInfoVector& vec );
171 protected:
172     std::auto_ptr<ConfigRom>( m_pConfigRom );
173     Ieee1394Service*          m_p1394Service;
174     int                       m_verboseLevel;
175     AvPlugVector              m_pcrPlugs;
176     AvPlugVector              m_externalPlugs;
177     AvPlugConnectionVector    m_plugConnections;
178     AvDeviceSubunitVector     m_subunits;
179     AvPlugManager*            m_pPlugManager;
180     SyncInfoVector            m_syncInfos;
181     SyncInfo*                 m_activeSyncInfo;
182     struct VendorModelEntry*  m_model;
183     int                       m_nodeId;
184     unsigned int              m_id;
185
186     // streaming stuff
187     FreebobStreaming::AmdtpReceiveStreamProcessor *m_receiveProcessor;
188     int m_receiveProcessorBandwidth;
189
190     FreebobStreaming::AmdtpTransmitStreamProcessor *m_transmitProcessor;
191     int m_transmitProcessorBandwidth;
192
193     DECLARE_DEBUG_MODULE;
194 };
195
196 }
197
198 #endif
199
200 #endif //#ifdef ENABLE_BEBOB
Note: See TracBrowser for help on using the browser.