AudioManager  7.5.11
Native Application Runtime Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CAmDatabaseObserver.cpp
Go to the documentation of this file.
1 
24 #include "CAmDatabaseObserver.h"
25 #include <string.h>
26 #include <cassert>
27 #include <errno.h>
28 #include <sys/socket.h>
29 #include <sys/ioctl.h>
30 #include "CAmCommandSender.h"
31 #include "CAmRoutingSender.h"
32 #include "CAmTelnetServer.h"
33 #include "CAmDltWrapper.h"
34 #include "CAmSerializer.h"
35 
36 namespace am {
37 
39  mCommandSender(iCommandSender), //
40  mRoutingSender(iRoutingSender), //
41  mTelnetServer(NULL), //
42  mSerializer(iSocketHandler) //
43 {
44  assert(mCommandSender!=0);
45  assert(mRoutingSender!=0);
46  assert(iSocketHandler!=0);
47 }
48 
49 CAmDatabaseObserver::CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler, CAmTelnetServer *iTelnetServer) :
50  mCommandSender(iCommandSender), //
51  mRoutingSender(iRoutingSender), //
52  mTelnetServer(iTelnetServer), //
53  mSerializer(iSocketHandler) //
54 {
55  assert(mTelnetServer!=0);
56  assert(mCommandSender!=0);
57  assert(mRoutingSender!=0);
58  assert(iSocketHandler!=0);
59 }
60 
62 {
63 }
64 
66 {
67  mSerializer.asyncCall<CAmCommandSender, const am_MainConnectionType_s>(mCommandSender, &CAmCommandSender::cbNewMainConnection, mainConnection);
68 }
69 
71 {
72  mSerializer.asyncCall<CAmCommandSender, const am_mainConnectionID_t>(mCommandSender, &CAmCommandSender::cbRemovedMainConnection, mainConnection);
73 }
74 
76 {
77  mRoutingSender->addSinkLookup(sink);
78  if (sink.visible)
79  {
80  am_SinkType_s s;
81  s.availability = sink.available;
82  s.muteState = sink.muteState;
83  s.name = sink.name;
84  s.sinkClassID = sink.sinkClassID;
85  s.sinkID = sink.sinkID;
86  s.volume = sink.mainVolume;
87  mSerializer.asyncCall<CAmCommandSender, const am_SinkType_s>(mCommandSender, &CAmCommandSender::cbNewSink, s);
88  }
89 }
90 
92 {
93  mRoutingSender->addSourceLookup(source);
94  if (source.visible)
95  {
97  s.availability = source.available;
98  s.name = source.name;
99  s.sourceClassID = source.sourceClassID;
100  s.sourceID = source.sourceID;
101  mSerializer.asyncCall<CAmCommandSender, const am_SourceType_s>(mCommandSender, &CAmCommandSender::cbNewSource, s);
102  }
103 }
104 
106 {
107  mRoutingSender->addDomainLookup(domain);
108 }
109 
111 {
112  (void) gateway;
113  //todo: implement something
114 }
115 
117 {
118  (void) coverter;
119  //todo: implement something
120 }
121 
123 {
124  mRoutingSender->addCrossfaderLookup(crossfader);
125 }
126 
127 void CAmDatabaseObserver::removedSink(const am_sinkID_t sinkID, const bool visible)
128 {
129  mRoutingSender->removeSinkLookup(sinkID);
130 
131  if (visible)
132  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t>(mCommandSender, &CAmCommandSender::cbRemovedSink, sinkID);
133 }
134 
135 void CAmDatabaseObserver::removedSource(const am_sourceID_t sourceID, const bool visible)
136 {
137  mRoutingSender->removeSourceLookup(sourceID);
138 
139  if (visible)
140  mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t>(mCommandSender, &CAmCommandSender::cbRemovedSource, sourceID);
141 }
142 
144 {
145  mRoutingSender->removeDomainLookup(domainID);
146 }
147 
149 {
150  (void) gatewayID;
151  //todo: implement something?
152 }
153 
155 {
156  (void) converterID;
157  //todo: implement something?
158 }
159 
161 {
162  mRoutingSender->removeCrossfaderLookup(crossfaderID);
163 }
164 
166 {
168 }
169 
171 {
173 }
174 
176 {
177  mSerializer.asyncCall<CAmCommandSender, const am_connectionID_t, const am_ConnectionState_e>(mCommandSender, &CAmCommandSender::cbMainConnectionStateChanged, connectionID, connectionState);
178 }
179 
181 {
182  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MainSoundProperty_s>(mCommandSender, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
183 }
184 
186 {
187  mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_MainSoundProperty_s>(mCommandSender, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
188 }
189 
191 {
192  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_Availability_s>(mCommandSender, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
193 }
194 
196 {
197  mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_Availability_s>(mCommandSender, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
198 }
199 
201 {
202  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_mainVolume_t>(mCommandSender, &CAmCommandSender::cbVolumeChanged, sinkID, volume);
203 }
204 
206 {
207  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MuteState_e>(mCommandSender, &CAmCommandSender::cbSinkMuteStateChanged, sinkID, muteState);
208 }
209 
211 {
212  mSerializer.asyncCall<CAmCommandSender, const am_SystemProperty_s>(mCommandSender, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
213 }
214 
216 {
217  mSerializer.asyncCall<CAmCommandSender, const am_mainConnectionID_t, const am_timeSync_t>(mCommandSender, &CAmCommandSender::cbTimingInformationChanged, mainConnection, time);
218 }
219 
220 void CAmDatabaseObserver::sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
221 {
222  if (visible)
223  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_sinkClass_t, const std::vector<am_MainSoundProperty_s> >(mCommandSender, &CAmCommandSender::cbSinkUpdated, sinkID, sinkClassID, listMainSoundProperties);
224 }
225 
226 void CAmDatabaseObserver::sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
227 {
228  if (visible)
229  mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_sourceClass_t, const std::vector<am_MainSoundProperty_s> >(mCommandSender, &CAmCommandSender::cbSinkUpdated, sourceID, sourceClassID, listMainSoundProperties);
230 }
231 
233 {
234  mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_NotificationConfiguration_s> (mCommandSender, &CAmCommandSender::cbSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration);
235 }
236 
238 {
239  mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_NotificationConfiguration_s>(mCommandSender, &CAmCommandSender::cbSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration);
240 }
241 
242 }
Implements the RoutingSendInterface.
void cbNewSink(am_SinkType_s sink)
am_MuteState_e muteState
This attribute reflects the muteState of the sink.
uint16_t am_connectionID_t
a connection ID
void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s &SoundProperty)
uint16_t am_sinkClass_t
bool visible
This Boolean flag indicates whether a sink is visible to the commandInterface or not.
This struct holds information about the configuration for notifications.
void sourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)
void cbSystemPropertyChanged(const am_SystemProperty_s &systemProperty)
void cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)
void newConverter(const am_Converter_s &coverter)
void cbNewMainConnection(const am_MainConnectionType_s mainConnection)
This struct describes the attribiutes of a sink.
void sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties, const bool visible)
am_sinkID_t sinkID
This is the ID of the sink, it is unique in the system.
am_Availability_s available
This attribute reflects the availability of the source.
This struct describes the attribiutes of a domain.
void sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties, const bool visible)
am_Error_e addSinkLookup(const am_Sink_s &sinkData)
std::string name
The name of the source.
void newSource(const am_Source_s &source)
uint16_t am_crossfaderID_t
a crossfader ID
void removedSink(const am_sinkID_t sinkID, const bool visible)
The am::CAmSocketHandler implements a mainloop for the AudioManager.
this type holds all information of sinks relevant to the HMI
int16_t am_timeSync_t
offset time that is introduced in milli seconds.
am_Availability_s availability
the availability of the source
am_Error_e addCrossfaderLookup(const am_Crossfader_s &crossfaderData)
am_Error_e addDomainLookup(const am_Domain_s &domainData)
void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty)
am_mainVolume_t mainVolume
This is the representation of the Volume for the commandInterface.
am_sourceClass_t sourceClassID
the sourceClassID, indicates the class the source is in.
void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
SPDX license identifier: MPL-2.0.
void newDomain(const am_Domain_s &domain)
void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s &availability)
void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s &soundProperty)
void cbRemovedSource(const am_sourceID_t source)
void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
void cbNewSource(const am_SourceType_s source)
std::string name
The name of the sink.
SPDX license identifier: MPL-2.0.
void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s &SoundProperty)
struct describing system properties
uint16_t am_converterID_t
a converter ID
void removeGateway(const am_gatewayID_t gatewayID)
am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID)
am_sourceID_t sourceID
This is the ID of the source, it is unique in the system.
struct describung mainsound property
void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
void systemPropertyChanged(const am_SystemProperty_s &SystemProperty)
am_Availability_s availability
This attribute reflects the availability of the sink.
void removedSource(const am_sourceID_t sourceID, const bool visible)
am_Error_e addSourceLookup(const am_Source_s &sourceData)
void removedMainConnection(const am_mainConnectionID_t mainConnection)
uint16_t am_sourceID_t
a source ID
void removeDomain(const am_domainID_t domainID)
void newGateway(const am_Gateway_s &gateway)
void newMainConnection(const am_MainConnectionType_s &mainConnection)
am_sinkID_t sinkID
This is the ID of the sink, it is unique in the system.
am_sourceClass_t sourceClassID
the sourceClassID, indicates the class the source is in.
am_sinkClass_t sinkClassID
The sinkClassID references to a sinkClass.
bool visible
This Boolean flag indicates whether a source is visible to the commandInterface or not...
SPDX license identifier: MPL-2.0.
am_Availability_s available
This attribute reflects the availability of the sink.
Implements a telnetserver that can be used to connect to the audiomanager, retrieve some information ...
void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s &availability)
am_mainVolume_t volume
This is the representation of the Volume for the commandInterface.
am_ConnectionState_e
represents the connection state
This struct describes the attributes of a converter.
void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
This struct describes the attribiutes of a crossfader.
am_sourceID_t sourceID
This is the ID of the source, it is unique in the system.
void removeCrossfader(const am_crossfaderID_t crossfaderID)
am_MuteState_e muteState
this type holds all information of connections relevant to the HMI
void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
void asyncCall(TClass *instance, TRet(TClass::*method)(TArgs...), TArgs &...arguments)
calls a function with variadic arguments threadsafe
void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
uint16_t am_sourceClass_t
void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection)
void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
this describes the availability of a sink or a source together with the latest change ...
This struct describes the attributes of a gateway.
SPDX license identifier: MPL-2.0.
void newSink(const am_Sink_s &sink)
void removeConverter(const am_converterID_t converterID)
CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler)
void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s &availability)
am_Error_e removeSinkLookup(const am_sinkID_t sinkID)
void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
SPDX license identifier: MPL-2.0.
void cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
SPDX license identifier: MPL-2.0.
uint16_t am_domainID_t
a domain ID
int16_t am_mainVolume_t
This is the volume presented on the command interface.
void newCrossfader(const am_Crossfader_s &crossfader)
am_Error_e removeSourceLookup(const am_sourceID_t sourceID)
void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s &availability)
this type holds all information of sources relevant to the HMI
uint16_t am_gatewayID_t
a gateway ID
This struct describes the attribiutes of a source.
std::string name
The name of the sink.
std::string name
The name of the source.
This class is used to send data to the CommandInterface.
uint16_t am_sinkID_t
a sink ID
uint16_t am_mainConnectionID_t
a mainConnection ID
am_sinkClass_t sinkClassID
The sinkClassID references to a sinkClass.
void sinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)
am_Error_e removeDomainLookup(const am_domainID_t domainID)
void cbRemovedSink(const am_sinkID_t sink)