root/trunk/libfreebob/src/bebob/bebob_avdevice.h

Revision 379, 6.2 kB (checked in by wagi, 16 years ago)

AvDevice?: all members are de/serialed now

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