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

Revision 416, 6.4 kB (checked in by pieterpalmers, 16 years ago)

- Introduced a generic option mechanism. AvDevices? now automatically

inherit from OptionContainer? (via IAvDevice) and can specify options
(e.g. at construction). These can then be get/set using the container
functions from the outside.

- Modified the bebob, bounce, motu, mh, rme AvDevices? to make use of the

option system for their Id value and the 'snoopMode' option.

- Made M-Audio avdevice a subclass of the BeBoB avdevice to avoid code

duplication.

- Extended the bounce device

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 #ifndef BEBOB_AVDEVICE_H
21 #define BEBOB_AVDEVICE_H
22
23 #include <stdint.h>
24
25 #include "debugmodule/debugmodule.h"
26 #include "libfreebobavc/avc_definitions.h"
27 #include "libfreebobavc/avc_extended_cmd_generic.h"
28 #include "libfreebob/xmlparser.h"
29
30 #include "bebob/bebob_avplug.h"
31 #include "bebob/bebob_avdevice_subunit.h"
32
33 #include "libstreaming/AmdtpStreamProcessor.h"
34 #include "libstreaming/AmdtpPort.h"
35 #include "libstreaming/AmdtpPortInfo.h"
36
37 #include "libutil/serialize.h"
38
39 #include "iavdevice.h"
40
41 #include <sstream>
42 #include <vector>
43
44 class ConfigRom;
45 class Ieee1394Service;
46 class SubunitPlugSpecificDataPlugAddress;
47
48 namespace BeBoB {
49
50 struct VendorModelEntry {
51     unsigned int vendor_id;
52     unsigned int model_id;
53     char *vendor_name;
54     char *model_name;
55 };
56
57 class AvDevice : public IAvDevice {
58 public:
59     AvDevice( std::auto_ptr<ConfigRom>( configRom ),
60               Ieee1394Service& ieee1394Service,
61               int nodeId,
62               int verboseLevel );
63     virtual ~AvDevice();
64
65     static bool probe( ConfigRom& configRom );
66     virtual bool discover();
67     virtual ConfigRom& getConfigRom() const;
68
69     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
70     virtual int getSamplingFrequency( );
71
72     virtual int getStreamCount();
73     virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i);
74
75     virtual bool prepare();
76     bool lock();
77     bool unlock();
78
79     bool startStreamByIndex(int i);
80     bool 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
185     // streaming stuff
186     typedef std::vector< FreebobStreaming::StreamProcessor * > StreamProcessorVector;
187     StreamProcessorVector m_receiveProcessors;
188     StreamProcessorVector m_transmitProcessors;
189
190     DECLARE_DEBUG_MODULE;
191 };
192
193 }
194
195 #endif
Note: See TracBrowser for help on using the browser.