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

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