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 "libavc/avc_definitions.h" |
---|
27 |
#include "libavc/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 |
virtual ~AvDevice(); |
---|
63 |
|
---|
64 |
void setVerboseLevel(int l); |
---|
65 |
|
---|
66 |
static bool probe( ConfigRom& configRom ); |
---|
67 |
virtual bool discover(); |
---|
68 |
|
---|
69 |
virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ); |
---|
70 |
virtual int getSamplingFrequency( ); |
---|
71 |
|
---|
72 |
virtual int getStreamCount(); |
---|
73 |
virtual Streaming::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 void showDevice() const; |
---|
83 |
|
---|
84 |
Ieee1394Service& get1394Service() |
---|
85 |
{ return *m_p1394Service; } |
---|
86 |
|
---|
87 |
AvPlugManager& getPlugManager() |
---|
88 |
{ return *m_pPlugManager; } |
---|
89 |
|
---|
90 |
struct SyncInfo { |
---|
91 |
SyncInfo( AvPlug& source, |
---|
92 |
AvPlug& destination, |
---|
93 |
std::string description ) |
---|
94 |
: m_source( &source ) |
---|
95 |
, m_destination( &destination ) |
---|
96 |
, m_description( description ) |
---|
97 |
{} |
---|
98 |
SyncInfo() |
---|
99 |
: m_source( 0 ) |
---|
100 |
, m_destination( 0 ) |
---|
101 |
, m_description( "" ) |
---|
102 |
{} |
---|
103 |
AvPlug* m_source; |
---|
104 |
AvPlug* m_destination; |
---|
105 |
std::string m_description; |
---|
106 |
}; |
---|
107 |
|
---|
108 |
typedef std::vector<SyncInfo> SyncInfoVector; |
---|
109 |
const SyncInfoVector& getSyncInfos() const |
---|
110 |
{ return m_syncInfos; } |
---|
111 |
const SyncInfo* getActiveSyncInfo() const |
---|
112 |
{ return m_activeSyncInfo; } |
---|
113 |
bool setActiveSync( const SyncInfo& syncInfo ); |
---|
114 |
|
---|
115 |
bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const; |
---|
116 |
static AvDevice* deserialize( Glib::ustring basePath, |
---|
117 |
Util::IODeserialize& deser, |
---|
118 |
Ieee1394Service& ieee1394Service ); |
---|
119 |
protected: |
---|
120 |
|
---|
121 |
bool enumerateSubUnits(); |
---|
122 |
|
---|
123 |
bool discoverPlugs(); |
---|
124 |
bool discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection, |
---|
125 |
plug_id_t plugMaxId ); |
---|
126 |
bool discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection, |
---|
127 |
plug_id_t plugMaxId ); |
---|
128 |
bool discoverPlugConnections(); |
---|
129 |
bool discoverSyncModes(); |
---|
130 |
bool discoverSubUnitsPlugConnections(); |
---|
131 |
|
---|
132 |
AvDeviceSubunit* getSubunit( subunit_type_t subunitType, |
---|
133 |
subunit_id_t subunitId ) const; |
---|
134 |
|
---|
135 |
unsigned int getNrOfSubunits( subunit_type_t subunitType ) const; |
---|
136 |
AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const; |
---|
137 |
|
---|
138 |
AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection ); |
---|
139 |
|
---|
140 |
AvPlug* getPlugById( AvPlugVector& plugs, |
---|
141 |
AvPlug::EAvPlugDirection plugDireciton, |
---|
142 |
int id ); |
---|
143 |
AvPlugVector getPlugsByType( AvPlugVector& plugs, |
---|
144 |
AvPlug::EAvPlugDirection plugDirection, |
---|
145 |
AvPlug::EAvPlugType type); |
---|
146 |
|
---|
147 |
bool addPlugToProcessor( AvPlug& plug, Streaming::StreamProcessor *processor, |
---|
148 |
Streaming::AmdtpAudioPort::E_Direction direction); |
---|
149 |
|
---|
150 |
bool setSamplingFrequencyPlug( AvPlug& plug, |
---|
151 |
AvPlug::EAvPlugDirection direction, |
---|
152 |
ESamplingFrequency samplingFrequency ); |
---|
153 |
|
---|
154 |
void showAvPlugs( AvPlugVector& plugs ) const; |
---|
155 |
|
---|
156 |
bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs, |
---|
157 |
AvPlugVector& prhs, |
---|
158 |
std::string syncDescription ); |
---|
159 |
|
---|
160 |
static bool serializeSyncInfoVector( Glib::ustring basePath, |
---|
161 |
Util::IOSerialize& ser, |
---|
162 |
const SyncInfoVector& vec ); |
---|
163 |
static bool deserializeSyncInfoVector( Glib::ustring basePath, |
---|
164 |
Util::IODeserialize& deser, |
---|
165 |
AvDevice& avDevice, |
---|
166 |
SyncInfoVector& vec ); |
---|
167 |
protected: |
---|
168 |
AvPlugVector m_pcrPlugs; |
---|
169 |
AvPlugVector m_externalPlugs; |
---|
170 |
AvPlugConnectionVector m_plugConnections; |
---|
171 |
AvDeviceSubunitVector m_subunits; |
---|
172 |
AvPlugManager* m_pPlugManager; |
---|
173 |
SyncInfoVector m_syncInfos; |
---|
174 |
SyncInfo* m_activeSyncInfo; |
---|
175 |
struct VendorModelEntry* m_model; |
---|
176 |
|
---|
177 |
// streaming stuff |
---|
178 |
typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector; |
---|
179 |
StreamProcessorVector m_receiveProcessors; |
---|
180 |
StreamProcessorVector m_transmitProcessors; |
---|
181 |
}; |
---|
182 |
|
---|
183 |
} |
---|
184 |
|
---|
185 |
#endif |
---|