28 #include <sys/types.h> 36 #include "audiomanagerconfig.h" 38 #define __METHOD_NAME__ std::string (std::string("CAmCommandSender::") + __func__) 46 #define CALL_ALL_INTERFACES(...) \ 47 std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin(); \ 48 std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end(); \ 49 for (; iter<iterEnd;++iter) \ 51 (*iter)->__VA_ARGS__; \ 57 mListLibraryHandles(),
60 mSerializer(iSocketHandler)
62 loadPlugins(listOfPluginDirectories);
79 s.
volume = sink.mainVolume;
154 void CAmCommandSender::loadPlugins(
const std::vector<std::string>& listOfPluginDirectories)
156 if (listOfPluginDirectories.empty())
161 std::vector<std::string> sharedLibraryNameList;
162 std::vector<std::string>::const_iterator dirIter = listOfPluginDirectories.begin();
163 std::vector<std::string>::const_iterator dirIterEnd = listOfPluginDirectories.end();
166 for (; dirIter < dirIterEnd; ++dirIter)
168 const char* directoryName = dirIter->c_str();
170 DIR *directory = opendir(directoryName);
179 struct dirent *itemInDirectory = 0;
180 while ((itemInDirectory = readdir(directory)))
182 unsigned char entryType = itemInDirectory->d_type;
183 std::string entryName = itemInDirectory->d_name;
184 std::string fullName = *dirIter +
"/" + entryName;
186 bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
187 bool sharedLibExtension = (
"so" == entryName.substr(entryName.find_last_of(
".") + 1));
190 if (entryType == DT_UNKNOWN)
194 if (stat(fullName.c_str(), &buf))
200 regularFile = S_ISREG(buf.st_mode);
203 if (regularFile && sharedLibExtension)
205 std::string name(directoryName);
206 sharedLibraryNameList.push_back(name +
"/" + entryName);
213 std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
214 std::vector<std::string>::iterator iterEnd = sharedLibraryNameList.end();
216 for (; iter < iterEnd; ++iter)
220 void* tempLibHandle = NULL;
221 createFunc = getCreateFunction<IAmCommandSend*()>(*iter, tempLibHandle);
234 dlclose(tempLibHandle);
241 uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
242 std::istringstream(version.substr(0, 1)) >> majorVersion;
243 std::istringstream(version.substr(2, 1)) >> minorVersion;
244 std::istringstream(cVersion.substr(0, 1)) >> cMajorVersion;
245 std::istringstream(cVersion.substr(2, 1)) >> cMinorVersion;
247 if (majorVersion < cMajorVersion || ((majorVersion == cMajorVersion) && (minorVersion > cMinorVersion)))
250 dlclose(tempLibHandle);
254 mListInterfaces.push_back(commander);
255 mListLibraryHandles.push_back(tempLibHandle);
256 mListLibraryNames.push_back(iter->c_str());
267 mCommandReceiver = iCommandReceiver;
270 std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin();
271 std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end();
272 for (; iter < iterEnd; ++iter)
274 am_Error_e error = (*iter)->startupInterface(iCommandReceiver);
280 return (returnError);
373 std::vector<uint16_t> listStartupHandles;
374 for (
size_t i = 0; i < mListInterfaces.size(); i++)
383 std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin();
384 std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end();
385 std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
386 for (; iter < iterEnd; ++iter)
388 (*iter)->setCommandReady(*(handleIter++));
396 std::vector<uint16_t> listStartupHandles;
397 for (
size_t i = 0; i < mListInterfaces.size(); i++)
406 std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin();
407 std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end();
408 std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
409 for (; iter < iterEnd; ++iter)
411 (*iter)->setCommandRundown(*(handleIter++));
422 interfaces = mListLibraryNames;
448 CALL_ALL_INTERFACES(cbMainSinkNotificationConfigurationChanged(sinkID,mainNotificationConfiguration));
453 CALL_ALL_INTERFACES(cbMainSourceNotificationConfigurationChanged(sourceID,mainNotificationConfiguration));
456 void CAmCommandSender::unloadLibraries(
void)
458 std::vector<void*>::iterator iterator = mListLibraryHandles.begin();
459 for (; iterator < mListLibraryHandles.end(); ++iterator)
463 mListLibraryHandles.clear();
am_Error_e getListPlugins(std::vector< std::string > &interfaces) const
void cbNumberOfSourceClassesChanged()
void cbNewSink(am_SinkType_s sink)
SPDX license identifier: MPL-2.0.
std::function< void(const am_sourceID_t, const bool)> dboRemovedSource
This class realizes the command Interface.
uint16_t getRundownHandle()
returns a rundown handle
std::function< void(const am_Sink_s &)> dboNewSink
std::function< void(const am_SystemProperty_s &)> dboSystemPropertyChanged
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
am_Error_e startupInterfaces(CAmCommandReceiver *iCommandReceiver)
am_Error_e
the errors of the audiomanager.
This struct holds information about the configuration for notifications.
void logInfo(T value, TArgs...args)
logs given values with infolevel with the default context
std::function< void(const am_sinkID_t, const am_sinkClass_t, const std::vector< am_MainSoundProperty_s > &, const bool)> dboSinkUpdated
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)
std::function< void(const am_sinkID_t, const bool)> dboRemovedSink
void cbNewMainConnection(const am_MainConnectionType_s mainConnection)
This struct describes the attribiutes of a sink.
This struct holds the payload of a notification.
std::function< void(const am_mainConnectionID_t, const am_timeSync_t)> dboTimingInformationChanged
std::function< void(const am_sourceID_t, const am_MainSoundProperty_s &)> dboMainSourceSoundPropertyChanged
virtual void getInterfaceVersion(std::string &version) const =0
returns the interface version as string.
#define CALL_ALL_INTERFACES(...)
macro to call all interfaces
std::string name
The name of the source.
void cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s ¬ification)
The am::CAmSocketHandler implements a mainloop for the AudioManager.
std::function< void(const am_mainConnectionID_t)> dboRemovedMainConnection
std::function< void(const am_sinkID_t, const am_Availability_s &)> dboSinkAvailabilityChanged
this type holds all information of sinks relevant to the HMI
std::function< void(const am_mainConnectionID_t, const am_ConnectionState_e)> dboMainConnectionStateChanged
int16_t am_timeSync_t
offset time that is introduced in milli seconds.
am_Availability_s availability
the availability of the source
std::function< void(const am_sourceID_t, const am_NotificationConfiguration_s)> dboSourceMainNotificationConfigurationChanged
void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty)
SPDX license identifier: MPL-2.0.
std::function< void(const am_Source_s &)> dboNewSource
std::function< void()> dboNumberOfSourceClassesChanged
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::function< void(const am_sourceID_t, const am_Availability_s &)> dboSourceAvailabilityChanged
CAmCommandSender(const std::vector< std::string > &listOfPluginDirectories, CAmSocketHandler *iSocketHandler)
struct describing system properties
void waitOnRundown(bool rundown)
tells the ComandReceiver to start waiting for all handles to be confirmed
SPDX license identifier: MPL-2.0.
am_sourceID_t sourceID
This is the ID of the source, it is unique in the system.
struct describung mainsound property
am_Availability_s availability
This attribute reflects the availability of the sink.
std::function< void(const am_sourceID_t, const am_sourceClass_t, const std::vector< am_MainSoundProperty_s > &, const bool)> dboSourceUpdated
void getInterfaceVersion(std::string &version) const
std::function< void()> dboNumberOfSinkClassesChanged
void cbNumberOfSinkClassesChanged()
uint16_t am_sourceID_t
a source ID
void cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s ¬ification)
am_sinkID_t sinkID
This is the ID of the sink, it is unique in the system.
std::function< void(const am_sinkID_t, const am_MuteState_e)> dboSinkMuteStateChanged
am_sourceClass_t sourceClassID
the sourceClassID, indicates the class the source is in.
std::function< void(const am_sinkID_t, const am_MainSoundProperty_s &)> dboMainSinkSoundPropertyChanged
std::function< void(const am_sinkID_t, const am_NotificationConfiguration_s)> dboSinkMainNotificationConfigurationChanged
am_mainVolume_t volume
This is the representation of the Volume for the commandInterface.
am_ConnectionState_e
represents the connection state
void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
this type holds all information of connections relevant to the HMI
void cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)
void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
uint16_t am_sourceClass_t
void cbRemovedMainConnection(const am_mainConnectionID_t mainConnection)
this describes the availability of a sink or a source together with the latest change ...
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s &availability)
void waitOnStartup(bool startup)
tells the ComandReceiver to start waiting for all handles to be confirmed
void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
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.
int16_t am_mainVolume_t
This is the volume presented on the command interface.
no error - positive reply
void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s &availability)
uint16_t getStartupHandle()
returns a startup handle
this type holds all information of sources relevant to the HMI
This struct describes the attribiutes of a source.
std::string name
The name of the sink.
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
This class handles and abstracts the database.
void asyncCall(TClass *instance, TMeth method, TArgs &&...arguments)
calls a function with variadic arguments threadsafe
am_sinkClass_t sinkClassID
The sinkClassID references to a sinkClass.
This interface handles all communication from the AudioManagerDaemon towards the system.
std::function< void(const am_sinkID_t, const am_mainVolume_t)> dboVolumeChanged
std::function< void(const am_MainConnectionType_s &)> dboNewMainConnection
void cbRemovedSink(const am_sinkID_t sink)