From 54c5e965fe8f9a53a78834028fd65c792493da2b Mon Sep 17 00:00:00 2001 From: christian linke Date: Mon, 17 Dec 2012 16:15:11 +0100 Subject: * added new interfaces & nsm support + nsm tests + fixed some unit tests + fixed rundown Signed-off-by: christian linke --- .gitignore | 2 +- AudioManagerDaemon/CMakeLists.txt | 26 +- AudioManagerDaemon/docx/01_mainpage.dox | 1 + AudioManagerDaemon/docx/02_license.dox | 2 +- AudioManagerDaemon/docx/02_x_dependecies.dox | 2 +- AudioManagerDaemon/docx/02_y_versioning.dox | 2 +- .../docx/03_architecture_overview.dox | 2 +- AudioManagerDaemon/docx/03_x_uml_model.dox | 2 +- AudioManagerDaemon/docx/04_components.dox | 2 +- AudioManagerDaemon/docx/04_x_elements.dox | 2 +- .../docx/04_y_audiomanager_and_sources.dox | 2 +- AudioManagerDaemon/docx/05_unique.dox | 2 +- AudioManagerDaemon/docx/06_classification.dox | 2 +- AudioManagerDaemon/docx/07_interrupts.dox | 2 +- AudioManagerDaemon/docx/08_connections.dox | 2 +- AudioManagerDaemon/docx/09_lipsync.dox | 2 +- AudioManagerDaemon/docx/10_early_audio.dox | 2 +- AudioManagerDaemon/docx/11_views.dox | 2 +- AudioManagerDaemon/docx/12_volumes.dox | 2 +- AudioManagerDaemon/docx/13_properties.dox | 2 +- AudioManagerDaemon/docx/14_misc.dox | 2 +- AudioManagerDaemon/docx/14_x_mainloop.dox | 2 +- AudioManagerDaemon/docx/14_y_watchdog.dox | 2 +- .../docx/14_z_nodeStateManagement.dox | 32 + AudioManagerDaemon/docx/15_dlt_support.dox | 2 +- AudioManagerDaemon/docx/15_x_eclipse.dox | 2 +- AudioManagerDaemon/docx/16_readme.dox | 2 +- AudioManagerDaemon/docx/Doxyfile.in | 8 +- AudioManagerDaemon/include/CAmCommandReceiver.h | 10 +- AudioManagerDaemon/include/CAmCommandSender.h | 7 + AudioManagerDaemon/include/CAmControlReceiver.h | 27 +- AudioManagerDaemon/include/CAmControlSender.h | 62 +- AudioManagerDaemon/include/CAmDatabaseHandler.h | 9 + AudioManagerDaemon/include/CAmDatabaseObserver.h | 4 + .../include/CAmNodeStateCommunicator.h | 72 ++ AudioManagerDaemon/include/CAmRoutingReceiver.h | 15 +- AudioManagerDaemon/include/CAmRoutingSender.h | 6 + AudioManagerDaemon/src/CAmCommandReceiver.cpp | 40 +- AudioManagerDaemon/src/CAmCommandSender.cpp | 30 + AudioManagerDaemon/src/CAmControlReceiver.cpp | 171 ++++- AudioManagerDaemon/src/CAmControlSender.cpp | 167 ++++- AudioManagerDaemon/src/CAmDatabaseHandler.cpp | 661 +++++++++++++++++- AudioManagerDaemon/src/CAmDatabaseObserver.cpp | 23 + AudioManagerDaemon/src/CAmDbusWrapper.cpp | 7 +- .../src/CAmNodeStateCommunicator.cpp | 763 +++++++++++++++++++++ AudioManagerDaemon/src/CAmRoutingReceiver.cpp | 97 ++- AudioManagerDaemon/src/CAmRoutingSender.cpp | 72 ++ AudioManagerDaemon/src/CAmSocketHandler.cpp | 17 +- AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp | 1 - AudioManagerDaemon/src/CAmWatchdog.cpp | 1 - AudioManagerDaemon/src/main.cpp | 44 +- .../CAmControlInterfaceTest.cpp | 2 +- .../test/AmControlInterfaceTest/CMakeLists.txt | 2 + .../CAmDatabaseHandlerTest.cpp | 281 +++++++- .../test/AmDatabaseHandlerTest/CMakeLists.txt | 2 + .../CAmNodeStateCommunicatorTest.cpp | 240 +++++++ .../CAmNodeStateCommunicatorTest.h | 61 ++ .../AmNodeStateCommunicatorTest/CMakeLists.txt | 112 +++ .../test/AmNodeStateCommunicatorTest/nsm.py | 179 +++++ .../org.genivi.NodeStateManager.Consumer.xml | 259 +++++++ .../test/AmNodeStateCommunicatorTest/send2nsm.py | 68 ++ .../test/AmRouterTest/CAmRouterTest.cpp | 28 +- .../test/AmRouterTest/CMakeLists.txt | 2 + .../CAmRoutingInterfaceTest.cpp | 2 +- .../test/AmRoutingInterfaceTest/CMakeLists.txt | 2 + .../AmTelnetServerTest/CAmTelnetServerTest.cpp | 13 +- .../test/AmTelnetServerTest/CAmTelnetServerTest.h | 2 +- .../test/AmTelnetServerTest/CMakeLists.txt | 2 + AudioManagerDaemon/test/CMakeLists.txt | 1 + AudioManagerDaemon/test/MockIAmCommandSend.h | 14 + AudioManagerDaemon/test/MockIAmControlSend.h | 217 +++--- AudioManagerDaemon/test/MockIAmRoutingSend.h | 75 +- CMakeLists.txt | 27 +- PluginCommandInterfaceDbus/cmake/config.cmake | 1 + .../include/CAmCommandSenderDbus.h | 6 + .../include/CAmDbusMessageHandler.h | 4 + .../include/CommandInterface.xml | 66 +- .../include/IAmCommandReceiverShadow.h | 4 + .../include/configCommandDbus.h | 3 +- .../src/CAmCommandSenderDbus.cpp | 83 ++- .../src/CAmDbusMessageHandler.cpp | 83 +++ .../src/IAmCommandReceiverShadow.cpp | 85 +++ .../test/CAmCommandSenderDbusSignalTest.cpp | 46 +- .../test/CAmCommandSenderDbusTest.cpp | 6 +- .../test/MockIAmCommandReceive.h | 97 +-- .../include/CAmControlSenderBase.h | 25 +- .../include/IAmControlReceiverShadow.h | 4 +- .../src/CAmControlSenderBase.cpp | 152 +++- .../src/IAmControlReceiverShadow.cpp | 10 +- .../test/MockIAmControlReceive.h | 329 +++++---- .../include/CAmRoutingSenderAsync.h | 3 + .../include/IAmRoutingReceiverShadow.h | 4 +- .../src/CAmRoutingSenderAsync.cpp | 48 +- .../src/IAmRoutingReceiverShadow.cpp | 12 +- .../test/CAmRoutingReceiverAsync.cpp | 117 ++-- .../test/CAmRoutingReceiverAsync.h | 2 + PluginRoutingInterfaceAsync/test/CMakeLists.txt | 1 - .../test/MockIAmRoutingReceive.h | 173 ++--- .../include/CAmRoutingSenderDbus.h | 3 + .../include/configRoutingDbus.h | 2 +- .../src/CAmRoutingSenderDbus.cpp | 26 + .../src/IAmRoutingReceiverShadow.cpp | 4 +- README | 10 +- README.html | 13 +- cmake/LifecycleConsumer.xml | 23 + cmake/config.cmake | 5 + cmake/genivi.audiomanager.service | 2 +- googleMock/CMakeLists.txt | 2 + googleMock/include/gmock/gmock-matchers.h | 2 +- include/audiomanagertypes.h | 596 +++++++++------- include/command/IAmCommandReceive.h | 128 ++-- include/command/IAmCommandSend.h | 106 ++- include/control/IAmControlReceive.h | 527 ++++++++------ include/control/IAmControlSend.h | 229 +++++-- include/projecttypes.h | 79 ++- include/routing/IAmRoutingReceive.h | 186 +++-- include/routing/IAmRoutingSend.h | 92 ++- include/shared/CAmSerializer.h | 1 - 118 files changed, 6003 insertions(+), 1409 deletions(-) create mode 100644 AudioManagerDaemon/docx/14_z_nodeStateManagement.dox create mode 100644 AudioManagerDaemon/include/CAmNodeStateCommunicator.h create mode 100644 AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp create mode 100644 AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp create mode 100644 AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h create mode 100644 AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt create mode 100644 AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py create mode 100644 AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml create mode 100644 AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py create mode 100644 cmake/LifecycleConsumer.xml mode change 100644 => 100755 include/projecttypes.h diff --git a/.gitignore b/.gitignore index b725bdc..fbff9e6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,4 @@ packages/ /packages /patch ProjectSpecific/ -PluginControlInterface/ + diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt index 2fa7343..4704864 100644 --- a/AudioManagerDaemon/CMakeLists.txt +++ b/AudioManagerDaemon/CMakeLists.txt @@ -69,6 +69,7 @@ IF(WITH_DBUS_WRAPPER) SET (AUDIOMAN_SRCS_CXX ${AUDIOMAN_SRCS_CXX} src/CAmDbusWrapper.cpp + src/CAmNodeStateCommunicator.cpp ) ENDIF(WITH_DBUS_WRAPPER) @@ -129,10 +130,6 @@ IF (SYSTEMD_FOUND) ) ENDIF (SYSTEMD_FOUND) -IF(WITH_TESTS) - add_subdirectory (test) -ENDIF(WITH_TESTS) - #IF(WITH_DOCUMENTATION) # file(MAKE_DIRECTORY ${DOC_OUTPUT_PATH}) # configure_file(${DOXY_FILE} ${DOC_OUTPUT_PATH}/Doxyfile @ONLY IMMEDIATE) @@ -154,6 +151,27 @@ INSTALL(DIRECTORY "${AUDIO_INCLUDE_FOLDER}/" COMPONENT dev ) +IF(WITH_DBUS_WRAPPER) + IF(USE_BUILD_LIBS) + SET(NSM_INTROSPECTION_FILE ${EXECUTABLE_OUTPUT_PATH}/LifeCycleConsumer.xml) + execute_process( + COMMAND mkdir -p "${CMAKE_SOURCE_DIR}/bin" + COMMAND cp "${CMAKE_SOURCE_DIR}/cmake/LifecycleConsumer.xml" ${NSM_INTROSPECTION_FILE}) + ELSE(USE_BUILD_LIBS) + SET(NSM_INTROSPECTION_FILE ${CMAKE_INSTALL_PREFIX}/share/audiomanager/LifeCycleConsumer.xml) + INSTALL( + FILES ${CMAKE_SOURCE_DIR}/cmake/LifecycleConsumer.xml + DESTINATION "${NSM_INTROSPECTION_FILE}" + COMPONENT bin) + ENDIF(USE_BUILD_LIBS) +ENDIF(WITH_DBUS_WRAPPER) + +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/include/config.h ) + +IF(WITH_TESTS) + add_subdirectory (test) +ENDIF(WITH_TESTS) + # General packet dependency SET(ADD_DEPEND_BIN_PROP "sqlite3(>=3.6.22)") diff --git a/AudioManagerDaemon/docx/01_mainpage.dox b/AudioManagerDaemon/docx/01_mainpage.dox index a890180..ad0848b 100644 --- a/AudioManagerDaemon/docx/01_mainpage.dox +++ b/AudioManagerDaemon/docx/01_mainpage.dox @@ -26,4 +26,5 @@ can be found at https://collab.genivi.org/wiki/display/genivi/GENIVI+Home \n \par About AudioManager The AudioManager is a Deamon that manages all Audio Connections in a GENIVI headunit. It is a managing instance that uses so called RoutingAdaptors to control AudioDomains that then do the "real" connections. + */ \ No newline at end of file diff --git a/AudioManagerDaemon/docx/02_license.dox b/AudioManagerDaemon/docx/02_license.dox index 1a31d63..45f68f3 100644 --- a/AudioManagerDaemon/docx/02_license.dox +++ b/AudioManagerDaemon/docx/02_license.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/02_x_dependecies.dox b/AudioManagerDaemon/docx/02_x_dependecies.dox index f334e37..ff5c346 100644 --- a/AudioManagerDaemon/docx/02_x_dependecies.dox +++ b/AudioManagerDaemon/docx/02_x_dependecies.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/02_y_versioning.dox b/AudioManagerDaemon/docx/02_y_versioning.dox index f6c0990..b166beb 100644 --- a/AudioManagerDaemon/docx/02_y_versioning.dox +++ b/AudioManagerDaemon/docx/02_y_versioning.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/03_architecture_overview.dox b/AudioManagerDaemon/docx/03_architecture_overview.dox index ec399f2..230a99a 100644 --- a/AudioManagerDaemon/docx/03_architecture_overview.dox +++ b/AudioManagerDaemon/docx/03_architecture_overview.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/03_x_uml_model.dox b/AudioManagerDaemon/docx/03_x_uml_model.dox index 93077ca..802d181 100644 --- a/AudioManagerDaemon/docx/03_x_uml_model.dox +++ b/AudioManagerDaemon/docx/03_x_uml_model.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/04_components.dox b/AudioManagerDaemon/docx/04_components.dox index 09acd1a..c4084b8 100644 --- a/AudioManagerDaemon/docx/04_components.dox +++ b/AudioManagerDaemon/docx/04_components.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/04_x_elements.dox b/AudioManagerDaemon/docx/04_x_elements.dox index 4afdd35..7990d37 100644 --- a/AudioManagerDaemon/docx/04_x_elements.dox +++ b/AudioManagerDaemon/docx/04_x_elements.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/04_y_audiomanager_and_sources.dox b/AudioManagerDaemon/docx/04_y_audiomanager_and_sources.dox index a333141..113cf6b 100644 --- a/AudioManagerDaemon/docx/04_y_audiomanager_and_sources.dox +++ b/AudioManagerDaemon/docx/04_y_audiomanager_and_sources.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/05_unique.dox b/AudioManagerDaemon/docx/05_unique.dox index a575ef8..5bf021a 100644 --- a/AudioManagerDaemon/docx/05_unique.dox +++ b/AudioManagerDaemon/docx/05_unique.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/06_classification.dox b/AudioManagerDaemon/docx/06_classification.dox index 0b77bde..ccedffc 100644 --- a/AudioManagerDaemon/docx/06_classification.dox +++ b/AudioManagerDaemon/docx/06_classification.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/07_interrupts.dox b/AudioManagerDaemon/docx/07_interrupts.dox index 51de73b..0e26b88 100644 --- a/AudioManagerDaemon/docx/07_interrupts.dox +++ b/AudioManagerDaemon/docx/07_interrupts.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/08_connections.dox b/AudioManagerDaemon/docx/08_connections.dox index f57f9a3..fd8a194 100644 --- a/AudioManagerDaemon/docx/08_connections.dox +++ b/AudioManagerDaemon/docx/08_connections.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/09_lipsync.dox b/AudioManagerDaemon/docx/09_lipsync.dox index 6d75343..6229198 100644 --- a/AudioManagerDaemon/docx/09_lipsync.dox +++ b/AudioManagerDaemon/docx/09_lipsync.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/10_early_audio.dox b/AudioManagerDaemon/docx/10_early_audio.dox index 1811049..bdd72f5 100644 --- a/AudioManagerDaemon/docx/10_early_audio.dox +++ b/AudioManagerDaemon/docx/10_early_audio.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/11_views.dox b/AudioManagerDaemon/docx/11_views.dox index b9efc92..2dda7c9 100644 --- a/AudioManagerDaemon/docx/11_views.dox +++ b/AudioManagerDaemon/docx/11_views.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/12_volumes.dox b/AudioManagerDaemon/docx/12_volumes.dox index c58b7f8..60603bc 100644 --- a/AudioManagerDaemon/docx/12_volumes.dox +++ b/AudioManagerDaemon/docx/12_volumes.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/13_properties.dox b/AudioManagerDaemon/docx/13_properties.dox index 577c743..2597fdf 100644 --- a/AudioManagerDaemon/docx/13_properties.dox +++ b/AudioManagerDaemon/docx/13_properties.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/14_misc.dox b/AudioManagerDaemon/docx/14_misc.dox index 1623f95..eae0caf 100644 --- a/AudioManagerDaemon/docx/14_misc.dox +++ b/AudioManagerDaemon/docx/14_misc.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/14_x_mainloop.dox b/AudioManagerDaemon/docx/14_x_mainloop.dox index cf327bc..8f112bc 100644 --- a/AudioManagerDaemon/docx/14_x_mainloop.dox +++ b/AudioManagerDaemon/docx/14_x_mainloop.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/14_y_watchdog.dox b/AudioManagerDaemon/docx/14_y_watchdog.dox index 8e7fb49..a1facc5 100644 --- a/AudioManagerDaemon/docx/14_y_watchdog.dox +++ b/AudioManagerDaemon/docx/14_y_watchdog.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/14_z_nodeStateManagement.dox b/AudioManagerDaemon/docx/14_z_nodeStateManagement.dox new file mode 100644 index 0000000..2e9150e --- /dev/null +++ b/AudioManagerDaemon/docx/14_z_nodeStateManagement.dox @@ -0,0 +1,32 @@ + /* + * Copyright (C) 2012, BMW AG + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * \\author Christian Linke (christian.linke@bmw.de) + * + */ + +/*! +\page nsm The Node state management +\section The Node state managemer +The nodestatemanager is part of the GENIVI compliance. It basically handles startup and rundown of components in the IVI context.\n +For more information, please go to http://projects.genivi.org + +\section nsmiact The Interaction between the NodeStateManager and the AudioManager +It is the job of am::CAmNodeStateCommunicator to interact with the nodestatemanager via DBUS.\n +The ControllerPlugin can register by the NSM to be informed when a shutdown will occour. For this, the Audiomanager presents an DBus interface, defined in LifeCycleConsumer.xml that will be called from the NSM during a shutdown, +but only after the Controller registered by the NSM via am::CAmNodeStateCommunicator::nsmRegisterShutdownClient.\n +The controller has to answer this request during the timeout with am::CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete . +For more information, check am::CAmNodeStateCommunicator and http://projects.genivi.org + + + */ diff --git a/AudioManagerDaemon/docx/15_dlt_support.dox b/AudioManagerDaemon/docx/15_dlt_support.dox index 93be712..ca34896 100644 --- a/AudioManagerDaemon/docx/15_dlt_support.dox +++ b/AudioManagerDaemon/docx/15_dlt_support.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/15_x_eclipse.dox b/AudioManagerDaemon/docx/15_x_eclipse.dox index 1a06c64..95c8e9f 100644 --- a/AudioManagerDaemon/docx/15_x_eclipse.dox +++ b/AudioManagerDaemon/docx/15_x_eclipse.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ diff --git a/AudioManagerDaemon/docx/16_readme.dox b/AudioManagerDaemon/docx/16_readme.dox index 18a9002..9483a68 100644 --- a/AudioManagerDaemon/docx/16_readme.dox +++ b/AudioManagerDaemon/docx/16_readme.dox @@ -11,7 +11,7 @@ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * - * \author Christian Mueller (christian.ei.mueller@bmw.de) + * \\author Christian Linke (christian.linke@bmw.de) * */ /*! diff --git a/AudioManagerDaemon/docx/Doxyfile.in b/AudioManagerDaemon/docx/Doxyfile.in index 4c6f48a..a71d39d 100644 --- a/AudioManagerDaemon/docx/Doxyfile.in +++ b/AudioManagerDaemon/docx/Doxyfile.in @@ -78,9 +78,9 @@ LAYOUT_FILE = # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = YES -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_IF_DOC_ERROR = YES +WARNINGS = NO +WARN_IF_UNDOCUMENTED = NO +WARN_IF_DOC_ERROR = NO WARN_NO_PARAMDOC = NO WARN_FORMAT = "$file:$line: $text " WARN_LOGFILE = @@ -93,7 +93,7 @@ FILE_PATTERNS = *.h *.cpp *.dox RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = */test/* */Plugin*/* */build*/* +EXCLUDE_PATTERNS = */test/* */Plugin*/* */build*/* */cmake/* */exampleCode/* */googleMock/* */ProjectSpecific/* EXCLUDE_SYMBOLS = EXAMPLE_PATH = @CMAKE_SOURCE_DIR@ EXAMPLE_PATTERNS = diff --git a/AudioManagerDaemon/include/CAmCommandReceiver.h b/AudioManagerDaemon/include/CAmCommandReceiver.h index 0459614..8d5b4a6 100644 --- a/AudioManagerDaemon/include/CAmCommandReceiver.h +++ b/AudioManagerDaemon/include/CAmCommandReceiver.h @@ -60,9 +60,13 @@ public: am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const; am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const; am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const; + void confirmCommandReady(const uint16_t handle, const am_Error_e error); + void confirmCommandRundown(const uint16_t handle, const am_Error_e error); void getInterfaceVersion(std::string& version) const; - void confirmCommandReady(const uint16_t handle); - void confirmCommandRundown(const uint16_t handle); + am_Error_e getListSinkMainNotificationConfigurations(const am_sinkID_t sinkID, std::vector& listMainNotificationConfigurations) const; + am_Error_e getListSourceMainNotificationConfigurations(const am_sourceID_t sourceID, std::vector& listMainNotificationConfigurations) const; + am_Error_e setSinkMainNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration); + am_Error_e setSourceMainNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration); uint16_t getStartupHandle(); //!< returns a startup handle uint16_t getRundownHandle(); //!< returns a rundown handle @@ -81,6 +85,8 @@ private: std::vector mListRundownHandles; //!< list of handles that wait for a confirm bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0 bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0 + am_Error_e mLastErrorStartup; + am_Error_e mLastErrorRundown; }; } diff --git a/AudioManagerDaemon/include/CAmCommandSender.h b/AudioManagerDaemon/include/CAmCommandSender.h index 4605da4..cf41b77 100644 --- a/AudioManagerDaemon/include/CAmCommandSender.h +++ b/AudioManagerDaemon/include/CAmCommandSender.h @@ -65,6 +65,13 @@ public: void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time); void getInterfaceVersion(std::string& version) const; am_Error_e getListPlugins(std::vector& interfaces) const; + void cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties); + void cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties); + void cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s notification); + void cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s notification); + void cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration); + void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration); + #ifdef UNIT_TEST friend class IAmCommandBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces #endif diff --git a/AudioManagerDaemon/include/CAmControlReceiver.h b/AudioManagerDaemon/include/CAmControlReceiver.h index a911706..a7b2554 100644 --- a/AudioManagerDaemon/include/CAmControlReceiver.h +++ b/AudioManagerDaemon/include/CAmControlReceiver.h @@ -32,6 +32,7 @@ class CAmDatabaseHandler; class CAmRoutingSender; class CAmCommandSender; class CAmRouter; +class CAmNodeStateCommunicator; /** * This class is used to receive all commands from the control interface @@ -39,6 +40,7 @@ class CAmRouter; class CAmControlReceiver: public IAmControlReceive { public: + CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator); CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter); ~CAmControlReceiver(); am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList); @@ -109,10 +111,30 @@ public: void setCommandRundown(); void setRoutingReady(); void setRoutingRundown(); - void confirmControllerReady(); - void confirmControllerRundown(); + void confirmControllerReady(const am_Error_e error); + void confirmControllerRundown(const am_Error_e error); am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler); void getInterfaceVersion(std::string& version) const; + am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties); + am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties); + am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix); + am_Error_e setVolumes(am_Handle_s& handle, const std::vector listVolumes); + am_Error_e setSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration); + am_Error_e setSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s norificationConfiguration); + void sendSinkMainNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s notificationPayload); + void sendSourceMainNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s notificationPayload); + am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration); + am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration); + am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) ; + am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) ; + am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) ; + NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) ; + NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) ; + NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) ; + NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) ; + NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) ; + am_Error_e nsmGetInterfaceVersion(uint32_t& version) ; + NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) ; private: CAmDatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler @@ -120,6 +142,7 @@ private: CAmCommandSender* mCommandSender; //!< pointer to the command send interface CAmSocketHandler* mSocketHandler; //!< pointer to the socketHandler CAmRouter* mRouter; //!< pointer to the Router + CAmNodeStateCommunicator* mNodeStateCommunicator; }; } diff --git a/AudioManagerDaemon/include/CAmControlSender.h b/AudioManagerDaemon/include/CAmControlSender.h index 65db2c8..c62c7e8 100644 --- a/AudioManagerDaemon/include/CAmControlSender.h +++ b/AudioManagerDaemon/include/CAmControlSender.h @@ -27,6 +27,7 @@ #endif #include "control/IAmControlSend.h" +#include "shared/CAmSocketHandler.h" namespace am { @@ -37,11 +38,12 @@ namespace am class CAmControlSender { public: - CAmControlSender(std::string controlPluginFile); + CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler); + CAmControlSender(); ~CAmControlSender(); am_Error_e startupController(IAmControlReceive* controlreceiveinterface) ; void setControllerReady() ; - void setControllerRundown() ; + void setControllerRundown(const int16_t signal) ; am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ; am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ; am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ; @@ -81,24 +83,68 @@ public: void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ; void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ; am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats) ; + void confirmCommandReady(const am_Error_e error) ; + void confirmRoutingReady(const am_Error_e error) ; + void confirmCommandRundown(const am_Error_e error) ; + void confirmRoutingRundown(const am_Error_e error) ; void getInterfaceVersion(std::string& version) const ; - void confirmCommandReady() ; - void confirmRoutingReady() ; - void confirmCommandRundown() ; - void confirmRoutingRundown() ; - static void CallsetControllerRundown() + am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) ; + am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) ; + am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFromats, const std::vector convertionMatrix) ; + void cbAckSetVolume(const am_Handle_s handle, const std::vector listVolumes, const am_Error_e error) ; + void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ; + void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ; + void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) ; + void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) ; + am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) ; + am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) ; + void hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) ; + void hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) ; + void hookSystemSessionStateChanged(const std::string sessionName, const int32_t seatID, const NsmSessionState_e sessionStateID) ; + NsmErrorStatus_e hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) ; + + void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData); + bool checkerCallback(const sh_pollHandle_t handle, void* userData); + bool dispatcherCallback(const sh_pollHandle_t handle, void* userData); + + void setControllerRundownSafe(int16_t signal) + { + int16_t p(signal); + write(mPipe[1], &p, sizeof(p)); + } + + TAmShPollFired receiverCallbackT; + TAmShPollCheck checkerCallbackT; + TAmShPollDispatch dispatcherCallbackT; + + //todo: add getSessionstate, interface nachbilden von org.genivi.NodeStateManager.LifeCycleConsumer, antwort nach NSM + //chek interface version RegisterShutdownClient, UnRegisterShutdownClient, GetSessionState, GetApplicationMode, GetNodeState + + //we need this here to call the rundown from the signal handler. In case everything screwed up + static void CallsetControllerRundown(int16_t signal) + { + if (mInstance) + mInstance->setControllerRundown(signal); + } + + //this static callback is used from the signal handler. It is used when a normal rundown is assumed and the mainloop is used to call rundown. + static void CallsetControllerRundownSafe(int16_t signal) { if (mInstance) - mInstance->setControllerRundown(); + { + mInstance->setControllerRundownSafe(signal); + } } #ifdef UNIT_TEST friend class IAmControlBackdoor; #endif private: + int mPipe[2]; void* mlibHandle; //!< pointer to the loaded control plugin interface IAmControlSend* mController; //!< pointer to the ControlSend interface static CAmControlSender* mInstance; + int16_t mSignal; }; } diff --git a/AudioManagerDaemon/include/CAmDatabaseHandler.h b/AudioManagerDaemon/include/CAmDatabaseHandler.h index e8e44c2..50a5bc7 100644 --- a/AudioManagerDaemon/include/CAmDatabaseHandler.h +++ b/AudioManagerDaemon/include/CAmDatabaseHandler.h @@ -136,6 +136,15 @@ public: am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID); am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID); am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID); + am_Error_e changeSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties); + am_Error_e changeSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties); + am_Error_e getListSinkMainNotificationConfigurations(const am_sinkID_t sinkID, std::vector& listMainNotificationConfigurations); + am_Error_e getListSourceMainNotificationConfigurations(const am_sourceID_t sourceID, std::vector& listMainNotificationConfigurations); + am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration); + am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration); + am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix); + am_Error_e changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID,const am_NotificationConfiguration_s notificationConfiguration); + am_Error_e changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID,const am_NotificationConfiguration_s notificationConfiguration); bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const; bool existcrossFader(const am_crossfaderID_t crossfaderID) const; diff --git a/AudioManagerDaemon/include/CAmDatabaseObserver.h b/AudioManagerDaemon/include/CAmDatabaseObserver.h index 9d89ef8..e3a016d 100644 --- a/AudioManagerDaemon/include/CAmDatabaseObserver.h +++ b/AudioManagerDaemon/include/CAmDatabaseObserver.h @@ -66,6 +66,10 @@ public: void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState); void systemPropertyChanged(const am_SystemProperty_s& SystemProperty); void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time); + void sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties, const bool visible); + void sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties, const bool visible); + void sinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration); + void sourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration); private: CAmCommandSender *mCommandSender; //!< pointer to the comandSender diff --git a/AudioManagerDaemon/include/CAmNodeStateCommunicator.h b/AudioManagerDaemon/include/CAmNodeStateCommunicator.h new file mode 100644 index 0000000..dfc6689 --- /dev/null +++ b/AudioManagerDaemon/include/CAmNodeStateCommunicator.h @@ -0,0 +1,72 @@ +/** + * Copyright (C) 2012, BMW AG + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Christian Linke, christian.linke@bmw.de BMW 2012 + * + * \file CAmNodeStateCommunicator.h + * For further information see http://www.genivi.org/. + * + */ +#ifndef CAMNODESTATECOMMUNICATOR_H_ +#define CAMNODESTATECOMMUNICATOR_H_ + +#include "shared/CAmDbusWrapper.h" +#include "NodeStateManager.h" + +namespace am +{ + +class CAmControlSender; + +/** communicates with the NSM + * The CAmNodeStateCommunicator communicates with the NodeStateManager via Dbus. Only works, if CAmDBusWrapper is enabled. + * The CAmNodeStateCommunicator is triggered via CAmControlReceiver, so you can communicate from the ControllerPlugin with it. + * Most if the interfaces are passive, so you get the information you need via retrieving it. If you need to register the AudioManager + * as LifeCycleConsumer, you need to call CAmNodeStateCommunicator::nsmRegisterShutdownClient which can be undone with CAmNodeStateCommunicator::nsmUnRegisterShutdownClient. + * After you have registered, you will get hookSystemLifecycleRequest on the ControlSendInterface of the controller. + * You should answer this within your set timeout with CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete. + */ +class CAmNodeStateCommunicator +{ +public: + CAmNodeStateCommunicator(CAmDbusWrapper* iDbusWrapper); + virtual ~CAmNodeStateCommunicator(); + am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) ; + am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) ; + am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) ; + NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) ; + NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) ; + NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) ; + NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) ; + NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) ; + am_Error_e nsmGetInterfaceVersion(uint32_t& version) ; + NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) ; + + void registerControlSender(CAmControlSender* iControlSender); + static DBusHandlerResult receiveCallback(DBusConnection *conn, DBusMessage *msg, void *user_data); + static DBusHandlerResult signalCallback(DBusConnection *conn, DBusMessage *msg, void *user_data); + + +private: + void sendIntrospection(DBusConnection* conn, DBusMessage* msg); + void sendMessage(DBusMessage* message, DBusMessage* origMessage); + DBusHandlerResult receiveCallbackDelegate(DBusConnection *conn, DBusMessage *msg); + am_Error_e readIntegerProperty(const std::string property, int32_t &value); + CAmDbusWrapper* mpDbusWrapper; + CAmControlSender* mpControlSender; + DBusConnection* mpDBusConnection; +}; + +} /* namespace am */ +#endif /* CAMNODESTATECOMMUNICATOR_H_ */ diff --git a/AudioManagerDaemon/include/CAmRoutingReceiver.h b/AudioManagerDaemon/include/CAmRoutingReceiver.h index ca2a4b4..3cb1225 100644 --- a/AudioManagerDaemon/include/CAmRoutingReceiver.h +++ b/AudioManagerDaemon/include/CAmRoutingReceiver.h @@ -79,8 +79,16 @@ public: am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const; am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const; void getInterfaceVersion(std::string& version) const; - void confirmRoutingReady(const uint16_t handle); - void confirmRoutingRundown(const uint16_t handle); + void confirmRoutingReady(const uint16_t handle, const am_Error_e error); + void confirmRoutingRundown(const uint16_t handle, const am_Error_e error); + am_Error_e updateGateway(const am_gatewayID_t gatewayID, std::vector listSourceFormats, const std::vector listSinkFormats, std::vector convertionMatrix); + am_Error_e updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties); + am_Error_e updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, std::vector listSoundProperties, std::vector listConnectionFormats, const std::vector listMainSoundProperties); + void ackSetVolumes(const am_Handle_s handle, const std::vector listvolumes, const am_Error_e error); + void ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error); + void ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ; + void hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) ; + void hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) ; uint16_t getStartupHandle(); //!< returns a startup handle uint16_t getRundownHandle(); //!< returns a rundown handle @@ -101,6 +109,9 @@ private: bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0 bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0 + am_Error_e mLastStartupError; + am_Error_e mLastRundownError; + }; } diff --git a/AudioManagerDaemon/include/CAmRoutingSender.h b/AudioManagerDaemon/include/CAmRoutingSender.h index 5f58689..ac3f9a2 100644 --- a/AudioManagerDaemon/include/CAmRoutingSender.h +++ b/AudioManagerDaemon/include/CAmRoutingSender.h @@ -72,6 +72,9 @@ public: am_Error_e getListHandles(std::vector & listHandles) const; am_Error_e getListPlugins(std::vector& interfaces) const; void getInterfaceVersion(std::string& version) const; + am_Error_e asyncSetVolumes(am_Handle_s& handle, const std::vector& listVolumes); + am_Error_e asyncSetSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration); + am_Error_e asyncSetSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration); struct InterfaceNamePairs //!< is used to pair interfaces with busnames { @@ -88,6 +91,7 @@ public: am_sourceID_t sourceID; am_crossfaderID_t crossfaderID; am_connectionID_t connectionID; + am_DataType_u volumeID; }; union @@ -97,6 +101,8 @@ public: am_volume_t volume; am_HotSink_e hotSink; std::vector* soundProperties; + std::vector* listVolumes; + am_NotificationConfiguration_s* notificationConfiguration; }; }; diff --git a/AudioManagerDaemon/src/CAmCommandReceiver.cpp b/AudioManagerDaemon/src/CAmCommandReceiver.cpp index c507d5f..f3fa3ef 100644 --- a/AudioManagerDaemon/src/CAmCommandReceiver.cpp +++ b/AudioManagerDaemon/src/CAmCommandReceiver.cpp @@ -39,7 +39,9 @@ CAmCommandReceiver::CAmCommandReceiver(CAmDatabaseHandler *iDatabaseHandler, CAm mListStartupHandles(), // mListRundownHandles(), // mWaitStartup(false), // - mWaitRundown(false) + mWaitRundown(false), + mLastErrorStartup(E_OK), // + mLastErrorRundown(E_OK) // { assert(mDatabaseHandler!=NULL); @@ -184,18 +186,22 @@ void CAmCommandReceiver::getInterfaceVersion(std::string & version) const version = CommandReceiveVersion; } -void CAmCommandReceiver::confirmCommandReady(const uint16_t handle) +void CAmCommandReceiver::confirmCommandReady(const uint16_t handle, const am_Error_e error) { + if (error !=E_OK) + mLastErrorStartup=error; mListStartupHandles.erase(std::remove(mListStartupHandles.begin(), mListStartupHandles.end(), handle), mListStartupHandles.end()); if (mWaitStartup && mListStartupHandles.empty()) - mControlSender->confirmCommandReady(); + mControlSender->confirmCommandReady(mLastErrorStartup); } -void CAmCommandReceiver::confirmCommandRundown(const uint16_t handle) +void CAmCommandReceiver::confirmCommandRundown(const uint16_t handle, const am_Error_e error) { + if (error !=E_OK) + mLastErrorRundown=error; mListRundownHandles.erase(std::remove(mListRundownHandles.begin(), mListRundownHandles.end(), handle), mListRundownHandles.end()); if (mWaitRundown && mListRundownHandles.empty()) - mControlSender->confirmCommandRundown(); + mControlSender->confirmCommandRundown(mLastErrorRundown); } uint16_t CAmCommandReceiver::getStartupHandle() @@ -215,11 +221,35 @@ uint16_t CAmCommandReceiver::getRundownHandle() void CAmCommandReceiver::waitOnStartup(bool startup) { mWaitStartup = startup; + mLastErrorStartup=E_OK; +} + +am_Error_e CAmCommandReceiver::getListSinkMainNotificationConfigurations(const am_sinkID_t sinkID, std::vector& listMainNotificationConfigurations) const +{ + return (mDatabaseHandler->getListSinkMainNotificationConfigurations(sinkID,listMainNotificationConfigurations)); +} + +am_Error_e CAmCommandReceiver::getListSourceMainNotificationConfigurations(const am_sourceID_t sourceID, std::vector& listMainNotificationConfigurations) const +{ + return (mDatabaseHandler->getListSourceMainNotificationConfigurations(sourceID,listMainNotificationConfigurations)); +} + +am_Error_e CAmCommandReceiver::setSinkMainNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + logInfo("CommandReceiver::setSinkMainNotificationConfiguration got called, sinkID=", sinkID, " notificationType=",mainNotificationConfiguration.notificationType, " parameter=", mainNotificationConfiguration.notificationParameter, "status=",mainNotificationConfiguration.notificationStatus); + return (mControlSender->hookUserSetMainSinkNotificationConfiguration(sinkID,mainNotificationConfiguration)); +} + +am_Error_e CAmCommandReceiver::setSourceMainNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + logInfo("CommandReceiver::setSourceMainNotificationConfiguration got called, sourceID=", sourceID, " notificationType=",mainNotificationConfiguration.notificationType, " parameter=", mainNotificationConfiguration.notificationParameter, "status=",mainNotificationConfiguration.notificationStatus); + return (mControlSender->hookUserSetMainSourceNotificationConfiguration(sourceID,mainNotificationConfiguration)); } void CAmCommandReceiver::waitOnRundown(bool rundown) { mWaitRundown = rundown; + mLastErrorStartup=E_OK; } } diff --git a/AudioManagerDaemon/src/CAmCommandSender.cpp b/AudioManagerDaemon/src/CAmCommandSender.cpp index 1494bc1..7ec2740 100644 --- a/AudioManagerDaemon/src/CAmCommandSender.cpp +++ b/AudioManagerDaemon/src/CAmCommandSender.cpp @@ -297,6 +297,36 @@ am_Error_e am::CAmCommandSender::getListPlugins(std::vector & inter return (E_OK); } +void CAmCommandSender::cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties) +{ + CALL_ALL_INTERFACES(cbSinkUpdated(sinkID,sinkClassID,listMainSoundProperties)); +} + +void CAmCommandSender::cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties) +{ + CALL_ALL_INTERFACES(cbSourceUpdated(sourceID,sourceClassID,listMainSoundProperties)); +} + +void CAmCommandSender::cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s notification) +{ + CALL_ALL_INTERFACES(cbSinkNotification(sinkID,notification)); +} + +void CAmCommandSender::cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s notification) +{ + CALL_ALL_INTERFACES(cbSourceNotification(sourceID,notification)); +} + +void CAmCommandSender::cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + CALL_ALL_INTERFACES(cbSinkMainNotificationConfigurationChanged(sinkID,mainNotificationConfiguration)); +} + +void CAmCommandSender::cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + CALL_ALL_INTERFACES(cbSourceMainNotificationConfigurationChanged(sourceID,mainNotificationConfiguration)); +} + void CAmCommandSender::unloadLibraries(void) { std::vector::iterator iterator = mListLibraryHandles.begin(); diff --git a/AudioManagerDaemon/src/CAmControlReceiver.cpp b/AudioManagerDaemon/src/CAmControlReceiver.cpp index f78a0f3..cfa9467 100644 --- a/AudioManagerDaemon/src/CAmControlReceiver.cpp +++ b/AudioManagerDaemon/src/CAmControlReceiver.cpp @@ -22,22 +22,42 @@ #include "CAmControlReceiver.h" #include #include +#include #include "config.h" #include "CAmDatabaseHandler.h" #include "CAmRoutingSender.h" #include "CAmCommandSender.h" #include "CAmRouter.h" +#include "CAmNodeStateCommunicator.h" #include "shared/CAmDltWrapper.h" #include "shared/CAmSocketHandler.h" + namespace am { +CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator) : + mDatabaseHandler(iDatabaseHandler), // + mRoutingSender(iRoutingSender), // + mCommandSender(iCommandSender), // + mSocketHandler(iSocketHandler), // + mRouter(iRouter), // + mNodeStateCommunicator(iNodeStateCommunicator) +{ + assert(mDatabaseHandler!=NULL); + assert(mRoutingSender!=NULL); + assert(mCommandSender!=NULL); + assert(mSocketHandler!=NULL); + assert(mRouter!=NULL); + assert(iNodeStateCommunicator!=NULL); +} + CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter) : mDatabaseHandler(iDatabaseHandler), // mRoutingSender(iRoutingSender), // mCommandSender(iCommandSender), // mSocketHandler(iSocketHandler), // - mRouter(iRouter) + mRouter(iRouter), // + mNodeStateCommunicator(NULL) { assert(mDatabaseHandler!=NULL); assert(mRoutingSender!=NULL); @@ -476,14 +496,26 @@ void CAmControlReceiver::setRoutingReady() mRoutingSender->setRoutingReady(); } -void CAmControlReceiver::confirmControllerReady() +void CAmControlReceiver::confirmControllerReady(const am_Error_e error) { //todo: one time implement here system interaction with NSM + if (error!=E_OK) + logError("CAmControlReceiver::confirmControllerReady controller reported error", error); } -void CAmControlReceiver::confirmControllerRundown() +void CAmControlReceiver::confirmControllerRundown(const am_Error_e error) { - logInfo ("CAmControlReceiver::confirmControllerRundown(), will exit now"); + if (error!=E_OK) + { + logError("CAmControlReceiver::confirmControllerRundown() exited with error ",error); + //we might be blocked here -> so lets better exit right away + throw std::runtime_error("controller Confirmed with error"); + } + + logInfo ("CAmControlReceiver::confirmControllerRundown(), will exit now"); + + //end the mainloop here... + mSocketHandler->exit_mainloop(); } am_Error_e CAmControlReceiver::getSocketHandler(CAmSocketHandler *& socketHandler) @@ -508,5 +540,136 @@ void CAmControlReceiver::getInterfaceVersion(std::string & version) const { version = ControlReceiveVersion; } + +am_Error_e CAmControlReceiver::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties) +{ + logInfo("CAmControlReceiver::changeSource was called, sourceID", sourceID); + return (mDatabaseHandler->changeSource(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties)); +} + +am_Error_e CAmControlReceiver::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties) +{ + logInfo("CAmControlReceiver::changeSink was called with sinkID", sinkID); + return (mDatabaseHandler->changeSink(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties)); +} + +am_Error_e CAmControlReceiver::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix) +{ + logInfo("CAmControlReceiver::changeGatewayDB was called with gatewayID", gatewayID); + return (mDatabaseHandler->changeGatewayDB(gatewayID,listSourceConnectionFormats,listSinkConnectionFormats,convertionMatrix)); +} + +am_Error_e CAmControlReceiver::setVolumes(am_Handle_s& handle, const std::vector listVolumes) +{ + logInfo("CAmControlReceiver::setVolumes got called"); + return (mRoutingSender->asyncSetVolumes(handle,listVolumes)); +} + +am_Error_e CAmControlReceiver::setSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) +{ + logInfo("CAmControlReceiver::setSinkNotificationConfiguration called, sinkID=",sinkID,"notificationConfiguration.notificationType=",notificationConfiguration.notificationType,"notificationConfiguration.notificationStatus",notificationConfiguration.notificationStatus,"notificationConfiguration.notificationParameter",notificationConfiguration.notificationParameter); + return (mRoutingSender->asyncSetSinkNotificationConfiguration(handle,sinkID,notificationConfiguration)); +} + +am_Error_e CAmControlReceiver::setSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) +{ + logInfo("CAmControlReceiver::setSourceNotificationConfiguration called, sourceID=",sourceID,"notificationConfiguration.notificationType=",notificationConfiguration.notificationType,"notificationConfiguration.notificationStatus",notificationConfiguration.notificationStatus,"notificationConfiguration.notificationParameter",notificationConfiguration.notificationParameter); + return (mRoutingSender->asyncSetSourceNotificationConfiguration(handle,sourceID,notificationConfiguration)); +} + +void CAmControlReceiver::sendSinkMainNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s notificationPayload) +{ + logInfo("CAmControlReceiver::sendSinkMainNotificationPayload called, sinkID=",sinkID,"type=",notificationPayload.notificationType,"value=",notificationPayload.notificationValue); + mCommandSender->cbSinkNotification(sinkID,notificationPayload); +} + +void CAmControlReceiver::sendSourceMainNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s notificationPayload) +{ + logInfo("CAmControlReceiver::sendSourceMainNotificationPayload called, sourceID=",sourceID,"type=",notificationPayload.notificationType,"value=",notificationPayload.notificationValue); + mCommandSender->cbSourceNotification(sourceID,notificationPayload); +} + +am_Error_e CAmControlReceiver::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + logInfo("CAmControlReceiver::changeMainSinkNotificationConfigurationDB was called with sinkID", sinkID); + return (mDatabaseHandler->changeMainSinkNotificationConfigurationDB(sinkID,mainNotificationConfiguration)); +} + +am_Error_e CAmControlReceiver::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + logInfo("CAmControlReceiver::changeMainSourceNotificationConfigurationDB was called with sourceID", sourceID); + return (mDatabaseHandler->changeMainSourceNotificationConfigurationDB(sourceID,mainNotificationConfiguration)); +} + +am_Error_e CAmControlReceiver::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) +{ + if (!mNodeStateCommunicator) + return (E_NON_EXISTENT); + return (mNodeStateCommunicator->nsmGetRestartReasonProperty(restartReason)); +} + +am_Error_e CAmControlReceiver::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) +{ + if (!mNodeStateCommunicator) + return (E_NON_EXISTENT); + return (mNodeStateCommunicator->nsmGetShutdownReasonProperty(ShutdownReason)); +} + +am_Error_e CAmControlReceiver::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) +{ + if (!mNodeStateCommunicator) + return (E_NON_EXISTENT); + return (mNodeStateCommunicator->nsmGetRunningReasonProperty(nsmRunningReason)); +} + +NsmErrorStatus_e CAmControlReceiver::nsmGetNodeState(NsmNodeState_e& nsmNodeState) +{ + if (!mNodeStateCommunicator) + return (NsmErrorStatus_Error); + return (mNodeStateCommunicator->nsmGetNodeState(nsmNodeState)); +} + +NsmErrorStatus_e CAmControlReceiver::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) +{ + if (!mNodeStateCommunicator) + return (NsmErrorStatus_Error); + return (mNodeStateCommunicator->nsmGetSessionState(sessionName,seatID,sessionState)); +} + +NsmErrorStatus_e CAmControlReceiver::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) +{ + if (!mNodeStateCommunicator) + return (NsmErrorStatus_Error); + return (mNodeStateCommunicator->nsmGetApplicationMode(applicationMode)); +} + +NsmErrorStatus_e CAmControlReceiver::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) +{ + if (!mNodeStateCommunicator) + return (NsmErrorStatus_Error); + return (mNodeStateCommunicator->nsmRegisterShutdownClient(shutdownMode,timeoutMs)); +} + +NsmErrorStatus_e CAmControlReceiver::nsmUnRegisterShutdownClient(const uint32_t shutdownMode) +{ + if (!mNodeStateCommunicator) + return (NsmErrorStatus_Error); + return (mNodeStateCommunicator->nsmUnRegisterShutdownClient(shutdownMode)); +} + +am_Error_e CAmControlReceiver::nsmGetInterfaceVersion(uint32_t& version) +{ + if (!mNodeStateCommunicator) + return (E_NON_EXISTENT); + return (mNodeStateCommunicator->nsmGetInterfaceVersion(version)); +} + +NsmErrorStatus_e CAmControlReceiver::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) +{ + if (!mNodeStateCommunicator) + return (NsmErrorStatus_Error); + return (mNodeStateCommunicator->nsmSendLifecycleRequestComplete(RequestId,status)); +} + } diff --git a/AudioManagerDaemon/src/CAmControlSender.cpp b/AudioManagerDaemon/src/CAmControlSender.cpp index 569e4c4..da2321e 100644 --- a/AudioManagerDaemon/src/CAmControlSender.cpp +++ b/AudioManagerDaemon/src/CAmControlSender.cpp @@ -36,14 +36,21 @@ namespace am CAmControlSender* CAmControlSender::mInstance=NULL; -CAmControlSender::CAmControlSender(std::string controlPluginFile) : +CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler) : + receiverCallbackT(this, &CAmControlSender::receiverCallback),// + checkerCallbackT(this, &CAmControlSender::checkerCallback),// + dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback), // + mPipe(), // mlibHandle(NULL), // - mController(NULL) + mController(NULL), // + mSignal(0) { + assert(sockethandler); std::ifstream isfile(controlPluginFile.c_str()); if (!isfile) { logError("ControlSender::ControlSender: Controller plugin not found:", controlPluginFile); + throw std::runtime_error("Could not find controller plugin!"); } else if (!controlPluginFile.empty()) { @@ -70,6 +77,18 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile) : { logError("ControlSender::ControlSender: No controller loaded !"); } + + //here we need a pipe to be able to call the rundown function out of the mainloop + if (pipe(mPipe) == -1) + { + logError("CAmControlSender could not create pipe!"); + } + + //add the pipe to the poll - nothing needs to be proccessed here we just need the pipe to trigger the ppoll + short event = 0; + sh_pollHandle_t handle; + event |= POLLIN; + sockethandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, handle); } CAmControlSender::~CAmControlSender() @@ -323,10 +342,11 @@ void CAmControlSender::setControllerReady() mController->setControllerReady(); } -void CAmControlSender::setControllerRundown() +void CAmControlSender::setControllerRundown(const int16_t signal) { assert(mController); - mController->setControllerRundown(); + logInfo("CAmControlSender::setControllerRundown received, signal=",signal); + mController->setControllerRundown(signal); } am_Error_e am::CAmControlSender::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector & listPrioConnectionFormats) @@ -340,27 +360,150 @@ void CAmControlSender::getInterfaceVersion(std::string & version) const version = ControlSendVersion; } -void CAmControlSender::confirmCommandReady() +void CAmControlSender::confirmCommandReady(const am_Error_e error) +{ + assert(mController); + mController->confirmCommandReady(error); +} + +void CAmControlSender::confirmRoutingReady(const am_Error_e error) +{ + assert(mController); + mController->confirmRoutingReady(error); +} + +void CAmControlSender::confirmCommandRundown(const am_Error_e error) +{ + assert(mController); + mController->confirmCommandRundown(error); +} + +void CAmControlSender::confirmRoutingRundown(const am_Error_e error) +{ + assert(mController); + mController->confirmRoutingRundown(error); +} + +void CAmControlSender::hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) +{ + assert(mController); + mController->hookSystemNodeStateChanged(NodeStateId); +} + +void CAmControlSender::hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) { assert(mController); - mController->confirmCommandReady(); + mController->hookSystemNodeApplicationModeChanged(ApplicationModeId); } -void CAmControlSender::confirmRoutingReady() +am_Error_e CAmControlSender::hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) { assert(mController); - mController->confirmRoutingReady(); + return (mController->hookSystemUpdateSink(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties)); } -void CAmControlSender::confirmCommandRundown() +am_Error_e CAmControlSender::hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) { assert(mController); - mController->confirmCommandRundown(); + return (mController->hookSystemUpdateSource(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties)); } -void CAmControlSender::confirmRoutingRundown() +am_Error_e CAmControlSender::hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFromats, const std::vector convertionMatrix) { assert(mController); - mController->confirmRoutingRundown(); + return (mController->hookSystemUpdateGateway(gatewayID,listSourceConnectionFormats,listSinkConnectionFromats,convertionMatrix)); } + +void CAmControlSender::cbAckSetVolume(const am_Handle_s handle, const std::vector listVolumes, const am_Error_e error) +{ + assert(mController); + mController->cbAckSetVolume(handle,listVolumes,error); +} + +void CAmControlSender::cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) +{ + assert(mController); + mController->cbAckSetSinkNotificationConfiguration(handle,error); +} + +void CAmControlSender::cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) +{ + assert(mController); + mController->cbAckSetSourceNotificationConfiguration(handle,error); +} + +void CAmControlSender::hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) +{ + assert(mController); + mController->hookSinkNotificationDataChanged(sinkID,payload); +} + +void CAmControlSender::hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) +{ + assert(mController); + mController->hookSourceNotificationDataChanged(sourceID,payload); +} + +am_Error_e CAmControlSender::hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) +{ + assert(mController); + return (mController->hookUserSetMainSinkNotificationConfiguration(sinkID,notificationConfiguration)); +} + +am_Error_e CAmControlSender::hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) +{ + assert(mController); + return (mController->hookUserSetMainSourceNotificationConfiguration(sourceID,notificationConfiguration)); +} + +void CAmControlSender::receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData) +{ + (void) handle; + (void) userData; + //get the signal number from the socket + read(pollfd.fd, &mSignal, sizeof(mSignal)); +} + +bool CAmControlSender::checkerCallback(const sh_pollHandle_t handle, void* userData) +{ + (void) handle; + (void) userData; + return (true); +} + +void CAmControlSender::hookSystemSessionStateChanged(const std::string sessionName, const int32_t seatID, const NsmSessionState_e sessionStateID) +{ + assert(mController); + mController->hookSystemSessionStateChanged(sessionName,seatID,sessionStateID); +} + +NsmErrorStatus_e CAmControlSender::hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) +{ + assert(mController); + return (mController->hookSystemLifecycleRequest(Request,RequestId)); +} + +/**for testing only contructor - do not use ! + * + */ +CAmControlSender::CAmControlSender() : + receiverCallbackT(this, &CAmControlSender::receiverCallback),// + checkerCallbackT(this, &CAmControlSender::checkerCallback),// + dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback), // + mPipe(), // + mlibHandle(NULL), // + mController(NULL), // + mSignal(0) +{ + logInfo("CAmControlSender was loaded in test mode!"); +} + +bool CAmControlSender::dispatcherCallback(const sh_pollHandle_t handle, void* userData) +{ + (void)handle; + (void)userData; + setControllerRundown(mSignal); + return (false); +} + } diff --git a/AudioManagerDaemon/src/CAmDatabaseHandler.cpp b/AudioManagerDaemon/src/CAmDatabaseHandler.cpp index 2e2fa7e..4e9e51e 100644 --- a/AudioManagerDaemon/src/CAmDatabaseHandler.cpp +++ b/AudioManagerDaemon/src/CAmDatabaseHandler.cpp @@ -427,6 +427,9 @@ am_Error_e CAmDatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID if (!this->sqQuery(command)) return (E_DATABASE_ERROR); command = "CREATE TABLE SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)"); + if (!this->sqQuery(command)) + return (E_DATABASE_ERROR); + command = "CREATE TABLE SinkNotificationConfiguration" + i2s(sinkID) + std::string("(notificationType INTEGER, notificationStatus INTEGER, notificationParameter INTEGER)"); if (!this->sqQuery(command)) return (E_DATABASE_ERROR); @@ -463,6 +466,24 @@ am_Error_e CAmDatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID MY_SQLITE_RESET(query) } + //Fill NotificationConfigurations + command = "INSERT INTO SinkNotificationConfiguration" + i2s(sinkID) + std::string("(notificationType,notificationStatus,notificationParameter) VALUES (?,?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator NotificationConfigurationIterator(sinkData.listNotificationConfigurations.begin()); + for (; NotificationConfigurationIterator < sinkData.listNotificationConfigurations.end(); ++NotificationConfigurationIterator) + { + MY_SQLITE_BIND_INT(query, 1, NotificationConfigurationIterator->notificationType) + MY_SQLITE_BIND_INT(query, 2, NotificationConfigurationIterator->notificationStatus) + MY_SQLITE_BIND_INT(query, 3, NotificationConfigurationIterator->notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::enterSinkDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + if (sinkData.visible == true) { command = "CREATE TABLE SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)"); @@ -486,6 +507,29 @@ am_Error_e CAmDatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID MY_SQLITE_RESET(query) } MY_SQLITE_FINALIZE(query) + + //now we got MainNotificationConfigurations as well + command = "CREATE TABLE SinkMainNotificationConfiguration" + i2s(sinkID) + std::string("(notificationType INTEGER, notificationStatus INTEGER, notificationParameter INTEGER)"); + if (!this->sqQuery(command)) + return (E_DATABASE_ERROR); + + command = "INSERT INTO SinkMainNotificationConfiguration" + i2s(sinkID) + std::string("(notificationType,notificationStatus,notificationParameter) VALUES (?,?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator mainNotificationConfigurationIterator(sinkData.listMainNotificationConfigurations.begin()); + for (; mainNotificationConfigurationIterator < sinkData.listMainNotificationConfigurations.end(); ++mainNotificationConfigurationIterator) + { + MY_SQLITE_BIND_INT(query, 1, mainNotificationConfigurationIterator->notificationType) + MY_SQLITE_BIND_INT(query, 2, mainNotificationConfigurationIterator->notificationStatus) + MY_SQLITE_BIND_INT(query, 3, mainNotificationConfigurationIterator->notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::enterSinkDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) } logInfo("DatabaseHandler::enterSinkDB entered new sink with name", sinkData.name, "domainID:", sinkData.domainID, "classID:", sinkData.sinkClassID, "volume:", sinkData.volume, "assigned ID:", sinkID); @@ -800,6 +844,9 @@ am_Error_e CAmDatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_ command = "CREATE TABLE SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)"); if (!this->sqQuery(command)) return (E_DATABASE_ERROR); + command = "CREATE TABLE SourceNotificationConfiguration" + i2s(sourceID) + std::string("(notificationType INTEGER, notificationStatus INTEGER, notificationParameter INTEGER)"); + if (!this->sqQuery(command)) + return (E_DATABASE_ERROR); //fill ConnectionFormats command = "INSERT INTO SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat) VALUES (?)"); @@ -835,7 +882,23 @@ am_Error_e CAmDatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_ MY_SQLITE_RESET(query) } - MY_SQLITE_FINALIZE(query) + //Fill NotificationConfigurations + command = "INSERT INTO SourceNotificationConfiguration" + i2s(sourceID) + std::string("(notificationType,notificationStatus,notificationParameter) VALUES (?,?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator NotificationConfigurationIterator(sourceData.listNotificationConfigurations.begin()); + for (; NotificationConfigurationIterator < sourceData.listNotificationConfigurations.end(); ++NotificationConfigurationIterator) + { + MY_SQLITE_BIND_INT(query, 1, NotificationConfigurationIterator->notificationType) + MY_SQLITE_BIND_INT(query, 2, NotificationConfigurationIterator->notificationStatus) + MY_SQLITE_BIND_INT(query, 3, NotificationConfigurationIterator->notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::enterSinkDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } if (sourceData.visible == true) { @@ -860,6 +923,29 @@ am_Error_e CAmDatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_ MY_SQLITE_RESET(query) } MY_SQLITE_FINALIZE(query) + + //now we got MainNotificationConfigurations as well + command = "CREATE TABLE SourceMainNotificationConfiguration" + i2s(sourceID) + std::string("(notificationType INTEGER, notificationStatus INTEGER, notificationParameter INTEGER)"); + if (!this->sqQuery(command)) + return (E_DATABASE_ERROR); + + command = "INSERT INTO SourceMainNotificationConfiguration" + i2s(sourceID) + std::string("(notificationType,notificationStatus,notificationParameter) VALUES (?,?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator mainNotificationConfigurationIterator(sourceData.listMainNotificationConfigurations.begin()); + for (; mainNotificationConfigurationIterator < sourceData.listMainNotificationConfigurations.end(); ++mainNotificationConfigurationIterator) + { + MY_SQLITE_BIND_INT(query, 1, mainNotificationConfigurationIterator->notificationType) + MY_SQLITE_BIND_INT(query, 2, mainNotificationConfigurationIterator->notificationStatus) + MY_SQLITE_BIND_INT(query, 3, mainNotificationConfigurationIterator->notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::enterSinkDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) } logInfo("DatabaseHandler::enterSourceDB entered new source with name", sourceData.name, "domainID:", sourceData.domainID, "classID:", sourceData.sourceClassID, "visible:", sourceData.visible, "assigned ID:", sourceID); @@ -1250,16 +1336,22 @@ am_Error_e CAmDatabaseHandler::removeSinkDB(const am_sinkID_t sinkID) std::string command1 = "DROP table SinkConnectionFormat" + i2s(sinkID); std::string command2 = "DROP table SinkSoundProperty" + i2s(sinkID); std::string command3 = "DROP table SinkMainSoundProperty" + i2s(sinkID); + std::string command4 = "DROP table SinkNotificationConfiguration" + i2s(sinkID); + std::string command5 = "DROP table SinkMainNotificationConfiguration" + i2s(sinkID); if (!sqQuery(command)) return (E_DATABASE_ERROR); if (!sqQuery(command1)) return (E_DATABASE_ERROR); if (!sqQuery(command2)) return (E_DATABASE_ERROR); + if (!sqQuery(command4)) + return (E_DATABASE_ERROR); if (visible) //only drop table if it ever existed { if (!sqQuery(command3)) return (E_DATABASE_ERROR); + if (!sqQuery(command5)) + return (E_DATABASE_ERROR); } logInfo("DatabaseHandler::removeSinkDB removed:", sinkID); @@ -2148,12 +2240,14 @@ am_Error_e CAmDatabaseHandler::getListConnections(std::vector & am_Error_e CAmDatabaseHandler::getListSinks(std::vector & listSinks) const { listSinks.clear(); - sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qMAinSoundProperty = NULL; + sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qNotificationConfiguration= NULL, *qMAinSoundProperty = NULL, *qMainNotificationConfiguration= NULL; int eCode = 0; am_Sink_s temp; am_ConnectionFormat_e tempConnectionFormat; am_SoundProperty_s tempSoundProperty; am_MainSoundProperty_s tempMainSoundProperty; + am_NotificationConfiguration_s tempNotificationConfiguration; + am_NotificationConfiguration_s tempMainNotificationConfiguration; std::string command = "SELECT name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0"; MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) @@ -2193,6 +2287,19 @@ am_Error_e CAmDatabaseHandler::getListSinks(std::vector & listSinks) MY_SQLITE_FINALIZE(qSoundProperty) + //read out notifications + std::string commandNotificationConfiguration = "SELECT notificationType, notificationStatus, notificationParameter FROM SinkNotificationConfiguration" + i2s(temp.sinkID); + MY_SQLITE_PREPARE_V2(mpDatabase, commandNotificationConfiguration.c_str(), -1, &qNotificationConfiguration, NULL) + while ((eCode = sqlite3_step(qNotificationConfiguration)) == SQLITE_ROW) + { + tempNotificationConfiguration.notificationType = static_cast (sqlite3_column_int(qNotificationConfiguration, 0)); + tempNotificationConfiguration.notificationStatus = static_cast (sqlite3_column_int(qNotificationConfiguration, 1)); + tempNotificationConfiguration.notificationParameter = static_cast (sqlite3_column_int(qNotificationConfiguration, 2)); + temp.listNotificationConfigurations.push_back(tempNotificationConfiguration); + } + + MY_SQLITE_FINALIZE(qNotificationConfiguration) + //read out MainSoundProperties if sink is visible if(temp.visible) { @@ -2206,6 +2313,19 @@ am_Error_e CAmDatabaseHandler::getListSinks(std::vector & listSinks) } MY_SQLITE_FINALIZE(qMAinSoundProperty) + + //and mainNotificationConfigurations + std::string commandMainNotificationConfiguration = "SELECT notificationType, notificationStatus, notificationParameter FROM SinkMainNotificationConfiguration" + i2s(temp.sinkID); + MY_SQLITE_PREPARE_V2(mpDatabase, commandMainNotificationConfiguration.c_str(), -1, &qMainNotificationConfiguration, NULL) + while ((eCode = sqlite3_step(qMainNotificationConfiguration)) == SQLITE_ROW) + { + tempMainNotificationConfiguration.notificationType = static_cast (sqlite3_column_int(qMainNotificationConfiguration, 0)); + tempMainNotificationConfiguration.notificationStatus = static_cast (sqlite3_column_int(qMainNotificationConfiguration, 1)); + tempMainNotificationConfiguration.notificationParameter = static_cast (sqlite3_column_int(qMainNotificationConfiguration, 2)); + temp.listMainNotificationConfigurations.push_back(tempMainNotificationConfiguration); + } + + MY_SQLITE_FINALIZE(qMainNotificationConfiguration) } listSinks.push_back(temp); @@ -4254,6 +4374,543 @@ am_Error_e am::CAmDatabaseHandler::peekSourceClassID(const std::string & name, a return (returnVal); } + +am_Error_e CAmDatabaseHandler::changeSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties) +{ + assert(sourceID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + am_sourceClass_t sourceClassOut(sourceClassID); + std::vector listMainSoundPropertiesOut(listMainSoundProperties); + + if (!existSource(sourceID)) + { + return (E_NON_EXISTENT); + } + + //check if sinkClass needs to be changed + if (sourceID!=0) + { + command = "UPDATE"+ std::string(SINK_TABLE)+ " SET sourceClassID=? WHERE sourceID=" + i2s(sourceID); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + MY_SQLITE_BIND_INT(query, 1, sourceClassID) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_FINALIZE(query); + } + + else //we need to read out the active one + { + command = "SELECT sourceClassID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 and sourceID=" + i2s(sourceID); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + + while ((eCode = sqlite3_step(query)) == SQLITE_ROW) + { + sourceClassOut = sqlite3_column_int(query, 0); + } + MY_SQLITE_FINALIZE(query) + } + + //check if soundProperties need to be updated + if (!listSoundProperties.empty()) + { + //first we drop the table + command = "DELETE from SourceSoundProperty" + i2s(sourceID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //then we'll have a new one + //Fill SinkSoundProperties + command = "INSERT INTO SourceSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator SoundPropertyIterator = listSoundProperties.begin(); + for (; SoundPropertyIterator < listSoundProperties.end(); ++SoundPropertyIterator) + { + MY_SQLITE_BIND_INT(query, 1, SoundPropertyIterator->type) + MY_SQLITE_BIND_INT(query, 2, SoundPropertyIterator->value) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + + //check if we have to update the list of connectionformats + if (!listConnectionFormats.empty()) + { + //first clear the table + command = "DELETE from SourceConnectionFormat" + i2s(sourceID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //fill ConnectionFormats + command = "INSERT INTO SourceConnectionFormat" + i2s(sourceID) + std::string("(soundFormat) VALUES (?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator connectionFormatIterator = listConnectionFormats.begin(); + for (; connectionFormatIterator < listConnectionFormats.end(); ++connectionFormatIterator) + { + MY_SQLITE_BIND_INT(query, 1, *connectionFormatIterator) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + + //then we need to check if we need to update the listMainSoundProperties + if (!listMainSoundProperties.empty() && sourceVisible(sourceID)) + { + command = "DELETE from SourceMainSoundProperty" + i2s(sourceID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //Fill MainSinkSoundProperties + command = "INSERT INTO SourceMainSoundProperty" + i2s(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator mainSoundPropertyIterator = listMainSoundProperties.begin(); + for (; mainSoundPropertyIterator < listMainSoundProperties.end(); ++mainSoundPropertyIterator) + { + MY_SQLITE_BIND_INT(query, 1, mainSoundPropertyIterator->type) + MY_SQLITE_BIND_INT(query, 2, mainSoundPropertyIterator->value) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + else //read out the properties + { + getListMainSourceSoundProperties(sourceID,listMainSoundPropertiesOut); + } + + logInfo("DatabaseHandler::changeSource changed changeSink of source:", sourceID); + + if (mpDatabaseObserver != NULL) + { + mpDatabaseObserver->sourceUpdated(sourceID,sourceClassOut,listMainSoundPropertiesOut,sourceVisible(sourceID)); + } + + return (E_OK); + +} + +am_Error_e CAmDatabaseHandler::changeSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties) +{ + assert(sinkID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + am_sinkClass_t sinkClassOut(sinkClassID); + std::vector listMainSoundPropertiesOut(listMainSoundProperties); + + if (!existSink(sinkID)) + { + return (E_NON_EXISTENT); + } + + //check if sinkClass needs to be changed + if (sinkClassID!=0) + { + command = "UPDATE"+ std::string(SINK_TABLE)+ " SET sinkClassID=? WHERE sinkID=" + i2s(sinkID); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + MY_SQLITE_BIND_INT(query, 1, sinkClassID) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_FINALIZE(query); + } + + else //we need to read out the active one + { + command = "SELECT sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 and sinkID=" + i2s(sinkID); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + + while ((eCode = sqlite3_step(query)) == SQLITE_ROW) + { + sinkClassOut = sqlite3_column_int(query, 0); + } + MY_SQLITE_FINALIZE(query) + } + + //check if soundProperties need to be updated + if (!listSoundProperties.empty()) + { + //first we drop the table + command = "DELETE from SinkSoundProperty" + i2s(sinkID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //then we'll have a new one + //Fill SinkSoundProperties + command = "INSERT INTO SinkSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator SoundPropertyIterator = listSoundProperties.begin(); + for (; SoundPropertyIterator < listSoundProperties.end(); ++SoundPropertyIterator) + { + MY_SQLITE_BIND_INT(query, 1, SoundPropertyIterator->type) + MY_SQLITE_BIND_INT(query, 2, SoundPropertyIterator->value) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + + //check if we have to update the list of connectionformats + if (!listConnectionFormats.empty()) + { + //first clear the table + command = "DELETE from SinkConnectionFormat" + i2s(sinkID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //fill ConnectionFormats + command = "INSERT INTO SinkConnectionFormat" + i2s(sinkID) + std::string("(soundFormat) VALUES (?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator connectionFormatIterator = listConnectionFormats.begin(); + for (; connectionFormatIterator < listConnectionFormats.end(); ++connectionFormatIterator) + { + MY_SQLITE_BIND_INT(query, 1, *connectionFormatIterator) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + + //then we need to check if we need to update the listMainSoundProperties + if (!listMainSoundProperties.empty() && sinkVisible(sinkID)) + { + command = "DELETE from SinkMainSoundProperty" + i2s(sinkID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //Fill MainSinkSoundProperties + command = "INSERT INTO SinkMainSoundProperty" + i2s(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator mainSoundPropertyIterator = listMainSoundProperties.begin(); + for (; mainSoundPropertyIterator < listMainSoundProperties.end(); ++mainSoundPropertyIterator) + { + MY_SQLITE_BIND_INT(query, 1, mainSoundPropertyIterator->type) + MY_SQLITE_BIND_INT(query, 2, mainSoundPropertyIterator->value) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeSink SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + else //read out the properties + { + getListMainSinkSoundProperties(sinkID,listMainSoundPropertiesOut); + } + + logInfo("DatabaseHandler::changeSink changed changeSink of sink:", sinkID); + + if (mpDatabaseObserver != NULL) + { + mpDatabaseObserver->sinkUpdated(sinkID,sinkClassOut,listMainSoundPropertiesOut,sinkVisible(sinkID)); + } + + return (E_OK); +} + +am_Error_e CAmDatabaseHandler::getListSinkMainNotificationConfigurations(const am_sinkID_t sinkID, std::vector& listMainNotificationConfigurations) +{ + assert(sinkID!=0); + if (!existSink(sinkID)) + return (E_DATABASE_ERROR); // todo: here we could change to non existen, but not shown in sequences + listMainNotificationConfigurations.clear(); + + sqlite3_stmt* query = NULL; + int eCode = 0; + am_NotificationConfiguration_s temp; + std::string command = "SELECT notificationType, notificationStatus, notificationParameter FROM SinkMainNotificationConfiguration" + i2s(sinkID); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + + while ((eCode = sqlite3_step(query)) == SQLITE_ROW) + { + temp.notificationType = static_cast(sqlite3_column_int(query, 0)); + temp.notificationStatus = static_cast(sqlite3_column_int(query, 1)); + temp.notificationParameter= static_cast(sqlite3_column_int(query, 2)); + listMainNotificationConfigurations.push_back(temp); + } + + if (eCode != SQLITE_DONE) + { + logError("DatabaseHandler::getListSinkMainNotificationConfigurations SQLITE error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + + MY_SQLITE_FINALIZE(query) + + return (E_OK); + +} + +am_Error_e CAmDatabaseHandler::getListSourceMainNotificationConfigurations(const am_sourceID_t sourceID, std::vector& listMainNotificationConfigurations) +{ + assert(sourceID!=0); + if (!existSource(sourceID)) + return (E_DATABASE_ERROR); // todo: here we could change to non existen, but not shown in sequences + listMainNotificationConfigurations.clear(); + + sqlite3_stmt* query = NULL; + int eCode = 0; + am_NotificationConfiguration_s temp; + std::string command = "SELECT notificationType, notificationStatus, notificationParameter FROM SourceMainNotificationConfiguration" + i2s(sourceID); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + + while ((eCode = sqlite3_step(query)) == SQLITE_ROW) + { + temp.notificationType = static_cast(sqlite3_column_int(query, 0)); + temp.notificationStatus = static_cast(sqlite3_column_int(query, 1)); + temp.notificationParameter= static_cast(sqlite3_column_int(query, 2)); + listMainNotificationConfigurations.push_back(temp); + } + + if (eCode != SQLITE_DONE) + { + logError("DatabaseHandler::getListSourceMainNotificationConfigurations SQLITE error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + + MY_SQLITE_FINALIZE(query) + + return (E_OK); +} + +am_Error_e CAmDatabaseHandler::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + assert(sinkID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + + if (!existSink(sinkID)) + { + return (E_NON_EXISTENT); + } + command = "UPDATE SinkMainNotificationConfiguration" + i2s(sinkID) + " SET notificationStatus=?, notificationParameter=? WHERE notificationType=" + i2s(mainNotificationConfiguration.notificationType); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + MY_SQLITE_BIND_INT(query, 1, mainNotificationConfiguration.notificationStatus) + MY_SQLITE_BIND_INT(query, 2, mainNotificationConfiguration.notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeMainSinkNotificationConfigurationDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_FINALIZE(query) + + logInfo("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", mainNotificationConfiguration.notificationType, "to status=", mainNotificationConfiguration.notificationStatus, "and parameter=",mainNotificationConfiguration.notificationParameter); + + if (mpDatabaseObserver) + mpDatabaseObserver->sinkMainNotificationConfigurationChanged(sinkID, mainNotificationConfiguration); + return (E_OK); +} + +am_Error_e CAmDatabaseHandler::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + assert(sourceID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + + if (!existSource(sourceID)) + { + return (E_NON_EXISTENT); + } + command = "UPDATE SourceMainNotificationConfiguration" + i2s(sourceID) + " SET notificationStatus=?, notificationParameter=? WHERE notificationType=" + i2s(mainNotificationConfiguration.notificationType); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + MY_SQLITE_BIND_INT(query, 1, mainNotificationConfiguration.notificationStatus) + MY_SQLITE_BIND_INT(query, 2, mainNotificationConfiguration.notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeMainSourceNotificationConfigurationDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_FINALIZE(query) + + logInfo("DatabaseHandler::changeMainSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", mainNotificationConfiguration.notificationType, "to status=", mainNotificationConfiguration.notificationStatus, "and parameter=",mainNotificationConfiguration.notificationParameter); + + if (mpDatabaseObserver) + mpDatabaseObserver->sourceMainNotificationConfigurationChanged(sourceID, mainNotificationConfiguration); + return (E_OK); +} + +am_Error_e CAmDatabaseHandler::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix) +{ + assert(gatewayID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + + if (!existGateway(gatewayID)) + { + return (E_NON_EXISTENT); + } + + if (!listSourceConnectionFormats.empty()) + { + //clear Database + command = "DELETE from GatewaySourceFormat" + i2s(gatewayID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + //fill ConnectionFormats + command = "INSERT INTO GatewaySourceFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator connectionFormatIterator = listSourceConnectionFormats.begin(); + for (; connectionFormatIterator < listSourceConnectionFormats.end(); ++connectionFormatIterator) + { + MY_SQLITE_BIND_INT(query, 1, *connectionFormatIterator) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::enterGatewayDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + + if (!listSinkConnectionFormats.empty()) + { + //clear Database + command = "DELETE from GatewaySinkFormat" + i2s(gatewayID); + if (!sqQuery(command)) + return (E_DATABASE_ERROR); + + command = "INSERT INTO GatewaySinkFormat" + i2s(gatewayID) + std::string("(soundFormat) VALUES (?)"); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + std::vector::const_iterator connectionFormatIterator = listSinkConnectionFormats.begin(); + for (; connectionFormatIterator < listSinkConnectionFormats.end(); ++connectionFormatIterator) + { + MY_SQLITE_BIND_INT(query, 1, *connectionFormatIterator) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::enterGatewayDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_RESET(query) + } + MY_SQLITE_FINALIZE(query) + } + + if (!convertionMatrix.empty()) + { + mListConnectionFormat.clear(); + mListConnectionFormat.insert(std::make_pair(gatewayID, convertionMatrix)); + } + + logInfo("DatabaseHandler::changeGatewayDB changed Gateway with ID", gatewayID); + + //todo: check if observer needs to be adopted. + return (E_OK); +} + +am_Error_e CAmDatabaseHandler::changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) +{ + assert(sinkID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + + if (!existSink(sinkID)) + { + return (E_NON_EXISTENT); + } + command = "UPDATE SinkNotificationConfiguration" + i2s(sinkID) + " SET notificationStatus=?, notificationParameter=? WHERE notificationType=" + i2s(notificationConfiguration.notificationType); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + MY_SQLITE_BIND_INT(query, 1, notificationConfiguration.notificationStatus) + MY_SQLITE_BIND_INT(query, 2, notificationConfiguration.notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeMainSinkNotificationConfigurationDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_FINALIZE(query) + + logInfo("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", notificationConfiguration.notificationType, "to status=", notificationConfiguration.notificationStatus, "and parameter=",notificationConfiguration.notificationParameter); + + //todo:: inform obsever here... + return (E_OK); +} + +am_Error_e CAmDatabaseHandler::changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) +{ + assert(sourceID!=0); + + sqlite3_stmt* query = NULL; + int eCode = 0; + std::string command; + + if (!existSource(sourceID)) + { + return (E_NON_EXISTENT); + } + command = "UPDATE SourceNotificationConfiguration" + i2s(sourceID) + " SET notificationStatus=?, notificationParameter=? WHERE notificationType=" + i2s(notificationConfiguration.notificationType); + MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL) + MY_SQLITE_BIND_INT(query, 1, notificationConfiguration.notificationStatus) + MY_SQLITE_BIND_INT(query, 2, notificationConfiguration.notificationParameter) + if ((eCode = sqlite3_step(query)) != SQLITE_DONE) + { + logError("DatabaseHandler::changeMainSourceNotificationConfigurationDB SQLITE Step error code:", eCode); + MY_SQLITE_FINALIZE(query) + return (E_DATABASE_ERROR); + } + MY_SQLITE_FINALIZE(query) + + logInfo("DatabaseHandler::changeSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", notificationConfiguration.notificationType, "to status=", notificationConfiguration.notificationStatus, "and parameter=",notificationConfiguration.notificationParameter); + + //todo:: implement observer function + return (E_OK); +} + void CAmDatabaseHandler::createTables() { for (uint16_t i = 0; i < sizeof(databaseTables) / sizeof(databaseTables[0]); i++) diff --git a/AudioManagerDaemon/src/CAmDatabaseObserver.cpp b/AudioManagerDaemon/src/CAmDatabaseObserver.cpp index 426f5d2..506ec01 100644 --- a/AudioManagerDaemon/src/CAmDatabaseObserver.cpp +++ b/AudioManagerDaemon/src/CAmDatabaseObserver.cpp @@ -202,4 +202,27 @@ void CAmDatabaseObserver::timingInformationChanged(const am_mainConnectionID_t m { mSerializer.asyncCall(mCommandSender, &CAmCommandSender::cbTimingInformationChanged, mainConnection, time); } + +void CAmDatabaseObserver::sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties, const bool visible) +{ + if (visible) + mSerializer.asyncCall >(mCommandSender, &CAmCommandSender::cbSinkUpdated, sinkID, sinkClassID, listMainSoundProperties); +} + +void CAmDatabaseObserver::sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties, const bool visible) +{ + if (visible) + mSerializer.asyncCall >(mCommandSender, &CAmCommandSender::cbSinkUpdated, sourceID, sourceClassID, listMainSoundProperties); +} + +void CAmDatabaseObserver::sinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + mSerializer.asyncCall (mCommandSender, &CAmCommandSender::cbSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration); +} + +void CAmDatabaseObserver::sourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + mSerializer.asyncCall(mCommandSender, &CAmCommandSender::cbSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration); +} + } diff --git a/AudioManagerDaemon/src/CAmDbusWrapper.cpp b/AudioManagerDaemon/src/CAmDbusWrapper.cpp index 23fc27e..89c6122 100644 --- a/AudioManagerDaemon/src/CAmDbusWrapper.cpp +++ b/AudioManagerDaemon/src/CAmDbusWrapper.cpp @@ -302,7 +302,6 @@ void CAmDbusWrapper::toogleWatchDelegate(DBusWatch *watch, void *userData) iterator = mMapHandleWatch.find(watch); if (iterator != mMapHandleWatch.end()) mpSocketHandler->updateEventFlags(iterator->second, event); - logInfo("DBusWrapper::toogleWatchDelegate watch was toggeled"); } dbus_bool_t CAmDbusWrapper::addTimeout(DBusTimeout *timeout, void* userData) @@ -337,7 +336,6 @@ dbus_bool_t CAmDbusWrapper::addTimeoutDelegate(DBusTimeout *timeout, void* userD //save timeout in Socket context userData = timeout; - logInfo("DBusWrapper::addTimeoutDelegate a timeout was added, timeout",localTimeout," handle ", *handle); return (true); } @@ -366,8 +364,7 @@ void CAmDbusWrapper::removeTimeoutDelegate(DBusTimeout *timeout, void* userData) } } delete handle; - logInfo("DBusWrapper::removeTimeoutDelegate a timeout was removed"); -} + } void CAmDbusWrapper::toggleTimeout(DBusTimeout *timeout, void* userData) { @@ -446,12 +443,10 @@ void CAmDbusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void* userData) { mpSocketHandler->stopTimer(*handle); } - logInfo("DBusWrapper::toggleTimeoutDelegate was called"); } void CAmDbusWrapper::dbusTimerCallback(sh_timerHandle_t handle, void *userData) { - logInfo("DBusWrapper::dbusTimerCallback was called"); assert(userData!=NULL); if (dbus_timeout_get_enabled((DBusTimeout*) userData)) { diff --git a/AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp b/AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp new file mode 100644 index 0000000..ce6fd62 --- /dev/null +++ b/AudioManagerDaemon/src/CAmNodeStateCommunicator.cpp @@ -0,0 +1,763 @@ +/** + * Copyright (C) 2012, BMW AG + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Christian Linke, christian.linke@bmw.de BMW 2012 + * + * \file CAmNodeStateCommunicator.cpp + * For further information see http://www.genivi.org/. + * + */ + +#include "CAmNodeStateCommunicator.h" +#include +#include +#include +#include +#include "CAmControlSender.h" +#include "shared/CAmDbusWrapper.h" +#include "shared/CAmDltWrapper.h" +#include "config.h" + +namespace am +{ + +static DBusObjectPathVTable gObjectPathVTable; + +CAmNodeStateCommunicator::CAmNodeStateCommunicator(CAmDbusWrapper* iDbusWrapper) : + mpDbusWrapper(iDbusWrapper), // + mpControlSender(NULL), // + mpDBusConnection(NULL) +{ + assert(mpDbusWrapper); + logInfo("CAmNodeStateCommunicator::CAmNodeStateCommunicator started"); + + //save the DBusConnection + mpDbusWrapper->getDBusConnection(mpDBusConnection); + assert(mpDBusConnection!=NULL); + + //register the path and the callback for receiving messages + std::string path("LifeCycleConsumer"); + gObjectPathVTable.message_function=CAmNodeStateCommunicator::receiveCallback; + mpDbusWrapper->registerCallback(&gObjectPathVTable, path, this); + + //now we need to make sure we catch the signals from the NSM: + dbus_bus_add_match(mpDBusConnection, "type=\'signal\',path=\'/org/genivi/NodeStateManager\'", NULL); + if (!dbus_connection_add_filter(mpDBusConnection, CAmNodeStateCommunicator::signalCallback, this, NULL)) + { + logError("CAmNodeStateCommunicator::CAmNodeStateCommunicator not enought memory!"); + throw std::runtime_error("CAmNodeStateCommunicator::CAmNodeStateCommunicator not enought memory!"); + } + dbus_connection_flush(mpDBusConnection); +} + +CAmNodeStateCommunicator::~CAmNodeStateCommunicator() +{} + +/** retrieves the actual restartReason + * + * @param restartReason + * @return E_OK on success + */ +am_Error_e CAmNodeStateCommunicator::nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) +{ + int32_t answer(0); + am_Error_e error=readIntegerProperty("RestartReason",answer); + restartReason=static_cast(answer); + return(error); +} + +/** retrieves the actual shutdownreason + * + * @param ShutdownReason + * @return E_OK on success + */ +am_Error_e CAmNodeStateCommunicator::nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) +{ + int32_t answer(0); + am_Error_e error=readIntegerProperty("ShutdownReason",answer); + ShutdownReason=static_cast(answer); + return(error); +} + +/** retrieves the actual runnuing reason + * + * @param nsmRunningReason + * @return E_OK on success + */ +am_Error_e CAmNodeStateCommunicator::nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) +{ + int32_t answer(0); + am_Error_e error=readIntegerProperty("WakeUpReason",answer); + nsmRunningReason=static_cast(answer); + return(error); +} + +/** gets the node state + * + * @param nsmNodeState + * @return NsmErrorStatus_Ok on success + */ +NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetNodeState(NsmNodeState_e& nsmNodeState) +{ + DBusError error; + dbus_error_init(&error); + + uint32_t nodeStateID; + uint32_t returnedError; + + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetNodeState"); + + if (!message) + { + logError("CAmNodeStateCommunicator::nsmGetNodeState dbus error:", error.message); + return (NsmErrorStatus_Dbus); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + if (!reply) + { + logError("CAmNodeStateCommunicator::nsmGetNodeState failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + + if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &nodeStateID, DBUS_TYPE_INT32, &returnedError, DBUS_TYPE_INVALID)) + return (NsmErrorStatus_Dbus); + + dbus_message_unref(reply); + + nsmNodeState=static_cast(nodeStateID); + return (static_cast(returnedError)); +} + +/** gets the session state for a session and seatID + * + * @param sessionName the name of the session + * @param seatID the seatID + * @param sessionState + * @return NsmErrorStatus_Ok on success + */ +NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) +{ + DBusError error; + dbus_error_init(&error); + DBusMessageIter iter; + + uint32_t returnedError; + int32_t BsessionState(0); + + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetSessionState"); + + if (!message) + { + logError("CAmNodeStateCommunicator::nsmGetSessionState dbus error:", error.message); + return (NsmErrorStatus_Dbus); + } + + dbus_message_iter_init_append(message, &iter); + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &sessionName)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &seatID)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + if (!reply) + { + logError("CAmNodeStateCommunicator::nsmGetSessionState failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + + if(!dbus_message_get_args(reply, &error, + DBUS_TYPE_INT32, &BsessionState, + DBUS_TYPE_INT32, &returnedError,DBUS_TYPE_INVALID)) + return (NsmErrorStatus_Dbus); + + dbus_message_unref(reply); + + sessionState=static_cast(BsessionState); + return (static_cast(returnedError)); +} + +/** gets the application mode + * + * @param applicationMode + * @return NsmErrorStatus_Ok on success + */ +NsmErrorStatus_e CAmNodeStateCommunicator::nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) +{ + DBusError error; + dbus_error_init(&error); + + uint32_t BapplicationMode(0),returnedError(0); + + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetApplicationMode"); + + if (!message) + { + logError("CAmNodeStateCommunicator::nsmGetApplicationMode dbus error:", error.message); + return (NsmErrorStatus_Dbus); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + if (!reply) + { + logError("CAmNodeStateCommunicator::nsmGetApplicationMode failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + + if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &BapplicationMode, DBUS_TYPE_INT32, &returnedError, DBUS_TYPE_INVALID)) + return (NsmErrorStatus_Dbus); + + dbus_message_unref(reply); + + applicationMode=static_cast(BapplicationMode); + return (static_cast(returnedError)); +} + +/** this function registers the AudioManager as shutdown client at the NSM + * for more information check the Nodestatemanager + * @param shutdownMode the shutdownmode you wish to set + * @param timeoutMs the timeout you need to have + * @return NsmErrorStatus_Ok on success + */ +NsmErrorStatus_e CAmNodeStateCommunicator::nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) +{ + DBusError error; + DBusMessageIter iter; + dbus_error_init(&error); + int16_t returnError(0); + std::string path = std::string(DBUS_SERVICE_OBJECT_PATH) + "/LifeCycleConsumer"; + const char* charPath = path.c_str(); + const char* service =DBUS_SERVICE_PREFIX; + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "RegisterShutdownClient"); + + if (!message) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient dbus error:", error.message); + return (NsmErrorStatus_Dbus); + } + dbus_message_iter_init_append(message, &iter); + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &charPath)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &shutdownMode)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &timeoutMs)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + dbus_message_unref(message); + + if (!reply) + { + logError( "CAmRoutingDbusSend::send failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + + if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &returnError,DBUS_TYPE_INVALID)) + { + logError( "CAmRoutingDbusSend::send failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + dbus_message_unref(reply); + + return (static_cast(returnError)); + +} + +/** this function unregisters the AudioManager as shutdown client at the NSM + * + * @param shutdownMode + * @return NsmErrorStatus_Ok on success + */ +NsmErrorStatus_e CAmNodeStateCommunicator::nsmUnRegisterShutdownClient(const uint32_t shutdownMode) +{ + DBusError error; + DBusMessageIter iter; + dbus_error_init(&error); + int16_t returnError(0); + std::string path = std::string(DBUS_SERVICE_OBJECT_PATH) + "/LifeCycleConsumer"; + const char* charPath = path.c_str(); + const char* service =DBUS_SERVICE_PREFIX; + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "UnRegisterShutdownClient"); + + if (!message) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient dbus error:", error.message); + return (NsmErrorStatus_Dbus); + } + dbus_message_iter_init_append(message, &iter); + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &service)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &charPath)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &shutdownMode)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient no more memory"); + return (NsmErrorStatus_Dbus); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + dbus_message_unref(message); + + if (!reply) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + + if(!dbus_message_get_args(reply, &error, DBUS_TYPE_INT32, &returnError, DBUS_TYPE_INVALID)) + { + logError( "CAmNodeStateCommunicator::nsmRegisterShutdownClient failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + dbus_message_unref(reply); + + return (static_cast(returnError)); +} + +/** returns the interface version + * + * @param version + * @return E_OK on success + */ +am_Error_e CAmNodeStateCommunicator::nsmGetInterfaceVersion(uint32_t& version) +{ + DBusError error; + dbus_error_init(&error); + + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "GetInterfaceVersion"); + + if (!message) + { + logError("CAmNodeStateCommunicator::nsmGetInterfaceVersion dbus error:", error.message); + return (E_UNKNOWN); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + + dbus_message_unref(message); + + if (!reply) + { + logError("CAmNodeStateCommunicator::nsmGetInterfaceVersion failed, dbus error", error.message); + return (E_UNKNOWN); + } + + if(!dbus_message_get_args(reply, &error, DBUS_TYPE_UINT32, &version, DBUS_TYPE_INVALID)) + { + logError("CAmNodeStateCommunicator::nsmGetInterfaceVersion failed, dbus error", error.message); + return (E_UNKNOWN); + } + + dbus_message_unref(reply); + + return (E_OK); +} + +/** sends out the Lifecycle request complete message + * + * @param RequestId + * @param status + * @return NsmErrorStatus_Ok on success + */ +NsmErrorStatus_e CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) +{ + DBusError error; + DBusMessageIter iter; + dbus_error_init(&error); + int16_t returnError(0); + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, NSM_INTERFACE, "LifecycleRequestComplete"); + + if (!message) + { + logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete dbus error:", error.message); + return (NsmErrorStatus_Dbus); + } + dbus_message_iter_init_append(message, &iter); + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_UINT32, &RequestId)) + { + logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete no more memory"); + return (NsmErrorStatus_Dbus); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32,&status)) + { + logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete no more memory"); + return (NsmErrorStatus_Dbus); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + dbus_message_unref(message); + + if (!reply) + { + logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + + if(!dbus_message_get_args(reply, &error,DBUS_TYPE_INT32, &returnError, DBUS_TYPE_INVALID)) + { + logError( "CAmNodeStateCommunicator::nsmSendLifecycleRequestComplete failed, dbus error", error.message); + return (NsmErrorStatus_Dbus); + } + dbus_message_unref(reply); + + return (static_cast(returnError)); +} + +void CAmNodeStateCommunicator::registerControlSender(CAmControlSender* iControlSender) +{ + assert(iControlSender); + mpControlSender=iControlSender; +} + +DBusHandlerResult CAmNodeStateCommunicator::receiveCallback(DBusConnection* conn, DBusMessage* msg, void* user_data) +{ + CAmNodeStateCommunicator* instance = static_cast(user_data); + assert(instance); + return (instance->receiveCallbackDelegate(conn,msg)); +} + +DBusHandlerResult CAmNodeStateCommunicator::receiveCallbackDelegate(DBusConnection* conn, DBusMessage* msg) +{ + if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) + { + sendIntrospection(conn, msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + else + { + DBusMessage * returnMessage; + dbus_uint16_t Request(0),RequestId(0); + //no introspection - ok. So we are only interested in out LifecycleRequest message... + std::string method(dbus_message_get_member(msg)); + if (method=="LifecycleRequest") + { + DBusMessageIter iter,replyIter; + if (!dbus_message_iter_init(msg, &iter)) + { + logError("CAmNodeStateCommunicator::receiveCallbackDelegate DBus Message has no arguments!"); + returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS, "DBUS Message has no arguments!"); + sendMessage(returnMessage,msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_UINT32) + { + logError("CAmNodeStateCommunicator::receiveCallbackDelegate DBus Message has invalid arguments!"); + returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS,"DBus argument is no uint16_t!"); + sendMessage(returnMessage,msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_get_basic(&iter, &Request); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_UINT32) + { + logError("CAmNodeStateCommunicator::receiveCallbackDelegate DBus Message has invalid arguments!"); + returnMessage = dbus_message_new_error(msg,DBUS_ERROR_INVALID_ARGS,"DBus argument is no uint16_t!"); + sendMessage(returnMessage,msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_get_basic(&iter, &RequestId); + + assert(mpControlSender); + NsmErrorStatus_e returnError = mpControlSender->hookSystemLifecycleRequest(static_cast(Request),static_cast(RequestId)); + + returnMessage = dbus_message_new_method_return(msg); + + if (returnMessage == NULL) + { + logError("CAmNodeStateCommunicator::receiveCallbackDelegate Cannot allocate DBus message!"); + returnMessage = dbus_message_new_error(msg,DBUS_ERROR_NO_MEMORY,"Cannot create reply!"); + sendMessage(returnMessage,msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_init_append(returnMessage, &replyIter); + + if (!dbus_message_iter_append_basic(&replyIter, DBUS_TYPE_INT32, &returnError)) + { + logError("CAmNodeStateCommunicator::receiveCallbackDelegate Cannot allocate DBus message!"); + returnMessage = dbus_message_new_error(msg,DBUS_ERROR_NO_MEMORY,"Cannot create reply!"); + } + sendMessage(returnMessage,msg); + return (DBUS_HANDLER_RESULT_HANDLED); + } + } + return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); +} + +void CAmNodeStateCommunicator::sendIntrospection(DBusConnection* conn, DBusMessage* msg) +{ + assert(conn != NULL); + assert(msg != NULL); + DBusMessage* reply; + DBusMessageIter args; + dbus_uint32_t serial = 0; + + // create a reply from the message + reply = dbus_message_new_method_return(msg); + std::string fullpath(NSM_INTROSPECTION_FILE); + std::ifstream in(fullpath.c_str(), std::ifstream::in); + if (!in) + { + logError("IAmCommandReceiverShadow::sendIntrospection could not load xml file ",fullpath); + throw std::runtime_error("IAmCommandReceiverShadow::sendIntrospection Could not load introspecton XML"); + } + std::string introspect((std::istreambuf_iterator(in)), std::istreambuf_iterator()); + const char* string = introspect.c_str(); + + // add the arguments to the reply + dbus_message_iter_init_append(reply, &args); + if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string)) + { + logError( "CAmNodeStateCommunicator::sendIntrospection DBUS handler Out Of Memory!"); + } + + // send the reply && flush the connection + if (!dbus_connection_send(conn, reply, &serial)) + { + logError( "CAmNodeStateCommunicator::sendIntrospection DBUS handler Out Of Memory!"); + } + dbus_connection_flush(conn); + + // free the reply + dbus_message_unref(reply); +} + +void CAmNodeStateCommunicator::sendMessage(DBusMessage* message, DBusMessage* origMessage) +{ + dbus_uint32_t serial = dbus_message_get_serial(origMessage); + + dbus_connection_send(mpDBusConnection, message, &serial); + dbus_connection_flush(mpDBusConnection); + dbus_message_unref(message); +} + +DBusHandlerResult CAmNodeStateCommunicator::signalCallback(DBusConnection* conn, DBusMessage* msg, void* user_data) +{ + (void) conn; + CAmNodeStateCommunicator* instance(static_cast(user_data)); + std::string interface = dbus_message_get_interface(msg); + std::string member = dbus_message_get_member(msg); + + if (interface=="org.genivi.NodeStateManager.Consumer") + { + if (member=="NodeState") + { + int32_t nodeState; + DBusMessageIter iter; + if (!dbus_message_iter_init(msg, &iter)) + { + logError("CAmNodeStateCommunicator::signalCallback NodeState DBus Message has no arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32) + { + logError("CAmNodeStateCommunicator::signalCallback NodeState DBus Message has invalid arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_get_basic(&iter, &nodeState); + + logInfo("CAmNodeStateCommunicator::signalCallback got signal NodeState, with nodeState",nodeState); + + assert(instance->mpControlSender); + instance->mpControlSender->hookSystemNodeStateChanged(static_cast(nodeState)); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + else if (member=="NodeApplicationMode") + { + int32_t nodeApplicationMode; + DBusMessageIter iter; + if (!dbus_message_iter_init(msg, &iter)) + { + logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has no arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32) + { + logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_get_basic(&iter, &nodeApplicationMode); + + logInfo("CAmNodeStateCommunicator::signalCallback got signal nodeApplicationMode, with applicationMode",nodeApplicationMode); + + assert(instance->mpControlSender); + instance->mpControlSender->hookSystemNodeApplicationModeChanged(static_cast(nodeApplicationMode)); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + else if (member=="SessionStateChanged") + { + std::string sessionName; + NsmSeat_e seatID; + NsmSessionState_e sessionState; + DBusMessageIter iter; + if (!dbus_message_iter_init(msg, &iter)) + { + logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has no arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_STRING) + { + logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + char * sessionNameChar; + dbus_message_iter_get_basic(&iter, &sessionNameChar); + sessionName=std::string(sessionNameChar); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32) + { + logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_get_basic(&iter, &seatID); + dbus_message_iter_next(&iter); + + if (dbus_message_iter_get_arg_type(&iter)!=DBUS_TYPE_INT32) + { + logError("CAmNodeStateCommunicator::signalCallback nodeApplicationMode DBus Message has invalid arguments!"); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + dbus_message_iter_get_basic(&iter, &sessionState); + + + logInfo("CAmNodeStateCommunicator::signalCallback got signal sessionStateChanged, with session",sessionName,"seatID=",seatID,"sessionState",sessionState); + + assert(instance->mpControlSender); + instance->mpControlSender->hookSystemSessionStateChanged(sessionName,seatID,sessionState); + return (DBUS_HANDLER_RESULT_HANDLED); + } + + else + { + return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); + } + } + else + { + return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); + } + printf("asdasdas\n"); + return (DBUS_HANDLER_RESULT_NOT_YET_HANDLED); +} + +am_Error_e CAmNodeStateCommunicator::readIntegerProperty(const std::string property, int32_t& value) +{ + DBusError error; + dbus_error_init(&error); + DBusMessageIter iter,iterVariant; + + DBusMessage * message = dbus_message_new_method_call(NSM_BUS_INTERFACE, NSM_PATH, "org.freedesktop.DBus.Properties", "Get"); + + if (!message) + { + logError("CAmNodeStateCommunicator::readIntegerProperty dbus error:", error.message); + return (E_UNKNOWN); + } + + + dbus_message_iter_init_append(message, &iter); + const char *interface=std::string(NSM_INTERFACE).c_str(); + const char *propertyChar=property.c_str(); + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &interface)) + { + logError("CAmNodeStateCommunicator::readIntegerProperty append error"); + return (E_UNKNOWN); + } + + if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &propertyChar)) + { + logError("CAmNodeStateCommunicator::readIntegerProperty append error"); + return (E_UNKNOWN); + } + + DBusMessage* reply(dbus_connection_send_with_reply_and_block(mpDBusConnection, message, -1, &error)); + if (!reply) + { + logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus error", error.message); + return (E_UNKNOWN); + } + + dbus_message_iter_init(reply,&iterVariant); + if (dbus_message_iter_get_arg_type (&iterVariant)!= DBUS_TYPE_VARIANT) + { + logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus return type wrong"); + return (E_UNKNOWN); + } + DBusMessageIter subiter; + dbus_message_iter_recurse (&iterVariant, &subiter); + if (dbus_message_iter_get_arg_type (&subiter)!= DBUS_TYPE_INT32) + { + logError("CAmNodeStateCommunicator::readIntegerProperty failed, dbus return type wrong"); + return (E_UNKNOWN); + } + + dbus_message_iter_get_basic(&subiter,&value); + dbus_message_unref(reply); + + return (E_OK); +} + +} /* namespace am */ diff --git a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp index f0821a9..f1f0e09 100644 --- a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp +++ b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp @@ -41,7 +41,9 @@ CAmRoutingReceiver::CAmRoutingReceiver(CAmDatabaseHandler *iDatabaseHandler, CAm mListRundownHandles(), // handleCount(0), // mWaitStartup(false), // - mWaitRundown(false) + mWaitRundown(false), // + mLastStartupError(E_OK), // + mLastRundownError(E_OK) // { assert(mpDatabaseHandler!=NULL); assert(mpRoutingSender!=NULL); @@ -59,7 +61,9 @@ CAmRoutingReceiver::CAmRoutingReceiver(CAmDatabaseHandler *iDatabaseHandler, CAm mListRundownHandles(), // handleCount(0), // mWaitStartup(false), // - mWaitRundown(false) + mWaitRundown(false), + mLastStartupError(E_OK), // + mLastRundownError(E_OK) // { assert(mpDatabaseHandler!=NULL); assert(mpRoutingSender!=NULL); @@ -345,18 +349,22 @@ void CAmRoutingReceiver::getInterfaceVersion(std::string & version) const version = RoutingReceiveVersion; } -void CAmRoutingReceiver::confirmRoutingReady(const uint16_t handle) +void CAmRoutingReceiver::confirmRoutingReady(const uint16_t handle, const am_Error_e error) { + if (error!=E_OK) + mLastStartupError=error; mListStartupHandles.erase(std::remove(mListStartupHandles.begin(), mListStartupHandles.end(), handle), mListStartupHandles.end()); if (mWaitStartup && mListStartupHandles.empty()) - mpControlSender->confirmRoutingReady(); + mpControlSender->confirmRoutingReady(mLastStartupError); } -void CAmRoutingReceiver::confirmRoutingRundown(const uint16_t handle) +void CAmRoutingReceiver::confirmRoutingRundown(const uint16_t handle, const am_Error_e error) { + if (error!=E_OK) + mLastRundownError=error; mListRundownHandles.erase(std::remove(mListRundownHandles.begin(), mListRundownHandles.end(), handle), mListRundownHandles.end()); if (mWaitRundown && mListRundownHandles.empty()) - mpControlSender->confirmRoutingRundown(); + mpControlSender->confirmRoutingRundown(mLastRundownError); } uint16_t am::CAmRoutingReceiver::getStartupHandle() @@ -376,11 +384,88 @@ uint16_t am::CAmRoutingReceiver::getRundownHandle() void am::CAmRoutingReceiver::waitOnStartup(bool startup) { mWaitStartup = startup; + mLastStartupError=E_OK; +} + +am_Error_e CAmRoutingReceiver::updateGateway(const am_gatewayID_t gatewayID, std::vector listSourceFormats, const std::vector listSinkFormats, std::vector convertionMatrix) +{ + return (mpControlSender->hookSystemUpdateGateway(gatewayID,listSourceFormats,listSinkFormats,convertionMatrix)); +} + +am_Error_e CAmRoutingReceiver::updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) +{ + return (mpControlSender->hookSystemUpdateSink(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties)); +} + +am_Error_e CAmRoutingReceiver::updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, std::vector listSoundProperties, std::vector listConnectionFormats, const std::vector listMainSoundProperties) +{ + return (mpControlSender->hookSystemUpdateSource(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties)); +} + +void CAmRoutingReceiver::ackSetVolumes(const am_Handle_s handle, const std::vector listvolumes, const am_Error_e error) +{ + CAmRoutingSender::am_handleData_c handleData = mpRoutingSender->returnHandleData(handle); + if (error == E_OK && handleData.volumeID.sink != 0) + { + std::vector::const_iterator iterator (listvolumes.begin()); + + for (;iterator!=listvolumes.end();++iterator) + { + if (iterator->volumeType==VT_SINK) + { + mpDatabaseHandler->changeSinkVolume(iterator->volumeID.sink,iterator->volume); + } + else if (iterator->volumeType==VT_SOURCE) + { + mpDatabaseHandler->changeSourceVolume(iterator->volumeID.source,iterator->volume); + } + } + + } + mpRoutingSender->removeHandle(handle); + mpControlSender->cbAckSetVolume(handle,listvolumes,error); +} + +void CAmRoutingReceiver::ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) +{ + CAmRoutingSender::am_handleData_c handleData = mpRoutingSender->returnHandleData(handle); + if (error == E_OK && handleData.sinkID != 0) + { + mpDatabaseHandler->changeSinkNotificationConfigurationDB(handleData.sinkID,*handleData.notificationConfiguration); + delete handleData.notificationConfiguration; + } + mpRoutingSender->removeHandle(handle); + mpControlSender->cbAckSetSinkNotificationConfiguration(handle,error); +} + +void CAmRoutingReceiver::ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) +{ + CAmRoutingSender::am_handleData_c handleData = mpRoutingSender->returnHandleData(handle); + if (error == E_OK && handleData.sourceID != 0) + { + mpDatabaseHandler->changeSourceNotificationConfigurationDB(handleData.sourceID,*handleData.notificationConfiguration); + delete handleData.notificationConfiguration; + } + mpRoutingSender->removeHandle(handle); + mpControlSender->cbAckSetSourceNotificationConfiguration(handle,error); +} + +void CAmRoutingReceiver::hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) +{ + logInfo("CAmRoutingReceiver::hookSinkNotificationDataChange received, sinkID=",sinkID,"notificationType=",payload.notificationType,"notificationValue=",payload.notificationValue); + mpControlSender->hookSinkNotificationDataChanged(sinkID,payload); +} + +void CAmRoutingReceiver::hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) +{ + logInfo("CAmRoutingReceiver::hookSourceNotificationDataChange received, sinkID=",sourceID,"notificationType=",payload.notificationType,"notificationValue=",payload.notificationValue); + mpControlSender->hookSourceNotificationDataChanged(sourceID,payload); } void am::CAmRoutingReceiver::waitOnRundown(bool rundown) { mWaitRundown = rundown; + mLastRundownError=E_OK; } am_Error_e CAmRoutingSender::removeConnectionLookup(const am_connectionID_t connectionID) diff --git a/AudioManagerDaemon/src/CAmRoutingSender.cpp b/AudioManagerDaemon/src/CAmRoutingSender.cpp index f45f918..57892c7 100644 --- a/AudioManagerDaemon/src/CAmRoutingSender.cpp +++ b/AudioManagerDaemon/src/CAmRoutingSender.cpp @@ -596,6 +596,78 @@ void CAmRoutingSender::setRoutingRundown() } } +am_Error_e CAmRoutingSender::asyncSetVolumes(am_Handle_s& handle, const std::vector& listVolumes) +{ + am_handleData_c handleData; + IAmRoutingSend* pRoutingInterface(NULL); + if (listVolumes.empty()) + return (E_NOT_POSSIBLE); + + //we need an interface so lets get either the sink or source ID from the first entry in the listVolumes + if (listVolumes[0].volumeType==VT_SINK) + { + am_sinkID_t sinkID=listVolumes[0].volumeID.sink; + SinkInterfaceMap::iterator iter = mMapSinkInterface.begin(); + iter = mMapSinkInterface.find(sinkID); + if(iter!=mMapSinkInterface.end()) + pRoutingInterface=iter->second; + else + return(E_NON_EXISTENT); + } + + else if (listVolumes[0].volumeType==VT_SOURCE) + { + am_sourceID_t sourceID=listVolumes[0].volumeID.source; + SourceInterfaceMap::iterator iter = mMapSourceInterface.begin(); + iter = mMapSourceInterface.find(sourceID); + if (iter!=mMapSourceInterface.end()) + pRoutingInterface=iter->second; + else + return(E_NON_EXISTENT); + } + else + return (E_NON_EXISTENT); + + handleData.volumeID=listVolumes[0].volumeID; + handleData.listVolumes= new std::vector(listVolumes); + handle = createHandle(handleData, H_SETVOLUMES); + + mMapHandleInterface.insert(std::make_pair(+ handle.handle, pRoutingInterface)); + return (pRoutingInterface->asyncSetVolumes(handle, listVolumes)); +} + +am_Error_e CAmRoutingSender::asyncSetSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) +{ + am_handleData_c handleData; + SinkInterfaceMap::iterator iter = mMapSinkInterface.begin(); + iter = mMapSinkInterface.find(sinkID); + if (iter != mMapSinkInterface.end()) + { + handleData.sinkID = sinkID; + handleData.notificationConfiguration = new am_NotificationConfiguration_s(notificationConfiguration); + handle = createHandle(handleData, H_SETSINKNOTIFICATION); + mMapHandleInterface.insert(std::make_pair(+ handle.handle, iter->second)); + return (iter->second->asyncSetSinkNotificationConfiguration(handle, sinkID,notificationConfiguration)); + } + return (E_NON_EXISTENT); +} + +am_Error_e CAmRoutingSender::asyncSetSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) +{ + am_handleData_c handleData; + SourceInterfaceMap::iterator iter = mMapSourceInterface.begin(); + iter = mMapSourceInterface.find(sourceID); + if (iter != mMapSourceInterface.end()) + { + handleData.sourceID = sourceID; + handleData.notificationConfiguration = new am_NotificationConfiguration_s(notificationConfiguration); + handle = createHandle(handleData, H_SETSOURCENOTIFICATION); + mMapHandleInterface.insert(std::make_pair(+ handle.handle, iter->second)); + return (iter->second->asyncSetSourceNotificationConfiguration(handle, sourceID,notificationConfiguration)); + } + return (E_NON_EXISTENT); +} + void CAmRoutingSender::unloadLibraries(void) { std::vector::iterator iterator = mListLibraryHandles.begin(); diff --git a/AudioManagerDaemon/src/CAmSocketHandler.cpp b/AudioManagerDaemon/src/CAmSocketHandler.cpp index f7c4ace..19d61c0 100644 --- a/AudioManagerDaemon/src/CAmSocketHandler.cpp +++ b/AudioManagerDaemon/src/CAmSocketHandler.cpp @@ -34,9 +34,9 @@ namespace am { -CAmSocketHandler* CAmSocketHandler::mInstance=NULL; - CAmSocketHandler::CAmSocketHandler() : + receiverCallbackT(this, &CAmSocketHandler::receiverCallback),// + checkerCallbackT(this, &CAmSocketHandler::checkerCallback),// mPipe(), mListPoll(), // mListTimer(), // @@ -44,12 +44,9 @@ CAmSocketHandler::CAmSocketHandler() : mLastInsertedHandle(0), // mLastInsertedPollHandle(0), // mRecreatePollfds(true), // - mStartTime(), // - receiverCallbackT(this, &CAmSocketHandler::receiverCallback),// - checkerCallbackT(this, &CAmSocketHandler::checkerCallback)// + mStartTime() // { gDispatchDone = 1; - mInstance=this; if (pipe(mPipe) == -1) { @@ -527,14 +524,6 @@ void CAmSocketHandler::exit_mainloop() write(mPipe[1], &p, sizeof(p)); } -void CAmSocketHandler::static_exit_mainloop() -{ - if (mInstance!=0) - { - mInstance->exit_mainloop(); - } -} - /** * is used to set the pointer for the ppoll command * @param buffertime diff --git a/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp b/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp index d820351..87f9659 100644 --- a/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp +++ b/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp @@ -1235,7 +1235,6 @@ void CAmTelnetMenuHelper::setSinkVolumeExec(std::queue& CmdQueue, i { am_volume_t volume = 0; am_sinkID_t sinkID = 0; - am_Handle_s handle; bool error = false; std::istringstream istream_sinkID(CmdQueue.front()); CmdQueue.pop(); diff --git a/AudioManagerDaemon/src/CAmWatchdog.cpp b/AudioManagerDaemon/src/CAmWatchdog.cpp index 15c7dcc..db34009 100755 --- a/AudioManagerDaemon/src/CAmWatchdog.cpp +++ b/AudioManagerDaemon/src/CAmWatchdog.cpp @@ -91,7 +91,6 @@ void CAmWatchdog::timerCallback(sh_timerHandle_t handle, void* userData) } mpCAmSocketHandler->restartTimer(handle); - logInfo("restarted watchdog "); } void CAmWatchdog::startWatchdog() diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp index 6b84ba3..51003cf 100755 --- a/AudioManagerDaemon/src/main.cpp +++ b/AudioManagerDaemon/src/main.cpp @@ -57,6 +57,7 @@ #include "CAmControlReceiver.h" #include "CAmDatabaseObserver.h" #include "CAmWatchdog.h" +#include "CAmNodeStateCommunicator.h" #include "shared/CAmDltWrapper.h" #include "shared/CAmSocketHandler.h" @@ -265,15 +266,32 @@ static void signalHandler(int sig, siginfo_t *siginfo, void *context) (void) siginfo; (void) context; logInfo("signal handler was called, signal",sig); - //todo: maually fire the mainloop - CAmControlSender::CallsetControllerRundown(); - //deinit the DLT - CAmDltWrapper* inst(getWrapper()); - inst->deinit(); + switch (sig) + { + /*ctl +c lets call direct controllerRundown, because we might be blocked at the moment. + But there is the risk of interrupting something important */ + case SIGINT: + CAmControlSender::CallsetControllerRundown(sig); + break; - CAmSocketHandler::static_exit_mainloop(); + /* huch- we are getting killed. Better take the fast but risky way: */ + case SIGQUIT: + CAmControlSender::CallsetControllerRundown(sig); + break; + + /* more friendly here assuming systemd wants to stop us, so we can use the mainloop */ + case SIGTERM: + CAmControlSender::CallsetControllerRundownSafe(sig); + break; + /* looks friendly, too, so lets take the long run */ + case SIGHUP: + CAmControlSender::CallsetControllerRundownSafe(sig); + break; + default: + break; + } } void mainProgram() @@ -283,6 +301,7 @@ void mainProgram() #ifdef WITH_DBUS_WRAPPER CAmDbusWrapper iDBusWrapper(&iSocketHandler,dbusWrapperType); + CAmNodeStateCommunicator iNodeStateCommunicator(&iDBusWrapper); #endif /*WITH_DBUS_WRAPPER */ #ifdef WITH_SYSTEMD_WATCHDOG @@ -292,19 +311,21 @@ void mainProgram() CAmDatabaseHandler iDatabaseHandler(databasePath); CAmRoutingSender iRoutingSender(listRoutingPluginDirs); CAmCommandSender iCommandSender(listCommandPluginDirs); - CAmControlSender iControlSender(controllerPlugin); + CAmControlSender iControlSender(controllerPlugin,&iSocketHandler); CAmRouter iRouter(&iDatabaseHandler, &iControlSender); #ifdef WITH_DBUS_WRAPPER CAmCommandReceiver iCommandReceiver(&iDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper); CAmRoutingReceiver iRoutingReceiver(&iDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper); - CAmControlReceiver iControlReceiver(&iDatabaseHandler, &iRoutingSender, &iCommandSender, &iSocketHandler, &iRouter); + CAmControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator); + iNodeStateCommunicator.registerControlSender(&iControlSender); #else /*WITH_DBUS_WRAPPER*/ CAmCommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler); CAmRoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler); CAmControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter); #endif /*WITH_DBUS_WRAPPER*/ + #ifdef WITH_TELNET CAmTelnetServer iTelnetServer(&iSocketHandler, &iCommandSender, &iCommandReceiver, &iRoutingSender, &iRoutingReceiver, &iControlSender, &iControlReceiver, &iDatabaseHandler, &iRouter, telnetport, maxConnections); CAmDatabaseObserver iObserver(&iCommandSender, &iRoutingSender, &iSocketHandler, &iTelnetServer); @@ -378,13 +399,18 @@ int main(int argc, char *argv[], char** envp) catch (std::exception& exc) { logError("The AudioManager ended by throwing the exception", exc.what()); - //todo: ergency exit here... call destructors etc... + std::cerr<<"The AudioManager ended by throwing an exception "<deinit(); + exit(0); } diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp index c4f71e1..b126efc 100644 --- a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp +++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp @@ -43,7 +43,7 @@ CAmControlInterfaceTest::CAmControlInterfaceTest() : pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // pControlInterfaceBackdoor(), // - pControlSender(std::string("")), // + pControlSender(), // pRouter(&pDatabaseHandler,&pControlSender), // pDatabaseObserver(&pCommandSender, &pRoutingSender, &pSocketHandler), // pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), // diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt index 8d4b2e9..6107389 100644 --- a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt @@ -54,6 +54,8 @@ file(GLOB CONTROL_INTERFACE_SRCS_CXX "../../src/CAmDltWrapper.cpp" "../../src/CAmSocketHandler.cpp" "../../src/CAmCommandReceiver.cpp" + "../../src/CAmNodeStateCommunicator.cpp" + "../../src/CAmDbusWrapper.cpp" "../CAmCommonFunctions.cpp" "*.cpp" ) diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp index a1b7e39..a5143ef 100644 --- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp +++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp @@ -45,7 +45,7 @@ CAmDatabaseHandlerTest::CAmDatabaseHandlerTest() : pMockInterface(), // pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // - pControlSender(""), // + pControlSender(), // pRouter(&pDatabaseHandler, &pControlSender), // pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), // pObserver(&pCommandSender,&pRoutingSender, &pSocketHandler) @@ -1915,6 +1915,285 @@ TEST_F(CAmDatabaseHandlerTest,enterSinksCorrect) ASSERT_EQ(true, equal); } +TEST_F(CAmDatabaseHandlerTest,enterNotificationConfigurationCorrect) +{ + am_Sink_s testSinkData; + pCF.createSink(testSinkData); + testSinkData.sinkID = 4; + am_sinkID_t sinkID; + std::vector listSinks; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + testSinkData.listNotificationConfigurations.push_back(notify); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks)) + << "ERROR: database error"; + + ASSERT_EQ(listSinks.begin()->listNotificationConfigurations.begin()->notificationParameter,notify.notificationParameter); + ASSERT_EQ(listSinks.begin()->listNotificationConfigurations.begin()->notificationStatus,notify.notificationStatus); + ASSERT_EQ(listSinks.begin()->listNotificationConfigurations.begin()->notificationType,notify.notificationType); +} + +TEST_F(CAmDatabaseHandlerTest,enterMainNotificationConfigurationCorrect) +{ + am_Sink_s testSinkData; + pCF.createSink(testSinkData); + testSinkData.sinkID = 4; + am_sinkID_t sinkID; + std::vector listSinks; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + + testSinkData.listMainNotificationConfigurations.push_back(notify); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks)) + << "ERROR: database error"; + + ASSERT_EQ(listSinks.begin()->listMainNotificationConfigurations.begin()->notificationParameter,notify.notificationParameter); + ASSERT_EQ(listSinks.begin()->listMainNotificationConfigurations.begin()->notificationStatus,notify.notificationStatus); + ASSERT_EQ(listSinks.begin()->listMainNotificationConfigurations.begin()->notificationType,notify.notificationType); +} + +TEST_F(CAmDatabaseHandlerTest,removeNotifications) +{ + am_Sink_s testSinkData; + pCF.createSink(testSinkData); + testSinkData.sinkID = 4; + am_sinkID_t sinkID; + std::vector listSinks; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + + testSinkData.listMainNotificationConfigurations.push_back(notify); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSinks(listSinks)) + << "ERROR: database error"; + + ASSERT_EQ(listSinks.begin()->listMainNotificationConfigurations.begin()->notificationParameter,notify.notificationParameter); + ASSERT_EQ(listSinks.begin()->listMainNotificationConfigurations.begin()->notificationStatus,notify.notificationStatus); + ASSERT_EQ(listSinks.begin()->listMainNotificationConfigurations.begin()->notificationType,notify.notificationType); + + //now we remove the sink + ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID)); +} + +TEST_F(CAmDatabaseHandlerTest,getMainNotificationsSink) +{ + am_Sink_s testSinkData; + pCF.createSink(testSinkData); + testSinkData.sinkID = 4; + am_sinkID_t sinkID; + std::vector listSinks; + std::vectorreturnList; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + + testSinkData.listMainNotificationConfigurations.push_back(notify); + + am_NotificationConfiguration_s notify1; + notify1.notificationType=NT_MAX; + notify1.notificationStatus=NS_PERIODIC; + notify1.notificationParameter=5; + + testSinkData.listMainNotificationConfigurations.push_back(notify1); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkMainNotificationConfigurations(sinkID,returnList)) + << "ERROR: database error"; + + ASSERT_EQ(returnList[0].notificationParameter,notify.notificationParameter); + ASSERT_EQ(returnList[0].notificationStatus,notify.notificationStatus); + ASSERT_EQ(returnList[0].notificationType,notify.notificationType); + + ASSERT_EQ(returnList[1].notificationParameter,notify1.notificationParameter); + ASSERT_EQ(returnList[1].notificationStatus,notify1.notificationStatus); + ASSERT_EQ(returnList[1].notificationType,notify1.notificationType); + +} + +TEST_F(CAmDatabaseHandlerTest,getMainNotificationsSources) +{ + am_Source_s testSourceData; + pCF.createSource(testSourceData); + testSourceData.sourceID = 4; + am_sourceID_t sourceID; + std::vector listSources; + std::vectorreturnList; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + + testSourceData.listMainNotificationConfigurations.push_back(notify); + + am_NotificationConfiguration_s notify1; + notify1.notificationType=NT_MAX; + notify1.notificationStatus=NS_PERIODIC; + notify1.notificationParameter=5; + + testSourceData.listMainNotificationConfigurations.push_back(notify1); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(testSourceData,sourceID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceMainNotificationConfigurations(sourceID,returnList)) + << "ERROR: database error"; + + ASSERT_EQ(returnList[0].notificationParameter,notify.notificationParameter); + ASSERT_EQ(returnList[0].notificationStatus,notify.notificationStatus); + ASSERT_EQ(returnList[0].notificationType,notify.notificationType); + + ASSERT_EQ(returnList[1].notificationParameter,notify1.notificationParameter); + ASSERT_EQ(returnList[1].notificationStatus,notify1.notificationStatus); + ASSERT_EQ(returnList[1].notificationType,notify1.notificationType); + +} + +TEST_F(CAmDatabaseHandlerTest,changeMainNotificationsSources) +{ + am_Source_s testSourceData; + pCF.createSource(testSourceData); + testSourceData.sourceID = 4; + am_sourceID_t sourceID; + std::vector listSources; + std::vectorreturnList,returnList1; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + + testSourceData.listMainNotificationConfigurations.push_back(notify); + + am_NotificationConfiguration_s notify1; + notify1.notificationType=NT_MAX; + notify1.notificationStatus=NS_PERIODIC; + notify1.notificationParameter=5; + + am_NotificationConfiguration_s notify2; + notify2.notificationType=NT_MAX; + notify2.notificationStatus=NS_CHANGE; + notify2.notificationParameter=10; + + testSourceData.listMainNotificationConfigurations.push_back(notify1); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(testSourceData,sourceID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceMainNotificationConfigurations(sourceID,returnList)) + << "ERROR: database error"; + + ASSERT_EQ(returnList[0].notificationParameter,notify.notificationParameter); + ASSERT_EQ(returnList[0].notificationStatus,notify.notificationStatus); + ASSERT_EQ(returnList[0].notificationType,notify.notificationType); + + ASSERT_EQ(returnList[1].notificationParameter,notify1.notificationParameter); + ASSERT_EQ(returnList[1].notificationStatus,notify1.notificationStatus); + ASSERT_EQ(returnList[1].notificationType,notify1.notificationType); + + //change a setting + ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSourceNotificationConfigurationDB(sourceID,notify2)); + + ASSERT_EQ(E_OK,pDatabaseHandler.getListSourceMainNotificationConfigurations(sourceID,returnList1)) + << "ERROR: database error"; + + ASSERT_EQ(returnList1[1].notificationParameter,notify2.notificationParameter); + ASSERT_EQ(returnList1[1].notificationStatus,notify2.notificationStatus); + ASSERT_EQ(returnList1[1].notificationType,notify2.notificationType); + +} + +TEST_F(CAmDatabaseHandlerTest,changeMainNotificationsSink) +{ + am_Sink_s testSinkData; + pCF.createSink(testSinkData); + testSinkData.sinkID = 4; + am_sinkID_t sinkID; + std::vector listSinks; + std::vectorreturnList,returnList1; + + am_NotificationConfiguration_s notify; + notify.notificationType=NT_UNKNOWN; + notify.notificationStatus=NS_CHANGE; + notify.notificationParameter=25; + + testSinkData.listMainNotificationConfigurations.push_back(notify); + + am_NotificationConfiguration_s notify1; + notify1.notificationType=NT_MAX; + notify1.notificationStatus=NS_PERIODIC; + notify1.notificationParameter=5; + + am_NotificationConfiguration_s notify2; + notify2.notificationType=NT_MAX; + notify2.notificationStatus=NS_CHANGE; + notify2.notificationParameter=27; + + testSinkData.listMainNotificationConfigurations.push_back(notify1); + + //enter the sink in the database + ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID)) + << "ERROR: database error"; + + //read it again + ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkMainNotificationConfigurations(sinkID,returnList)) + << "ERROR: database error"; + + ASSERT_EQ(returnList[0].notificationParameter,notify.notificationParameter); + ASSERT_EQ(returnList[0].notificationStatus,notify.notificationStatus); + ASSERT_EQ(returnList[0].notificationType,notify.notificationType); + + ASSERT_EQ(returnList[1].notificationParameter,notify1.notificationParameter); + ASSERT_EQ(returnList[1].notificationStatus,notify1.notificationStatus); + ASSERT_EQ(returnList[1].notificationType,notify1.notificationType); + + ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSinkNotificationConfigurationDB(sinkID,notify2)) + << "ERROR: database error"; + + ASSERT_EQ(E_OK,pDatabaseHandler.getListSinkMainNotificationConfigurations(sinkID,returnList1)) + << "ERROR: database error"; + + ASSERT_EQ(returnList1[1].notificationParameter,notify2.notificationParameter); + ASSERT_EQ(returnList1[1].notificationStatus,notify2.notificationStatus); + ASSERT_EQ(returnList1[1].notificationType,notify2.notificationType); +} + //Commented out - gives always a warning.. //TEST_F(databaseTest,registerDomainFailonID0) //{ diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt index 184a50d..24f79be 100644 --- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt @@ -55,6 +55,8 @@ file(GLOB DATABASE_SRCS_CXX "../../src/CAmSocketHandler.cpp" "../../src/CAmCommandReceiver.cpp" "../../src/CAmRoutingReceiver.cpp" + "../../src/CAmNodeStateCommunicator.cpp" + "../../src/CAmDbusWrapper.cpp" "../CAmCommonFunctions.cpp" "*.cpp" ) diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp new file mode 100644 index 0000000..0624ff4 --- /dev/null +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.cpp @@ -0,0 +1,240 @@ +/** + * Copyright (C) 2012, BMW AG + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Christian Linke, christian.linke@bmw.de BMW 2012 + * + * \file CAmNodeStateCommunicatorTest.cpp + * For further information see http://www.genivi.org/. + * + */ + +#include "CAmNodeStateCommunicatorTest.h" +#include +#include "shared/CAmDltWrapper.h" +#include "shared/CAmSocketHandler.h" +#include "shared/CAmDbusWrapper.h" + +using namespace testing; +using namespace am; + +static CAmEnvironment* env; + +CAmNodeStateCommunicatorTest::CAmNodeStateCommunicatorTest() +{ +} + +CAmNodeStateCommunicatorTest::~CAmNodeStateCommunicatorTest() +{ + // TODO Auto-generated destructor stub +} + +/**This is the thread for the nsm python fake + * + * @param + */ +void* nsmThread (void*) +{ + system("python nsm.py"); + return (NULL); +} + +/**this is the thread the mainloop runs in + * + * @param importHandler + */ +void* mainLoop(void* importHandler) +{ + CAmSocketHandler* handler=static_cast(importHandler); + handler->start_listenting(); + return (NULL); +} + + + +TEST_F(CAmNodeStateCommunicatorTest, nsmChangeNodeState) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmNodeState_e newstate(NsmNodeState_BaseRunning) ; + EXPECT_CALL(pMockControlInterface,hookSystemNodeStateChanged(newstate)); + std::ostringstream send; + send<<"python send2nsm.py nodeState "<(newstate); + system(send.str().c_str()); +} + +TEST_F(CAmNodeStateCommunicatorTest, nsmChangeApplicationMode) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmApplicationMode_e appmode(NsmApplicationMode_Swl) ; + EXPECT_CALL(pMockControlInterface,hookSystemNodeApplicationModeChanged(appmode)); + std::ostringstream send; + send<<"python send2nsm.py appMode "<(appmode); + system(send.str().c_str()); +} + +TEST_F(CAmNodeStateCommunicatorTest, nsmChangeSessionState) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + std::string sessionName("mySession"); + NsmSeat_e seatID(NsmSeat_CoDriver); + NsmSessionState_e sessionState(NsmSessionState_Inactive) ; + EXPECT_CALL(pMockControlInterface,hookSystemSessionStateChanged(sessionName,seatID,sessionState)); + std::ostringstream send; + send<<"python send2nsm.py sessionState "<(seatID)<<" "<(sessionState); + system(send.str().c_str()); +} + +TEST_F(CAmNodeStateCommunicatorTest, getRestartReason) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmRestartReason_e restartReason; + ASSERT_EQ(E_OK,env->nsmController.nsmGetRestartReasonProperty(restartReason)); + ASSERT_EQ(restartReason,1); +} + +TEST_F(CAmNodeStateCommunicatorTest, getShutdownReason) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmShutdownReason_e ShutdownReason; + ASSERT_EQ(E_OK,env->nsmController.nsmGetShutdownReasonProperty(ShutdownReason)); + ASSERT_EQ(ShutdownReason,2); +} + +TEST_F(CAmNodeStateCommunicatorTest, getWakeUpReason) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmRunningReason_e WakeUpReason; + ASSERT_EQ(E_OK,env->nsmController.nsmGetRunningReasonProperty(WakeUpReason)); + ASSERT_EQ(WakeUpReason,3); +} + +TEST_F(CAmNodeStateCommunicatorTest, getNodeState) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmNodeState_e nodeState; + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetNodeState(nodeState)); + ASSERT_EQ(nodeState,1); +} + +TEST_F(CAmNodeStateCommunicatorTest, getApplicationMode) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + NsmApplicationMode_e applicationMode; + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Error,env->nsmController.nsmGetApplicationMode(applicationMode)); + ASSERT_EQ(applicationMode,5); +} + +TEST_F(CAmNodeStateCommunicatorTest, getSessionState) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + std::string sessionName("mySession"); + NsmSeat_e seatID(NsmSeat_Driver); + NsmSessionState_e sessionState; + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmGetSessionState(sessionName,seatID,sessionState)); + ASSERT_EQ(sessionState,5); +} + +TEST_F(CAmNodeStateCommunicatorTest, RegisterShutdownClient) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + uint32_t shutdownmode(1), timeoutMs(100); + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs)); +} + +TEST_F(CAmNodeStateCommunicatorTest, receiveLifecycleRequest) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + uint32_t shutdownmode(1),timeoutMs(100),Request(1),RequestID(4); + EXPECT_CALL(pMockControlInterface,hookSystemLifecycleRequest(Request,RequestID)).WillOnce(Return(NsmErrorStatus_e::NsmErrorStatus_Ok)); + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs)); + std::ostringstream send; + send << "python send2nsm.py LifecycleRequest "<(Request)<<" "<(RequestID); + system(send.str().c_str()); +} + +TEST_F(CAmNodeStateCommunicatorTest, UnRegisterShutdownClient) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + uint32_t shutdownmode(1),timeoutMs(100); + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmRegisterShutdownClient(shutdownmode,timeoutMs)); + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmUnRegisterShutdownClient(shutdownmode)); + +} + +TEST_F(CAmNodeStateCommunicatorTest, sendLifecycleRequestComplete) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + uint32_t RequestID(22); + NsmErrorStatus_e errorStatus(NsmErrorStatus_Internal); + ASSERT_EQ(NsmErrorStatus_e::NsmErrorStatus_Ok,env->nsmController.nsmSendLifecycleRequestComplete(RequestID,errorStatus)); +} + +TEST_F(CAmNodeStateCommunicatorTest, getInterfaceVersion) +{ + env->pControlInterfaceBackdoor.replaceController(&env->pControlSender,&pMockControlInterface); + uint32_t version(0); + ASSERT_EQ(E_OK,env->nsmController.nsmGetInterfaceVersion(version)); + ASSERT_EQ(version,static_cast(23)); +} + +void CAmNodeStateCommunicatorTest::SetUp() +{ +} + +void CAmNodeStateCommunicatorTest::TearDown() +{ +} + +int main(int argc, char **argv) +{ + CAmDltWrapper::instance()->registerApp("nsm", "nsmtest"); + logInfo("nsmtest Test started "); + ::testing::InitGoogleTest(&argc, argv); + ::testing::Environment* const env = ::testing::AddGlobalTestEnvironment(new CAmEnvironment); + (void) env; + return RUN_ALL_TESTS(); +} + +CAmEnvironment::CAmEnvironment() : + pControlInterfaceBackdoor(), + pControlSender(), + iSocketHandler(), + wrapper(&iSocketHandler,DBusBusType::DBUS_BUS_SESSION), + nsmController(&wrapper) +{ + env=this; +} + +CAmEnvironment::~CAmEnvironment() +{ +} + +void CAmEnvironment::SetUp() +{ + //create the nsm thread + pthread_create(&pNsmThread, NULL, nsmThread, NULL); + nsmController.registerControlSender(&pControlSender); + //create the mainloop thread + pthread_create(&pMainLoopThread, NULL, mainLoop, (void*)&iSocketHandler); + sleep(1); +} + +void CAmEnvironment::TearDown() +{ + //end the nsm per dbus + system("python send2nsm.py finish"); + pthread_join(pNsmThread, NULL); + //end the mainloop + iSocketHandler.exit_mainloop(); + pthread_join(pMainLoopThread, NULL); +} diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h new file mode 100644 index 0000000..bd83e97 --- /dev/null +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CAmNodeStateCommunicatorTest.h @@ -0,0 +1,61 @@ +/** + * Copyright (C) 2012, BMW AG + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Christian Linke, christian.linke@bmw.de BMW 2012 + * + * \file CAmNodeStateCommunicatorTest.h + * For further information see http://www.genivi.org/. + * + */ +#ifndef CAMNODESTATECOMMUNICATORTEST_H_ +#define CAMNODESTATECOMMUNICATORTEST_H_ + +#include "CAmNodeStateCommunicator.h" +#include "CAmControlSender.h" +#include "gtest/gtest.h" +#include "gmock/gmock.h" +#include "../IAmControlBackdoor.h" +#include "../MockIAmControlSend.h" + +using namespace testing; +using namespace am; + +class CAmEnvironment : public ::testing::Environment +{ +public: + IAmControlBackdoor pControlInterfaceBackdoor; + CAmControlSender pControlSender; + CAmSocketHandler iSocketHandler; + CAmDbusWrapper wrapper; + CAmNodeStateCommunicator nsmController; + pthread_t pNsmThread, pMainLoopThread; + CAmEnvironment(); + ~CAmEnvironment(); + void SetUp(); + // Override this to define how to tear down the environment. + void TearDown(); +}; + +class CAmNodeStateCommunicatorTest:public ::testing::Test +{ +public: + MockIAmControlSend pMockControlInterface; + CAmNodeStateCommunicatorTest(); + virtual ~CAmNodeStateCommunicatorTest(); + void SetUp(); + void TearDown(); +}; + + +#endif /* CAMNODESTATECOMMUNICATORTEST_H_ */ diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt new file mode 100644 index 0000000..4300e49 --- /dev/null +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/CMakeLists.txt @@ -0,0 +1,112 @@ +# Copyright (c) 2012 GENIVI Alliance +# Copyright (c) 2012 BMW +# +# author Christian Linke, christian.linke@bmw.de BMW 2011,2012 +# +# copyright +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR +# THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# For further information see http://www.genivi.org/. +# + +cmake_minimum_required(VERSION 2.6) + +PROJECT(AmNodeStateCommunicatorTest) + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -DUNIT_TEST=1") + +set(STD_INCLUDE_DIRS "/usr/include") +set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH}) + +FIND_PACKAGE(Threads) +FIND_PACKAGE(DBUS REQUIRED) +FIND_PACKAGE(PkgConfig) +FIND_PACKAGE(PythonLibs REQUIRED) +pkg_check_modules(SQLITE REQUIRED sqlite3) + + +IF(WITH_DLT) + pkg_check_modules(DLT REQUIRED automotive-dlt>=2.2.0) +ENDIF(WITH_DLT) + +INCLUDE_DIRECTORIES( + ${STD_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${AUDIO_INCLUDE_FOLDER} + ${DBUS_ARCH_INCLUDE_DIR} + ${DBUS_INCLUDE_FOLDER} + ${CMAKE_SOURCE_DIR} + ${DLT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIR} + ${INCLUDE_FOLDER} + ${PYTHON_INCLUDE_DIRS} + ${GOOGLE_TEST_INCLUDE_DIR} + ${GMOCK_INCLUDE_DIR} + "../../include" +) + +file(GLOB NODESTATECOMMUNICATOR + "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseObserver.cpp" + "../../src/CAmRoutingSender.cpp" + "../../src/CAmRoutingReceiver.cpp" + "../../src/CAmDbusWrapper.cpp" + "../../src/CAmDltWrapper.cpp" + "../../src/CAmSocketHandler.cpp" + "../../src/CAmNodeStateCommunicator.cpp" + "../../src/CAmControlSender.cpp" + "../../src/CAmCommandSender.cpp" + "../../src/CAmCommandReceiver.cpp" + "../CAmCommonFunctions.cpp" + "../../src/CAmRouter.cpp" + "*.cpp" + ) + +ADD_EXECUTABLE(AmNodeStateCommunicatorTest ${NODESTATECOMMUNICATOR}) + +TARGET_LINK_LIBRARIES(AmNodeStateCommunicatorTest + ${SQLITE_LIBRARIES} + ${DLT_LIBRARIES} + ${DBUS_LIBRARY} + ${CMAKE_DL_LIBS} + ${CMAKE_THREAD_LIBS_INIT} + ${PYTHON_LIBRARY} + gtest + gmock +) + +ADD_DEPENDENCIES(AmNodeStateCommunicatorTest gtest gmock) + +INSTALL(TARGETS AmNodeStateCommunicatorTest + DESTINATION "~/AudioManagerTest/" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ + COMPONENT tests +) + +INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml + ${CMAKE_CURRENT_SOURCE_DIR}/nsm.py + ${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py + DESTINATION "~/AudioManagerTest/" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ + COMPONENT tests +) + +IF(USE_BUILD_LIBS) + execute_process( + COMMAND mkdir -p "${EXECUTABLE_OUTPUT_PATH}" + COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/org.genivi.NodeStateManager.Consumer.xml" ${EXECUTABLE_OUTPUT_PATH}/org.genivi.NodeStateManager.Consumer.xml + COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/nsm.py" ${EXECUTABLE_OUTPUT_PATH}/nsm.py + COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/send2nsm.py" ${EXECUTABLE_OUTPUT_PATH}/send2nsm.py) +ENDIF(USE_BUILD_LIBS) + +SET(ADD_DEPEND "audiomanager-bin" "sqlite3(>=3.6.22)" "dlt" "libdbus-1-3(>=1.2.16)" "gtest" "libpthread-stubs0") +set_property(GLOBAL APPEND PROPERTY tests_prop "${ADD_DEPEND}") + diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py new file mode 100644 index 0000000..7a02d05 --- /dev/null +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/nsm.py @@ -0,0 +1,179 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012, BMW AG +# +# This file is part of GENIVI Project AudioManager. +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# \copyright +# This Source Code Form is subject to the terms of the +# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# +# \author Christian Linke, christian.linke@bmw.de BMW 2012 +# +# For further information see http://www.genivi.org/. +# + +import sys +import traceback +import gobject +import math +import dbus +import dbus.service +import dbus.mainloop.glib + +loop = gobject.MainLoop() +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) + +class NodeStateManager(dbus.service.Object): + def __init__(self, loop): + busName = dbus.service.BusName('org.genivi.NodeStateManager', bus = dbus.SessionBus()) + dbus.service.Object.__init__(self, busName, '/org/genivi/NodeStateManager') + self.properties = {'RestartReason': 1, 'ShutdownReason': 2, 'WakeUpReason' :3, 'BootMode' :4} + self.ABus="" + self.APath="" + self.loop=loop + + @dbus.service.method(dbus_interface='org.freedesktop.DBus.Introspectable', out_signature = 's') + def Introspect(self): + f = open('org.genivi.NodeStateManager.Consumer.xml', "r") + text = f.read() + return text + + @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'ii') + def GetNodeState(self): + NodeStateId=1 + ErrorCode=1 + print('[----------] send out nodeState' + str(NodeStateId) + ' ErrorCode '+ str(1)) + return NodeStateId, ErrorCode + + @dbus.service.method('org.genivi.NodeStateManager.Consumer', out_signature = 'ii') + def GetApplicationMode(self): + ApplicationModeId=5 + ErrorCode=2 + print('[----------] send out ApplicationMode' + str(ApplicationModeId) + ' ErrorCode '+ str(2)) + return ApplicationModeId, ErrorCode + + @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='si', out_signature = 'ii') + def GetSessionState(self,SessionName,seatID): + SessionState=0 + ErrorCode=2 + + if SessionName=="mySession" and seatID==1: + SessionState=5 + ErrorCode=1 + + print('[----------] GetSessionState for session ' + SessionName + ' seatID '+ str(seatID) + ' returnState ' + str (SessionState)) + return SessionState, ErrorCode + + @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssuu', out_signature = 'i') + def RegisterShutdownClient(self,BName,ObjName,ShutdownMode,TimeoutMs): + print('[----------] Busname: ' + BName) + print('[----------] ObjName: ' + ObjName) + print('[----------] ShutdownMode: ' + str(ShutdownMode)) + print('[----------] TimeoutMs: ' + str(TimeoutMs)) + ErrorCode=1 + if TimeoutMs!=100: + ErrorCode=3 + if BName!="org.genivi.audiomanager": + ErrorCode=4 + if ShutdownMode!=1: + ErrorCode=5 + if ObjName!="/org/genivi/audiomanager/LifeCycleConsumer": + ErrorCode=6 + self.ABus=BName + self.APath=ObjName + return ErrorCode + + @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ssu', out_signature = 'i') + def UnRegisterShutdownClient(self,BusName,ObjName,ShutdownMode): + print('[----------] Busname: ' + str(BusName)) + print('[----------] ObjName: ' + str(ObjName)) + print('[----------] ShutdownMode: ' + str(ShutdownMode)) + ErrorCode=1 + if BusName!=self.ABus: + ErrorCode=2 + if ObjName!=self.APath: + ErrorCode=2 + if ShutdownMode!=1: + ErrorCode=2 + return ErrorCode + + @dbus.service.method(dbus_interface='org.genivi.NodeStateManager.Consumer', out_signature = 'u') + def GetInterfaceVersion(self): + version=23 + return version + + @dbus.service.method('org.genivi.NodeStateManager.Consumer', in_signature='ui', out_signature='i') + def LifecycleRequestComplete(self,RequestID,Status): + print('[----------] RequestId: ' + str(RequestID)) + print('[----------] Status: ' + str(Status)) + ErrorCode=1 + if RequestID!=22: + ErrorCode=2 + if Status!=4: + ErrorCode=2 + return ErrorCode + + @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ss', out_signature='v') + def Get(self, interface, prop): + if prop in self.properties: + print('[----------] send out ' + str(self.properties[prop]) + ' for property '+ prop) + return self.properties[prop] + return 0 + + @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='ssv') + def Set(self, interface, prop, value): + return 3 + + @dbus.service.method(dbus.PROPERTIES_IFACE, in_signature='s', out_signature='a{sv}') + def GetAll(self, interface): + return self.properties + + @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i') + def NodeApplicationMode(self, ApplicationModeId): + print "[----------] Send out application mode ID %d" % (ApplicationModeId) + + @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='i') + def NodeState(self, NodeState): + print "[----------] Send out NodeState %d" % (NodeState) + + @dbus.service.signal(dbus_interface='org.genivi.NodeStateManager.Consumer', signature='sii') + def SessionStateChanged(self, SessionStateName,SeatID,SessionState): + print "[----------] Send out SessionStateChanged " + SessionStateName + + @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i') + def sendNodeApplicationMode(self, input): + self.NodeApplicationMode(input) + return input + + @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='i') + def sendNodeState(self, input): + self.NodeState(input) + return input + + @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='sii') + def sendSessionState(self, SessionStateName,SeatID,SessionState): + self.SessionStateChanged (SessionStateName,SeatID,SessionState) + return SeatID + + @dbus.service.method('org.genivi.NodeStateManager.Control', in_signature='uu', out_signature='i') + def sendLifeCycleRequest(self, request, requestID): + bus = dbus.SessionBus() + remote_object = bus.get_object(self.ABus,self.APath) + iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.LifeCycleConsumer') + iface.LifecycleRequest(request,requestID) + return 42 + + @dbus.service.method('org.genivi.NodeStateManager.Control') + def finish(self): + print '[----------] Going to exit now!' + self.loop.quit() + return 0 + +nsm = NodeStateManager(loop) +loop.run() diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml new file mode 100644 index 0000000..bb40a96 --- /dev/null +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/org.genivi.NodeStateManager.Consumer.xml @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py new file mode 100644 index 0000000..3b6cad3 --- /dev/null +++ b/AudioManagerDaemon/test/AmNodeStateCommunicatorTest/send2nsm.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2012, BMW AG +# +# This file is part of GENIVI Project AudioManager. +# +# Contributions are licensed to the GENIVI Alliance under one or more +# Contribution License Agreements. +# +# \copyright +# This Source Code Form is subject to the terms of the +# Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +# this file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# +# \author Christian Linke, christian.linke@bmw.de BMW 2012 +# +# For further information see http://www.genivi.org/. +# + +import sys +import traceback +import gobject +import math +import dbus +import dbus.service + +def nodeState (nodeState): + bus = dbus.SessionBus() + remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager') + iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control') + iface.sendNodeState(int(nodeState)) + +def appMode (appMode): + bus = dbus.SessionBus() + remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager') + iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control') + iface.sendNodeApplicationMode(int(appMode)) + +def sessionState (SessionStateName,SeatID,SessionState): + bus = dbus.SessionBus() + remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager') + iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control') + iface.sendSessionState(SessionStateName,int(SeatID),int(SessionState)) + +def finish(): + bus = dbus.SessionBus() + remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager') + iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control') + iface.finish() + +def LifecycleRequest(Request,RequestID): + bus = dbus.SessionBus() + remote_object = bus.get_object('org.genivi.NodeStateManager','/org/genivi/NodeStateManager') + iface = dbus.Interface(remote_object, 'org.genivi.NodeStateManager.Control') + iface.sendLifeCycleRequest(Request,RequestID) + +command=sys.argv[1] +if command=="nodeState": + nodeState(sys.argv[2]) +if command=="finish": + finish() +if command=="appMode": + appMode(sys.argv[2]) +if command=="sessionState": + sessionState(sys.argv[2],sys.argv[3],sys.argv[4]) +if command=="LifecycleRequest": + LifecycleRequest(sys.argv[2],sys.argv[3]) diff --git a/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp b/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp index 0758a01..9f172be 100644 --- a/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp +++ b/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.cpp @@ -30,7 +30,7 @@ CAmRouterTest::CAmRouterTest() : plistCommandPluginDirs(), // pSocketHandler(), // pDatabaseHandler(std::string(":memory:")), // - pControlSender(std::string("")), // + pControlSender(), // pRouter(&pDatabaseHandler, &pControlSender), // pRoutingSender(plistRoutingPluginDirs), // pCommandSender(plistCommandPluginDirs), // @@ -121,7 +121,7 @@ TEST_F(CAmRouterTest,simpleRoute2withDomainNoMatchFormats) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes)); - ASSERT_EQ(0, listRoutes.size()); + ASSERT_EQ(static_cast(0), listRoutes.size()); } @@ -182,7 +182,7 @@ TEST_F(CAmRouterTest,simpleRoute2withDomain) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -290,7 +290,7 @@ TEST_F(CAmRouterTest,simpleRoute2DomainsOnlyFree) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -412,10 +412,10 @@ TEST_F(CAmRouterTest,simpleRoute2DomainsOnlyFreeNotFree) ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection1,id2)); ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes)); - ASSERT_EQ(0, listRoutes.size()); + ASSERT_EQ(static_cast(0), listRoutes.size()); ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -575,7 +575,7 @@ TEST_F(CAmRouterTest,simpleRoute3DomainsListConnectionFormats_2) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -729,7 +729,7 @@ TEST_F(CAmRouterTest,simpleRoute3DomainsListConnectionFormats_1) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -878,7 +878,7 @@ TEST_F(CAmRouterTest,simpleRoute3DomainsListConnectionFormats) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -1112,7 +1112,7 @@ TEST_F(CAmRouterTest,simpleRoute4Domains2Routes) compareRoute1.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(2, listRoutes.size()); + ASSERT_EQ(static_cast(2), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[1])); } @@ -1259,7 +1259,7 @@ TEST_F(CAmRouterTest,simpleRoute3DomainsNoConnection) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(0, listRoutes.size()); + ASSERT_EQ(static_cast(0), listRoutes.size()); } //test that checks just 2 domains, one sink one source with only one connection format each TEST_F(CAmRouterTest,simpleRoute2Domains) @@ -1364,7 +1364,7 @@ TEST_F(CAmRouterTest,simpleRoute2Domains) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } @@ -1472,7 +1472,7 @@ TEST_F(CAmRouterTest,simpleRoute2DomainsNoMatchConnectionFormats) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(0, listRoutes.size()); + ASSERT_EQ(static_cast(0), listRoutes.size()); } //test that checks 3 domains, one sink one source. @@ -1616,7 +1616,7 @@ TEST_F(CAmRouterTest,simpleRoute3Domains) compareRoute.sourceID = sourceID; ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes)); - ASSERT_EQ(1, listRoutes.size()); + ASSERT_EQ(static_cast(1), listRoutes.size()); ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0])); } diff --git a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt index aae97e5..2a0468f 100644 --- a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt @@ -55,6 +55,8 @@ file(GLOB ROUTING_SRCS_CXX "../../src/CAmSocketHandler.cpp" "../../src/CAmCommandReceiver.cpp" "../../src/CAmRoutingReceiver.cpp" + "../../src/CAmNodeStateCommunicator.cpp" + "../../src/CAmDbusWrapper.cpp" "../CAmCommonFunctions.cpp" "*.cpp" ) diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp index 47181b3..d7bb96d 100644 --- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp +++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp @@ -31,7 +31,7 @@ CAmRoutingInterfaceTest::CAmRoutingInterfaceTest() : pDatabaseHandler(std::string(":memory:")), // pRoutingSender(plistRoutingPluginDirs), // pCommandSender(plistCommandPluginDirs), // - pControlSender(""), // + pControlSender(), // pRouter(&pDatabaseHandler, &pControlSender), // pMockInterface(), // pRoutingInterfaceBackdoor(), // diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt index 5b903b5..abda5c1 100644 --- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt @@ -57,6 +57,8 @@ file(GLOB ROUTING_INTERFACE_SRCS_CXX "../../src/CAmSocketHandler.cpp" "../../src/CAmRoutingReceiver.cpp" "../../src/CAmCommandReceiver.cpp" + "../../src/CAmNodeStateCommunicator.cpp" + "../../src/CAmDbusWrapper.cpp" "*.cpp" ) diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp index ebc3705..686ac92 100644 --- a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp +++ b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp @@ -44,9 +44,8 @@ static CAmSocketHandler* mpSocketHandler = NULL; void* startSocketHandler(void* data) { CAmEnvironment* Env = static_cast(data); - CAmSocketHandler mySocketHandler; - Env->setSocketHandler(&mySocketHandler); - mySocketHandler.start_listenting(); + Env->setSocketHandler(&Env->mSocketHandler); + Env->mSocketHandler.start_listenting(); Env->setSocketHandler(NULL); return (NULL); } @@ -54,11 +53,11 @@ void* startSocketHandler(void* data) CAmEnvironment::CAmEnvironment() : mlistRoutingPluginDirs() , mlistCommandPluginDirs() -//, mpSocketHandler(NULL) +, mSocketHandler() , mDatabasehandler(std::string(":memory:")) , mRoutingSender(mlistRoutingPluginDirs) , mCommandSender(mlistRoutingPluginDirs) -, mControlSender(controllerPlugin) +, mControlSender(controllerPlugin,&mSocketHandler) , mRouter(&mDatabasehandler,&mControlSender) , mpCommandReceiver(NULL) , mpRoutingReceiver(NULL) @@ -172,7 +171,7 @@ TEST_F(CAmTelnetServerTest,sendCmdTelnetServer) std::string string("help"); ssize_t sizesent = send(staticSocket, string.c_str(), string.size(), 0); - ASSERT_EQ(sizesent,string.size()); + ASSERT_EQ(static_cast(sizesent),string.size()); char buffer[1000]; memset(buffer,0,sizeof(buffer)); @@ -187,7 +186,7 @@ TEST_F(CAmTelnetServerTest,closeTelnetServerConnection) mpSocketHandler->stop_listening(); ssize_t sizesent = send(staticSocket, string.c_str(), string.size(), 0); - ASSERT_EQ(sizesent,string.size()); + ASSERT_EQ(static_cast(sizesent),string.size()); char buffer[1000]; memset(buffer,0,sizeof(buffer)); diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h index 06d10fe..a584b97 100644 --- a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h +++ b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h @@ -63,7 +63,7 @@ class CAmEnvironment : public ::testing::Environment std::vector mlistRoutingPluginDirs; std::vector mlistCommandPluginDirs; - //SocketHandler* mpSocketHandler; + CAmSocketHandler mSocketHandler; CAmDatabaseHandler mDatabasehandler; CAmRoutingSender mRoutingSender; CAmCommandSender mCommandSender; diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt index b2c44a9..181940c 100644 --- a/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt @@ -63,6 +63,8 @@ file(GLOB TELNET_SRCS_CXX "../../src/CAmRouter.cpp" "../../src/CAmDltWrapper.cpp" "../../src/CAmTelnetMenuHelper.cpp" + "../../src/CAmNodeStateCommunicator.cpp" + "../../src/CAmDbusWrapper.cpp" "*.cpp" ) diff --git a/AudioManagerDaemon/test/CMakeLists.txt b/AudioManagerDaemon/test/CMakeLists.txt index fb93efa..2588e8f 100644 --- a/AudioManagerDaemon/test/CMakeLists.txt +++ b/AudioManagerDaemon/test/CMakeLists.txt @@ -25,6 +25,7 @@ add_subdirectory (AmDatabaseHandlerTest) add_subdirectory (AmRouterTest) add_subdirectory (AmRoutingInterfaceTest) add_subdirectory (AmSocketHandlerTest) +add_subdirectory (AmNodeStateCommunicatorTest) IF(WITH_TELNET) add_subdirectory (AmTelnetServerTest) ENDIF(WITH_TELNET) diff --git a/AudioManagerDaemon/test/MockIAmCommandSend.h b/AudioManagerDaemon/test/MockIAmCommandSend.h index 11c1992..70cdc4f 100644 --- a/AudioManagerDaemon/test/MockIAmCommandSend.h +++ b/AudioManagerDaemon/test/MockIAmCommandSend.h @@ -71,6 +71,20 @@ class MockIAmCommandSend : public IAmCommandSend { void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)); MOCK_CONST_METHOD1(getInterfaceVersion, void(std::string& version)); + MOCK_METHOD3(cbSinkUpdated, + void(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties)); + MOCK_METHOD3(cbSourceUpdated, + void(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties)); + MOCK_METHOD2(cbSinkNotification, + void(const am_sinkID_t sinkID, const am_NotificationPayload_s notification)); + MOCK_METHOD2(cbSourceNotification, + void(const am_sourceID_t sourceID, const am_NotificationPayload_s notification)); + MOCK_METHOD2(cbSinkMainNotificationConfigurationChanged, + void(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)); + MOCK_METHOD2(cbSourceMainNotificationConfigurationChanged, + void(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)); + + }; } // namespace am diff --git a/AudioManagerDaemon/test/MockIAmControlSend.h b/AudioManagerDaemon/test/MockIAmControlSend.h index 7f51ab0..7f83823 100644 --- a/AudioManagerDaemon/test/MockIAmControlSend.h +++ b/AudioManagerDaemon/test/MockIAmControlSend.h @@ -29,100 +29,129 @@ namespace am { class MockIAmControlSend : public IAmControlSend { public: - MOCK_METHOD1(startupController, - am_Error_e(IAmControlReceive* controlreceiveinterface)); - MOCK_METHOD0(setControllerReady, - void()); - MOCK_METHOD0(setControllerRundown, - void()); - MOCK_METHOD3(hookUserConnectionRequest, - am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID)); - MOCK_METHOD1(hookUserDisconnectionRequest, - am_Error_e(const am_mainConnectionID_t connectionID)); - MOCK_METHOD2(hookUserSetMainSinkSoundProperty, - am_Error_e(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty)); - MOCK_METHOD2(hookUserSetMainSourceSoundProperty, - am_Error_e(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty)); - MOCK_METHOD1(hookUserSetSystemProperty, - am_Error_e(const am_SystemProperty_s& property)); - MOCK_METHOD2(hookUserVolumeChange, - am_Error_e(const am_sinkID_t SinkID, const am_mainVolume_t newVolume)); - MOCK_METHOD2(hookUserVolumeStep, - am_Error_e(const am_sinkID_t SinkID, const int16_t increment)); - MOCK_METHOD2(hookUserSetSinkMuteState, - am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState)); - MOCK_METHOD2(hookSystemRegisterDomain, - am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID)); - MOCK_METHOD1(hookSystemDeregisterDomain, - am_Error_e(const am_domainID_t domainID)); - MOCK_METHOD1(hookSystemDomainRegistrationComplete, - void(const am_domainID_t domainID)); - MOCK_METHOD2(hookSystemRegisterSink, - am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID)); - MOCK_METHOD1(hookSystemDeregisterSink, - am_Error_e(const am_sinkID_t sinkID)); - MOCK_METHOD2(hookSystemRegisterSource, - am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID)); - MOCK_METHOD1(hookSystemDeregisterSource, - am_Error_e(const am_sourceID_t sourceID)); - MOCK_METHOD2(hookSystemRegisterGateway, - am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID)); - MOCK_METHOD1(hookSystemDeregisterGateway, - am_Error_e(const am_gatewayID_t gatewayID)); - MOCK_METHOD2(hookSystemRegisterCrossfader, - am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID)); - MOCK_METHOD1(hookSystemDeregisterCrossfader, - am_Error_e(const am_crossfaderID_t crossfaderID)); - MOCK_METHOD3(hookSystemSinkVolumeTick, - void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)); - MOCK_METHOD3(hookSystemSourceVolumeTick, - void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)); - MOCK_METHOD2(hookSystemInterruptStateChange, - void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)); - MOCK_METHOD2(hookSystemSinkAvailablityStateChange, - void(const am_sinkID_t sinkID, const am_Availability_s& availability)); - MOCK_METHOD2(hookSystemSourceAvailablityStateChange, - void(const am_sourceID_t sourceID, const am_Availability_s& availability)); - MOCK_METHOD2(hookSystemDomainStateChange, - void(const am_domainID_t domainID, const am_DomainState_e state)); - MOCK_METHOD1(hookSystemReceiveEarlyData, - void(const std::vector& data)); - MOCK_METHOD1(hookSystemSpeedChange, - void(const am_speed_t speed)); - MOCK_METHOD2(hookSystemTimingInformationChanged, - void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)); - MOCK_METHOD2(cbAckConnect, - void(const am_Handle_s handle, const am_Error_e errorID)); - MOCK_METHOD2(cbAckDisconnect, - void(const am_Handle_s handle, const am_Error_e errorID)); - MOCK_METHOD3(cbAckCrossFade, - void(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)); - MOCK_METHOD3(cbAckSetSinkVolumeChange, - void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)); - MOCK_METHOD3(cbAckSetSourceVolumeChange, - void(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error)); - MOCK_METHOD2(cbAckSetSourceState, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(cbAckSetSourceSoundProperties, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(cbAckSetSourceSoundProperty, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(cbAckSetSinkSoundProperties, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(cbAckSetSinkSoundProperty, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD5(getConnectionFormatChoice, - am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats)); - MOCK_CONST_METHOD1(getInterfaceVersion, - void(std::string& version)); - MOCK_METHOD0(confirmCommandReady, - void()); - MOCK_METHOD0(confirmRoutingReady, - void()); - MOCK_METHOD0(confirmCommandRundown, - void()); - MOCK_METHOD0(confirmRoutingRundown, - void()); + MOCK_CONST_METHOD1(getInterfaceVersion, + void(std::string& version)); + MOCK_METHOD1(startupController, + am_Error_e(IAmControlReceive* controlreceiveinterface)); + MOCK_METHOD0(setControllerReady, + void()); + MOCK_METHOD1(setControllerRundown, + void(const int16_t signal)); + MOCK_METHOD3(hookUserConnectionRequest, + am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID)); + MOCK_METHOD1(hookUserDisconnectionRequest, + am_Error_e(const am_mainConnectionID_t connectionID)); + MOCK_METHOD2(hookUserSetMainSinkSoundProperty, + am_Error_e(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty)); + MOCK_METHOD2(hookUserSetMainSourceSoundProperty, + am_Error_e(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty)); + MOCK_METHOD1(hookUserSetSystemProperty, + am_Error_e(const am_SystemProperty_s& property)); + MOCK_METHOD2(hookUserVolumeChange, + am_Error_e(const am_sinkID_t SinkID, const am_mainVolume_t newVolume)); + MOCK_METHOD2(hookUserVolumeStep, + am_Error_e(const am_sinkID_t SinkID, const int16_t increment)); + MOCK_METHOD2(hookUserSetSinkMuteState, + am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState)); + MOCK_METHOD2(hookSystemRegisterDomain, + am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID)); + MOCK_METHOD1(hookSystemDeregisterDomain, + am_Error_e(const am_domainID_t domainID)); + MOCK_METHOD1(hookSystemDomainRegistrationComplete, + void(const am_domainID_t domainID)); + MOCK_METHOD2(hookSystemRegisterSink, + am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID)); + MOCK_METHOD1(hookSystemDeregisterSink, + am_Error_e(const am_sinkID_t sinkID)); + MOCK_METHOD2(hookSystemRegisterSource, + am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID)); + MOCK_METHOD1(hookSystemDeregisterSource, + am_Error_e(const am_sourceID_t sourceID)); + MOCK_METHOD2(hookSystemRegisterGateway, + am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID)); + MOCK_METHOD1(hookSystemDeregisterGateway, + am_Error_e(const am_gatewayID_t gatewayID)); + MOCK_METHOD2(hookSystemRegisterCrossfader, + am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID)); + MOCK_METHOD1(hookSystemDeregisterCrossfader, + am_Error_e(const am_crossfaderID_t crossfaderID)); + MOCK_METHOD3(hookSystemSinkVolumeTick, + void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)); + MOCK_METHOD3(hookSystemSourceVolumeTick, + void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)); + MOCK_METHOD2(hookSystemInterruptStateChange, + void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)); + MOCK_METHOD2(hookSystemSinkAvailablityStateChange, + void(const am_sinkID_t sinkID, const am_Availability_s& availability)); + MOCK_METHOD2(hookSystemSourceAvailablityStateChange, + void(const am_sourceID_t sourceID, const am_Availability_s& availability)); + MOCK_METHOD2(hookSystemDomainStateChange, + void(const am_domainID_t domainID, const am_DomainState_e state)); + MOCK_METHOD1(hookSystemReceiveEarlyData, + void(const std::vector& data)); + MOCK_METHOD1(hookSystemSpeedChange, + void(const am_speed_t speed)); + MOCK_METHOD2(hookSystemTimingInformationChanged, + void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)); + MOCK_METHOD2(cbAckConnect, + void(const am_Handle_s handle, const am_Error_e errorID)); + MOCK_METHOD2(cbAckDisconnect, + void(const am_Handle_s handle, const am_Error_e errorID)); + MOCK_METHOD3(cbAckCrossFade, + void(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)); + MOCK_METHOD3(cbAckSetSinkVolumeChange, + void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)); + MOCK_METHOD3(cbAckSetSourceVolumeChange, + void(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSourceState, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSourceSoundProperties, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSourceSoundProperty, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSinkSoundProperties, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSinkSoundProperty, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD5(getConnectionFormatChoice, + am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats)); + MOCK_METHOD1(confirmCommandReady, + void(const am_Error_e error)); + MOCK_METHOD1(confirmRoutingReady, + void(const am_Error_e error)); + MOCK_METHOD1(confirmCommandRundown, + void(const am_Error_e error)); + MOCK_METHOD1(confirmRoutingRundown, + void(const am_Error_e error)); + MOCK_METHOD5(hookSystemUpdateSink, + am_Error_e(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties)); + MOCK_METHOD5(hookSystemUpdateSource, + am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties)); + MOCK_METHOD4(hookSystemUpdateGateway, + am_Error_e(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix)); + MOCK_METHOD3(cbAckSetVolume, + void(const am_Handle_s handle, const std::vector listVolumes, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSinkNotificationConfiguration, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(cbAckSetSourceNotificationConfiguration, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(hookSinkNotificationDataChanged, + void(const am_sinkID_t sinkID, const am_NotificationPayload_s payload)); + MOCK_METHOD2(hookSourceNotificationDataChanged, + void(const am_sourceID_t sourceID, const am_NotificationPayload_s payload)); + MOCK_METHOD2(hookUserSetMainSinkNotificationConfiguration, + am_Error_e(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration)); + MOCK_METHOD2(hookUserSetMainSourceNotificationConfiguration, + am_Error_e(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration)); + MOCK_METHOD1(hookSystemNodeStateChanged, + void(const NsmNodeState_e NodeStateId)); + MOCK_METHOD1(hookSystemNodeApplicationModeChanged, + void(const NsmApplicationMode_e ApplicationModeId)); + MOCK_METHOD3(hookSystemSessionStateChanged, + void(const std::string sessionName, const int32_t seatID, const NsmSessionState_e sessionStateID)); + MOCK_METHOD2(hookSystemLifecycleRequest, + NsmErrorStatus_e(const uint32_t Request, const uint32_t RequestId)); + }; } // namespace am diff --git a/AudioManagerDaemon/test/MockIAmRoutingSend.h b/AudioManagerDaemon/test/MockIAmRoutingSend.h index 0534e41..029790e 100644 --- a/AudioManagerDaemon/test/MockIAmRoutingSend.h +++ b/AudioManagerDaemon/test/MockIAmRoutingSend.h @@ -29,40 +29,47 @@ namespace am { class MockIAmRoutingSend : public IAmRoutingSend { public: - MOCK_METHOD1(startupInterface, - am_Error_e(IAmRoutingReceive* routingreceiveinterface)); - MOCK_METHOD1(setRoutingReady, - void(const uint16_t handle)); - MOCK_METHOD1(setRoutingRundown, - void(const uint16_t handle)); - MOCK_METHOD1(asyncAbort, - am_Error_e(const am_Handle_s handle)); - MOCK_METHOD5(asyncConnect, - am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat)); - MOCK_METHOD2(asyncDisconnect, - am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID)); - MOCK_METHOD5(asyncSetSinkVolume, - am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)); - MOCK_METHOD5(asyncSetSourceVolume, - am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)); - MOCK_METHOD3(asyncSetSourceState, - am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)); - MOCK_METHOD3(asyncSetSinkSoundProperties, - am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector& listSoundProperties)); - MOCK_METHOD3(asyncSetSinkSoundProperty, - am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)); - MOCK_METHOD3(asyncSetSourceSoundProperties, - am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector& listSoundProperties)); - MOCK_METHOD3(asyncSetSourceSoundProperty, - am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)); - MOCK_METHOD5(asyncCrossFade, - am_Error_e(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time)); - MOCK_METHOD2(setDomainState, - am_Error_e(const am_domainID_t domainID, const am_DomainState_e domainState)); - MOCK_CONST_METHOD1(returnBusName, - am_Error_e(std::string& BusName)); - MOCK_CONST_METHOD1(getInterfaceVersion, - void(std::string& version)); + MOCK_CONST_METHOD1(getInterfaceVersion, + void(std::string& version)); + MOCK_METHOD1(startupInterface, + am_Error_e(IAmRoutingReceive* routingreceiveinterface)); + MOCK_METHOD1(setRoutingReady, + void(const uint16_t handle)); + MOCK_METHOD1(setRoutingRundown, + void(const uint16_t handle)); + MOCK_METHOD1(asyncAbort, + am_Error_e(const am_Handle_s handle)); + MOCK_METHOD5(asyncConnect, + am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat)); + MOCK_METHOD2(asyncDisconnect, + am_Error_e(const am_Handle_s handle, const am_connectionID_t connectionID)); + MOCK_METHOD5(asyncSetSinkVolume, + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)); + MOCK_METHOD5(asyncSetSourceVolume, + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)); + MOCK_METHOD3(asyncSetSourceState, + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)); + MOCK_METHOD3(asyncSetSinkSoundProperties, + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector& listSoundProperties)); + MOCK_METHOD3(asyncSetSinkSoundProperty, + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)); + MOCK_METHOD3(asyncSetSourceSoundProperties, + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector& listSoundProperties)); + MOCK_METHOD3(asyncSetSourceSoundProperty, + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)); + MOCK_METHOD5(asyncCrossFade, + am_Error_e(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time)); + MOCK_METHOD2(setDomainState, + am_Error_e(const am_domainID_t domainID, const am_DomainState_e domainState)); + MOCK_CONST_METHOD1(returnBusName, + am_Error_e(std::string& BusName)); + MOCK_METHOD2(asyncSetVolumes, + am_Error_e(const am_Handle_s handle, const std::vector& listVolumes)); + MOCK_METHOD3(asyncSetSinkNotificationConfiguration, + am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)); + MOCK_METHOD3(asyncSetSourceNotificationConfiguration, + am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)); + }; } // namespace am diff --git a/CMakeLists.txt b/CMakeLists.txt index f7af947..8632ec8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,9 +64,6 @@ OPTION( WITH_PLUGIN_CONTROL OPTION( WITH_PLUGIN_ROUTING "Build routing pluings" ON) -OPTION( WITH_MAIN - "Build with daemon" ON) - OPTION( WITH_TELNET "build with Telnetserver (can only work with SocketHandler)" ON) @@ -100,6 +97,21 @@ IF(NOT DEFINED MAX_TELNETCONNECTIONS) SET( MAX_TELNETCONNECTIONS 3 ) ENDIF(NOT DEFINED MAX_TELNETCONNECTIONS) +#Can be changed via passing -DNSM_BUS_INTERFACE="XXX" to cmake +IF(NOT DEFINED NSM_BUS_INTERFACE) + SET( NSM_BUS_INTERFACE "org.genivi.NodeStateManager") +ENDIF(NOT DEFINED NSM_BUS_INTERFACE) + +#Can be changed via passing -DNSM_PATH="XXX" to cmake +IF(NOT DEFINED NSM_PATH) + SET( NSM_PATH "/org/genivi/NodeStateManager") +ENDIF(NOT DEFINED NSM_PATH) + +#Can be changed via passing -DNSM_INTERFACE="XXX" to cmake +IF(NOT DEFINED NSM_INTERFACE) + SET( NSM_INTERFACE "org.genivi.NodeStateManager.Consumer") +ENDIF(NOT DEFINED NSM_INTERFACE) + SET(PLUGINS_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/plugins) SET(LIB_INSTALL_SUFFIX "audioManager") @@ -137,7 +149,6 @@ SET(TEST_EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin/test) SET(DOXY_PROTOTYPE ${CMAKE_SOURCE_DIR}/cmake/DoxyFile.in) SET(DOXY_FILE ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile) -CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/cmake/config.cmake ${CMAKE_SOURCE_DIR}/include/config.h ) CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/AudioManagerDaemon/docx/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/DoxyFile ) IF(WITH_DLT) @@ -160,7 +171,7 @@ IF(WITH_DOCUMENTATION) ENDIF(WITH_DOCUMENTATION) ##global build flags set(CPACK_RPM_COMPONENT_INSTALL ON) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE -pedantic -Wno-variadic-macros -Wno-long-long") +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=gnu++0x -D_GNU_SOURCE -pedantic -Wno-variadic-macros -Wno-long-long") #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -std=c++98 -D_GNU_SOURCE") if(WITH_PLUGIN_COMMAND) @@ -169,16 +180,14 @@ endif(WITH_PLUGIN_COMMAND) if(WITH_PLUGIN_ROUTING) add_subdirectory (PluginRoutingInterfaceDbus) -# add_subdirectory (PluginRoutingInterfaceAsync) + add_subdirectory (PluginRoutingInterfaceAsync) endif(WITH_PLUGIN_ROUTING) if(WITH_PLUGIN_CONTROL) add_subdirectory (PluginControlInterface) endif(WITH_PLUGIN_CONTROL) -if(WITH_MAIN) - add_subdirectory (AudioManagerDaemon) -endif(WITH_MAIN) +add_subdirectory (AudioManagerDaemon) IF(EXISTS "${CMAKE_SOURCE_DIR}/ProjectSpecific/") add_subdirectory (ProjectSpecific) diff --git a/PluginCommandInterfaceDbus/cmake/config.cmake b/PluginCommandInterfaceDbus/cmake/config.cmake index 35c9aeb..6b8c553 100644 --- a/PluginCommandInterfaceDbus/cmake/config.cmake +++ b/PluginCommandInterfaceDbus/cmake/config.cmake @@ -2,5 +2,6 @@ #define _COMMANDDBUS_CONFIG_H #cmakedefine COMMAND_DBUS_INTROSPECTION_FILE "@COMMAND_DBUS_INTROSPECTION_FILE@" +#cmakedefine LIBRARY_OUTPUT_PATH "@LIBRARY_OUTPUT_PATH@" #endif /* _COMMANDDBUS_CONFIG_H */ diff --git a/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h b/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h index cb3edcc..d8a2a0c 100644 --- a/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h +++ b/PluginCommandInterfaceDbus/include/CAmCommandSenderDbus.h @@ -65,6 +65,12 @@ public: void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty); void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time); void getInterfaceVersion(std::string& version) const; + void cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties); + void cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties); + void cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s notification); + void cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s notification); + void cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration); + void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration); #ifdef UNIT_TEST friend class CAmCommandSenderDbusBackdoor; diff --git a/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h b/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h index 4cada87..582bf51 100644 --- a/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h +++ b/PluginCommandInterfaceDbus/include/CAmDbusMessageHandler.h @@ -80,6 +80,7 @@ public: double getDouble(); char* getString(); void getProperty(dbus_int16_t& type, dbus_int16_t& value); + void getNotificationConfiguration(dbus_int16_t& notificationType, dbus_int16_t& notificationStatus, dbus_int16_t& notificationParameter); /** * the overloaded append function appends different datatypes to the dbusmessage @@ -101,6 +102,9 @@ public: void append(const std::vector& listSourceClasses); void append(const std::vector& listSinkClasses); void append(const std::vector& listSystemProperties); + void append(const std::vector& listNotifications); + void append(const am::am_NotificationPayload_s& notificationPayload); + void append(const am::am_NotificationConfiguration_s& notificationConfiguration); private: diff --git a/PluginCommandInterfaceDbus/include/CommandInterface.xml b/PluginCommandInterfaceDbus/include/CommandInterface.xml index f6f07a0..5eb51c7 100644 --- a/PluginCommandInterfaceDbus/include/CommandInterface.xml +++ b/PluginCommandInterfaceDbus/include/CommandInterface.xml @@ -5,7 +5,6 @@ - @@ -92,7 +91,7 @@ - + @@ -100,24 +99,35 @@ + + + + + + + + + + + + - - + - - + + - + - - + + - - + + @@ -169,6 +179,38 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h b/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h index 758266d..c582ee6 100644 --- a/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h +++ b/PluginCommandInterfaceDbus/include/IAmCommandReceiverShadow.h @@ -59,6 +59,10 @@ public: void getListSinkClasses(DBusConnection *conn, DBusMessage *msg); void getListSystemProperties(DBusConnection *conn, DBusMessage *msg); void getTimingInformation(DBusConnection *conn, DBusMessage *msg); + void getListSinkMainNotificationConfigurations(DBusConnection *conn, DBusMessage *msg); + void getListSourceMainNotificationConfigurations(DBusConnection *conn, DBusMessage *msg); + void setSinkMainNotificationConfiguration(DBusConnection *conn, DBusMessage *msg); + void setSourceMainNotificationConfiguration(DBusConnection *conn, DBusMessage *msg); /** * sets the pointer to the CommandReceiveInterface and registers Callback diff --git a/PluginCommandInterfaceDbus/include/configCommandDbus.h b/PluginCommandInterfaceDbus/include/configCommandDbus.h index 685d911..369beea 100644 --- a/PluginCommandInterfaceDbus/include/configCommandDbus.h +++ b/PluginCommandInterfaceDbus/include/configCommandDbus.h @@ -1,6 +1,7 @@ #ifndef _COMMANDDBUS_CONFIG_H #define _COMMANDDBUS_CONFIG_H -#define COMMAND_DBUS_INTROSPECTION_FILE "/usr/share/audiomanager/CommandInterface.xml" +#define COMMAND_DBUS_INTROSPECTION_FILE "/home/christian/workspace/AudioManager/bin/CommandInterface.xml" +#define LIBRARY_OUTPUT_PATH "/home/christian/workspace/AudioManager/bin/plugins/command" #endif /* _COMMANDDBUS_CONFIG_H */ diff --git a/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp b/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp index 05b829b..3705c0d 100644 --- a/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp +++ b/PluginCommandInterfaceDbus/src/CAmCommandSenderDbus.cpp @@ -82,14 +82,14 @@ void CAmCommandSenderDbus::setCommandReady(const uint16_t handle) //todo:implement handle handling log(&commandDbus, DLT_LOG_INFO, "cbCommunicationReady called"); mReady = true; - mpIAmCommandReceive->confirmCommandReady(handle); + mpIAmCommandReceive->confirmCommandReady(handle,E_OK); } void CAmCommandSenderDbus::setCommandRundown(const uint16_t handle) { log(&commandDbus, DLT_LOG_INFO, "cbCommunicationRundown called"); mReady = false; - mpIAmCommandReceive->confirmCommandRundown(handle); + mpIAmCommandReceive->confirmCommandRundown(handle,E_OK); /** * todo: implement DbusCommandSender::cbCommunicationRundown() */ @@ -320,3 +320,82 @@ void CAmCommandSenderDbus::getInterfaceVersion(std::string & version) const version = CommandSendVersion; } +void am::CAmCommandSenderDbus::cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties) +{ + log(&commandDbus, DLT_LOG_INFO, "cbSinkUpdated called, sinkID", sinkID); + + if (mReady) + { + mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkUpdated")); + mCAmDbusMessageHandler.append(static_cast(sinkID)); + mCAmDbusMessageHandler.append(static_cast(sinkClassID)); + mCAmDbusMessageHandler.append(listMainSoundProperties); + mCAmDbusMessageHandler.sendMessage(); + } +} + +void am::CAmCommandSenderDbus::cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties) +{ + log(&commandDbus, DLT_LOG_INFO, "cbSourceUpdated called, sourceID", sourceID); + + if (mReady) + { + mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkUpdated")); + mCAmDbusMessageHandler.append(static_cast(sourceID)); + mCAmDbusMessageHandler.append(static_cast(sourceClassID)); + mCAmDbusMessageHandler.append(listMainSoundProperties); + mCAmDbusMessageHandler.sendMessage(); + } +} + +void am::CAmCommandSenderDbus::cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s notification) +{ + log(&commandDbus, DLT_LOG_INFO, "cbSinkNotification called, sinkID", sinkID); + + if (mReady) + { + mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkNotification")); + mCAmDbusMessageHandler.append(static_cast(sinkID)); + mCAmDbusMessageHandler.append(notification); + mCAmDbusMessageHandler.sendMessage(); + } +} + +void am::CAmCommandSenderDbus::cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s notification) +{ + log(&commandDbus, DLT_LOG_INFO, "cbSourceNotification called, sourceID", sourceID); + + if (mReady) + { + mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SourceNotification")); + mCAmDbusMessageHandler.append(static_cast(sourceID)); + mCAmDbusMessageHandler.append(notification); + mCAmDbusMessageHandler.sendMessage(); + } +} + +void am::CAmCommandSenderDbus::cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + log(&commandDbus, DLT_LOG_INFO, "cbSinkMainNotificationConfigurationChanged called, sinkID", sinkID); + + if (mReady) + { + mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkMainNotificationConfigurationChanged")); + mCAmDbusMessageHandler.append(static_cast(sinkID)); + mCAmDbusMessageHandler.append(mainNotificationConfiguration); + mCAmDbusMessageHandler.sendMessage(); + } +} + +void am::CAmCommandSenderDbus::cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +{ + log(&commandDbus, DLT_LOG_INFO, "cbSourceMainNotificationConfigurationChanged called, sourceID", sourceID); + + if (mReady) + { + mCAmDbusMessageHandler.initSignal(std::string(MY_NODE), std::string("SinkMainNotificationConfigurationChanged")); + mCAmDbusMessageHandler.append(static_cast(sourceID)); + mCAmDbusMessageHandler.append(mainNotificationConfiguration); + mCAmDbusMessageHandler.sendMessage(); + } +} diff --git a/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp b/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp index f7cf4d6..55169b2 100644 --- a/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp +++ b/PluginCommandInterfaceDbus/src/CAmDbusMessageHandler.cpp @@ -622,4 +622,87 @@ void CAmDbusMessageHandler::append(const std::vector & mErrorMsg = "Cannot create reply!"; } } + +void CAmDbusMessageHandler::getNotificationConfiguration(dbus_int16_t& notificationType, dbus_int16_t& notificationStatus, dbus_int16_t& notificationParameter) +{ + DBusMessageIter arrayIter; + if (DBUS_TYPE_STRUCT != dbus_message_iter_get_arg_type(&mDBusMessageIter)) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::getProperty DBUS handler argument is no array!"); + mErrorName = std::string(DBUS_ERROR_INVALID_ARGS); + mErrorMsg = "DBus argument is no array"; + } + else + { + dbus_message_iter_recurse(&mDBusMessageIter, &arrayIter); + dbus_message_iter_get_basic(&arrayIter, ¬ificationType); + dbus_message_iter_next(&arrayIter); + dbus_message_iter_get_basic(&arrayIter, ¬ificationStatus); + dbus_message_iter_next(&arrayIter); + dbus_message_iter_get_basic(&arrayIter, ¬ificationParameter); + dbus_message_iter_next(&mDBusMessageIter); + } +} + +void CAmDbusMessageHandler::append(const std::vector& listNotifications) +{ + DBusMessageIter arrayIter; + DBusMessageIter structIter; + std::vector::const_iterator listIterator = listNotifications.begin(); + dbus_bool_t success = true; + + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_ARRAY, "(nnn)", &arrayIter); + for (; listIterator < listNotifications.end(); ++listIterator) + { + success = success && dbus_message_iter_open_container(&arrayIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->notificationType); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->notificationStatus); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, &listIterator->notificationParameter); + success = success && dbus_message_iter_close_container(&arrayIter, &structIter); + } + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &arrayIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const am::am_NotificationPayload_s& notificationPayload) +{ + DBusMessageIter structIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, ¬ificationPayload.notificationType); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, ¬ificationPayload.notificationValue); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + +void CAmDbusMessageHandler::append(const am::am_NotificationConfiguration_s& notificationConfiguration) +{ + DBusMessageIter structIter; + dbus_bool_t success = true; + success = success && dbus_message_iter_open_container(&mDBusMessageIter, DBUS_TYPE_STRUCT, NULL, &structIter); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, ¬ificationConfiguration.notificationType); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, ¬ificationConfiguration.notificationStatus); + success = success && dbus_message_iter_append_basic(&structIter, DBUS_TYPE_INT16, ¬ificationConfiguration.notificationParameter); + success = success && dbus_message_iter_close_container(&mDBusMessageIter, &structIter); + + if (!success) + { + log(&commandDbus, DLT_LOG_ERROR, "DBusMessageHandler::append Cannot allocate DBus message!"); + mErrorName = std::string(DBUS_ERROR_NO_MEMORY); + mErrorMsg = "Cannot create reply!"; + } +} + } diff --git a/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp b/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp index 7322b99..42a669d 100644 --- a/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp +++ b/PluginCommandInterfaceDbus/src/IAmCommandReceiverShadow.cpp @@ -416,6 +416,87 @@ void IAmCommandReceiverShadow::setCommandReceiver(IAmCommandReceive*& receiver) mpCAmDbusWrapper->registerCallback(&gObjectPathVTable, path, this); } +void am::IAmCommandReceiverShadow::getListSinkMainNotificationConfigurations(DBusConnection* conn, DBusMessage* msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSinkMainNotificationConfigurations called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sinkID_t sinkID = static_cast(mDBUSMessageHandler.getUInt()); + std::vector listNotificationConfigurations; + am_Error_e returnCode = mpIAmCommandReceive->getListSinkMainNotificationConfigurations(sinkID,listNotificationConfigurations); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listNotificationConfigurations); + mDBUSMessageHandler.sendMessage(); +} + +void am::IAmCommandReceiverShadow::getListSourceMainNotificationConfigurations(DBusConnection* conn, DBusMessage* msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::getListSourceMainNotificationConfigurations called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sourceID_t sourceID = static_cast(mDBUSMessageHandler.getUInt()); + std::vector listNotificationConfigurations; + am_Error_e returnCode = mpIAmCommandReceive->getListSourceMainNotificationConfigurations(sourceID,listNotificationConfigurations); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.append(listNotificationConfigurations); + mDBUSMessageHandler.sendMessage(); + +} + +void am::IAmCommandReceiverShadow::setSinkMainNotificationConfiguration(DBusConnection* conn, DBusMessage* msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setSinkMainNotificationConfiguration called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sinkID_t sinkID = (am_sinkID_t) mDBUSMessageHandler.getUInt(); + dbus_int16_t type = 0; + dbus_int16_t status = 0; + dbus_int16_t parameter = 0; + mDBUSMessageHandler.getNotificationConfiguration(type, status, parameter); + am_NotificationConfiguration_s mainNotificationConfiguration; + mainNotificationConfiguration.notificationType = static_cast (type); + mainNotificationConfiguration.notificationStatus = static_cast (status); + mainNotificationConfiguration.notificationParameter = static_cast(parameter); + am_Error_e returnCode = mpIAmCommandReceive->setSinkMainNotificationConfiguration(sinkID,mainNotificationConfiguration); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + +void am::IAmCommandReceiverShadow::setSourceMainNotificationConfiguration(DBusConnection* conn, DBusMessage* msg) +{ + log(&commandDbus, DLT_LOG_INFO, "CommandReceiverShadow::setSourceMainNotificationConfiguration called"); + + (void) conn; + assert(mpIAmCommandReceive!=NULL); + + mDBUSMessageHandler.initReceive(msg); + am_sourceID_t sourceID = (am_sourceID_t) mDBUSMessageHandler.getUInt(); + dbus_int16_t type = 0; + dbus_int16_t status = 0; + dbus_int16_t parameter = 0; + mDBUSMessageHandler.getNotificationConfiguration(type, status, parameter); + am_NotificationConfiguration_s mainNotificationConfiguration; + mainNotificationConfiguration.notificationType = static_cast (type); + mainNotificationConfiguration.notificationStatus = static_cast (status); + mainNotificationConfiguration.notificationParameter = static_cast(parameter); + am_Error_e returnCode = mpIAmCommandReceive->setSourceMainNotificationConfiguration(sourceID,mainNotificationConfiguration); + mDBUSMessageHandler.initReply(msg); + mDBUSMessageHandler.append((dbus_int16_t) returnCode); + mDBUSMessageHandler.sendMessage(); +} + IAmCommandReceiverShadow::functionMap_t IAmCommandReceiverShadow::createMap() { functionMap_t m; @@ -436,6 +517,10 @@ IAmCommandReceiverShadow::functionMap_t IAmCommandReceiverShadow::createMap() m["GetListSystemProperties"] = &IAmCommandReceiverShadow::getListSystemProperties; m["GetTimingInformation"] = &IAmCommandReceiverShadow::getTimingInformation; m["SetSystemProperty"] = &IAmCommandReceiverShadow::setSystemProperty; + m["getListSinkMainNotificationConfigurations"] = &IAmCommandReceiverShadow::getListSinkMainNotificationConfigurations; + m["getListSourceMainNotificationConfigurations"] = &IAmCommandReceiverShadow::getListSourceMainNotificationConfigurations; + m["setSinkMainNotificationConfiguration"] = &IAmCommandReceiverShadow::setSinkMainNotificationConfiguration; + m["setSourceMainNotificationConfiguration"] = & IAmCommandReceiverShadow::setSourceMainNotificationConfiguration; return (m); } diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp index 052c46f..3065e1f 100644 --- a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusSignalTest.cpp @@ -29,6 +29,7 @@ #include "../include/CAmDbusMessageHandler.h" #include "../../AudioManagerDaemon/include/TAmPluginTemplate.h" #include "shared/CAmDltWrapper.h" +#include "configCommandDbus.h" using namespace am; using namespace testing; @@ -46,7 +47,7 @@ CAmCommandSenderDbusSignalTest::~CAmCommandSenderDbusSignalTest() void* NumberOfMainConnectionsChanged(void* ppCommandSend) { - sleep(1); + sleep(3); IAmCommandSend* sender=static_cast(ppCommandSend); am_MainConnectionType_s mainConnection; sender->cbNewMainConnection(mainConnection); @@ -225,12 +226,13 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) IAmCommandSend* (*createFunc)(); void* tempLibHandle = NULL; - std::string libname("../plugins/command/libPluginCommandInterfaceDbus.so"); + std::string libname(LIBRARY_OUTPUT_PATH); + libname.append("/libPluginCommandInterfaceDbus.so"); createFunc = getCreateFunction(libname, tempLibHandle); if (!createFunc) { - logError("CommandSendInterface Test Entry point of RoutingPlugin not found"); + logError("CommandSendInterface Test Entry point of CommandPlugin not found"); exit(1); } @@ -238,13 +240,13 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) if (!ppCommandSend) { - logError("CommandSendInterface Test RoutingPlugin initialization failed. Entry Function not callable"); + logError("CommandSendInterface Test CommandPlugin initialization failed. Entry Function not callable"); exit(1); } // ok, here we give the DBusWrapper pointer to the Plugin and start the interface EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper), Return(E_OK))); - EXPECT_CALL(pReceiveInterface, confirmCommandReady(10)); + EXPECT_CALL(pReceiveInterface, confirmCommandReady(10,_)); ppCommandSend->startupInterface(&pReceiveInterface); ppCommandSend->setCommandReady(10); @@ -256,13 +258,15 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) "import gobject\n" "import dbus\n" "import dbus.mainloop.glib\n" + "print('Started thread') \n" "loop = gobject.MainLoop()\n" "def catchsignal(*arg, **kwarg):\n" " print ('Caught NumberOfMainConnectionsChanged') \n" " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchsignal, signal_name='NumberOfMainConnectionsChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchsignal, signal_name='NumberOfMainConnectionsChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" + "print('Started thread') \n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -282,7 +286,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkAdded, signal_name='SinkAdded', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSinkAdded, signal_name='SinkAdded', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -311,7 +315,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkRemoved, signal_name='SinkRemoved', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSinkRemoved, signal_name='SinkRemoved', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -341,7 +345,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSourceAdded, signal_name='SourceAdded', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSourceAdded, signal_name='SourceAdded', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -370,7 +374,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSourceRemoved, signal_name='SourceRemoved', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSourceRemoved, signal_name='SourceRemoved', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -396,7 +400,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchNumberOfSinkClassesChanged, signal_name='NumberOfSinkClassesChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchNumberOfSinkClassesChanged, signal_name='NumberOfSinkClassesChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -412,7 +416,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(CatchNumberOfSourceClassesChanged, signal_name='NumberOfSourceClassesChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(CatchNumberOfSourceClassesChanged, signal_name='NumberOfSourceClassesChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -435,7 +439,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchMainConnectionStateChanged, signal_name='MainConnectionStateChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchMainConnectionStateChanged, signal_name='MainConnectionStateChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -477,7 +481,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchMainSinkSoundPropertyChanged, signal_name='MainSinkSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchMainSinkSoundPropertyChanged, signal_name='MainSinkSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -518,7 +522,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchMainSourceSoundPropertyChanged, signal_name='MainSourceSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchMainSourceSoundPropertyChanged, signal_name='MainSourceSoundPropertyChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -559,7 +563,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkAvailabilityChanged, signal_name='SinkAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSinkAvailabilityChanged, signal_name='SinkAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -600,7 +604,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSourceAvailability, signal_name='SourceAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSourceAvailability, signal_name='SourceAvailabilityChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -641,7 +645,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchVolumeChanged, signal_name='VolumeChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchVolumeChanged, signal_name='VolumeChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -683,7 +687,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSinkMuteStateChanged, signal_name='SinkMuteStateChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSinkMuteStateChanged, signal_name='SinkMuteStateChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -724,7 +728,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchSystemPropertyChanged, signal_name='SystemPropertyChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchSystemPropertyChanged, signal_name='SystemPropertyChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); @@ -756,7 +760,7 @@ TEST_F(CAmCommandSenderDbusSignalTest,cbSourceAvailabilityChanged) " loop.quit()\n" "dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\n" "bus = dbus.SessionBus()\n" - "bus.add_signal_receiver(catchTimingInformationChanged, signal_name='TimingInformationChanged', dbus_interface = 'org.genivi.audiomanager', message_keyword='dbus_message')\n" + "bus.add_signal_receiver(catchTimingInformationChanged, signal_name='TimingInformationChanged', dbus_interface = 'org.genivi.audiomanager.CommandInterface', message_keyword='dbus_message')\n" "loop.run()\n", NULL); pthread_join(pythonloop, NULL); diff --git a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp index 9156b77..932001a 100644 --- a/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp +++ b/PluginCommandInterfaceDbus/test/CAmCommandSenderDbusTest.cpp @@ -122,7 +122,7 @@ ACTION(returnListSourceClasses){ std::vector list; am::am_SourceClass_s listItem; am::am_ClassProperty_s property; -property.classProperty=CP_MAX; +property.classProperty=static_cast(2); property.value=12; listItem.name="FirstCLass"; listItem.sourceClassID=23; @@ -139,7 +139,7 @@ ACTION(returnListSinkClasses){ std::vector list; am::am_SinkClass_s listItem; am::am_ClassProperty_s property; -property.classProperty=CP_MAX; +property.classProperty=static_cast(1); property.value=122; listItem.name="FirstCLass"; listItem.sinkClassID=2123; @@ -202,7 +202,7 @@ TEST_F(CAmCommandSenderDbusTest, MessageTest) // ok, here we give the DBusWrapper pointer to the Plugin and start the interface EXPECT_CALL(pReceiveInterface,getDBusConnectionWrapper(_)).WillRepeatedly(DoAll(SetArgReferee<0>(&pDBusWrapper), Return(E_OK))); - EXPECT_CALL(pReceiveInterface, confirmCommandReady(10)); + EXPECT_CALL(pReceiveInterface, confirmCommandReady(10,E_OK)); ppCommandSend->startupInterface(&pReceiveInterface); ppCommandSend->setCommandReady(10); diff --git a/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h b/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h index 0949bf0..ce1dcc4 100644 --- a/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h +++ b/PluginCommandInterfaceDbus/test/MockIAmCommandReceive.h @@ -26,50 +26,59 @@ namespace am { class MockIAmCommandReceive : public IAmCommandReceive { public: - MOCK_METHOD3(connect, - am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID)); - MOCK_METHOD1(disconnect, - am_Error_e(const am_mainConnectionID_t mainConnectionID)); - MOCK_METHOD2(setVolume, - am_Error_e(const am_sinkID_t sinkID, const am_mainVolume_t volume)); - MOCK_METHOD2(volumeStep, - am_Error_e(const am_sinkID_t sinkID, const int16_t volumeStep)); - MOCK_METHOD2(setSinkMuteState, - am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState)); - MOCK_METHOD2(setMainSinkSoundProperty, - am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID)); - MOCK_METHOD2(setMainSourceSoundProperty, - am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID)); - MOCK_METHOD1(setSystemProperty, - am_Error_e(const am_SystemProperty_s& property)); - MOCK_CONST_METHOD1(getListMainConnections, - am_Error_e(std::vector& listConnections)); - MOCK_CONST_METHOD1(getListMainSinks, - am_Error_e(std::vector& listMainSinks)); - MOCK_CONST_METHOD1(getListMainSources, - am_Error_e(std::vector& listMainSources)); - MOCK_CONST_METHOD2(getListMainSinkSoundProperties, - am_Error_e(const am_sinkID_t sinkID, std::vector& listSoundProperties)); - MOCK_CONST_METHOD2(getListMainSourceSoundProperties, - am_Error_e(const am_sourceID_t sourceID, std::vector& listSourceProperties)); - MOCK_CONST_METHOD1(getListSourceClasses, - am_Error_e(std::vector& listSourceClasses)); - MOCK_CONST_METHOD1(getListSinkClasses, - am_Error_e(std::vector& listSinkClasses)); - MOCK_CONST_METHOD1(getListSystemProperties, - am_Error_e(std::vector& listSystemProperties)); - MOCK_CONST_METHOD2(getTimingInformation, - am_Error_e(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay)); - MOCK_CONST_METHOD1(getDBusConnectionWrapper, - am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper)); - MOCK_CONST_METHOD1(getSocketHandler, - am_Error_e(CAmSocketHandler*& socketHandler)); - MOCK_CONST_METHOD1(getInterfaceVersion, - void(std::string& version)); - MOCK_METHOD1(confirmCommandReady, - void(const uint16_t handle)); - MOCK_METHOD1(confirmCommandRundown, - void(const uint16_t handle)); + MOCK_CONST_METHOD1(getInterfaceVersion, + void(std::string& version)); + MOCK_METHOD3(connect, + am_Error_e(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID)); + MOCK_METHOD1(disconnect, + am_Error_e(const am_mainConnectionID_t mainConnectionID)); + MOCK_METHOD2(setVolume, + am_Error_e(const am_sinkID_t sinkID, const am_mainVolume_t volume)); + MOCK_METHOD2(volumeStep, + am_Error_e(const am_sinkID_t sinkID, const int16_t volumeStep)); + MOCK_METHOD2(setSinkMuteState, + am_Error_e(const am_sinkID_t sinkID, const am_MuteState_e muteState)); + MOCK_METHOD2(setMainSinkSoundProperty, + am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID)); + MOCK_METHOD2(setMainSourceSoundProperty, + am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID)); + MOCK_METHOD1(setSystemProperty, + am_Error_e(const am_SystemProperty_s& property)); + MOCK_CONST_METHOD1(getListMainConnections, + am_Error_e(std::vector& listConnections)); + MOCK_CONST_METHOD1(getListMainSinks, + am_Error_e(std::vector& listMainSinks)); + MOCK_CONST_METHOD1(getListMainSources, + am_Error_e(std::vector& listMainSources)); + MOCK_CONST_METHOD2(getListMainSinkSoundProperties, + am_Error_e(const am_sinkID_t sinkID, std::vector& listSoundProperties)); + MOCK_CONST_METHOD2(getListMainSourceSoundProperties, + am_Error_e(const am_sourceID_t sourceID, std::vector& listSourceProperties)); + MOCK_CONST_METHOD1(getListSourceClasses, + am_Error_e(std::vector& listSourceClasses)); + MOCK_CONST_METHOD1(getListSinkClasses, + am_Error_e(std::vector& listSinkClasses)); + MOCK_CONST_METHOD1(getListSystemProperties, + am_Error_e(std::vector& listSystemProperties)); + MOCK_CONST_METHOD2(getTimingInformation, + am_Error_e(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay)); + MOCK_CONST_METHOD1(getDBusConnectionWrapper, + am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper)); + MOCK_CONST_METHOD1(getSocketHandler, + am_Error_e(CAmSocketHandler*& socketHandler)); + MOCK_METHOD2(confirmCommandReady, + void(const uint16_t handle, const am_Error_e error)); + MOCK_METHOD2(confirmCommandRundown, + void(const uint16_t handle, const am_Error_e error)); + MOCK_CONST_METHOD2(getListSinkMainNotificationConfigurations, + am_Error_e(const am_sinkID_t sinkID, std::vector& listMainNotificationConfigurations)); + MOCK_CONST_METHOD2(getListSourceMainNotificationConfigurations, + am_Error_e(const am_sourceID_t sourceID, std::vector& listMainNotificationConfigurations)); + MOCK_METHOD2(setSinkMainNotificationConfiguration, + am_Error_e(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)); + MOCK_METHOD2(setSourceMainNotificationConfiguration, + am_Error_e(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)); + }; } // namespace am diff --git a/PluginControlInterface/include/CAmControlSenderBase.h b/PluginControlInterface/include/CAmControlSenderBase.h index 893cbaa..55758f0 100644 --- a/PluginControlInterface/include/CAmControlSenderBase.h +++ b/PluginControlInterface/include/CAmControlSenderBase.h @@ -30,7 +30,7 @@ public: virtual ~CAmControlSenderBase(); am_Error_e startupController(IAmControlReceive* controlreceiveinterface); void setControllerReady(); - void setControllerRundown(); + void setControllerRundown(const int16_t signal); am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID); am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID); am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty); @@ -71,10 +71,25 @@ public: void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error); am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats); void getInterfaceVersion(std::string& version) const; - void confirmCommandReady(); - void confirmRoutingReady(); - void confirmCommandRundown(); - void confirmRoutingRundown(); + void confirmCommandReady(const am_Error_e error) ; + void confirmRoutingReady(const am_Error_e error) ; + void confirmCommandRundown(const am_Error_e error) ; + void confirmRoutingRundown(const am_Error_e error) ; + am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) ; + am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) ; + am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix) ; + void cbAckSetVolume(const am_Handle_s handle, const std::vector listVolumes, const am_Error_e error) ; + void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ; + void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ; + void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) ; + void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) ; + am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) ; + am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) ; + void hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) ; + void hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) ; + void hookSystemSessionStateChanged(const std::string sessionName, const int32_t seatID, const NsmSessionState_e sessionStateID) ; + NsmErrorStatus_e hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) ; + private: IAmControlReceive * mControlReceiveInterface; diff --git a/PluginControlInterface/include/IAmControlReceiverShadow.h b/PluginControlInterface/include/IAmControlReceiverShadow.h index 830fc33..ed8c774 100644 --- a/PluginControlInterface/include/IAmControlReceiverShadow.h +++ b/PluginControlInterface/include/IAmControlReceiverShadow.h @@ -102,8 +102,8 @@ public: void setCommandRundown(); void setRoutingReady(); void setRoutingRundown(); - void confirmControllerReady(); - void confirmControllerRundown(); + void confirmControllerReady(am_Error_e error); + void confirmControllerRundown(am_Error_e error); am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler); private: IAmControlReceive *mpIAmControlReceiver; diff --git a/PluginControlInterface/src/CAmControlSenderBase.cpp b/PluginControlInterface/src/CAmControlSenderBase.cpp index 3e0c65b..8975c32 100644 --- a/PluginControlInterface/src/CAmControlSenderBase.cpp +++ b/PluginControlInterface/src/CAmControlSenderBase.cpp @@ -556,10 +556,13 @@ void CAmControlSenderBase::cbAckSetSinkSoundProperties(const am_Handle_s handle, (void) handle; } -void CAmControlSenderBase::setControllerRundown() +void CAmControlSenderBase::setControllerRundown(const int16_t signal) { - logInfo("CAmControlSenderBase::setControllerRundown() was called"); - mControlReceiveInterface->confirmControllerRundown(); + logInfo("CAmControlSenderBase::setControllerRundown() was called signal=",signal); + if (signal==2) + mControlReceiveInterface->confirmControllerRundown(E_UNKNOWN); + + mControlReceiveInterface->confirmControllerRundown(E_OK); } am_Error_e CAmControlSenderBase::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector & listPrioConnectionFormats) @@ -577,20 +580,6 @@ void CAmControlSenderBase::getInterfaceVersion(std::string & version) const version = ControlSendVersion; } -void CAmControlSenderBase::confirmCommandReady() -{ - logInfo("ControlSenderPlugin got Routing Ready confirmed"); -} - -void CAmControlSenderBase::confirmRoutingReady() -{ - logInfo("ControlSenderPlugin got Command Ready confirmed"); -} - -void CAmControlSenderBase::confirmRoutingRundown() -{ - logInfo("ControlSenderPlugin got Command Rundown confirmed"); -} void CAmControlSenderBase::disconnect(am_mainConnectionID_t connectionID) { @@ -621,11 +610,6 @@ void CAmControlSenderBase::disconnect(am_mainConnectionID_t connectionID) mListOpenDisconnections.push_back(set); } -void CAmControlSenderBase::confirmCommandRundown() -{ - logInfo("ControlSenderPlugin got Routing Rundown confirmed"); -} - void CAmControlSenderBase::connect(am_sourceID_t sourceID, am_sinkID_t sinkID, am_mainConnectionID_t mainConnectionID) { std::vector listRoutes; @@ -771,6 +755,130 @@ void CAmControlSenderBase::callNaviHandler() } } +void CAmControlSenderBase::confirmCommandReady(const am_Error_e error) +{ + (void) error; + logInfo("ControlSenderPlugin got Command Ready confirmed"); +} + +void CAmControlSenderBase::confirmRoutingReady(const am_Error_e error) +{ + (void)error; + logInfo("ControlSenderPlugin got Routing Ready confirmed"); +} + +void CAmControlSenderBase::confirmCommandRundown(const am_Error_e error) +{ + (void)error; + logInfo("ControlSenderPlugin got Command Rundown confirmed"); +} + +void CAmControlSenderBase::confirmRoutingRundown(const am_Error_e error) +{ + (void)error; + logInfo("ControlSenderPlugin got Routing Rundown confirmed"); +} + +void CAmControlSenderBase::hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) +{ + (void) NodeStateId; + //here you can process informations about the notestate +} + +void CAmControlSenderBase::hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) +{ + (void) ApplicationModeId; +} + +void CAmControlSenderBase::hookSystemSessionStateChanged(const std::string sessionName, const int32_t seatID, const NsmSessionState_e sessionStateID) +{ + (void) sessionName; + (void) seatID; + (void) sessionStateID; +} + +am_Error_e CAmControlSenderBase::hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) +{ + (void) sinkID; + (void) sinkClassID; + (void) listMainSoundProperties; + (void) listConnectionFormats; + (void) listSoundProperties; + return (E_NOT_USED); + } + +am_Error_e CAmControlSenderBase::hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) +{ + (void) sourceID; + (void) sourceClassID; + (void) listSoundProperties; + (void) listMainSoundProperties; + (void) listConnectionFormats; + return (E_NOT_USED); + } + +am_Error_e CAmControlSenderBase::hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix) +{ + (void) gatewayID; + (void) listSourceConnectionFormats; + (void) listSinkConnectionFormats; + (void) convertionMatrix; + return (E_NOT_USED); +} + +void CAmControlSenderBase::cbAckSetVolume(const am_Handle_s handle, const std::vector listVolumes, const am_Error_e error) +{ + (void) handle; + (void) listVolumes; + (void) error; +} + +void CAmControlSenderBase::cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) +{ + (void) handle; + (void) error; +} + +void CAmControlSenderBase::cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) +{ + (void) handle; + (void) error; +} + +void CAmControlSenderBase::hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) +{ + (void) sinkID; + (void) payload; +} + +void CAmControlSenderBase::hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) +{ + (void) sourceID; + (void) payload; +} + +am_Error_e CAmControlSenderBase::hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) +{ + (void) sinkID; + (void) notificationConfiguration; + return (E_NOT_USED); +} + +am_Error_e CAmControlSenderBase::hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) +{ + (void) sourceID; + (void) notificationConfiguration; + return (E_NOT_USED); +} + +NsmErrorStatus_e CAmControlSenderBase::hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) +{ + (void) Request; + (void) RequestId; + logInfo("CAmControlSenderBase::hookSystemLifecycleRequest request=",Request," requestID=",RequestId); + return (NsmErrorStatus_Error); +} + void CAmControlSenderBase::callTAHandler() { logInfo("CAmControlSenderBase::callTAHandler() called, state ",mConnectSf); diff --git a/PluginControlInterface/src/IAmControlReceiverShadow.cpp b/PluginControlInterface/src/IAmControlReceiverShadow.cpp index 78083cc..6546deb 100644 --- a/PluginControlInterface/src/IAmControlReceiverShadow.cpp +++ b/PluginControlInterface/src/IAmControlReceiverShadow.cpp @@ -319,14 +319,14 @@ void IAmControlReceiverShadow::setRoutingRundown() mCAmSerializer.asyncCall(mpIAmControlReceiver, &IAmControlReceive::setRoutingRundown); } -void IAmControlReceiverShadow::confirmControllerReady() +void am::IAmControlReceiverShadow::confirmControllerReady(am_Error_e error) { - mCAmSerializer.asyncCall(mpIAmControlReceiver, &IAmControlReceive::confirmControllerReady); + mCAmSerializer.asyncCall(mpIAmControlReceiver,&IAmControlReceive::confirmControllerReady,error); } -void IAmControlReceiverShadow::confirmControllerRundown() +void am::IAmControlReceiverShadow::confirmControllerRundown(am_Error_e error) { - mCAmSerializer.asyncCall(mpIAmControlReceiver, &IAmControlReceive::confirmControllerRundown); + mCAmSerializer.asyncCall(mpIAmControlReceiver, &IAmControlReceive::confirmControllerRundown,error); } am_Error_e IAmControlReceiverShadow::getSocketHandler(CAmSocketHandler *& socketHandler) @@ -518,4 +518,6 @@ am_Error_e IAmControlReceiverShadow::getListGatewaysOfDomain(am_domainID_t domai return (error); } + + } /* namespace am */ diff --git a/PluginControlInterface/test/MockIAmControlReceive.h b/PluginControlInterface/test/MockIAmControlReceive.h index 09ef539..b90574f 100644 --- a/PluginControlInterface/test/MockIAmControlReceive.h +++ b/PluginControlInterface/test/MockIAmControlReceive.h @@ -25,150 +25,191 @@ namespace am { class MockIAmControlReceive : public IAmControlReceive { public: - MOCK_METHOD4(getRoute, - am_Error_e(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList)); - MOCK_METHOD5(connect, - am_Error_e(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)); - MOCK_METHOD2(disconnect, - am_Error_e(am_Handle_s& handle, const am_connectionID_t connectionID)); - MOCK_METHOD5(crossfade, - am_Error_e(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime)); - MOCK_METHOD1(abortAction, - am_Error_e(const am_Handle_s handle)); - MOCK_METHOD3(setSourceState, - am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state)); - MOCK_METHOD5(setSinkVolume, - am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)); - MOCK_METHOD5(setSourceVolume, - am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time)); - MOCK_METHOD3(setSinkSoundProperties, - am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector& soundProperty)); - MOCK_METHOD3(setSinkSoundProperty, - am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)); - MOCK_METHOD3(setSourceSoundProperties, - am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector& soundProperty)); - MOCK_METHOD3(setSourceSoundProperty, - am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)); - MOCK_METHOD2(setDomainState, - am_Error_e(const am_domainID_t domainID, const am_DomainState_e domainState)); - MOCK_METHOD2(enterDomainDB, - am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID)); - MOCK_METHOD2(enterMainConnectionDB, - am_Error_e(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID)); - MOCK_METHOD2(enterSinkDB, - am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID)); - MOCK_METHOD2(enterCrossfaderDB, - am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID)); - MOCK_METHOD2(enterGatewayDB, - am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID)); - MOCK_METHOD2(enterSourceDB, - am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID)); - MOCK_METHOD2(enterSinkClassDB, - am_Error_e(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID)); - MOCK_METHOD2(enterSourceClassDB, - am_Error_e(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass)); - MOCK_METHOD1(changeSinkClassInfoDB, - am_Error_e(const am_SinkClass_s& sinkClass)); - MOCK_METHOD1(changeSourceClassInfoDB, - am_Error_e(const am_SourceClass_s& sourceClass)); - MOCK_METHOD1(enterSystemPropertiesListDB, - am_Error_e(const std::vector& listSystemProperties)); - MOCK_METHOD2(changeMainConnectionRouteDB, - am_Error_e(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID)); - MOCK_METHOD2(changeMainConnectionStateDB, - am_Error_e(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)); - MOCK_METHOD2(changeSinkMainVolumeDB, - am_Error_e(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)); - MOCK_METHOD2(changeSinkAvailabilityDB, - am_Error_e(const am_Availability_s& availability, const am_sinkID_t sinkID)); - MOCK_METHOD2(changDomainStateDB, - am_Error_e(const am_DomainState_e domainState, const am_domainID_t domainID)); - MOCK_METHOD2(changeSinkMuteStateDB, - am_Error_e(const am_MuteState_e muteState, const am_sinkID_t sinkID)); - MOCK_METHOD2(changeMainSinkSoundPropertyDB, - am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID)); - MOCK_METHOD2(changeMainSourceSoundPropertyDB, - am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID)); - MOCK_METHOD2(changeSourceAvailabilityDB, - am_Error_e(const am_Availability_s& availability, const am_sourceID_t sourceID)); - MOCK_METHOD1(changeSystemPropertyDB, - am_Error_e(const am_SystemProperty_s& property)); - MOCK_METHOD1(removeMainConnectionDB, - am_Error_e(const am_mainConnectionID_t mainConnectionID)); - MOCK_METHOD1(removeSinkDB, - am_Error_e(const am_sinkID_t sinkID)); - MOCK_METHOD1(removeSourceDB, - am_Error_e(const am_sourceID_t sourceID)); - MOCK_METHOD1(removeGatewayDB, - am_Error_e(const am_gatewayID_t gatewayID)); - MOCK_METHOD1(removeCrossfaderDB, - am_Error_e(const am_crossfaderID_t crossfaderID)); - MOCK_METHOD1(removeDomainDB, - am_Error_e(const am_domainID_t domainID)); - MOCK_METHOD1(removeSinkClassDB, - am_Error_e(const am_sinkClass_t sinkClassID)); - MOCK_METHOD1(removeSourceClassDB, - am_Error_e(const am_sourceClass_t sourceClassID)); - MOCK_CONST_METHOD2(getSourceClassInfoDB, - am_Error_e(const am_sourceID_t sourceID, am_SourceClass_s& classInfo)); - MOCK_CONST_METHOD2(getSinkClassInfoDB, - am_Error_e(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass)); - MOCK_CONST_METHOD2(getSinkInfoDB, - am_Error_e(const am_sinkID_t sinkID, am_Sink_s& sinkData)); - MOCK_CONST_METHOD2(getSourceInfoDB, - am_Error_e(const am_sourceID_t sourceID, am_Source_s& sourceData)); - MOCK_CONST_METHOD2(getGatewayInfoDB, - am_Error_e(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData)); - MOCK_CONST_METHOD2(getCrossfaderInfoDB, - am_Error_e(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData)); - MOCK_CONST_METHOD2(getMainConnectionInfoDB, - am_Error_e(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData)); - MOCK_CONST_METHOD2(getListSinksOfDomain, - am_Error_e(const am_domainID_t domainID, std::vector& listSinkID)); - MOCK_CONST_METHOD2(getListSourcesOfDomain, - am_Error_e(const am_domainID_t domainID, std::vector& listSourceID)); - MOCK_CONST_METHOD2(getListCrossfadersOfDomain, - am_Error_e(const am_domainID_t domainID, std::vector& listCrossfadersID)); - MOCK_CONST_METHOD2(getListGatewaysOfDomain, - am_Error_e(const am_domainID_t domainID, std::vector& listGatewaysID)); - MOCK_CONST_METHOD1(getListMainConnections, - am_Error_e(std::vector& listMainConnections)); - MOCK_CONST_METHOD1(getListDomains, - am_Error_e(std::vector& listDomains)); - MOCK_CONST_METHOD1(getListConnections, - am_Error_e(std::vector& listConnections)); - MOCK_CONST_METHOD1(getListSinks, - am_Error_e(std::vector& listSinks)); - MOCK_CONST_METHOD1(getListSources, - am_Error_e(std::vector& listSources)); - MOCK_CONST_METHOD1(getListSourceClasses, - am_Error_e(std::vector& listSourceClasses)); - MOCK_CONST_METHOD1(getListHandles, - am_Error_e(std::vector& listHandles)); - MOCK_CONST_METHOD1(getListCrossfaders, - am_Error_e(std::vector& listCrossfaders)); - MOCK_CONST_METHOD1(getListGateways, - am_Error_e(std::vector& listGateways)); - MOCK_CONST_METHOD1(getListSinkClasses, - am_Error_e(std::vector& listSinkClasses)); - MOCK_CONST_METHOD1(getListSystemProperties, - am_Error_e(std::vector& listSystemProperties)); - MOCK_METHOD0(setCommandReady, - void()); - MOCK_METHOD0(setCommandRundown, - void()); - MOCK_METHOD0(setRoutingReady, - void()); - MOCK_METHOD0(setRoutingRundown, - void()); - MOCK_METHOD0(confirmControllerReady, - void()); - MOCK_METHOD0(confirmControllerRundown, - void()); - MOCK_METHOD1(getSocketHandler, - am_Error_e(CAmSocketHandler*& socketHandler)); - MOCK_CONST_METHOD1(getInterfaceVersion, - void(std::string& version)); + MOCK_CONST_METHOD1(getInterfaceVersion, + void(std::string& version)); + MOCK_METHOD4(getRoute, + am_Error_e(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList)); + MOCK_METHOD5(connect, + am_Error_e(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)); + MOCK_METHOD2(disconnect, + am_Error_e(am_Handle_s& handle, const am_connectionID_t connectionID)); + MOCK_METHOD5(crossfade, + am_Error_e(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime)); + MOCK_METHOD1(abortAction, + am_Error_e(const am_Handle_s handle)); + MOCK_METHOD3(setSourceState, + am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state)); + MOCK_METHOD5(setSinkVolume, + am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time)); + MOCK_METHOD5(setSourceVolume, + am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time)); + MOCK_METHOD3(setSinkSoundProperties, + am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector& soundProperty)); + MOCK_METHOD3(setSinkSoundProperty, + am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty)); + MOCK_METHOD3(setSourceSoundProperties, + am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector& soundProperty)); + MOCK_METHOD3(setSourceSoundProperty, + am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty)); + MOCK_METHOD2(setDomainState, + am_Error_e(const am_domainID_t domainID, const am_DomainState_e domainState)); + MOCK_METHOD2(enterDomainDB, + am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID)); + MOCK_METHOD2(enterMainConnectionDB, + am_Error_e(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID)); + MOCK_METHOD2(enterSinkDB, + am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID)); + MOCK_METHOD2(enterCrossfaderDB, + am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID)); + MOCK_METHOD2(enterGatewayDB, + am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID)); + MOCK_METHOD2(enterSourceDB, + am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID)); + MOCK_METHOD2(enterSinkClassDB, + am_Error_e(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID)); + MOCK_METHOD2(enterSourceClassDB, + am_Error_e(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass)); + MOCK_METHOD1(changeSinkClassInfoDB, + am_Error_e(const am_SinkClass_s& sinkClass)); + MOCK_METHOD1(changeSourceClassInfoDB, + am_Error_e(const am_SourceClass_s& sourceClass)); + MOCK_METHOD1(enterSystemPropertiesListDB, + am_Error_e(const std::vector& listSystemProperties)); + MOCK_METHOD2(changeMainConnectionRouteDB, + am_Error_e(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID)); + MOCK_METHOD2(changeMainConnectionStateDB, + am_Error_e(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)); + MOCK_METHOD2(changeSinkMainVolumeDB, + am_Error_e(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)); + MOCK_METHOD2(changeSinkAvailabilityDB, + am_Error_e(const am_Availability_s& availability, const am_sinkID_t sinkID)); + MOCK_METHOD2(changDomainStateDB, + am_Error_e(const am_DomainState_e domainState, const am_domainID_t domainID)); + MOCK_METHOD2(changeSinkMuteStateDB, + am_Error_e(const am_MuteState_e muteState, const am_sinkID_t sinkID)); + MOCK_METHOD2(changeMainSinkSoundPropertyDB, + am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID)); + MOCK_METHOD2(changeMainSourceSoundPropertyDB, + am_Error_e(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID)); + MOCK_METHOD2(changeSourceAvailabilityDB, + am_Error_e(const am_Availability_s& availability, const am_sourceID_t sourceID)); + MOCK_METHOD1(changeSystemPropertyDB, + am_Error_e(const am_SystemProperty_s& property)); + MOCK_METHOD1(removeMainConnectionDB, + am_Error_e(const am_mainConnectionID_t mainConnectionID)); + MOCK_METHOD1(removeSinkDB, + am_Error_e(const am_sinkID_t sinkID)); + MOCK_METHOD1(removeSourceDB, + am_Error_e(const am_sourceID_t sourceID)); + MOCK_METHOD1(removeGatewayDB, + am_Error_e(const am_gatewayID_t gatewayID)); + MOCK_METHOD1(removeCrossfaderDB, + am_Error_e(const am_crossfaderID_t crossfaderID)); + MOCK_METHOD1(removeDomainDB, + am_Error_e(const am_domainID_t domainID)); + MOCK_METHOD1(removeSinkClassDB, + am_Error_e(const am_sinkClass_t sinkClassID)); + MOCK_METHOD1(removeSourceClassDB, + am_Error_e(const am_sourceClass_t sourceClassID)); + MOCK_CONST_METHOD2(getSourceClassInfoDB, + am_Error_e(const am_sourceID_t sourceID, am_SourceClass_s& classInfo)); + MOCK_CONST_METHOD2(getSinkClassInfoDB, + am_Error_e(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass)); + MOCK_CONST_METHOD2(getSinkInfoDB, + am_Error_e(const am_sinkID_t sinkID, am_Sink_s& sinkData)); + MOCK_CONST_METHOD2(getSourceInfoDB, + am_Error_e(const am_sourceID_t sourceID, am_Source_s& sourceData)); + MOCK_CONST_METHOD2(getGatewayInfoDB, + am_Error_e(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData)); + MOCK_CONST_METHOD2(getCrossfaderInfoDB, + am_Error_e(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData)); + MOCK_CONST_METHOD2(getMainConnectionInfoDB, + am_Error_e(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData)); + MOCK_CONST_METHOD2(getListSinksOfDomain, + am_Error_e(const am_domainID_t domainID, std::vector& listSinkID)); + MOCK_CONST_METHOD2(getListSourcesOfDomain, + am_Error_e(const am_domainID_t domainID, std::vector& listSourceID)); + MOCK_CONST_METHOD2(getListCrossfadersOfDomain, + am_Error_e(const am_domainID_t domainID, std::vector& listCrossfadersID)); + MOCK_CONST_METHOD2(getListGatewaysOfDomain, + am_Error_e(const am_domainID_t domainID, std::vector& listGatewaysID)); + MOCK_CONST_METHOD1(getListMainConnections, + am_Error_e(std::vector& listMainConnections)); + MOCK_CONST_METHOD1(getListDomains, + am_Error_e(std::vector& listDomains)); + MOCK_CONST_METHOD1(getListConnections, + am_Error_e(std::vector& listConnections)); + MOCK_CONST_METHOD1(getListSinks, + am_Error_e(std::vector& listSinks)); + MOCK_CONST_METHOD1(getListSources, + am_Error_e(std::vector& listSources)); + MOCK_CONST_METHOD1(getListSourceClasses, + am_Error_e(std::vector& listSourceClasses)); + MOCK_CONST_METHOD1(getListHandles, + am_Error_e(std::vector& listHandles)); + MOCK_CONST_METHOD1(getListCrossfaders, + am_Error_e(std::vector& listCrossfaders)); + MOCK_CONST_METHOD1(getListGateways, + am_Error_e(std::vector& listGateways)); + MOCK_CONST_METHOD1(getListSinkClasses, + am_Error_e(std::vector& listSinkClasses)); + MOCK_CONST_METHOD1(getListSystemProperties, + am_Error_e(std::vector& listSystemProperties)); + MOCK_METHOD0(setCommandReady, + void()); + MOCK_METHOD0(setCommandRundown, + void()); + MOCK_METHOD0(setRoutingReady, + void()); + MOCK_METHOD0(setRoutingRundown, + void()); + MOCK_METHOD1(confirmControllerReady, + void(const am_Error_e error)); + MOCK_METHOD1(confirmControllerRundown, + void(const am_Error_e error)); + MOCK_METHOD1(getSocketHandler, + am_Error_e(CAmSocketHandler*& socketHandler)); + MOCK_METHOD5(changeSourceDB, + am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties)); + MOCK_METHOD5(changeSinkDB, + am_Error_e(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties)); + MOCK_METHOD4(changeGatewayDB, + am_Error_e(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix)); + MOCK_METHOD2(setVolumes, + am_Error_e(am_Handle_s& handle, const std::vector listVolumes)); + MOCK_METHOD3(setSinkNotificationConfiguration, + am_Error_e(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration)); + MOCK_METHOD3(setSourceNotificationConfiguration, + am_Error_e(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s norificationConfiguration)); + MOCK_METHOD2(sendSinkMainNotificationPayload, + void(const am_sinkID_t sinkID, const am_NotificationPayload_s notificationPayload)); + MOCK_METHOD2(sendSourceMainNotificationPayload, + void(const am_sourceID_t sourceID, const am_NotificationPayload_s notificationPayload)); + MOCK_METHOD2(changeMainSinkNotificationConfigurationDB, + am_Error_e(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)); + MOCK_METHOD2(changeMainSourceNotificationConfigurationDB, + am_Error_e(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)); + MOCK_METHOD1(nsmGetRestartReasonProperty, + am_Error_e(NsmRestartReason_e& restartReason)); + MOCK_METHOD1(nsmGetShutdownReasonProperty, + am_Error_e(NsmShutdownReason_e& ShutdownReason)); + MOCK_METHOD1(nsmGetRunningReasonProperty, + am_Error_e(NsmRunningReason_e& nsmRunningReason)); + MOCK_METHOD1(nsmGetNodeState, + NsmErrorStatus_e(NsmNodeState_e& nsmNodeState)); + MOCK_METHOD3(nsmGetSessionState, + NsmErrorStatus_e(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState)); + MOCK_METHOD1(nsmGetApplicationMode, + NsmErrorStatus_e(NsmApplicationMode_e& applicationMode)); + MOCK_METHOD2(nsmRegisterShutdownClient, + NsmErrorStatus_e(const uint32_t shutdownMode, const uint32_t timeoutMs)); + MOCK_METHOD1(nsmUnRegisterShutdownClient, + NsmErrorStatus_e(const uint32_t shutdownMode)); + MOCK_METHOD1(nsmGetInterfaceVersion, + am_Error_e(uint32_t& version)); + MOCK_METHOD2(nsmSendLifecycleRequestComplete, + NsmErrorStatus_e(const uint32_t RequestId, const NsmErrorStatus_e status)); + }; } // namespace am diff --git a/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h b/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h index c0da207..6d1fbed 100644 --- a/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h +++ b/PluginRoutingInterfaceAsync/include/CAmRoutingSenderAsync.h @@ -138,6 +138,9 @@ public: am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ; am_Error_e returnBusName(std::string& BusName) const ; void getInterfaceVersion(std::string& version) const ; + am_Error_e asyncSetVolumes(const am_Handle_s handle, const std::vector& listVolumes) ; + am_Error_e asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ; + am_Error_e asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ; /** * threadafe insert of route and connectionID diff --git a/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h b/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h index 90ced6f..48056f1 100644 --- a/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h +++ b/PluginRoutingInterfaceAsync/include/IAmRoutingReceiverShadow.h @@ -56,8 +56,8 @@ public: am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ; am_Error_e deregisterSource(const am_sourceID_t sourceID) ; am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ; - void confirmRoutingReady(uint16_t starupHandle); - void confirmRoutingRundown(uint16_t rundownHandle); + void confirmRoutingReady(uint16_t starupHandle, am_Error_e error); + void confirmRoutingRundown(uint16_t rundownHandle,am_Error_e error); private: diff --git a/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp b/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp index 43de210..83415e9 100644 --- a/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp +++ b/PluginRoutingInterfaceAsync/src/CAmRoutingSenderAsync.cpp @@ -73,8 +73,8 @@ mNumThreads(numThreads) mListWorkers.resize(mNumThreads); for (int i=0;iconfirmRoutingRundown(handle); + mShadow->confirmRoutingRundown(handle,E_OK); } am_Error_e CAmRoutingSenderAsync::asyncAbort(const am_Handle_s handle) @@ -315,7 +315,7 @@ am_Error_e CAmRoutingSenderAsync::asyncConnect(const am_Handle_s handle, const a //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -350,7 +350,7 @@ am_Error_e CAmRoutingSenderAsync::asyncDisconnect(const am_Handle_s handle, cons //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -392,7 +392,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkVolume(const am_Handle_s handle, c //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -434,7 +434,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSourceVolume(const am_Handle_s handle, //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -476,7 +476,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSourceState(const am_Handle_s handle, //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -518,7 +518,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkSoundProperty(const am_Handle_s ha //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -607,7 +607,7 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSourceSoundProperty(const am_Handle_s //save the handle related to the workerID pthread_mutex_lock(&mMapHandleWorkerMutex); - mMapHandleWorker.insert(std::make_pair(handle.handle, work)); + mMapHandleWorker.insert(std::make_pair(+handle.handle, work)); pthread_mutex_unlock(&mMapHandleWorkerMutex); return (E_OK); @@ -880,6 +880,32 @@ am_Error_e CAmRoutingSenderAsync::asyncSetSinkSoundProperties(const am_Handle_s return (E_NOT_USED); } +am_Error_e am::CAmRoutingSenderAsync::asyncSetVolumes(const am_Handle_s handle, const std::vector& listVolumes) +{ + (void)handle; + (void)listVolumes; + //todo: implement + return (E_NOT_USED); +} + +am_Error_e am::CAmRoutingSenderAsync::asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) +{ + (void)handle; + (void)sinkID; + (void)notificationConfiguration; + //todo: implement + return (E_NOT_USED); +} + +am_Error_e am::CAmRoutingSenderAsync::asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) +{ + (void)handle; + (void)sourceID; + (void)notificationConfiguration; + //todo: implement + return (E_NOT_USED); +} + std::vector CAmRoutingSenderAsync::createGatewayTable() { std::vector table; @@ -1283,7 +1309,7 @@ void syncRegisterWorker::start2work() } mAsyncSender->updateSinkListSafe(mListSinks); - mShadow->confirmRoutingReady(mHandle); + mShadow->confirmRoutingReady(mHandle,E_OK); } void syncRegisterWorker::cancelWork() diff --git a/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp b/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp index 5ab2360..71b0cc5 100644 --- a/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp +++ b/PluginRoutingInterfaceAsync/src/IAmRoutingReceiverShadow.cpp @@ -99,12 +99,12 @@ void IAmRoutingReceiverShadow::hookInterruptStatusChange(const am_sourceID_t sou void IAmRoutingReceiverShadow::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability) { - mSerializer.asyncCall(mRoutingReceiveInterface, &IAmRoutingReceive::hookSinkAvailablityStatusChange, sinkID, availability); + mSerializer.asyncCall(mRoutingReceiveInterface, &IAmRoutingReceive::hookSinkAvailablityStatusChange, sinkID, availability); } void IAmRoutingReceiverShadow::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability) { - mSerializer.asyncCall(mRoutingReceiveInterface, &IAmRoutingReceive::hookSourceAvailablityStatusChange, sourceID, availability); + mSerializer.asyncCall(mRoutingReceiveInterface, &IAmRoutingReceive::hookSourceAvailablityStatusChange, sourceID, availability); } void IAmRoutingReceiverShadow::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState) @@ -173,14 +173,14 @@ am_Error_e am::IAmRoutingReceiverShadow::registerCrossfader(const am_Crossfader_ return (error); } -void am::IAmRoutingReceiverShadow::confirmRoutingReady(uint16_t starupHandle) +void am::IAmRoutingReceiverShadow::confirmRoutingReady(uint16_t starupHandle, am_Error_e error) { - mSerializer.asyncCall(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingReady,starupHandle); + mSerializer.asyncCall(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingReady,starupHandle,error); } -void am::IAmRoutingReceiverShadow::confirmRoutingRundown(uint16_t rundownHandle) +void am::IAmRoutingReceiverShadow::confirmRoutingRundown(uint16_t rundownHandle, am_Error_e error) { - mSerializer.asyncCall(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingRundown,rundownHandle); + mSerializer.asyncCall(mRoutingReceiveInterface,&IAmRoutingReceive::confirmRoutingRundown,rundownHandle,error); } diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp index 17e4cff..c02d5d3 100644 --- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp +++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.cpp @@ -26,15 +26,18 @@ using namespace am; using namespace testing; +static CAmEnvironment* env; + am_domainID_t CAmEnvironment::mDomainIDCount = 0; static IAmRoutingSend* pRouter; -static CAmSocketHandler pSocketHandler; -static MockIAmRoutingReceive pReceiveInterface; CAmEnvironment::CAmEnvironment() : + pSocketHandler(), + pReceiveInterface(), ptimerCallback(this, &CAmEnvironment::timerCallback) { DefaultValue::Set(E_OK); // Sets the default value to be returned. + env=this; } CAmEnvironment::~CAmEnvironment() @@ -49,11 +52,11 @@ void CAmEnvironment::SetUp() domainIDs.push_back(0); domainIDs.push_back(1); - EXPECT_CALL(pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&pSocketHandler), Return(E_OK))); - EXPECT_CALL(pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleDomainRegister)); - EXPECT_CALL(pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSourceRegister)); - EXPECT_CALL(pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSinkRegister)); - EXPECT_CALL(pReceiveInterface,confirmRoutingReady(_)).Times(1); + EXPECT_CALL(env->pReceiveInterface,getSocketHandler(_)).WillOnce(DoAll(SetArgReferee<0>(&env->pSocketHandler), Return(E_OK))); + EXPECT_CALL(env->pReceiveInterface,registerDomain(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleDomainRegister)); + EXPECT_CALL(env->pReceiveInterface,registerSource(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSourceRegister)); + EXPECT_CALL(env->pReceiveInterface,registerSink(_,_)).WillRepeatedly(Invoke(CAmEnvironment::handleSinkRegister)); + EXPECT_CALL(env->pReceiveInterface,confirmRoutingReady(_,_)).Times(1); IAmRoutingSend* (*createFunc)(); void* tempLibHandle = NULL; @@ -74,7 +77,7 @@ void CAmEnvironment::SetUp() exit(1); } - pRouter->startupInterface(&pReceiveInterface); + pRouter->startupInterface(&env->pReceiveInterface); pRouter->setRoutingReady(10); timespec t; @@ -84,8 +87,8 @@ void CAmEnvironment::SetUp() sh_timerHandle_t handle; //lets use a timeout so the test will finish - pSocketHandler.addTimer(t, &ptimerCallback, handle, (void*) NULL); - pSocketHandler.start_listenting(); + env->pSocketHandler.addTimer(t, &ptimerCallback, handle, (void*) NULL); + env->pSocketHandler.start_listenting(); } @@ -107,7 +110,7 @@ void CAmRoutingReceiverAsync::timerCallback(sh_timerHandle_t handle, void *userD { (void) handle; (void) userData; - pSocketHandler.stop_listening(); + env->pSocketHandler.stop_listening(); } void CAmRoutingReceiverAsync::SetUp() @@ -120,7 +123,7 @@ void CAmRoutingReceiverAsync::SetUp() // // shTimerCallBack *buf = &ptimerCallback; // //lets use a timeout so the test will finish -// pSocketHandler.addTimer(t, buf, handle, (void*) NULL); +// env->pSocketHandler.addTimer(t, buf, handle, (void*) NULL); } std::vector CAmEnvironment::returnListPlugins() @@ -154,8 +157,8 @@ void CAmEnvironment::timerCallback(sh_timerHandle_t handle, void *userData) { (void) handle; (void) userData; - pSocketHandler.restartTimer(handle); - pSocketHandler.stop_listening(); + env->pSocketHandler.restartTimer(handle); + env->pSocketHandler.stop_listening(); } void CAmRoutingReceiverAsync::TearDown() @@ -167,10 +170,10 @@ TEST_F(CAmRoutingReceiverAsync,setDomainState) am_domainID_t domainID = 1; am_DomainState_e state = DS_INDEPENDENT_RUNDOWN; - EXPECT_CALL(pReceiveInterface,hookDomainStateChange(_,DS_INDEPENDENT_RUNDOWN)).Times(1); + EXPECT_CALL(env->pReceiveInterface,hookDomainStateChange(_,DS_INDEPENDENT_RUNDOWN)).Times(1); ASSERT_EQ(E_OK, pRouter->setDomainState(domainID,state)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,setSourceSoundProperty) @@ -185,10 +188,10 @@ TEST_F(CAmRoutingReceiverAsync,setSourceSoundProperty) property.type = SP_EXAMPLE_MID; property.value = 24; - EXPECT_CALL(pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackSetSourceSoundProperty(_,E_OK)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncSetSourceSoundProperty(handle,sourceID,property)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,setSinkSoundProperty) @@ -203,10 +206,10 @@ TEST_F(CAmRoutingReceiverAsync,setSinkSoundProperty) property.type = SP_EXAMPLE_MID; property.value = 24; - EXPECT_CALL(pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackSetSinkSoundProperty(_,E_OK)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncSetSinkSoundProperty(handle,sinkID,property)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,setSourceState) @@ -219,10 +222,10 @@ TEST_F(CAmRoutingReceiverAsync,setSourceState) am_sourceID_t sourceID = 1; am_SourceState_e state = SS_OFF; - EXPECT_CALL(pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackSetSourceState(_,E_OK)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncSetSourceState(handle,sourceID,state)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,setSourceVolume) @@ -237,11 +240,11 @@ TEST_F(CAmRoutingReceiverAsync,setSourceVolume) am_RampType_e ramp = RAMP_GENIVI_DIRECT; am_time_t myTime = 25; - EXPECT_CALL(pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(AtLeast(1)); - EXPECT_CALL(pReceiveInterface,ackSetSourceVolumeChange(_,volume,E_OK)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackSourceVolumeTick(_,sourceID,_)).Times(AtLeast(1)); + EXPECT_CALL(env->pReceiveInterface,ackSetSourceVolumeChange(_,volume,E_OK)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncSetSourceVolume(handle,sourceID,volume,ramp,myTime)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,setSinkVolume) @@ -256,11 +259,11 @@ TEST_F(CAmRoutingReceiverAsync,setSinkVolume) am_RampType_e ramp = RAMP_GENIVI_DIRECT; am_time_t myTime = 25; - EXPECT_CALL(pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2)); - EXPECT_CALL(pReceiveInterface,ackSetSinkVolumeChange(_,volume,E_OK)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackSinkVolumeTick(_,sinkID,_)).Times(AtLeast(2)); + EXPECT_CALL(env->pReceiveInterface,ackSetSinkVolumeChange(_,volume,E_OK)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,setSinkVolumeAbort) @@ -275,13 +278,13 @@ TEST_F(CAmRoutingReceiverAsync,setSinkVolumeAbort) am_RampType_e ramp = RAMP_GENIVI_DIRECT; am_time_t myTime = 25; - EXPECT_CALL(pReceiveInterface, ackSinkVolumeTick(_,sinkID,_)); - EXPECT_CALL(pReceiveInterface,ackSetSinkVolumeChange(_,AllOf(Ne(volume),Ne(0)),E_ABORTED)).Times(1); + EXPECT_CALL(env->pReceiveInterface, ackSinkVolumeTick(_,sinkID,_)); + EXPECT_CALL(env->pReceiveInterface,ackSetSinkVolumeChange(_,AllOf(Ne(volume),Ne(0)),E_ABORTED)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncSetSinkVolume(handle,sinkID,volume,ramp,myTime)); sleep(0.5); ASSERT_EQ(E_OK, pRouter->asyncAbort(handle)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,disconnectNonExisting) @@ -293,10 +296,10 @@ TEST_F(CAmRoutingReceiverAsync,disconnectNonExisting) am_connectionID_t connectionID = 4; - EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); - EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(env->pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncDisconnect(handle,connectionID)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,disconnectTooEarly) @@ -315,11 +318,11 @@ TEST_F(CAmRoutingReceiverAsync,disconnectTooEarly) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK)); - EXPECT_CALL(pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(env->pReceiveInterface,ackDisconnect(_,connectionID,E_OK)).Times(0); ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncDisconnect(handle,connectionID)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,disconnectAbort) @@ -338,13 +341,13 @@ TEST_F(CAmRoutingReceiverAsync,disconnectAbort) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK)); - EXPECT_CALL(pReceiveInterface, ackDisconnect(_,connectionID,E_ABORTED)); + EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(env->pReceiveInterface, ackDisconnect(_,connectionID,E_ABORTED)); ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); sleep(2); ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID)); ASSERT_EQ(E_OK, pRouter->asyncAbort(handle)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,disconnect) @@ -363,12 +366,12 @@ TEST_F(CAmRoutingReceiverAsync,disconnect) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK)); - EXPECT_CALL(pReceiveInterface, ackDisconnect(_,connectionID,E_OK)); + EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(env->pReceiveInterface, ackDisconnect(_,connectionID,E_OK)); ASSERT_EQ(E_OK, pRouter->asyncConnect(handle_c,connectionID,sourceID,sinkID,format)); sleep(2); ASSERT_EQ(E_OK, pRouter->asyncDisconnect(handle,connectionID)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connectAbortTooLate) @@ -383,11 +386,11 @@ TEST_F(CAmRoutingReceiverAsync,connectAbortTooLate) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); sleep(3); ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncAbort(handle)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connectAbort) @@ -402,11 +405,11 @@ TEST_F(CAmRoutingReceiverAsync,connectAbort) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_ABORTED)).Times(1); ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); sleep(0.5); ASSERT_EQ(E_OK, pRouter->asyncAbort(handle)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connectWrongFormat) @@ -421,9 +424,9 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongFormat) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_MONO; - EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); ASSERT_EQ(E_WRONG_FORMAT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connectWrongSink) @@ -438,9 +441,9 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongSink) am_sinkID_t sinkID = 122; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connectWrongSource) @@ -454,9 +457,9 @@ TEST_F(CAmRoutingReceiverAsync,connectWrongSource) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,connectionID,E_OK)).Times(0); ASSERT_EQ(E_NON_EXISTENT, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connect) @@ -471,9 +474,9 @@ TEST_F(CAmRoutingReceiverAsync,connect) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface, ackConnect(_,connectionID,E_OK)); + EXPECT_CALL(env->pReceiveInterface, ackConnect(_,connectionID,E_OK)); ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads) @@ -488,7 +491,7 @@ TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads) am_sinkID_t sinkID = 1; am_ConnectionFormat_e format = CF_GENIVI_ANALOG; - EXPECT_CALL(pReceiveInterface,ackConnect(_,_,E_OK)).Times(10); + EXPECT_CALL(env->pReceiveInterface,ackConnect(_,_,E_OK)).Times(10); for (int i = 0; i < 10; i++) { handle.handle++; @@ -496,7 +499,7 @@ TEST_F(CAmRoutingReceiverAsync,connectNoMoreThreads) ASSERT_EQ(E_OK, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); } ASSERT_EQ(E_NOT_POSSIBLE, pRouter->asyncConnect(handle,connectionID,sourceID,sinkID,format)); - pSocketHandler.start_listenting(); + env->pSocketHandler.start_listenting(); } int main(int argc, char **argv) diff --git a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h index 37fd5a1..a9b2007 100644 --- a/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h +++ b/PluginRoutingInterfaceAsync/test/CAmRoutingReceiverAsync.h @@ -33,6 +33,8 @@ namespace am class CAmEnvironment: public ::testing::Environment { public: + CAmSocketHandler pSocketHandler; + MockIAmRoutingReceive pReceiveInterface; static std::vector returnListPlugins(); static am_Error_e handleDomainRegister(const am_Domain_s& domainData, am_domainID_t& domainID); static am_Error_e handleSourceRegister(const am_Source_s& sourceData, am_sourceID_t& sourceID); diff --git a/PluginRoutingInterfaceAsync/test/CMakeLists.txt b/PluginRoutingInterfaceAsync/test/CMakeLists.txt index 1097d41..a8ca55c 100644 --- a/PluginRoutingInterfaceAsync/test/CMakeLists.txt +++ b/PluginRoutingInterfaceAsync/test/CMakeLists.txt @@ -29,7 +29,6 @@ FIND_PACKAGE(DBUS REQUIRED) IF(WITH_DLT) pkg_check_modules(DLT REQUIRED automotive-dlt) -) ENDIF(WITH_DLT) pkg_check_modules(SQLITE REQUIRED sqlite3) diff --git a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h index 0554c5c..1dafefc 100644 --- a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h +++ b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h @@ -24,84 +24,101 @@ namespace am { class MockIAmRoutingReceive : public IAmRoutingReceive { public: - MOCK_METHOD3(ackConnect, - void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)); - MOCK_METHOD3(ackDisconnect, - void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)); - MOCK_METHOD3(ackSetSinkVolumeChange, - void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)); - MOCK_METHOD3(ackSetSourceVolumeChange, - void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)); - MOCK_METHOD2(ackSetSourceState, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(ackSetSinkSoundProperties, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(ackSetSinkSoundProperty, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(ackSetSourceSoundProperties, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD2(ackSetSourceSoundProperty, - void(const am_Handle_s handle, const am_Error_e error)); - MOCK_METHOD3(ackCrossFading, - void(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)); - MOCK_METHOD3(ackSourceVolumeTick, - void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)); - MOCK_METHOD3(ackSinkVolumeTick, - void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)); - MOCK_METHOD2(peekDomain, - am_Error_e(const std::string& name, am_domainID_t& domainID)); - MOCK_METHOD2(registerDomain, - am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID)); - MOCK_METHOD1(deregisterDomain, - am_Error_e(const am_domainID_t domainID)); - MOCK_METHOD2(registerGateway, - am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID)); - MOCK_METHOD1(deregisterGateway, - am_Error_e(const am_gatewayID_t gatewayID)); - MOCK_METHOD2(peekSink, - am_Error_e(const std::string& name, am_sinkID_t& sinkID)); - MOCK_METHOD2(registerSink, - am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID)); - MOCK_METHOD1(deregisterSink, - am_Error_e(const am_sinkID_t sinkID)); - MOCK_METHOD2(peekSource, - am_Error_e(const std::string& name, am_sourceID_t& sourceID)); - MOCK_METHOD2(registerSource, - am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID)); - MOCK_METHOD1(deregisterSource, - am_Error_e(const am_sourceID_t sourceID)); - MOCK_METHOD2(registerCrossfader, - am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID)); - MOCK_METHOD1(deregisterCrossfader, - am_Error_e(const am_crossfaderID_t crossfaderID)); - MOCK_METHOD2(peekSourceClassID, - am_Error_e(const std::string& name, am_sourceClass_t& sourceClassID)); - MOCK_METHOD2(peekSinkClassID, - am_Error_e(const std::string& name, am_sinkClass_t& sinkClassID)); - MOCK_METHOD2(hookInterruptStatusChange, - void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)); - MOCK_METHOD1(hookDomainRegistrationComplete, - void(const am_domainID_t domainID)); - MOCK_METHOD2(hookSinkAvailablityStatusChange, - void(const am_sinkID_t sinkID, const am_Availability_s& availability)); - MOCK_METHOD2(hookSourceAvailablityStatusChange, - void(const am_sourceID_t sourceID, const am_Availability_s& availability)); - MOCK_METHOD2(hookDomainStateChange, - void(const am_domainID_t domainID, const am_DomainState_e domainState)); - MOCK_METHOD2(hookTimingInformationChanged, - void(const am_connectionID_t connectionID, const am_timeSync_t delay)); - MOCK_METHOD1(sendChangedData, - void(const std::vector& earlyData)); - MOCK_CONST_METHOD1(getDBusConnectionWrapper, - am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper)); - MOCK_CONST_METHOD1(getSocketHandler, - am_Error_e(CAmSocketHandler*& socketHandler)); - MOCK_CONST_METHOD1(getInterfaceVersion, - void(std::string& version)); - MOCK_METHOD1(confirmRoutingReady, - void(const uint16_t handle)); - MOCK_METHOD1(confirmRoutingRundown, - void(const uint16_t handle)); + MOCK_CONST_METHOD1(getInterfaceVersion, + void(std::string& version)); + MOCK_METHOD3(ackConnect, + void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)); + MOCK_METHOD3(ackDisconnect, + void(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)); + MOCK_METHOD3(ackSetSinkVolumeChange, + void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)); + MOCK_METHOD3(ackSetSourceVolumeChange, + void(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)); + MOCK_METHOD2(ackSetSourceState, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(ackSetSinkSoundProperties, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(ackSetSinkSoundProperty, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(ackSetSourceSoundProperties, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(ackSetSourceSoundProperty, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD3(ackCrossFading, + void(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)); + MOCK_METHOD3(ackSourceVolumeTick, + void(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)); + MOCK_METHOD3(ackSinkVolumeTick, + void(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)); + MOCK_METHOD2(peekDomain, + am_Error_e(const std::string& name, am_domainID_t& domainID)); + MOCK_METHOD2(registerDomain, + am_Error_e(const am_Domain_s& domainData, am_domainID_t& domainID)); + MOCK_METHOD1(deregisterDomain, + am_Error_e(const am_domainID_t domainID)); + MOCK_METHOD2(registerGateway, + am_Error_e(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID)); + MOCK_METHOD1(deregisterGateway, + am_Error_e(const am_gatewayID_t gatewayID)); + MOCK_METHOD2(peekSink, + am_Error_e(const std::string& name, am_sinkID_t& sinkID)); + MOCK_METHOD2(registerSink, + am_Error_e(const am_Sink_s& sinkData, am_sinkID_t& sinkID)); + MOCK_METHOD1(deregisterSink, + am_Error_e(const am_sinkID_t sinkID)); + MOCK_METHOD2(peekSource, + am_Error_e(const std::string& name, am_sourceID_t& sourceID)); + MOCK_METHOD2(registerSource, + am_Error_e(const am_Source_s& sourceData, am_sourceID_t& sourceID)); + MOCK_METHOD1(deregisterSource, + am_Error_e(const am_sourceID_t sourceID)); + MOCK_METHOD2(registerCrossfader, + am_Error_e(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID)); + MOCK_METHOD1(deregisterCrossfader, + am_Error_e(const am_crossfaderID_t crossfaderID)); + MOCK_METHOD2(peekSourceClassID, + am_Error_e(const std::string& name, am_sourceClass_t& sourceClassID)); + MOCK_METHOD2(peekSinkClassID, + am_Error_e(const std::string& name, am_sinkClass_t& sinkClassID)); + MOCK_METHOD2(hookInterruptStatusChange, + void(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)); + MOCK_METHOD1(hookDomainRegistrationComplete, + void(const am_domainID_t domainID)); + MOCK_METHOD2(hookSinkAvailablityStatusChange, + void(const am_sinkID_t sinkID, const am_Availability_s& availability)); + MOCK_METHOD2(hookSourceAvailablityStatusChange, + void(const am_sourceID_t sourceID, const am_Availability_s& availability)); + MOCK_METHOD2(hookDomainStateChange, + void(const am_domainID_t domainID, const am_DomainState_e domainState)); + MOCK_METHOD2(hookTimingInformationChanged, + void(const am_connectionID_t connectionID, const am_timeSync_t delay)); + MOCK_METHOD1(sendChangedData, + void(const std::vector& earlyData)); + MOCK_CONST_METHOD1(getDBusConnectionWrapper, + am_Error_e(CAmDbusWrapper*& dbusConnectionWrapper)); + MOCK_CONST_METHOD1(getSocketHandler, + am_Error_e(CAmSocketHandler*& socketHandler)); + MOCK_METHOD2(confirmRoutingReady, + void(const uint16_t handle, const am_Error_e error)); + MOCK_METHOD2(confirmRoutingRundown, + void(const uint16_t handle, const am_Error_e error)); + MOCK_METHOD4(updateGateway, + am_Error_e(const am_gatewayID_t gatewayID, std::vector listSourceFormats, const std::vector listSinkFormats, std::vector convertionMatrix)); + MOCK_METHOD5(updateSink, + am_Error_e(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties)); + MOCK_METHOD5(updateSource, + am_Error_e(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, std::vector listSoundProperties, std::vector listConnectionFormats, const std::vector listMainSoundProperties)); + MOCK_METHOD3(ackSetVolumes, + void(const am_Handle_s handle, const std::vector listvolumes, const am_Error_e error)); + MOCK_METHOD2(ackSinkNotificationConfiguration, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(ackSourceNotificationConfiguration, + void(const am_Handle_s handle, const am_Error_e error)); + MOCK_METHOD2(hookSinkNotificationDataChange, + void(const am_sinkID_t sinkID, const am_NotificationPayload_s payload)); + MOCK_METHOD2(hookSourceNotificationDataChange, + void(const am_sourceID_t sourceID, const am_NotificationPayload_s payload)); + }; } // namespace am diff --git a/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h b/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h index 751f5ae..a7f251b 100644 --- a/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h +++ b/PluginRoutingInterfaceDbus/include/CAmRoutingSenderDbus.h @@ -49,6 +49,9 @@ public: am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState); am_Error_e returnBusName(std::string& BusName) const; void getInterfaceVersion(std::string& version) const; + am_Error_e asyncSetVolumes(const am_Handle_s handle, const std::vector& listVolumes) ; + am_Error_e asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ; + am_Error_e asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ; struct rs_lookupData_s { diff --git a/PluginRoutingInterfaceDbus/include/configRoutingDbus.h b/PluginRoutingInterfaceDbus/include/configRoutingDbus.h index 6ce5638..2420184 100644 --- a/PluginRoutingInterfaceDbus/include/configRoutingDbus.h +++ b/PluginRoutingInterfaceDbus/include/configRoutingDbus.h @@ -1,6 +1,6 @@ #ifndef _ROUTINGDBUS_CONFIG_H #define _ROUTINGDBUS_CONFIG_H -#define ROUTING_DBUS_INTROSPECTION_FILE "/usr/share/audiomanager/RoutingReceiver.xml" +#define ROUTING_DBUS_INTROSPECTION_FILE "/home/christian/workspace/AudioManager/bin/RoutingReceiver.xml" #endif /* _ROUTINGDBUS_CONFIG_H */ diff --git a/PluginRoutingInterfaceDbus/src/CAmRoutingSenderDbus.cpp b/PluginRoutingInterfaceDbus/src/CAmRoutingSenderDbus.cpp index 8784c07..078f47a 100644 --- a/PluginRoutingInterfaceDbus/src/CAmRoutingSenderDbus.cpp +++ b/PluginRoutingInterfaceDbus/src/CAmRoutingSenderDbus.cpp @@ -345,6 +345,32 @@ void CAmRoutingSenderDbus::removeSourceLookup(am_sourceID_t sourceID) mMapHandles.erase(sourceID); } +am_Error_e CAmRoutingSenderDbus::asyncSetVolumes(const am_Handle_s handle, const std::vector& listVolumes) +{ + (void) handle; + (void) listVolumes; + //todo: implement asyncSetVolumes; + return (E_NOT_USED); +} + +am_Error_e CAmRoutingSenderDbus::asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) +{ + (void) handle; + (void) sinkID; + (void) notificationConfiguration; + //todo: implement asyncSetSinkNotificationConfiguration; + return (E_NOT_USED); +} + +am_Error_e CAmRoutingSenderDbus::asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) +{ + (void) handle; + (void) sourceID; + (void) notificationConfiguration; + //todo: implement asyncSetSourceNotificationConfiguration; + return (E_NOT_USED); +} + void CAmRoutingSenderDbus::removeSinkLookup(am_sinkID_t sinkID) { mMapHandles.erase(sinkID); diff --git a/PluginRoutingInterfaceDbus/src/IAmRoutingReceiverShadow.cpp b/PluginRoutingInterfaceDbus/src/IAmRoutingReceiverShadow.cpp index 91004c4..4115a21 100644 --- a/PluginRoutingInterfaceDbus/src/IAmRoutingReceiverShadow.cpp +++ b/PluginRoutingInterfaceDbus/src/IAmRoutingReceiverShadow.cpp @@ -669,7 +669,7 @@ void IAmRoutingReceiverShadowDbus::confirmRoutingReady(DBusConnection* conn, DBu mNumberDomains--; if(mNumberDomains==0) - mRoutingReceiveInterface->confirmRoutingRundown(mHandle); + mRoutingReceiveInterface->confirmRoutingRundown(mHandle,E_OK); } void IAmRoutingReceiverShadowDbus::confirmRoutingRundown(DBusConnection* conn, DBusMessage* msg) @@ -682,7 +682,7 @@ void IAmRoutingReceiverShadowDbus::confirmRoutingRundown(DBusConnection* conn, D mNumberDomains--; if(mNumberDomains==0) - mRoutingReceiveInterface->confirmRoutingReady(mHandle); + mRoutingReceiveInterface->confirmRoutingReady(mHandle,E_OK); } void IAmRoutingReceiverShadowDbus::gotReady(int16_t numberDomains, uint16_t handle) diff --git a/README b/README index ec69609..4ae427c 100755 --- a/README +++ b/README @@ -64,8 +64,7 @@ These are the compile options with default values: USE_BUILD_LIBS ON WITH_DBUS_WRAPPER ON WITH_DLT ON - WITH_DOCUMENTATION OFF - WITH_MAIN ON + WITH_DOCUMENTATION OFF WITH_PLUGIN_COMMAND ON WITH_PLUGIN_CONTROL ON WITH_PLUGIN_ROUTING ON @@ -105,12 +104,19 @@ You will need to fullfill some dependencies in order to comile the GENIVI AudioM * sqlite3 [tested on version 3.6.22] * automotive-dlt [greater 2.5.0] * doxygen (only when WITH_DOCUMENTATION==ON) [tested on version 1.6.3] +* nodestatemanager headers [tested with version 0.1.0] To install them in a build environment like Ubuntu you can use: ---- sudo apt-get install libdbus-1-dev libsqlite3-dev doxygen git cmake build-essential ---- +The nodestatemanager can be retrieved from projects.genivi.org . You can install the headers on you system by + +---- +sudo make install-includeHEADERS +---- + For building the tests, you will need the following packages: * python [tested on version 2.6, should work on higher versions as well] diff --git a/README.html b/README.html index d805a5f..c1be5ea 100644 --- a/README.html +++ b/README.html @@ -810,7 +810,6 @@ USE_BUILD_LIBS ON WITH_DBUS_WRAPPER ON WITH_DLT ON WITH_DOCUMENTATION OFF -WITH_MAIN ON WITH_PLUGIN_COMMAND ON WITH_PLUGIN_CONTROL ON WITH_PLUGIN_ROUTING ON @@ -858,12 +857,22 @@ automotive-dlt [greater 2.5.0] doxygen (only when WITH_DOCUMENTATION==ON) [tested on version 1.6.3]

+
  • +

    +nodestatemanager headers [tested with version 0.1.0] +

    +
  • To install them in a build environment like Ubuntu you can use:

    sudo apt-get install libdbus-1-dev libsqlite3-dev doxygen git cmake build-essential
    +

    The nodestatemanager can be retrieved from projects.genivi.org . You can install the headers on you system by

    +
    +
    +
    sudo make install-includeHEADERS
    +

    For building the tests, you will need the following packages:

    • @@ -1191,7 +1200,7 @@ handle later on.


    diff --git a/cmake/LifecycleConsumer.xml b/cmake/LifecycleConsumer.xml new file mode 100644 index 0000000..ec1162b --- /dev/null +++ b/cmake/LifecycleConsumer.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + diff --git a/cmake/config.cmake b/cmake/config.cmake index a8989e5..cab37fc 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -22,4 +22,9 @@ #cmakedefine EXECUTABLE_OUTPUT_PATH "@EXECUTABLE_OUTPUT_PATH@" +#cmakedefine NSM_BUS_INTERFACE "@NSM_BUS_INTERFACE@" +#cmakedefine NSM_PATH "@NSM_PATH@" +#cmakedefine NSM_INTERFACE "@NSM_INTERFACE@" +#cmakedefine NSM_INTROSPECTION_FILE "@NSM_INTROSPECTION_FILE@" + #endif /* _CONFIG_H */ diff --git a/cmake/genivi.audiomanager.service b/cmake/genivi.audiomanager.service index 7cfbb34..d7b58dc 100644 --- a/cmake/genivi.audiomanager.service +++ b/cmake/genivi.audiomanager.service @@ -23,7 +23,7 @@ Description=The GENIVI AudioManager [Service] -#Type=notify +Type=notify User=christian ExecStart=/usr/bin/AudioManager Restart=always diff --git a/googleMock/CMakeLists.txt b/googleMock/CMakeLists.txt index 061c2fc..2db2f96 100644 --- a/googleMock/CMakeLists.txt +++ b/googleMock/CMakeLists.txt @@ -7,6 +7,8 @@ # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to # make it prominent in the GUI. +set (CMAKE_CXX_FLAGS "-std=gnu++0x -D_GNU_SOURCE -Wno-variadic-macros") + option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) # Forces BUILD_SHARED_LIBS to OFF as Google Mock currently does not support diff --git a/googleMock/include/gmock/gmock-matchers.h b/googleMock/include/gmock/gmock-matchers.h index c21fa51..a6e0488 100644 --- a/googleMock/include/gmock/gmock-matchers.h +++ b/googleMock/include/gmock/gmock-matchers.h @@ -370,7 +370,7 @@ class PolymorphicMatcher { template inline Matcher MakeMatcher(const MatcherInterface* impl) { return Matcher(impl); -}; +} // Creates a polymorphic matcher from its implementation. This is // easier to use than the PolymorphicMatcher constructor as it diff --git a/include/audiomanagertypes.h b/include/audiomanagertypes.h index 54760b4..8e4bf41 100644 --- a/include/audiomanagertypes.h +++ b/include/audiomanagertypes.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_F9B4F59D_FED5_44ac_85F2_F9F60549C133__INCLUDED_) -#define EA_F9B4F59D_FED5_44ac_85F2_F9F60549C133__INCLUDED_ +#if !defined(EA_4739DD27_2A1B_4548_8F5F_7D50DB15209C__INCLUDED_) +#define EA_4739DD27_2A1B_4548_8F5F_7D50DB15209C__INCLUDED_ #include #include "projecttypes.h" @@ -29,112 +29,137 @@ #define AM_MUTE -3000 +#include "projecttypes.h" + namespace am { /** * a domain ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_domainID_t; /** * a source ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_sourceID_t; /** * a sink ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_sinkID_t; /** * a gateway ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_gatewayID_t; /** * a crossfader ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_crossfaderID_t; /** * a connection ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_connectionID_t; /** * a mainConnection ID * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_mainConnectionID_t; /** * speed * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_speed_t; /** - * The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE). The minimum and - * maximum can be limited by actual project. + * The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE). The minimum and maximum can be limited by actual project. * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef int16_t am_volume_t; /** - * This is the volume presented on the command interface. It is in the duty of the - * Controller to change the volumes given here into meaningful values on the - * routing interface. + * This is the volume presented on the command interface. It is in the duty of the Controller to change the volumes given + * here into meaningful values on the routing interface. * The range of this type is customer specific. * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef int16_t am_mainVolume_t; /** * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_sourceClass_t; /** * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_sinkClass_t; /** * time in ms! * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef uint16_t am_time_t; /** * offset time that is introduced in milli seconds. * @author Christian Mueller - * @created 07-Mar-2012 6:06:13 PM + * @created 16-Dez-2012 15:58:12 */ typedef int16_t am_timeSync_t; /** - * with the help of this enum, sinks and sources can report their availability - * state + * describes the active sink of a crossfader. * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 + */ + enum am_HotSink_e + { + /** + * default + */ + HS_UNKNOWN = 0, + /** + * sinkA is active + */ + HS_SINKA = 1, + /** + * sinkB is active + */ + HS_SINKB = 2, + /** + * the crossfader is in the transition state + */ + HS_INTERMEDIATE = 3, + HS_MAX + }; + + /** + * with the help of this enum, sinks and sources can report their availability state + * @author Christian Mueller + * @created 16-Dez-2012 15:58:12 */ enum am_Availablility_e { @@ -156,7 +181,7 @@ namespace am { /** * represents the connection state * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_ConnectionState_e { @@ -174,8 +199,7 @@ namespace am { */ CS_DISCONNECTING = 3, /** - * only relevant for connectionStatechanged. Is send after the connection was - * removed + * only relevant for connectionStatechanged. Is send after the connection was removed */ CS_DISCONNECTED = 4, /** @@ -187,7 +211,7 @@ namespace am { /** * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_DomainState_e { @@ -213,7 +237,7 @@ namespace am { /** * This enum characterizes the data of the EarlyData_t * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_EarlyDataType_e { @@ -241,10 +265,9 @@ namespace am { }; /** - * the errors of the audiomanager. All possible errors are in here. This enum is - * used widely as return parameter. + * the errors of the audiomanager. All possible errors are in here. This enum is used widely as return parameter. * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_Error_e { @@ -289,9 +312,8 @@ namespace am { */ E_ABORTED = 9, /** - * This error is returned in case a connect is issued with a connectionFormat that - * cannot be selected for the connection. This could be either due to the - * capabilities of a source or a sink or gateway compatibilities for example + * This error is returned in case a connect is issued with a connectionFormat that cannot be selected for the connection. + * This could be either due to the capabilities of a source or a sink or gateway compatibilities for example */ E_WRONG_FORMAT = 10, E_MAX @@ -299,7 +321,7 @@ namespace am { /** * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_MuteState_e { @@ -321,7 +343,7 @@ namespace am { /** * The source state reflects the state of the source * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_SourceState_e { @@ -335,18 +357,16 @@ namespace am { */ SS_OFF = 2, /** - * The source is paused. Meaning it cannot be heared but should be prepared to - * play again soon. + * The source is paused. Meaning it cannot be heared but should be prepared to play again soon. */ SS_PAUSED = 3, SS_MAX }; /** - * This enumeration is used to define the type of the action that is correlated to - * a handle. + * This enumeration is used to define the type of the action that is correlated to a handle. * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_Handle_e { @@ -361,12 +381,15 @@ namespace am { H_SETSINKSOUNDPROPERTIES = 8, H_SETSOURCESOUNDPROPERTIES = 9, H_CROSSFADE = 10, + H_SETVOLUMES = 11, + H_SETSINKNOTIFICATION = 12, + H_SETSOURCENOTIFICATION = 13, H_MAX }; /** * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ enum am_InterruptState_e { @@ -386,36 +409,60 @@ namespace am { }; /** - * describes the active sink of a crossfader. - * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * This datatype determines if a sourceID or a sinkID is used in the union following + * @author q232968 + * @version 1.0 + * @created 16-Dez-2012 15:58:12 */ - enum am_HotSink_e + enum am_VolumeType_e { + VT_UNKNOWN = 0, /** - * default + * the following type is a sink */ - HS_UNKNOWN = 0, + VT_SINK = 1, /** - * sinkA is active + * the following type is a source */ - HS_SINKA = 1, + VT_SOURCE = 2, + VT_MAX + }; + + /** + * @author q232968 + * @version 1.0 + * @created 16-Dez-2012 15:58:12 + */ + enum am_NotificationStatus_e + { + NS_UNKNOWN = 0, /** - * sinkB is active + * No notification, the function is turned off */ - HS_SINKB = 2, + NS_OFF = 1, /** - * the crossfader is in the transition state + * Periodic notifications are sent out. The period in ms is given by am_NotificationParameter */ - HS_INTERMEDIATE = 3, - HS_MAX + NS_PERIODIC = 2, + /** + * The notification is sent out when the minimum given by am_NotificationParameter is reached. + */ + NS_MINIMUM = 3, + /** + * The notification is sent out when the maximum given by am_NotificationParameter is reached. + */ + NS_MAXIMUM = 4, + /** + * The notification is sent out whena change happend. The Resolution of the change is defined by am_NotificationParameter. + */ + NS_CHANGE = 5, + NS_MAX }; /** - * this describes the availability of a sink or a source together with the latest - * change + * this describes the availability of a sink or a source together with the latest change * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ struct am_Availability_s { @@ -426,8 +473,7 @@ namespace am { */ am_Availablility_e availability; /** - * the reason for the last change. This can be used to trigger events that deal - * with state changes. + * the reason for the last change. This can be used to trigger events that deal with state changes. */ am_AvailabilityReason_e availabilityReason; @@ -436,7 +482,7 @@ namespace am { /** * describes class properties * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ struct am_ClassProperty_s { @@ -456,17 +502,16 @@ namespace am { /** * This struct describes the attribiutes of a crossfader. * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ struct am_Crossfader_s { public: /** - * This is the ID of the crossfader, it is unique in the system. There are 2 ways, - * ID can be created: either it is assigned during the registration process (in a - * dynamic context, uniqueness will be ensured by the AudioManager daemon), or it - * is a fixed (the project has to ensure the uniqueness of the ID). + * This is the ID of the crossfader, it is unique in the system. There are 2 ways, ID can be created: either it is + * assigned during the registration process (in a dynamic context, uniqueness will be ensured by the AudioManager daemon), + * or it is a fixed (the project has to ensure the uniqueness of the ID). */ am_crossfaderID_t crossfaderID; /** @@ -474,18 +519,15 @@ namespace am { */ std::string name; /** - * The sinkID of the SinkA. Sinks shall be registered before registering the - * crossfader. + * The sinkID of the SinkA. Sinks shall be registered before registering the crossfader. */ am_sinkID_t sinkID_A; /** - * The sinkID of the SinkB. Sinks shall be registered before registering the - * crossfader. + * The sinkID of the SinkB. Sinks shall be registered before registering the crossfader. */ am_sinkID_t sinkID_B; /** - * The sourceID of the crossfader source. The source shall be registered before - * the crossfader. + * The sourceID of the crossfader source. The source shall be registered before the crossfader. */ am_sourceID_t sourceID; /** @@ -493,9 +535,8 @@ namespace am { * * HS_SINKA sinkA is the current hot one, sinkB is not audible * HS_SINKB sinkB is the current hot one, sinkB is not audible - * HS_INTERMEDIATE the fader is stuck in between a cross-fading action. This - * could be due to an abort or an error. Before using the crossfader, it must be - * set to either HS_SINKA or HS_SINKB. + * HS_INTERMEDIATE the fader is stuck in between a cross-fading action. This could be due to an abort or an error. + * Before using the crossfader, it must be set to either HS_SINKA or HS_SINKB. */ am_HotSink_e hotSink; @@ -504,17 +545,16 @@ namespace am { /** * This struct describes the attributes of a gateway. * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:12 */ struct am_Gateway_s { public: /** - * This is the ID of the gateway, it is unique in the system. There are 2 ways, ID - * can be created: either it is assigned during the registration process (in a - * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it - * is a fixed (the project has to ensure the uniqueness of the ID). + * This is the ID of the gateway, it is unique in the system. There are 2 ways, ID can be created: either it is assigned + * during the registration process (in a dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it is + * a fixed (the project has to ensure the uniqueness of the ID). */ am_gatewayID_t gatewayID; /** @@ -522,35 +562,29 @@ namespace am { */ std::string name; /** - * The sinkID of the gateway sink-end. The sink is a full blown sink with - * connectionFormats, sinkClassIDs etc... It makes sense to register the sinks of - * a gateway as non-visible. Care needs to be taken that the connectionsFormats - * match with the ones in the conversionMatrix. If the sink is located in the - * controllingDomain, the ID needs to be retrieved by registering the sink before - * registering the gateway. In case the sink is in a different domain, the ID - * needs to be retrieved via peeking. + * The sinkID of the gateway sink-end. The sink is a full blown sink with connectionFormats, sinkClassIDs etc... It makes + * sense to register the sinks of a gateway as non-visible. Care needs to be taken that the connectionsFormats match with + * the ones in the conversionMatrix. If the sink is located in the controllingDomain, the ID needs to be retrieved by + * registering the sink before registering the gateway. In case the sink is in a different domain, the ID needs to be + * retrieved via peeking. */ am_sinkID_t sinkID; /** - * The sourceID of the gateway sink-end. The sink is a full blown source with - * connectionFormats, sinkClassIDs etc... It makes sense to register the sources - * of a gateway as non-visible. Care needs to be taken that the connectionsFormats - * match with the ones in the conversionMatrix. If the source is located in the - * controllingDomain, the ID needs to be retrieved by registering the source - * before registering the gateway. In case the source is in a different domain, - * the ID needs to be retrieved via peeking. + * The sourceID of the gateway sink-end. The sink is a full blown source with connectionFormats, sinkClassIDs etc... It + * makes sense to register the sources of a gateway as non-visible. Care needs to be taken that the connectionsFormats + * match with the ones in the conversionMatrix. If the source is located in the controllingDomain, the ID needs to be + * retrieved by registering the source before registering the gateway. In case the source is in a different domain, the ID + * needs to be retrieved via peeking. */ am_sourceID_t sourceID; /** - * The ID of the sink. If the domain is the same like the controlling domain, the - * ID is known due to registration. If the domain is different, the ID needs to be - * retrieved via peeking. + * The ID of the sink. If the domain is the same like the controlling domain, the ID is known due to registration. If the + * domain is different, the ID needs to be retrieved via peeking. */ am_domainID_t domainSinkID; /** - * The ID of the source. If the domain is the same like the controlling domain, - * the ID is known due to registration. If the domain is different, the ID needs - * to be retrieved via peeking. + * The ID of the source. If the domain is the same like the controlling domain, the ID is known due to registration. If + * the domain is different, the ID needs to be retrieved via peeking. */ am_domainID_t domainSourceID; /** @@ -558,28 +592,23 @@ namespace am { */ am_domainID_t controlDomainID; /** - * This is the list of available formats on the source side of the gateway. It is - * not defined during the gateway registration but copied from the source - * registration. + * This is the list of available formats on the source side of the gateway. It is not defined during the gateway + * registration but copied from the source registration. */ std::vector listSourceFormats; /** - * This is the list of available formats on the sink side of the gateway. It is - * not defined during the gateway registration but copied from the sink - * registration. + * This is the list of available formats on the sink side of the gateway. It is not defined during the gateway + * registration but copied from the sink registration. */ std::vector listSinkFormats; /** - * This is matrix holding information about the conversion capability of the - * gateway, it's length is defined by the length(listSinkFormats) x - * length(listSourceFormats). - * If a SinkFormat can be converted into a SourceFormat, the vector will hold a 1, - * if no conversion is possible, a 0. - * The data is stored row orientated, where the rows are related to the - * sinksFormats and the columns to the sourceFormats. The first value will hold - * the conversion information from the first sourceFormat to the first sinkFormat - * for example and the seventh value the information about the 3rd sinkFormat to - * the 1st sourceFormat in case we would have 3 sourceFormats. + * This is matrix holding information about the conversion capability of the gateway, it's length is defined by the + * length(listSinkFormats) x length(listSourceFormats). + * If a SinkFormat can be converted into a SourceFormat, the vector will hold a 1, if no conversion is possible, a 0. + * The data is stored row orientated, where the rows are related to the sinksFormats and the columns to the sourceFormats. + * The first value will hold the conversion information from the first sourceFormat to the first sinkFormat for example + * and the seventh value the information about the 3rd sinkFormat to the 1st sourceFormat in case we would have 3 + * sourceFormats. * * This matrix * 110 011 000 111 001 @@ -601,7 +630,7 @@ namespace am { /** * This represents one "hopp" in a route * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:13 */ struct am_RoutingElement_s { @@ -629,7 +658,7 @@ namespace am { /** * a list of routing elements that lead from source to sink * @author Christian Mueller - * @created 07-Mar-2012 6:06:14 PM + * @created 16-Dez-2012 15:58:13 */ struct am_Route_s { @@ -653,7 +682,7 @@ namespace am { /** * struct describing the sound property * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_SoundProperty_s { @@ -673,7 +702,7 @@ namespace am { /** * struct describing system properties * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_SystemProperty_s { @@ -693,7 +722,7 @@ namespace am { /** * struct describing sinkclasses * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_SinkClass_s { @@ -708,8 +737,8 @@ namespace am { */ std::string name; /** - * the list of the class properties. These are pairs of a project specific enum - * describing the type of the value and an integer holding the real value. + * the list of the class properties. These are pairs of a project specific enum describing the type of the value and an + * integer holding the real value. */ std::vector listClassProperties; @@ -718,7 +747,7 @@ namespace am { /** * struct describing source classes * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_SourceClass_s { @@ -733,8 +762,8 @@ namespace am { */ std::string name; /** - * the list of the class properties. These are pairs of a project specific enum - * describing the type of the value and an integer holding the real value. + * the list of the class properties. These are pairs of a project specific enum describing the type of the value and an + * integer holding the real value. */ std::vector listClassProperties; @@ -743,17 +772,16 @@ namespace am { /** * this type holds all information of sources relevant to the HMI * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_SourceType_s { public: /** - * This is the ID of the source, it is unique in the system. There are 2 ways, ID - * can be created: either it is assigned during the registration process (in a - * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it - * is a fixed (the project has to ensure the uniqueness of the ID). + * This is the ID of the source, it is unique in the system. There are 2 ways, ID can be created: either it is assigned + * during the registration process (in a dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it is + * a fixed (the project has to ensure the uniqueness of the ID). */ am_sourceID_t sourceID; /** @@ -765,9 +793,8 @@ namespace am { */ am_Availability_s availability; /** - * the sourceClassID, indicates the class the source is in. This information can - * be used by the Controller to implement different behaviour for different - * classes. + * the sourceClassID, indicates the class the source is in. This information can be used by the Controller to implement + * different behaviour for different classes. */ am_sourceClass_t sourceClassID; @@ -776,17 +803,16 @@ namespace am { /** * this type holds all information of sinks relevant to the HMI * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_SinkType_s { public: /** - * This is the ID of the sink, it is unique in the system. There are 2 ways, ID - * can be created: either it is assigned during the registration process (in a - * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it - * is a fixed (the project has to ensure the uniqueness of the ID). + * This is the ID of the sink, it is unique in the system. There are 2 ways, ID can be created: either it is assigned + * during the registration process (in a dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it is + * a fixed (the project has to ensure the uniqueness of the ID). */ am_sinkID_t sinkID; /** @@ -794,37 +820,33 @@ namespace am { */ std::string name; /** - * This attribute reflects the availability of the sink. There are several reasons - * why a sink could be not available for the moment: for example the shutdown of a - * sink because of overtemperature or over- & undervoltage. The availability + * This attribute reflects the availability of the sink. There are several reasons why a sink could be not available for + * the moment: for example the shutdown of a sink because of overtemperature or over- & undervoltage. The availability * consists of two pieces of information: * - * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or - * A_UNKNOWN - * AvailabilityReason: this informs about the last reason for a change in - * availability. The reasons itself are product specific. + * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or A_UNKNOWN + * AvailabilityReason: this informs about the last reason for a change in availability. The reasons itself are product + * specific. */ am_Availability_s availability; /** - * This is the representation of the Volume for the commandInterface. It is used - * by the HMI to set the volume of a sink, the AudioManagerController has to - * transform this into real source and sink volumes. + * This is the representation of the Volume for the commandInterface. It is used by the HMI to set the volume of a sink, + * the AudioManagerController has to transform this into real source and sink volumes. */ am_mainVolume_t volume; am_MuteState_e muteState; /** - * The sinkClassID references to a sinkClass. With the help of classification, - * rules can be setup to define the system behaviour. + * The sinkClassID references to a sinkClass. With the help of classification, rules can be setup to define the system + * behaviour. */ am_sinkClass_t sinkClassID; }; /** - * a handle is used for asynchronous operations and is uniquely assigned for each - * of this operations + * a handle is used for asynchronous operations and is uniquely assigned for each of this operations * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_Handle_s { @@ -833,18 +855,18 @@ namespace am { /** * the handletype */ - am_Handle_e handleType:4; + am_Handle_e handleType:6; /** * the handle as value */ - uint16_t handle:12; + uint16_t handle:10; }; /** * struct describung mainsound property * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_MainSoundProperty_s { @@ -864,7 +886,7 @@ namespace am { /** * this type holds all information of connections relevant to the HMI * @author Christian Mueller - * @created 07-Mar-2012 6:06:15 PM + * @created 16-Dez-2012 15:58:13 */ struct am_MainConnectionType_s { @@ -896,7 +918,7 @@ namespace am { /** * struct that holds attribiutes of a mainconnection * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:13 */ struct am_MainConnection_s { @@ -929,20 +951,70 @@ namespace am { }; + /** + * This struct holds the payload of a notification. + * @author q232968 + * @version 1.0 + * @created 16-Dez-2012 15:58:13 + */ + struct am_NotificationPayload_s + { + + public: + /** + * This defines the notification type + */ + am_NotificationType_e notificationType; + /** + * This is finally the value of the notification. It's meaning depends on the notificationType + */ + int16_t notificationValue; + + }; + + /** + * This struct holds information about the configuration for notifications + * @author q232968 + * @version 1.0 + * @created 16-Dez-2012 15:58:13 + */ + struct am_NotificationConfiguration_s + { + + public: + /** + * The notification type of the notification + */ + am_NotificationType_e notificationType; + /** + * The Notification status. This can be periodic, min/max value based or even off for example + */ + am_NotificationStatus_e notificationStatus; + /** + * This gives additional information to the notification status. + * Relation between notification status and the value: + * NS_PERIODIC - the period in ms + * NS_MINIMUM - the minimum value that triggers the notification + * NS_MAXIMUM - the maximum value that triggers the notifcation + * NS_CHANGE - the resolution of the change value + */ + int16_t notificationParameter; + + }; + /** * This struct describes the attribiutes of a sink * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:13 */ struct am_Sink_s { public: /** - * This is the ID of the sink, it is unique in the system. There are 2 ways, ID - * can be created: either it is assigned during the registration process (in a - * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it - * is a fixed (the project has to ensure the uniqueness of the ID). + * This is the ID of the sink, it is unique in the system. There are 2 ways, ID can be created: either it is assigned + * during the registration process (in a dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it is + * a fixed (the project has to ensure the uniqueness of the ID). */ am_sinkID_t sinkID; /** @@ -950,13 +1022,12 @@ namespace am { */ std::string name; /** - * The domainID is the domain the sink belongs to. A sink can only be in one - * domain. + * The domainID is the domain the sink belongs to. A sink can only be in one domain. */ am_domainID_t domainID; /** - * The sinkClassID references to a sinkClass. With the help of classification, - * rules can be setup to define the system behaviour. + * The sinkClassID references to a sinkClass. With the help of classification, rules can be setup to define the system + * behaviour. */ am_sinkClass_t sinkClassID; /** @@ -964,77 +1035,74 @@ namespace am { */ am_volume_t volume; /** - * This Boolean flag indicates whether a sink is visible to the commandInterface - * or not. If the User must have the possibility to choose the source in the HMI, - * it must be visible. But there are also good reasons for invisible sinks, for - * example if the sink is part of a crossfader or gateway. HMI relevant changes in - * visible sinks will be automatically reported by the daemon to the - * commandInterface. + * This Boolean flag indicates whether a sink is visible to the commandInterface or not. If the User must have the + * possibility to choose the source in the HMI, it must be visible. But there are also good reasons for invisible sinks, + * for example if the sink is part of a crossfader or gateway. HMI relevant changes in visible sinks will be automatically + * reported by the daemon to the commandInterface. */ bool visible; /** - * This attribute reflects the availability of the sink. There are several reasons - * why a sink could be not available for the moment: for example the shutdown of a - * sink because of overtemperature or over- & undervoltage. The availability + * This attribute reflects the availability of the sink. There are several reasons why a sink could be not available for + * the moment: for example the shutdown of a sink because of overtemperature or over- & undervoltage. The availability * consists of two pieces of information: * - * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or - * A_UNKNOWN - * AvailabilityReason: this informs about the last reason for a change in - * availability. The reasons itself are product specific. + * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or A_UNKNOWN + * AvailabilityReason: this informs about the last reason for a change in availability. The reasons itself are product + * specific. */ am_Availability_s available; /** - * This attribute reflects the muteState of the sink. The information is not the - * "real" state of the sink, but the HMI representation for he commandInterface - * controlled by the AudioManagerController. + * This attribute reflects the muteState of the sink. The information is not the "real" state of the sink, but the HMI + * representation for he commandInterface controlled by the AudioManagerController. */ am_MuteState_e muteState; /** - * This is the representation of the Volume for the commandInterface. It is used - * by the HMI to set the volume of a sink, the AudioManagerController has to - * transform this into real source and sink volumes. + * This is the representation of the Volume for the commandInterface. It is used by the HMI to set the volume of a sink, + * the AudioManagerController has to transform this into real source and sink volumes. */ am_mainVolume_t mainVolume; /** - * This is the list of soundProperties, that the sink is capable of. The - * soundProperties itself are project specific. For sinks, a possible - * soundProperty could be for example settings. + * This is the list of soundProperties, that the sink is capable of. The soundProperties itself are project specific. For + * sinks, a possible soundProperty could be for example settings. */ std::vector listSoundProperties; /** - * This list holds information about the formats that the Source is capable of - * supporting when delivering audio. + * This list holds information about the formats that the Source is capable of supporting when delivering audio. */ std::vector listConnectionFormats; /** - * This is the list of the available mainSoundProperties. The principle is the - * same than with soundProperties, but they are only visible to the - * CommandInterface. + * This is the list of the available mainSoundProperties. The principle is the same than with soundProperties, but they + * are only visible to the CommandInterface. */ std::vector listMainSoundProperties; + /** + * This is the list of the MainNotificationConfigurations. These notifications work on the level of command interface. + */ + std::vector listMainNotificationConfigurations; + /** + * This is the list of the NotificationConfigurations. These notifications work on the level of RoutingPlugins. + */ + std::vector listNotificationConfigurations; }; /** * This struct describes the attribiutes of a source * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:14 */ struct am_Source_s { public: /** - * This is the ID of the source, it is unique in the system. There are 2 ways, ID - * can be created: either it is assigned during the registration process (in a - * dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it - * is a fixed (the project has to ensure the uniqueness of the ID). + * This is the ID of the source, it is unique in the system. There are 2 ways, ID can be created: either it is assigned + * during the registration process (in a dynamic context, uniqueness will be ensured by the AudioManagerDaemon), or it is + * a fixed (the project has to ensure the uniqueness of the ID). */ am_sourceID_t sourceID; /** - * The domainID is the domain the source belongs to. A source can only be in one - * domain. + * The domainID is the domain the source belongs to. A source can only be in one domain. */ am_domainID_t domainID; /** @@ -1042,17 +1110,15 @@ namespace am { */ std::string name; /** - * the sourceClassID, indicates the class the source is in. This information can - * be used by the Controller to implement different behaviour for different - * classes. + * the sourceClassID, indicates the class the source is in. This information can be used by the Controller to implement + * different behaviour for different classes. */ am_sourceClass_t sourceClassID; /** - * The source state is an indication towards the source if it is actively heard or - * not. The source can use this information to implement features like automatic - * spin down of CD's in case the CD is not the active source or AF following of a - * tuner that is not actively heard. The source state is set by the - * AudioManagerController.There are 3 possible states: + * The source state is an indication towards the source if it is actively heard or not. The source can use this + * information to implement features like automatic spin down of CD's in case the CD is not the active source or AF + * following of a tuner that is not actively heard. The source state is set by the AudioManagerController.There are 3 + * possible states: * * SS_ON: the source is active * SS_OFF: the source is off @@ -1060,38 +1126,31 @@ namespace am { */ am_SourceState_e sourceState; /** - * This is the volume of the source. It is set by the AudioManagerController. It - * is used to adopt different audiolevels in a system and mixing of sources (e.g. - * navigation hints & music). + * This is the volume of the source. It is set by the AudioManagerController. It is used to adopt different audiolevels in + * a system and mixing of sources (e.g. navigation hints & music). */ am_volume_t volume; /** - * This Boolean flag indicates whether a source is visible to the commandInterface - * or not. If the User must have the possibility to choose the source in the HMI, - * it must be visible. But there are also good reasons for invisible sources, for - * example if the source is part of a crossfader or gateway. HMI relevant changes - * in visible sources will be automatically reported by the daemon to the - * commandInterface. + * This Boolean flag indicates whether a source is visible to the commandInterface or not. If the User must have the + * possibility to choose the source in the HMI, it must be visible. But there are also good reasons for invisible sources, + * for example if the source is part of a crossfader or gateway. HMI relevant changes in visible sources will be + * automatically reported by the daemon to the commandInterface. */ bool visible; /** - * This attribute reflects the availability of the source. There are several - * reasons why a source could be not available for the moment. For example a CD - * player which has no CD entered in the slot can be unavailable, or a USB player - * with no or unreadable stick attached. Other scenarios involve the shutdown of a - * source because of overtemperature or over- & undervoltage. The availability - * consists of two informations: + * This attribute reflects the availability of the source. There are several reasons why a source could be not available + * for the moment. For example a CD player which has no CD entered in the slot can be unavailable, or a USB player with no + * or unreadable stick attached. Other scenarios involve the shutdown of a source because of overtemperature or over- & + * undervoltage. The availability consists of two informations: * - * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or - * A_UNKNOWN - * AvailabilityReason: this informs about the last reason for a change in - * availability. The reasons itself are product specific. + * Availablility: the status itself, can be A_AVAILABLE, A_UNAVAILABLE or A_UNKNOWN + * AvailabilityReason: this informs about the last reason for a change in availability. The reasons itself are product + * specific. */ am_Availability_s available; /** - * Some special sources can have special behaviors, the are so called "Low Level - * Interrupts". Here the current status is documented. The information can be used - * by the AudioManagerController to react to the changes by for example lowering + * Some special sources can have special behaviors, the are so called "Low Level Interrupts". Here the current status is + * documented. The information can be used by the AudioManagerController to react to the changes by for example lowering * the volume of the mainSources. The two states are * * IS_OFF: the interrupt is not active at the moment @@ -1099,29 +1158,34 @@ namespace am { */ am_InterruptState_e interruptState; /** - * This is the list of soundProperties, that the source is capable of. The - * soundProperties itself are project specific. For sources, a possible - * soundProperty could be navigation volume offset, for example. + * This is the list of soundProperties, that the source is capable of. The soundProperties itself are project specific. + * For sources, a possible soundProperty could be navigation volume offset, for example. */ std::vector listSoundProperties; /** - * This list holds information about the formats that the Source is capable of - * supporting when delivering audio. + * This list holds information about the formats that the Source is capable of supporting when delivering audio. */ std::vector listConnectionFormats; /** - * This is the list of the available mainSoundProperties. The principle is the - * same than with soundProperties, but they are only visible to the - * CommandInterface. + * This is the list of the available mainSoundProperties. The principle is the same than with soundProperties, but they + * are only visible to the CommandInterface. */ std::vector listMainSoundProperties; + /** + * The list of MainNotificationConfigurations. These notifications work on the level of CommandInterface. + */ + std::vector listMainNotificationConfigurations; + /** + * The list of MainNotificationConfigurations. These notifications work on the level of RoutingInterface. + */ + std::vector listNotificationConfigurations; }; /** * This struct describes the attribiutes of a domain * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:14 */ struct am_Domain_s { @@ -1136,8 +1200,7 @@ namespace am { */ std::string name; /** - * the busname. This is equal to a plugin name and is used to dispatch messages to - * the elements of a plugin + * the busname. This is equal to a plugin name and is used to dispatch messages to the elements of a plugin */ std::string busname; /** @@ -1162,7 +1225,7 @@ namespace am { /** * a connection * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:14 */ struct am_Connection_s { @@ -1196,7 +1259,7 @@ namespace am { * volume_t in case of ED_SOURCE_VOLUME, ED_SINK_VOLUME * soundProperty_t in case of ED_SOURCE_PROPERTY, ED_SINK_PROPERTY * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:14 */ union am_EarlyData_u { @@ -1212,7 +1275,7 @@ namespace am { * sourceID in case of ED_SOURCE_VOLUME, ED_SOURCE_PROPERTY * sinkID in case of ED_SINK_VOLUME, ED_SINK_PROPERTY * @author Christian Mueller - * @created 07-Mar-2012 6:06:16 PM + * @created 16-Dez-2012 15:58:14 */ union am_DataType_u { @@ -1225,7 +1288,7 @@ namespace am { /** * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ struct am_EarlyData_s { @@ -1236,5 +1299,38 @@ namespace am { am_EarlyData_u data; }; + + /** + * This types describe a mixed description for source and sinks volumes. + * @author q232968 + * @version 1.0 + * @created 16-Dez-2012 15:58:14 + */ + struct am_Volumes_s + { + + public: + /** + * describes the type of the volume: source or sink. + */ + am_VolumeType_e volumeType; + /** + * either sourceID or sinkID + */ + am_DataType_u volumeID; + /** + * The volume + */ + am_volume_t volume; + /** + * the ramp that shall be driven + */ + am_RampType_e ramp; + /** + * the time for the ramp + */ + am_time_t time; + + }; } -#endif // !defined(EA_F9B4F59D_FED5_44ac_85F2_F9F60549C133__INCLUDED_) +#endif // !defined(EA_4739DD27_2A1B_4548_8F5F_7D50DB15209C__INCLUDED_) diff --git a/include/command/IAmCommandReceive.h b/include/command/IAmCommandReceive.h index 9239555..5a1a06c 100644 --- a/include/command/IAmCommandReceive.h +++ b/include/command/IAmCommandReceive.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_B1A684DC_5ED5_4848_82ED_4D3376454A3B__INCLUDED_) -#define EA_B1A684DC_5ED5_4848_82ED_4D3376454A3B__INCLUDED_ +#if !defined(EA_3888D932_2C16_4c2a_BD7C_E1F819C9A7F0__INCLUDED_) +#define EA_3888D932_2C16_4c2a_BD7C_E1F819C9A7F0__INCLUDED_ #include #include @@ -31,25 +31,23 @@ class CAmSocketHandler; } -#define CommandReceiveVersion "1.0" +#include "audiomanagertypes.h" + +#define CommandReceiveVersion "2.0" namespace am { /** - * The interface towards the Controlling Instance (e.g HMI). It handles the - * communication towards the HMI and other system components who need to interact - * with the audiomanagement. - * There are two rules that have to be kept in mind when implementing against this - * interface:\n + * The interface towards the Controlling Instance (e.g HMI). It handles the communication towards the HMI and other system + * components who need to interact with the audiomanagement. + * There are two rules that have to be kept in mind when implementing against this interface:\n * \warning * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n - * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS - * CALL THAT EXPECTS A RETURN VALUE.\n + * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n * \details - * Violation these rules may lead to unexpected behavior! Nevertheless you can - * implement thread safe by using the deferred-call pattern described on the wiki - * which also helps to implement calls that are forbidden.\n + * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred- + * call pattern described on the wiki which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ class IAmCommandReceive { @@ -71,8 +69,7 @@ namespace am { virtual void getInterfaceVersion(std::string& version) const =0; /** * connects a source to sink - * @return E_OK on success, E_NOT_POSSIBLE on failure, E_ALREADY_EXISTS if the - * connection does already exists + * @return E_OK on success, E_NOT_POSSIBLE on failure, E_ALREADY_EXISTS if the connection does already exists * * @param sourceID * @param sinkID @@ -81,16 +78,14 @@ namespace am { virtual am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) =0; /** * disconnects a mainConnection - * @return E_OK on successes, E_NON_EXISTENT if the connection does not exist, - * E_NOT_POSSIBLE on error. + * @return E_OK on successes, E_NON_EXISTENT if the connection does not exist, E_NOT_POSSIBLE on error. * * @param mainConnectionID */ virtual am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID) =0; /** * sets the volume for a sink - * @return E_OK on success, E_UNKOWN on error, E_OUT_OF_RANGE in case the value is - * out of range + * @return E_OK on success, E_UNKOWN on error, E_OUT_OF_RANGE in case the value is out of range * * @param sinkID the sink * @param volume the volume @@ -98,40 +93,34 @@ namespace am { virtual am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume) =0; /** * This function is used to increment or decrement the current volume for a sink. - * @return E_OK on success, E_UNKNOWN on error and E_OUT_OF_RANGE if the value is - * not in the given volume range. + * @return E_OK on success, E_UNKNOWN on error and E_OUT_OF_RANGE if the value is not in the given volume range. * * @param sinkID - * @param volumeStep indicated the number of steps that should be incremented - * or decremented. Positive values here inkrement, negative values decrement + * @param volumeStep indicated the number of steps that should be incremented or decremented. Positive values here + * inkrement, negative values decrement */ virtual am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep) =0; /** * sets the mute state of a sink - * @return E_OK on success, E_UNKNOWN on error. If the mute state is already the - * desired one, the Daemon will return E_OK. + * @return E_OK on success, E_UNKNOWN on error. If the mute state is already the desired one, the Daemon will return E_OK. * * @param sinkID * @param muteState */ virtual am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) =0; /** - * This method is used to set sound properties, e.g. Equalizer Values. Since the - * capabilities of the system can differ, the exact key value pairs can be - * extended in each product - * @return E_OK on success, E_OUT_OF_RANGE if value exceeds range, E_UNKNOWN in - * case of an error + * This method is used to set sound properties, e.g. Equalizer Values. Since the capabilities of the system can differ, + * the exact key value pairs can be extended in each product + * @return E_OK on success, E_OUT_OF_RANGE if value exceeds range, E_UNKNOWN in case of an error * * @param soundProperty * @param sinkID */ virtual am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID) =0; /** - * This method is used to set sound properties, e.g. Equalizer Values. Since the - * capabilities of the system can differ, the exact key value pairs can be - * extended in each product - * @return E_OK on success, E_OUT_OF_RANGE if value exceeds range, E_UNKNOWN in - * case of an error + * This method is used to set sound properties, e.g. Equalizer Values. Since the capabilities of the system can differ, + * the exact key value pairs can be extended in each product + * @return E_OK on success, E_OUT_OF_RANGE if value exceeds range, E_UNKNOWN in case of an error * * @param soundProperty * @param sourceID @@ -139,8 +128,7 @@ namespace am { virtual am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID) =0; /** * is used to set a specific system property. - * @return E_OK on success, E_OUT_OF_RANGE if value exceeds range, E_UNKNOWN in - * case of an error + * @return E_OK on success, E_OUT_OF_RANGE if value exceeds range, E_UNKNOWN in case of an error * * @param property the property that shall be set */ @@ -167,8 +155,8 @@ namespace am { */ virtual am_Error_e getListMainSources(std::vector& listMainSources) const =0; /** - * This is used to retrieve all source sound properties related to a source. - * Returns a vector of the sound properties and values as pair + * This is used to retrieve all source sound properties related to a source. Returns a vector of the sound properties and + * values as pair * @return E_OK on success, E_DATABASE_ERROR on error * * @param sinkID @@ -206,8 +194,8 @@ namespace am { virtual am_Error_e getListSystemProperties(std::vector& listSystemProperties) const =0; /** * returns the delay in ms that the audiopath for the given mainConnection has - * @return E_OK on success, E_NOT_POSSIBLE if timing information is not yet - * retrieved, E_DATABASE_ERROR on read error on the database + * @return E_OK on success, E_NOT_POSSIBLE if timing information is not yet retrieved, E_DATABASE_ERROR on read error on + * the database * * @param mainConnectionID * @param delay @@ -215,20 +203,16 @@ namespace am { virtual am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const =0; /** * this function is used to retrieve a pointer to the dBusConnectionWrapper - * @return E_OK if pointer is valid, E_UKNOWN if AudioManager was compiled without - * DBus Support + * @return E_OK if pointer is valid, E_UKNOWN if AudioManager was compiled without DBus Support * - * @param dbusConnectionWrapper This is a wrapper class that is needed to keep - * dbus inclusions away from the interface. The DBusWrapperClass will return the - * pointer to the DbusConnection call (getDBusConnection) + * @param dbusConnectionWrapper This is a wrapper class that is needed to keep dbus inclusions away from the interface. + * The DBusWrapperClass will return the pointer to the DbusConnection call (getDBusConnection) */ virtual am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const =0; /** - * This function returns the pointer to the socketHandler. This can be used to - * integrate socket-based activites like communication with the mainloop of the - * AudioManager. - * returns E_OK if pointer is valid, E_UNKNOWN in case AudioManager was compiled - * without socketHandler support, + * This function returns the pointer to the socketHandler. This can be used to integrate socket-based activites like + * communication with the mainloop of the AudioManager. + * returns E_OK if pointer is valid, E_UNKNOWN in case AudioManager was compiled without socketHandler support, * * @param socketHandler */ @@ -237,15 +221,47 @@ namespace am { * asynchronous confirmation of setCommandReady. * * @param handle the handle that was handed over by setCommandReady + * @param error E_OK if the ready command succeeded. E_UNKNOWN if an error happened. */ - virtual void confirmCommandReady(const uint16_t handle) =0; + virtual void confirmCommandReady(const uint16_t handle, const am_Error_e error) =0; /** * asynchronous confirmation of setCommandRundown * * @param handle the handle that was given via setCommandRundown + * @param error E_OK if the ready command succeeded. E_UNKNOWN if an error happened. + */ + virtual void confirmCommandRundown(const uint16_t handle, const am_Error_e error) =0; + /** + * Rtrieves the list of MainNotifications for a sink. + * + * @param sinkID The sinkID + * @param listMainNotificationConfigurations + */ + virtual am_Error_e getListSinkMainNotificationConfigurations(const am_sinkID_t sinkID, std::vector& listMainNotificationConfigurations) const =0; + /** + * Rtrieves the list of MainNotifications for a source. + * + * @param sourceID The sourceID + * @param listMainNotificationConfigurations + */ + virtual am_Error_e getListSourceMainNotificationConfigurations(const am_sourceID_t sourceID, std::vector& listMainNotificationConfigurations) const =0; + /** + * sets a MainNotificationConfiuration. This can be used to turn on an off notifications an to change the mode of the + * configuration. + * + * @param sinkID The sinkID of the MainNotification to be changed + * @param mainNotificationConfiguration The MainNotifiication that needs to be set + */ + virtual am_Error_e setSinkMainNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) =0; + /** + * sets a MainNotificationConfiuration. This can be used to turn on an off notifications an to change the mode of the + * configuration. + * + * @param sourceID The sourceID of the MainNotification to be changed + * @param mainNotificationConfiguration The MainNotifiication that needs to be set */ - virtual void confirmCommandRundown(const uint16_t handle) =0; + virtual am_Error_e setSourceMainNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) =0; }; } -#endif // !defined(EA_B1A684DC_5ED5_4848_82ED_4D3376454A3B__INCLUDED_) +#endif // !defined(EA_3888D932_2C16_4c2a_BD7C_E1F819C9A7F0__INCLUDED_) diff --git a/include/command/IAmCommandSend.h b/include/command/IAmCommandSend.h index bf073f9..ce32131 100644 --- a/include/command/IAmCommandSend.h +++ b/include/command/IAmCommandSend.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_EA24D1A2_FDA1_4285_8606_7E77A080B4E9__INCLUDED_) -#define EA_EA24D1A2_FDA1_4285_8606_7E77A080B4E9__INCLUDED_ +#if !defined(EA_B053C89D_3921_4e1a_836D_C3B98FAD2E36__INCLUDED_) +#define EA_B053C89D_3921_4e1a_836D_C3B98FAD2E36__INCLUDED_ #include #include @@ -31,29 +31,25 @@ class IAmCommandReceive; } #include "IAmCommandReceive.h" +#include "audiomanagertypes.h" -#define CommandSendVersion "1.0" +#define CommandSendVersion "2.0" namespace am { /** - * This interface handles all communication from the AudioManagerDaemon towards - * the system. It is designed in such a way that only callbacks with no return - * types are implemented. So when the CommandInterfacePlugins are designed in such - * a way that they broadcast signals to any node who is interested in the - * particular information (like signals on Dbus for example), more information can - * be retrieved via the CommandReceiveInterface. - * There are two rules that have to be kept in mind when implementing against this - * interface:\n + * This interface handles all communication from the AudioManagerDaemon towards the system. It is designed in such a way + * that only callbacks with no return types are implemented. So when the CommandInterfacePlugins are designed in such a + * way that they broadcast signals to any node who is interested in the particular information (like signals on Dbus for + * example), more information can be retrieved via the CommandReceiveInterface. + * There are two rules that have to be kept in mind when implementing against this interface:\n * \warning * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n - * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS - * CALL THAT EXPECTS A RETURN VALUE.\n + * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n * \details - * Violation these rules may lead to unexpected behavior! Nevertheless you can - * implement thread safe by using the deferred-call pattern described on the wiki - * which also helps to implement calls that are forbidden.\n + * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred- + * call pattern described on the wiki which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ class IAmCommandSend { @@ -74,33 +70,29 @@ namespace am { */ virtual void getInterfaceVersion(std::string& version) const =0; /** - * This command starts the interface, the plugin itself. This is not meant to - * start communication with the HMI itself. It is a good idea to implement here - * everything that sets up the basic communication like DbusCommunication etc... + * This command starts the interface, the plugin itself. This is not meant to start communication with the HMI itself. It + * is a good idea to implement here everything that sets up the basic communication like DbusCommunication etc... * Be aware of side effects with systemd and socketbased communication! * @return E_OK on success, E_UNKNOWN on error * - * @param commandreceiveinterface pointer to the receive interface. Is used to - * call the audiomanagerdaemon + * @param commandreceiveinterface pointer to the receive interface. Is used to call the audiomanagerdaemon */ virtual am_Error_e startupInterface(IAmCommandReceive* commandreceiveinterface) =0; /** - * This function will indirectly be called by the Controller and is used to start - * the Communication. Before this command, all communication will be ignored by - * the AudioManager. - * After the Plugin is ready, it will asynchronously answer with - * condfirmCommandReady, the handle that is handed over must be returned. + * This function will indirectly be called by the Controller and is used to start the Communication. Before this command, + * all communication will be ignored by the AudioManager. + * After the Plugin is ready, it will asynchronously answer with condfirmCommandReady, the handle that is handed over must + * be returned. * * @param handle the handle uniquely idenfies the request */ virtual void setCommandReady(const uint16_t handle) =0; /** - * This function will indirectly be called by the Controller and is used to stop - * the Communication. After this command, all communication will be ignored by the - * AudioManager. The plugin has to be prepared that either the power will be + * This function will indirectly be called by the Controller and is used to stop the Communication. After this command, + * all communication will be ignored by the AudioManager. The plugin has to be prepared that either the power will be * switched off or the Interface is started again with setCommandReady - * After the Plugin is ready to rundown, it will asynchronously answer with - * condfirmCommandRundown, the handle that is handed over must be returned. + * After the Plugin is ready to rundown, it will asynchronously answer with condfirmCommandRundown, the handle that is + * handed over must be returned. * * @param handle This handle uniquly idenfies the request */ @@ -211,7 +203,53 @@ namespace am { * @param time */ virtual void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) =0; + /** + * This callback is called when a sink is updated. + * + * @param sinkID The sinkID that is updated + * @param sinkClassID The sinkClassID of the updated sink. gives the current value even if not updated + * @param listMainSoundProperties The list of mainSoundProperties. Gives the actual list of MainSoundProperties even if + * not changed + */ + virtual void cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector& listMainSoundProperties) =0; + /** + * This callback is called when a source is updated. + * + * @param sourceID The sourceID that is updated + * @param sourceClassID The sourceClassID of the updated source. Gives the current value even if not updated + * @param listMainSoundProperties The list of mainSoundProperties. Gives the actual list of MainSoundProperties even if + * not changed + */ + virtual void cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector& listMainSoundProperties) =0; + /** + * This callback is called when a notifcated value of a sink changes. + * + * @param sinkID The sinkID + * @param notification The payload of the notification + */ + virtual void cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s notification) =0; + /** + * This callback is called when a notifcated value of a source changes. + * + * @param sourceID The sourceID + * @param notification The payload of the notification + */ + virtual void cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s notification) =0; + /** + * This callback is triggered when a mainNotificationConfiguration is changed. + * + * @param sinkID + * @param mainNotificationConfiguration The MainNotificationConfiguration that changed + */ + virtual void cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) =0; + /** + * This callback is triggered when a mainNotificationConfiguration is changed. + * + * @param sourceID + * @param mainNotificationConfiguration The MainNotificationConfiguration that changed + */ + virtual void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) =0; }; } -#endif // !defined(EA_EA24D1A2_FDA1_4285_8606_7E77A080B4E9__INCLUDED_) +#endif // !defined(EA_B053C89D_3921_4e1a_836D_C3B98FAD2E36__INCLUDED_) diff --git a/include/control/IAmControlReceive.h b/include/control/IAmControlReceive.h index 1cbf244..ccba927 100644 --- a/include/control/IAmControlReceive.h +++ b/include/control/IAmControlReceive.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_6E701C15_A8E8_4ad3_A50B_D91A5BD0973F__INCLUDED_) -#define EA_6E701C15_A8E8_4ad3_A50B_D91A5BD0973F__INCLUDED_ +#if !defined(EA_AC2A0532_F989_4f95_A467_1055C94D9C1E__INCLUDED_) +#define EA_AC2A0532_F989_4f95_A467_1055C94D9C1E__INCLUDED_ #include #include @@ -30,24 +30,25 @@ class CAmSocketHandler; } -#define ControlReceiveVersion "1.0" +#include "audiomanagertypes.h" +#include "projecttypes.h" +#include "NodeStateManager.h" + +#define ControlReceiveVersion "2.0" namespace am { /** - * This interface gives access to all important functions of the audiomanager that - * are used by the AudioManagerController to control the system. - * There are two rules that have to be kept in mind when implementing against this - * interface:\n + * This interface gives access to all important functions of the audiomanager that are used by the AudioManagerController + * to control the system. + * There are two rules that have to be kept in mind when implementing against this interface:\n * \warning * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n - * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS - * CALL THAT EXPECTS A RETURN VALUE.\n + * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n * \details - * Violation these rules may lead to unexpected behavior! Nevertheless you can - * implement thread safe by using the deferred-call pattern described on the wiki - * which also helps to implement calls that are forbidden.\n + * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred- + * call pattern described on the wiki which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer * @author Christian Mueller - * @created 07-Mar-2012 6:06:18 PM + * @created 16-Dez-2012 15:58:15 */ class IAmControlReceive { @@ -71,20 +72,17 @@ namespace am { * calculates a route from source to sink. * @return E_OK on success, E_UNKNOWN on error * - * @param onlyfree if true return only routes which use gateways that are not - * in use at the moment + * @param onlyfree if true return only routes which use gateways that are not in use at the moment * @param sourceID * @param sinkID - * @param returnList this is a list of routes that are possible to take. - * unsorted! The longest could be first. + * @param returnList this is a list of routes that are possible to take. unsorted! The longest could be first. * In case not route can be found, the list will return empty. */ virtual am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector& returnList) =0; /** * With this function, elementary connects can be triggered by the controller. - * @return E_OK on success, E_UNKNOWN on error, E_WRONG_FORMAT of - * connectionFormats do not match, E_NO_CHANGE if the desired connection is - * already build up + * @return E_OK on success, E_UNKNOWN on error, E_WRONG_FORMAT of connectionFormats do not match, E_NO_CHANGE if the + * desired connection is already build up * * @param handle * @param connectionID @@ -95,8 +93,8 @@ namespace am { virtual am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID) =0; /** * is used to disconnect a connection - * @return E_OK on success, E_UNKNOWN on error, E_NON_EXISTENT if connection was - * not found, E_NO_CHANGE if no change is neccessary + * @return E_OK on success, E_UNKNOWN on error, E_NON_EXISTENT if connection was not found, E_NO_CHANGE if no change is + * neccessary * * @param handle * @param connectionID @@ -104,12 +102,10 @@ namespace am { virtual am_Error_e disconnect(am_Handle_s& handle, const am_connectionID_t connectionID) =0; /** * triggers a cross fade. - * @return E_OK on success, E_UNKNOWN on error E_NO_CHANGE if no change is - * neccessary + * @return E_OK on success, E_UNKNOWN on error E_NO_CHANGE if no change is neccessary * * @param handle - * @param hotSource this is the source that is going to be the active one after - * the fading + * @param hotSource this is the source that is going to be the active one after the fading * @param crossfaderID * @param rampType * @param rampTime rampTime 0 means default value @@ -123,10 +119,9 @@ namespace am { */ virtual am_Error_e abortAction(const am_Handle_s handle) =0; /** - * this method sets a source state for a source. This function will trigger the - * callback cbAckSetSourceState - * @return E_OK on success, E_NO_CHANGE if the desired value is already correct, - * E_UNKNOWN on error, E_NO_CHANGE if no change is neccessary + * this method sets a source state for a source. This function will trigger the callback cbAckSetSourceState + * @return E_OK on success, E_NO_CHANGE if the desired value is already correct, E_UNKNOWN on error, E_NO_CHANGE if no + * change is neccessary * * @param handle * @param sourceID @@ -134,13 +129,12 @@ namespace am { */ virtual am_Error_e setSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state) =0; /** - * with this function, setting of sinks volumes is done. The behavior of the - * volume set is depended on the given ramp and time information. - * This function is not only used to ramp volume, but also to mute and direct set - * the level. Exact behavior is depended on the selected mute ramps. - * @return E_OK on success, E_NO_CHANGE if the volume is already on the desired - * value, E_OUT_OF_RANGE is the volume is out of range, E_UNKNOWN on every other - * error. + * with this function, setting of sinks volumes is done. The behavior of the volume set is depended on the given ramp and + * time information. + * This function is not only used to ramp volume, but also to mute and direct set the level. Exact behavior is depended on + * the selected mute ramps. + * @return E_OK on success, E_NO_CHANGE if the volume is already on the desired value, E_OUT_OF_RANGE is the volume is out + * of range, E_UNKNOWN on every other error. * * @param handle * @param sinkID @@ -150,13 +144,12 @@ namespace am { */ virtual am_Error_e setSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) =0; /** - * with this function, setting of source volumes is done. The behavior of the - * volume set is depended on the given ramp and time information. - * This function is not only used to ramp volume, but also to mute and direct set - * the level. Exact behavior is depended on the selected mute ramps. - * @return E_OK on success, E_NO_CHANGE if the volume is already on the desired - * value, E_OUT_OF_RANGE is the volume is out of range, E_UNKNOWN on every other - * error. + * with this function, setting of source volumes is done. The behavior of the volume set is depended on the given ramp and + * time information. + * This function is not only used to ramp volume, but also to mute and direct set the level. Exact behavior is depended on + * the selected mute ramps. + * @return E_OK on success, E_NO_CHANGE if the volume is already on the desired value, E_OUT_OF_RANGE is the volume is out + * of range, E_UNKNOWN on every other error. * * @param handle * @param sourceID @@ -167,8 +160,8 @@ namespace am { virtual am_Error_e setSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time) =0; /** * is used to set several sinkSoundProperties at a time - * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out - * of range, E_NO_CHANGE if no change is neccessary + * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out of range, E_NO_CHANGE if no change is + * neccessary * * @param handle * @param sinkID @@ -177,8 +170,8 @@ namespace am { virtual am_Error_e setSinkSoundProperties(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector& soundProperty) =0; /** * is used to set sinkSoundProperties - * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out - * of range, E_NO_CHANGE if no change is neccessary + * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out of range, E_NO_CHANGE if no change is + * neccessary * * @param handle * @param sinkID @@ -187,8 +180,8 @@ namespace am { virtual am_Error_e setSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) =0; /** * is used to set several SourceSoundProperties at a time - * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out - * of range. E_NO_CHANGE if no change is neccessary + * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out of range. E_NO_CHANGE if no change is + * neccessary * * @param handle * @param sourceID @@ -197,8 +190,8 @@ namespace am { virtual am_Error_e setSourceSoundProperties(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector& soundProperty) =0; /** * is used to set sourceSoundProperties - * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out - * of range. E_NO_CHANGE if no change is neccessary + * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if property is out of range. E_NO_CHANGE if no change is + * neccessary * * @param handle * @param sourceID @@ -207,8 +200,7 @@ namespace am { virtual am_Error_e setSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) =0; /** * sets the domain state of a domain - * @return E_OK on success, E_UNKNOWN on error, E_NO_CHANGE if no change is - * neccessary + * @return E_OK on success, E_UNKNOWN on error, E_NO_CHANGE if no change is neccessary * * @param domainID * @param domainState @@ -216,8 +208,8 @@ namespace am { virtual am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) =0; /** * enters a domain in the database, creates and ID - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error * * @param domainData domainID in am_Domain_s must be 0 here * @param domainID @@ -227,127 +219,109 @@ namespace am { * enters a mainconnection in the database, creates and ID * @return E_OK on success, E_DATABASE_ERROR if the database had an error * - * @param mainConnectionData the MainConnectionID is omitted since it is - * created during the registration + * @param mainConnectionData the MainConnectionID is omitted since it is created during the registration * @param connectionID */ virtual am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID) =0; /** * enters a sink in the database. - * The sinkID in am_Sink_s shall be 0 in case of a dynamic added source A sinkID - * greater than 100 will be assigned. If a specific sinkID with a value <100 is - * given, the given value will be used. This is for a static setup where the ID's - * are predefined. - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error - * - * @param sinkData the sinkID will be omitted since it is created during the - * registration + * The sinkID in am_Sink_s shall be 0 in case of a dynamic added source A sinkID greater than 100 will be assigned. If a + * specific sinkID with a value <100 is given, the given value will be used. This is for a static setup where the ID's are + * predefined. + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error + * + * @param sinkData the sinkID will be omitted since it is created during the registration * @param sinkID */ virtual am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID) =0; /** * enters a crossfader in the database. - * The crossfaderID in am_Crossfader_s shall be 0 in case of a dynamic added - * source A crossfaderID greater than 100 will be assigned. If a specific - * crossfaderID with a value <100 is given, the given value will be used. This is - * for a static setup where the ID's are predefined. - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error - * - * @param crossfaderData the ID in the data will be ignored since it is created - * during the registration + * The crossfaderID in am_Crossfader_s shall be 0 in case of a dynamic added source A crossfaderID greater than 100 will + * be assigned. If a specific crossfaderID with a value <100 is given, the given value will be used. This is for a static + * setup where the ID's are predefined. + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error + * + * @param crossfaderData the ID in the data will be ignored since it is created during the registration * @param crossfaderID */ virtual am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) =0; /** * enters a gateway in the database. - * The gatewayID in am_Gateway_s shall be 0 in case of a dynamic added source A - * gatewayID greater than 100 will be assigned. If a specific gatewayID with a - * value <100 is given, the given value will be used. This is for a static setup + * The gatewayID in am_Gateway_s shall be 0 in case of a dynamic added source A gatewayID greater than 100 will be + * assigned. If a specific gatewayID with a value <100 is given, the given value will be used. This is for a static setup * where the ID's are predefined. - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error * - * @param gatewayData In a fixed setup, the gatewayID must be below 100. In a - * dynamic setup, the gatewayID shall be 0! listSourceFormats and listSinkFormats - * are empty at registration time. Values are taken over when sources and sinks - * are registered. + * @param gatewayData In a fixed setup, the gatewayID must be below 100. In a dynamic setup, the gatewayID shall be 0! + * listSourceFormats and listSinkFormats are empty at registration time. Values are taken over when sources and sinks are + * registered. * @param gatewayID */ virtual am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) =0; /** * enters a source in the database. - * The sourceID in am_Source_s shall be 0 in case of a dynamic added source A - * sourceID greater than 100 will be assigned. If a specific sourceID with a value - * <100 is given, the given value will be used. This is for a static setup where - * the ID's are predefined. - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error - * - * @param sourceData sourceID is omitted here since it is created during - * registration + * The sourceID in am_Source_s shall be 0 in case of a dynamic added source A sourceID greater than 100 will be assigned. + * If a specific sourceID with a value <100 is given, the given value will be used. This is for a static setup where the + * ID's are predefined. + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error + * + * @param sourceData sourceID is omitted here since it is created during registration * @param sourceID */ virtual am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID) =0; /** * Enters a sourceClass into the database. - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error * - * @param sinkClass IDs given with the SinkCLassID are valid below 100 (static). - * If given as 0, sinkClass will be enterd dynamic and ID above 100 will be - * created. + * @param sinkClass IDs given with the SinkCLassID are valid below 100 (static). If given as 0, sinkClass will be + * enterd dynamic and ID above 100 will be created. * @param sinkClassID */ virtual am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID) =0; /** * Enters a sourceClass into the database. - * The sourceClassID in am_sourceClass_s shall be 0 in case of a dynamic added - * source A sourceClassID greater than 100 will be assigned. If a specific - * sourceClassID with a value <100 is given, the given value will be used. This is - * for a static setup where the ID's are predefined. - * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the - * database, E_DATABASE_ERROR if the database had an error + * The sourceClassID in am_sourceClass_s shall be 0 in case of a dynamic added source A sourceClassID greater than 100 + * will be assigned. If a specific sourceClassID with a value <100 is given, the given value will be used. This is for a + * static setup where the ID's are predefined. + * @return E_OK on success, E_ALREADY_EXISTENT if the ID or name is already in the database, E_DATABASE_ERROR if the + * database had an error * * @param sourceClassID - * @param sourceClass IDs given with the SourceCLassID are valid below 100 - * (static). If given as 0, sourceClass will be enterd dynamic and ID above 100 - * will be created. + * @param sourceClass IDs given with the SourceCLassID are valid below 100 (static). If given as 0, sourceClass will be + * enterd dynamic and ID above 100 will be created. */ virtual am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass) =0; /** * changes class information of a sinkclass. - * The properties will overwrite the values of the sinkClassID given in the - * sinkClass. - * It is the duty of the controller to check if the property is valid. If it does - * not exist, the daemon will not return an error. - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if - * sinkClassID was not found. + * The properties will overwrite the values of the sinkClassID given in the sinkClass. + * It is the duty of the controller to check if the property is valid. If it does not exist, the daemon will not return an + * error. + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sinkClassID was not found. * - * @param sinkClass if a SourceClass ID other than 0 is given, the - * classInformation replaces the existing one. In case of ClassID 0, a new classID - * is created and returned + * @param sinkClass if a SourceClass ID other than 0 is given, the classInformation replaces the existing one. In case + * of ClassID 0, a new classID is created and returned */ virtual am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) =0; /** * changes class information of a sourceClass. - * The properties will overwrite the values of the sourceClassID given in the - * sourceClass. - * It is the duty of the controller to check if the property is valid. If it does - * not exist, the daemon will not return an error. - * @return E_OK on success, E_DATABASE_ERROR on error and E_NON_EXISTENT if the - * ClassID does not exist. + * The properties will overwrite the values of the sourceClassID given in the sourceClass. + * It is the duty of the controller to check if the property is valid. If it does not exist, the daemon will not return an + * error. + * @return E_OK on success, E_DATABASE_ERROR on error and E_NON_EXISTENT if the ClassID does not exist. * - * @param sourceClass if a SourceClass ID other than 0 is given, the - * classInformation replaces the existing one. In case of ClassID 0, a new classID - * is created and returned + * @param sourceClass if a SourceClass ID other than 0 is given, the classInformation replaces the existing one. In + * case of ClassID 0, a new classID is created and returned */ virtual am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) =0; /** * This function is used to enter the system Properties into the database. - * All entries in the database will be erased before entering the new List. It - * should only be called once at system startup. + * All entries in the database will be erased before entering the new List. It should only be called once at system + * startup. * @return E_OK on success, E_DATABASE_ERROR if the database had an error * * @param listSystemProperties @@ -355,8 +329,7 @@ namespace am { virtual am_Error_e enterSystemPropertiesListDB(const std::vector& listSystemProperties) =0; /** * changes the mainConnectionState of MainConnection - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if - * mainconnection + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if mainconnection * * @param mainconnectionID * @param listConnectionID @@ -364,8 +337,7 @@ namespace am { virtual am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector& listConnectionID) =0; /** * changes the mainConnectionState of MainConnection - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if - * mainconnection + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if mainconnection * * @param mainconnectionID * @param connectionState @@ -373,8 +345,7 @@ namespace am { virtual am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) =0; /** * changes the sink volume of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param mainVolume * @param sinkID @@ -382,8 +353,7 @@ namespace am { virtual am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) =0; /** * changes the availablility of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param availability * @param sinkID @@ -391,8 +361,7 @@ namespace am { virtual am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID) =0; /** * changes the domainstate of a domain - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain was not found * * @param domainState * @param domainID @@ -400,8 +369,7 @@ namespace am { virtual am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) =0; /** * changes the mute state of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param muteState * @param sinkID @@ -409,8 +377,7 @@ namespace am { virtual am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) =0; /** * changes the mainsinksoundproperty of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param soundProperty * @param sinkID @@ -418,8 +385,7 @@ namespace am { virtual am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID) =0; /** * changes the mainsourcesoundproperty of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if source - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if source was not found * * @param soundProperty * @param sourceID @@ -427,8 +393,7 @@ namespace am { virtual am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID) =0; /** * changes the availablility of a source - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if source - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if source was not found * * @param availability * @param sourceID @@ -436,80 +401,70 @@ namespace am { virtual am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID) =0; /** * changes a systemProperty - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if property - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if property was not found * * @param property */ virtual am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property) =0; /** * removes a mainconnection from the DB - * @return E_OK on success, E_NON_EXISTENT if main connection was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if main connection was not found, E_DATABASE_ERROR if the database had an error * * @param mainConnectionID */ virtual am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) =0; /** * removes a sink from the DB - * @return E_OK on success, E_NON_EXISTENT if sink was not found, E_DATABASE_ERROR - * if the database had an error + * @return E_OK on success, E_NON_EXISTENT if sink was not found, E_DATABASE_ERROR if the database had an error * * @param sinkID */ virtual am_Error_e removeSinkDB(const am_sinkID_t sinkID) =0; /** * removes a source from the DB - * @return E_OK on success, E_NON_EXISTENT if source was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if source was not found, E_DATABASE_ERROR if the database had an error * * @param sourceID */ virtual am_Error_e removeSourceDB(const am_sourceID_t sourceID) =0; /** * removes a gateway from the DB - * @return E_OK on success, E_NON_EXISTENT if gateway was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if gateway was not found, E_DATABASE_ERROR if the database had an error * * @param gatewayID */ virtual am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID) =0; /** * removes a crossfader from the DB - * @return E_OK on success, E_NON_EXISTENT if crossfader was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if crossfader was not found, E_DATABASE_ERROR if the database had an error * * @param crossfaderID */ virtual am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID) =0; /** * removes a domain from the DB - * @return E_OK on success, E_NON_EXISTENT if domain was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if domain was not found, E_DATABASE_ERROR if the database had an error * * @param domainID */ virtual am_Error_e removeDomainDB(const am_domainID_t domainID) =0; /** * removes a domain from the DB - * @return E_OK on success, E_NON_EXISTENT if domain was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if domain was not found, E_DATABASE_ERROR if the database had an error * * @param sinkClassID */ virtual am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID) =0; /** * removes a domain from the DB - * @return E_OK on success, E_NON_EXISTENT if domain was not found, - * E_DATABASE_ERROR if the database had an error + * @return E_OK on success, E_NON_EXISTENT if domain was not found, E_DATABASE_ERROR if the database had an error * * @param sourceClassID */ virtual am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID) =0; /** * returns the ClassInformation of a source - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if source - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if source was not found * * @param sourceID * @param classInfo @@ -517,8 +472,7 @@ namespace am { virtual am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const =0; /** * returns the ClassInformation of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param sinkID * @param sinkClass @@ -526,8 +480,7 @@ namespace am { virtual am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const =0; /** * returns the sinkData of a sink - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param sinkID * @param sinkData @@ -535,8 +488,7 @@ namespace am { virtual am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const =0; /** * returns the sourcekData of a source - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was - * not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if sink was not found * * @param sourceID * @param sourceData @@ -544,8 +496,7 @@ namespace am { virtual am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const =0; /** * return source and sink of a gateway - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if gateway - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if gateway was not found * * @param gatewayID * @param gatewayData @@ -553,8 +504,7 @@ namespace am { virtual am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const =0; /** * returns sources and the sink of a crossfader - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if - * crossfader was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if crossfader was not found * * @param crossfaderID * @param crossfaderData @@ -562,8 +512,7 @@ namespace am { virtual am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const =0; /** * returns sources and the sink of a crossfader - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if - * crossfader was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if crossfader was not found * * @param mainConnectionID * @param mainConnectionData @@ -571,8 +520,7 @@ namespace am { virtual am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const =0; /** * returns all sinks of a domain - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain was not found * * @param domainID * @param listSinkID @@ -580,8 +528,7 @@ namespace am { virtual am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector& listSinkID) const =0; /** * returns all source of a domain - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain was not found * * @param domainID * @param listSourceID @@ -589,8 +536,7 @@ namespace am { virtual am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector& listSourceID) const =0; /** * returns all crossfaders of a domain - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain was not found * * @param domainID * @param listCrossfadersID @@ -598,8 +544,7 @@ namespace am { virtual am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector& listCrossfadersID) const =0; /** * returns all gateways of a domain - * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain - * was not found + * @return E_OK on success, E_DATABASE_ERROR on error, E_NON_EXISTENT if domain was not found * * @param domainID * @param listGatewaysID @@ -682,45 +627,217 @@ namespace am { */ virtual am_Error_e getListSystemProperties(std::vector& listSystemProperties) const =0; /** - * sets the command interface to ready. Will send setCommandReady to each of the - * plugins. The corresponding answer is confirmCommandReady. + * sets the command interface to ready. Will send setCommandReady to each of the plugins. The corresponding answer is + * confirmCommandReady. */ virtual void setCommandReady() =0; /** - * sets the command interface into the rundown state. Will send setCommandRundown - * to each of the plugins. The corresponding answer is confirmCommandRundown. + * sets the command interface into the rundown state. Will send setCommandRundown to each of the plugins. The + * corresponding answer is confirmCommandRundown. */ virtual void setCommandRundown() =0; /** - * sets the routinginterface to ready. Will send the command setRoutingReady to - * each of the plugins. The related answer is confirmRoutingReady. + * sets the routinginterface to ready. Will send the command setRoutingReady to each of the plugins. The related answer + * is confirmRoutingReady. */ virtual void setRoutingReady() =0; /** - * sets the routinginterface to the rundown state. Will send the command - * setRoutingRundown to each of the plugins. The related answer is - * confirmRoutingRundown. + * sets the routinginterface to the rundown state. Will send the command setRoutingRundown to each of the plugins. The + * related answer is confirmRoutingRundown. */ virtual void setRoutingRundown() =0; /** * acknowledges the setControllerReady call. + * + * @param error E_OK if the ready command succeeded. E_UNKNOWN if an error happened. */ - virtual void confirmControllerReady() =0; + virtual void confirmControllerReady(const am_Error_e error) =0; /** - * acknowledges the setControllerRundown call. + * Acknowledges the setControllerRundown call. + * + * @param error E_OK if the ready command succeeded. E_UNKNOWN if an error happened. + * If an error !=E_OK is returned than the AudioManager will terminate with an exception. + * If E_OK is returned, the AudioManager will exit clean */ - virtual void confirmControllerRundown() =0; + virtual void confirmControllerRundown(const am_Error_e error) =0; /** - * This function returns the pointer to the socketHandler. This can be used to - * integrate socket-based activites like communication with the mainloop of the - * AudioManager. - * returns E_OK if pointer is valid, E_UNKNOWN in case AudioManager was compiled - * without socketHandler support, + * This function returns the pointer to the socketHandler. This can be used to integrate socket-based activites like + * communication with the mainloop of the AudioManager. + * returns E_OK if pointer is valid, E_UNKNOWN in case AudioManager was compiled without socketHandler support, * * @param socketHandler */ virtual am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) =0; + /** + * Change the data of the source. + * + * @param sourceID The sourceID of the source that needs to be changed. + * @param sourceClassID If this sourceClassID !=0, the sourceClassID of the source will be changed. + * @param listSoundProperties If the size of the list !=0, the list replaces the current one. + * @param listConnectionFormats If the size of the list !=0, the list replaces the current one. + * @param listMainSoundProperties If the size of the list !=0, the list replaces the current one. + */ + virtual am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties) =0; + /** + * Change the data of the sink. + * + * @param sinkID the sinkID of the sink to be changed + * @param sinkClassID If !=0, the sinkClass will replace the current one. + * @param listSoundProperties The list of the sound properties. If The lenght of the list !=0, the current + * soundProperties will be changed. + * @param listConnectionFormats The list of the connectionformats to be changed. They will only be changed, if length + * of the list !=0 + * @param listMainSoundProperties The list of the mainsoundproperties that need to be changed. Will be changed. if the + * length of the list !=0 + */ + virtual am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, const std::vector listMainSoundProperties) =0; + /** + * changes Gateway Data + * + * @param gatewayID the gatewayData to be changed + * @param listSourceConnectionFormats The list of the sourceConnectionFormats. Will be changed it the lenght of the + * list !=0. + * @param listSinkConnectionFormats The list of the sinkConnectionFormats. Will be changed it the lenght of the list + * !=0. + * @param convertionMatrix the convertionmatrix + */ + virtual am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix) =0; + /** + * with this function, setting of multiple volumes at a time is done. The behavior of the volume set is depended on the + * given ramp and time information. + * This function is not only used to ramp volume, but also to mute and direct set the level. Exact behavior is depended on + * the selected mute ramps. + * @return E_OK on success, E_NO_CHANGE if the volume is already on the desired value, E_OUT_OF_RANGE is the volume is out + * of range, E_UNKNOWN on every other error. + * + * @param handle + * @param listVolumes + */ + virtual am_Error_e setVolumes(am_Handle_s& handle, const std::vector listVolumes) =0; + /** + * set a sink notification configuration + * + * @param handle the handle that will be assigned for this operation + * @param sinkID the sinkID + * @param notificationConfiguration + */ + virtual am_Error_e setSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) =0; + /** + * set a source notification configuration + * + * @param handle the handle that will be assigned for this operation + * @param sourceID the sinkID + * @param norificationConfiguration + */ + virtual am_Error_e setSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s norificationConfiguration) =0; + /** + * Sends out the main notificiation of a sink + * @return E_OK on success, E_UNKNOWN on error + * + * @param sinkID + * @param notificationPayload the payload + */ + virtual void sendSinkMainNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s notificationPayload) =0; + /** + * Sends out the main notificiation of a source + * @return E_OK on success, E_UNKNOWN on error + * + * @param sourceID + * @param notificationPayload the payload + */ + virtual void sendSourceMainNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s notificationPayload) =0; + /** + * change the mainNotificationConfiguration of a sink + * @return E_OK when successful, E_DATABASE on error + * + * @param sinkID the sinkID + * @param mainNotificationConfiguration the mainNotificationConfiguration + */ + virtual am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) =0; + /** + * change the mainNotificationConfiguration of a source + * @return E_OK when successful, E_DATABASE on error + * + * @param sourceID the sourceID + * @param mainNotificationConfiguration the mainNotificationConfiguration + */ + virtual am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) =0; + /** + * Retrieves the Restart Reason Property + * @return E_OK on success E_UNKNOWN if property could not be retrieved. + * + * @param restartReason the restart reason + */ + virtual am_Error_e nsmGetRestartReasonProperty(NsmRestartReason_e& restartReason) =0; + /** + * Retrieves the shutdown reason property + * @return E_OK on success E_UNKNOWN if property could not be retrieved. + * + * @param ShutdownReason The shutdown reason + */ + virtual am_Error_e nsmGetShutdownReasonProperty(NsmShutdownReason_e& ShutdownReason) =0; + /** + * Retrieves the running reason + * @return E_OK on success E_UNKNOWN if property could not be retrieved. + * + * @param nsmRunningReason the running reson + */ + virtual am_Error_e nsmGetRunningReasonProperty(NsmRunningReason_e& nsmRunningReason) =0; + /** + * @return NsmErrorStatus_Ok in case of success + * + * @param nsmNodeState The current node state + */ + virtual NsmErrorStatus_e nsmGetNodeState(NsmNodeState_e& nsmNodeState) =0; + /** + * Retrieves the current session state + * @return NsmErrorStatus_Ok on success E_UNKNOWN if property could not be retrieved. + * + * @param sessionName The current session state + * @param seatID + * @param sessionState The sessionState + */ + virtual NsmErrorStatus_e nsmGetSessionState(const std::string& sessionName, const NsmSeat_e& seatID, NsmSessionState_e& sessionState) =0; + /** + * Retrieves the current applicationmode + * @return NsmErrorStatus_Ok on success E_UNKNOWN if property could not be retrieved. + * + * @param applicationMode The current application Mode + */ + virtual NsmErrorStatus_e nsmGetApplicationMode(NsmApplicationMode_e& applicationMode) =0; + /** + * Registers the AudioManager as shutdown client + * @return NsmErrorStatus_Ok on success + * The interface for the client will be provided by the AudioManagerDeamon, therefore is no need to mention it here. + * + * @param shutdownMode The shutdown mode that the controller wants to register for. Can be + * @param timeoutMs Max. Timeout to wait for response from shutdown client in ms + */ + virtual NsmErrorStatus_e nsmRegisterShutdownClient(const uint32_t shutdownMode, const uint32_t timeoutMs) =0; + /** + * unregisters the AudioManager as shutdown client + * @return NsmErrorStatus_Ok on success + * + * @param shutdownMode Shutdown mode for which client wants to unregister (NSM_SHUTDOWNTYPE_NORMAL, + * NSM_SHUTDOWNTYPE_FAST) + */ + virtual NsmErrorStatus_e nsmUnRegisterShutdownClient(const uint32_t shutdownMode) =0; + /** + * @return E_OK on success, E_UNKOWN if interface could not be reached + * + * @param version + */ + virtual am_Error_e nsmGetInterfaceVersion(uint32_t& version) =0; + /** + * Sends out the lifecyclerequest complete to the NSM + * @return NsmErrorStatus_Ok in case of success + * + * @param RequestId The request ID of the request. + * @param status The result of the call to "LifecycleRequest". NsmErrorStatus_Ok: Request successfully processed. + * NsmErrorStatus_Error: An error occured while processing the "LifecycleRequest". + */ + virtual NsmErrorStatus_e nsmSendLifecycleRequestComplete(const uint32_t RequestId, const NsmErrorStatus_e status) =0; }; } -#endif // !defined(EA_6E701C15_A8E8_4ad3_A50B_D91A5BD0973F__INCLUDED_) +#endif // !defined(EA_AC2A0532_F989_4f95_A467_1055C94D9C1E__INCLUDED_) diff --git a/include/control/IAmControlSend.h b/include/control/IAmControlSend.h index bac33b2..9b2d0b9 100644 --- a/include/control/IAmControlSend.h +++ b/include/control/IAmControlSend.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_B9BE9751_825D_44b9_86F1_C2F02E5FA3ED__INCLUDED_) -#define EA_B9BE9751_825D_44b9_86F1_C2F02E5FA3ED__INCLUDED_ +#if !defined(EA_9CC33091_C4F5_4262_9C42_042DFB7606F2__INCLUDED_) +#define EA_9CC33091_C4F5_4262_9C42_042DFB7606F2__INCLUDED_ #include #include @@ -31,27 +31,25 @@ class IAmControlReceive; } #include "IAmControlReceive.h" +#include "audiomanagertypes.h" +#include "NodeStateManager.h" -#define ControlSendVersion "1.0" +#define ControlSendVersion "2.0" namespace am { /** * This interface is presented by the AudioManager controller. - * All the hooks represent system events that need to be handled. The callback - * functions are used to handle for example answers to function calls on the - * AudioManagerCoreInterface. - * There are two rules that have to be kept in mind when implementing against this - * interface:\n + * All the hooks represent system events that need to be handled. The callback functions are used to handle for example + * answers to function calls on the AudioManagerCoreInterface. + * There are two rules that have to be kept in mind when implementing against this interface:\n * \warning * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n - * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS - * CALL THAT EXPECTS A RETURN VALUE.\n + * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n * \details - * Violation these rules may lead to unexpected behavior! Nevertheless you can - * implement thread safe by using the deferred-call pattern described on the wiki - * which also helps to implement calls that are forbidden.\n + * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred- + * call pattern described on the wiki which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer * @author Christian Mueller - * @created 07-Mar-2012 6:06:18 PM + * @created 16-Dez-2012 15:58:15 */ class IAmControlSend { @@ -75,25 +73,32 @@ namespace am { /** * Starts up the controller. * - * @param controlreceiveinterface This is a pointer to the - * ControlReceiveInterface so that the controller knows to whom to communicate. + * @param controlreceiveinterface This is a pointer to the ControlReceiveInterface so that the controller knows to whom + * to communicate. */ virtual am_Error_e startupController(IAmControlReceive* controlreceiveinterface) =0; /** - * this message is used tell the controller that it should get ready. This message - * must be acknowledged via confirmControllerReady. + * this message is used tell the controller that it should get ready. This message must be acknowledged via + * confirmControllerReady. */ virtual void setControllerReady() =0; /** - * this message tells the controller that he should prepare everything for the - * power to be switched off. This message must be acknowledged via - * confirmControllerRundown. + * This message tells the controller that he should prepare everything for the power to be switched off. This message must + * be acknowledged via confirmControllerRundown. + * The method will give the signal as integer that was responsible for calling the setControllerRundown. + * This function is called from the signal handler, either direct (when the program is killed) or from within the mainloop + * (if the program is terminated). + * + * @param signal The signal NO that was responsible for the rundown. Can be: + * SIGINT + * SIGQUIT + * SIGTERM + * SIGHUP */ - virtual void setControllerRundown() =0; + virtual void setControllerRundown(const int16_t signal) =0; /** * is called when a connection request comes in via the command interface - * @return E_OK on success, E_NOT_POSSIBLE on error, E_ALREADY_EXISTENT if already - * exists + * @return E_OK on success, E_NOT_POSSIBLE on error, E_ALREADY_EXISTENT if already exists * * @param sourceID * @param sinkID @@ -102,8 +107,7 @@ namespace am { virtual am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) =0; /** * is called when a disconnection request comes in via the command interface - * @return E_OK on success, E_NOT_POSSIBLE on error, E_NON_EXISTENT if connection - * does not exists + * @return E_OK on success, E_NOT_POSSIBLE on error, E_NON_EXISTENT if connection does not exists * * @param connectionID */ @@ -157,8 +161,7 @@ namespace am { virtual am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) =0; /** * is called when a routing adaptor registers its domain - * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already - * exists + * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already exists * * @param domainData ID is omitted here since it has not been created yet * @param domainID @@ -179,8 +182,7 @@ namespace am { virtual void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) =0; /** * is called when a routing adaptor registers a sink - * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already - * exists + * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already exists * * @param sinkData Id is omitted here, since it has not been created yet * @param sinkID @@ -195,8 +197,7 @@ namespace am { virtual am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) =0; /** * is called when a routing adaptor registers a source - * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already - * exists + * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already exists * * @param sourceData ID is omitted here since it is not yet created * @param sourceID @@ -211,11 +212,9 @@ namespace am { virtual am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) =0; /** * is called when a routing adaptor registers a gateway - * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already - * exists + * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already exists * - * @param gatewayData gatewayID is not set here since it is not created at this - * point of time + * @param gatewayData gatewayID is not set here since it is not created at this point of time * @param gatewayID */ virtual am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) =0; @@ -228,11 +227,9 @@ namespace am { virtual am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) =0; /** * is called when a routing adaptor registers a crossfader - * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already - * exists + * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXISTENT if already exists * - * @param crossfaderData gatewayID is not set here since it is not created at - * this point of time + * @param crossfaderData gatewayID is not set here since it is not created at this point of time * @param crossfaderID */ virtual am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) =0; @@ -295,15 +292,13 @@ namespace am { virtual void hookSystemReceiveEarlyData(const std::vector& data) =0; /** * this hook provides information about speed changes. - * The quantization and sampling rate of the speed can be adjusted at compile time - * of the AudioManagerDaemon. + * The quantization and sampling rate of the speed can be adjusted at compile time of the AudioManagerDaemon. * * @param speed */ virtual void hookSystemSpeedChange(const am_speed_t speed) =0; /** - * this hook is fired whenever the timing information of a mainconnection has - * changed. + * this hook is fired whenever the timing information of a mainconnection has changed. * * @param mainConnectionID * @param time @@ -343,8 +338,8 @@ namespace am { * ack for source volume changes * * @param handle the handle that is connected to the volume change - * @param voulme the volume after the action ended (the desired volume if - * everything went right, the actual one in case of abortion) + * @param voulme the volume after the action ended (the desired volume if everything went right, the actual one in case + * of abortion) * @param error */ virtual void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) =0; @@ -384,36 +379,154 @@ namespace am { */ virtual void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) =0; /** - * This function is used by the routing algorithm to retrieve a priorized list of - * connectionFormats from the Controller. + * This function is used by the routing algorithm to retrieve a priorized list of connectionFormats from the Controller. * @return E_OK in case of successfull priorisation. * * @param sourceID sourceID of source that shall be connected * @param sinkID sinkID of sink that shall be connected - * @param listRoute This route is the one the priorized connectionFormats is - * for. + * @param listRoute This route is the one the priorized connectionFormats is for. * @param listPossibleConnectionFormats list of possible connectionformats - * @param listPrioConnectionFormats the list return with prioos from the - * controller. Best choice on first position. + * @param listPrioConnectionFormats the list return with prioos from the controller. Best choice on first position. */ virtual am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector listPossibleConnectionFormats, std::vector& listPrioConnectionFormats) =0; /** * confirms the setCommandReady call + * + * @param error E_OK if everything went right. If a plugin returns an error, it will be forwared here */ - virtual void confirmCommandReady() =0; + virtual void confirmCommandReady(const am_Error_e error) =0; /** * confirms the setRoutingReady call + * + * @param error E_OK if everything went right. If a plugin returns an error, it will be forwared here */ - virtual void confirmRoutingReady() =0; + virtual void confirmRoutingReady(const am_Error_e error) =0; /** * confirms the setCommandRundown call + * + * @param error E_OK if everything went right. If a plugin returns an error, it will be forwared here */ - virtual void confirmCommandRundown() =0; + virtual void confirmCommandRundown(const am_Error_e error) =0; /** * confirms the setRoutingRundown command + * + * @param error E_OK if everything went right. If a plugin returns an error, it will be forwared here + */ + virtual void confirmRoutingRundown(const am_Error_e error) =0; + /** + * update form the SinkData + * + * @param sinkID the sinkID + * @param sinkClassID + * @param listSoundProperties + * @param listConnectionFormats + * @param listMainSoundProperties + */ + virtual am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) =0; + /** + * update from the source Data + * + * @param sourceID the sourceID + * @param sourceClassID + * @param listSoundProperties + * @param listConnectionFormats + * @param listMainSoundProperties + */ + virtual am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) =0; + /** + * updates the Gateway Data + * + * @param gatewayID the gatewayID + * @param listSourceConnectionFormats + * @param listSinkConnectionFormats + * @param convertionMatrix + */ + virtual am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector listSourceConnectionFormats, const std::vector listSinkConnectionFormats, const std::vector convertionMatrix) =0; + /** + * ack for mulitple volume changes + * + * @param handle + * @param listVolumes the list of volumes with the current status + * @param error + */ + virtual void cbAckSetVolume(const am_Handle_s handle, const std::vector listVolumes, const am_Error_e error) =0; + /** + * The acknowledge of the sink notification configuration + * + * @param handle the handle + * @param error the error + */ + virtual void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) =0; + /** + * The acknowledge of the sink notification configuration + * + * @param handle the handle + * @param error the error + */ + virtual void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) =0; + /** + * + * @param sinkID the sinkID of the changed notification + * @param payload the payload + */ + virtual void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) =0; + /** + * + * @param sourceID the sinkID of the changed notification + * @param payload the payload + */ + virtual void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) =0; + /** + * sets a user MainSinkNotificationConfiguration + * @return E_OK on success, E_OUT_OF_RANGE if out of range, E_UNKNOWN on error + * + * @param sinkID + * @param notificationConfiguration + */ + virtual am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) =0; + /** + * sets a user MainSourceNotificationConfiguration + * @return E_OK on success, E_OUT_OF_RANGE if out of range, E_UNKNOWN on error + * + * @param sourceID + * @param notificationConfiguration + */ + virtual am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) =0; + /** + * This hook is connected to the NodeState signal of the NodeStateManager + * + * @param NodeStateId The new current state of the node + */ + virtual void hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) =0; + /** + * This hook is connected to the NodeApplicationMode signal of the NodeStateManager + * + * @param ApplicationModeId The new ApplicationMode + */ + virtual void hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) =0; + /** + * the sessionstate change was send by the NSM + * + * @param sessionName + * @param seatID + * @param sessionStateID + */ + virtual void hookSystemSessionStateChanged(const std::string sessionName, const int32_t seatID, const NsmSessionState_e sessionStateID) =0; + /** + * A lifecycle request comes in from the NSM and must be processed. + * @return NsmErrorStatus_Ok if successful + * The controller has to respond to this message with LifecycleRequestComplete. + * + * @param Request the shutdown request from the NSM. One of the types + * + * NSM_SHUTDOWNTYPE_RUNUP, NSM_SHUTDOWNTYPE_NORMAL + * NSM_SHUTDOWNTYPE_FAST + * + * In order to receive this request, the controller needs to register for this request first via RegisterShutdownClient + * @param RequestId the requestID */ - virtual void confirmRoutingRundown() =0; + virtual NsmErrorStatus_e hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) =0; }; } -#endif // !defined(EA_B9BE9751_825D_44b9_86F1_C2F02E5FA3ED__INCLUDED_) +#endif // !defined(EA_9CC33091_C4F5_4262_9C42_042DFB7606F2__INCLUDED_) diff --git a/include/projecttypes.h b/include/projecttypes.h old mode 100644 new mode 100755 index 0b1faa2..00919a0 --- a/include/projecttypes.h +++ b/include/projecttypes.h @@ -1,32 +1,33 @@ /** - * Copyright (C) 2012, BMW AG + * Copyright (C) 2012, BMW AG * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * This file is part of GENIVI Project AudioManager. * - * \copyright - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, - * subject to the following conditions: - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. * - * \file - * For further information see http://www.genivi.org/. + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 + * + * \file + * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_E2993ED0_906E_49c8_A444_958D08CA0905__INCLUDED_) -#define EA_E2993ED0_906E_49c8_A444_958D08CA0905__INCLUDED_ +#if !defined(EA_793BA955_1445_4da2_9C22_4EFA92A026C5__INCLUDED_) +#define EA_793BA955_1445_4da2_9C22_4EFA92A026C5__INCLUDED_ namespace am { /** - * This enum classifies the format in which data is exchanged within a connection. - * The enum itself is project specific although there are some Genivi standard - * formats defined. + * This enum classifies the format in which data is exchanged within a connection. The enum itself is project specific + * although there are some Genivi standard formats defined. * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_ConnectionFormat_e { @@ -56,7 +57,7 @@ namespace am { /** * This enum gives the information about reason for reason for Source/Sink change * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_AvailabilityReason_e { @@ -94,7 +95,7 @@ namespace am { /** * product specific identifier of property * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_ClassProperty_e { @@ -103,8 +104,8 @@ namespace am { */ CP_UNKNOWN = 0, /** - * defines the source type of a source. Project specific, could be for example - * differentiation between interrupt source and main source. + * defines the source type of a source. Project specific, could be for example differentiation between interrupt source + * and main source. */ CP_GENIVI_SOURCE_TYPE = 1, /** @@ -115,12 +116,10 @@ namespace am { }; /** - * The given ramp types here are just a possiblity. for products, different ramp - * types can be defined here. - * It is in the responsibility of the product to make sure that the routing - * plugins are aware of the ramp types used. + * The given ramp types here are just a possiblity. for products, different ramp types can be defined here. + * It is in the responsibility of the product to make sure that the routing plugins are aware of the ramp types used. * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_RampType_e { @@ -140,10 +139,9 @@ namespace am { }; /** - * sound properties. Within genivi only the standard properties are defined, for - * products these need to be extended. + * sound properties. Within genivi only the standard properties are defined, for products these need to be extended. * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_SoundPropertyType_e { @@ -167,10 +165,9 @@ namespace am { }; /** - * Here are all SoundProperties that can be set via the CommandInterface. Product - * specific + * Here are all SoundProperties that can be set via the CommandInterface. Product specific * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_MainSoundPropertyType_e { @@ -196,7 +193,7 @@ namespace am { /** * describes the different system properties. Project specific * @author Christian Mueller - * @created 07-Mar-2012 6:06:17 PM + * @created 16-Dez-2012 15:58:14 */ enum am_SystemPropertyType_e { @@ -206,5 +203,17 @@ namespace am { SYP_UNKNOWN = 0, SYP_MAX }; + + /** + * gives the type of the Notification. + * @author q232968 + * @version 1.0 + * @created 16-Dez-2012 15:58:14 + */ + enum am_NotificationType_e + { + NT_UNKNOWN = 0, + NT_MAX + }; } -#endif // !defined(EA_E2993ED0_906E_49c8_A444_958D08CA0905__INCLUDED_) +#endif // !defined(EA_793BA955_1445_4da2_9C22_4EFA92A026C5__INCLUDED_) diff --git a/include/routing/IAmRoutingReceive.h b/include/routing/IAmRoutingReceive.h index 45097ab..fd88178 100644 --- a/include/routing/IAmRoutingReceive.h +++ b/include/routing/IAmRoutingReceive.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_F3B2C6E5_FEAE_42a2_AEB2_59B2AE54EE05__INCLUDED_) -#define EA_F3B2C6E5_FEAE_42a2_AEB2_59B2AE54EE05__INCLUDED_ +#if !defined(EA_36ADD7D1_5B51_4364_9C3B_4839230FAAC2__INCLUDED_) +#define EA_36ADD7D1_5B51_4364_9C3B_4839230FAAC2__INCLUDED_ #include #include @@ -32,19 +32,22 @@ class CAmSocketHandler; } -#define RoutingReceiveVersion "1.0" +#include "audiomanagertypes.h" + +#define RoutingReceiveVersion "2.0" namespace am { /** - * Routing Receive sendInterface description. This class implements everything from RoutingAdapter -> Audiomanager - * There are two rules that have to be kept in mind when implementing against this interface:\n - * \warning - * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n - * 2. YOU MAY NOT THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n - * \details - * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred-call pattern described on the wiki which also helps to implement calls that are forbidden.\n + * Routing Receive sendInterface description. This class implements everything from RoutingAdapter -> Audiomanager + * There are two rules that have to be kept in mind when implementing against this interface:\n + * \warning + * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n + * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n + * \details + * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred- + * call pattern described on the wiki which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer * @author Christian Mueller - * @created 06-Mar-2012 8:01:08 PM + * @created 16-Dez-2012 15:58:16 */ class IAmRoutingReceive { @@ -58,6 +61,12 @@ namespace am { } + /** + * This function returns the version of the interface + * + * @param version retrieves the verison of the interface + */ + virtual void getInterfaceVersion(std::string& version) const =0; /** * acknowledges a asyncConnect * @@ -75,17 +84,17 @@ namespace am { */ virtual void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) =0; /** - * acknowledges a asyncsetSinkVolume + * acknowledges a asyncsetSinkVolume * * @param handle - * @param volume The current actual value that is set + * @param volume The current actual value that is set * @param error E_OK on success, E_ABORTED if action was aborted, E_UNKNOWN on error */ virtual void ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) =0; /** * acknowledges a asyncsetSourceVolume * - * @param handle handle that belongs to the change + * @param handle handle that belongs to the change * @param volume the current volume * @param error E_OK on success, E_ABORTED if action was aborted, E_UNKNOWN on error */ @@ -150,7 +159,9 @@ namespace am { */ virtual void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) =0; /** - * This function returns the ID to the given domainName. If already a domain is registered with this name, it will return the corresponding ID, if not it will reserve an ID but not register the domain. The other parameters of the domain will be overwritten when the domain is registered. + * This function returns the ID to the given domainName. If already a domain is registered with this name, it will return + * the corresponding ID, if not it will reserve an ID but not register the domain. The other parameters of the domain will + * be overwritten when the domain is registered. * @return E_OK on success, E_UNKNOWN on error * * @param name @@ -158,7 +169,7 @@ namespace am { */ virtual am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID) =0; /** - * registers a domain + * registers a domain * @return E_OK on succes, E_ALREADY_EXISTENT if already registered E_UNKOWN on error * * @param domainData domainID in am_Domain_s must be 0! @@ -166,7 +177,7 @@ namespace am { */ virtual am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID) =0; /** - * deregisters a domain. All sources, sinks, gateways and crossfaders from that domain will be removed as well. + * deregisters a domain. All sources, sinks, gateways and crossfaders from that domain will be removed as well. * @return E_OK on succes, E_NON_EXISTENT if not found E_UNKOWN on error * * @param domainID < the nonde of the bus @@ -175,21 +186,25 @@ namespace am { /** * registers a gateway. @return E_OK on succes, E_ALREADY_EXISTENT if already registered E_UNKOWN on error * - * @param gatewayData In a fixed setup, the gatewayID must be below 100. In a dynamic setup, the gatewayID shall be 0. listSourceFormats and listSinkFormats are empty at registration time. Values are taken over when sources and sinks are registered. - * + * @param gatewayData In a fixed setup, the gatewayID must be below 100. In a dynamic setup, the gatewayID shall be 0. + * listSourceFormats and listSinkFormats are empty at registration time. Values are taken over when sources and sinks are + * registered. + * * * @param gatewayID */ virtual am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) =0; /** - * deregisters a gateway. Also removes all sinks and sources of the controlling domain. + * deregisters a gateway. Also removes all sinks and sources of the controlling domain. * @return E_OK on succes, E_NON_EXISTENT if not found E_UNKOWN on error * * @param gatewayID domainID of the control domain */ virtual am_Error_e deregisterGateway(const am_gatewayID_t gatewayID) =0; /** - * This function returns the ID to the given sinkName. If already a sink is registered with this name, it will return the corresponding ID, if not it will reserve an ID but not register the sink. The other parameters of the sink will be overwritten when the sink is registered. + * This function returns the ID to the given sinkName. If already a sink is registered with this name, it will return the + * corresponding ID, if not it will reserve an ID but not register the sink. The other parameters of the sink will be + * overwritten when the sink is registered. * @return E_OK on success, E_UNKNOWN on error * * @param name ID is not valid since not created yet @@ -197,22 +212,25 @@ namespace am { */ virtual am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID) =0; /** - * Registers a sink. If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation + * Registers a sink. If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation * @return E_OK on succes, E_ALREADY_EXISTENT if already registered E_UNKOWN on error * - * @param sinkData In a fixed setup, the sinkID within am_Sink_s must be below 100. In a dynamic setup the sinkID must be 0 in am_Sink_s. + * @param sinkData In a fixed setup, the sinkID within am_Sink_s must be below 100. In a dynamic setup the sinkID must + * be 0 in am_Sink_s. * @param sinkID */ virtual am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) =0; /** - * deregisters a sink. + * deregisters a sink. * @return E_OK on succes, E_NON_EXISTENT if not found E_UNKOWN on error * * @param sinkID */ virtual am_Error_e deregisterSink(const am_sinkID_t sinkID) =0; /** - * This function returns the ID to the given sourceName. If already a source is registered with this name, it will return the corresponding ID, if not it will reserve an ID but not register the source. The other parameters of the source will be overwritten when the source is registered. + * This function returns the ID to the given sourceName. If already a source is registered with this name, it will return + * the corresponding ID, if not it will reserve an ID but not register the source. The other parameters of the source will + * be overwritten when the source is registered. * @return E_OK on success, E_UNKNOWN on error * * @param name @@ -220,37 +238,39 @@ namespace am { */ virtual am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID) =0; /** - * registers a source. If the source is part of a gateway, the listconnectionFormats is copied to the gatewayInformation + * registers a source. If the source is part of a gateway, the listconnectionFormats is copied to the gatewayInformation * @return E_OK on success, E_UNKNOWN on error, E_ALREADY_EXIST if either name or sourceID already exists * - * @param sourceData In a fixed setup, the sourceID within am_Source_s must be below 100. In a dynamic setup the sourceID must be 0 in am_Source_s + * @param sourceData In a fixed setup, the sourceID within am_Source_s must be below 100. In a dynamic setup the + * sourceID must be 0 in am_Source_s * @param sourceID */ virtual am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) =0; /** - * deregisters a source + * deregisters a source * @return E_OK on succes, E_NON_EXISTENT if not found E_UNKOWN on error * * @param sourceID */ virtual am_Error_e deregisterSource(const am_sourceID_t sourceID) =0; /** - * this function registers a crossfader. + * this function registers a crossfader. * @return E_OK on succes, E_ALREADY_EXISTENT if already registered E_UNKOWN on error * - * @param crossfaderData in a fixed setup, the crossfaderID must be below 100. In a dynamic setup the crossfasderID shall be 0 + * @param crossfaderData in a fixed setup, the crossfaderID must be below 100. In a dynamic setup the crossfasderID + * shall be 0 * @param crossfaderID */ virtual am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) =0; /** - * this function deregisters a crossfader. removes all sources and sinks assiated as well. + * this function deregisters a crossfader. removes all sources and sinks assiated as well. * @return E_OK on succes, E_NON_EXISTENT if not found E_UNKOWN on error * * @param crossfaderID */ virtual am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID) =0; /** - * this function peeks a sourceclassID. It is used by the RoutingPlugins to determine the SinkClassIDs of a sinkClass. + * this function peeks a sourceclassID. It is used by the RoutingPlugins to determine the SinkClassIDs of a sinkClass. * @return E_OK on succes, E_DATABASE_ERROR on error * * @param name @@ -258,7 +278,7 @@ namespace am { */ virtual am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID) =0; /** - * this function peeks a sourceclassID. It is used by the RoutingPlugins to determine the SinkClassIDs of a sinkClass. + * this function peeks a sourceclassID. It is used by the RoutingPlugins to determine the SinkClassIDs of a sinkClass. * @return E_OK on succes, E_DATABASE_ERROR on error * * @param name @@ -273,7 +293,7 @@ namespace am { */ virtual void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) =0; /** - * This hook is called when all elements from a domain are registered. + * This hook is called when all elements from a domain are registered. * Is used by the Controller to know when all expected domains are finally registered * * @param domainID @@ -308,45 +328,115 @@ namespace am { */ virtual void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay) =0; /** - * this function is used to send out all data that has been changed in an early state. + * this function is used to send out all data that has been changed in an early state. * @return E_OK on success, E_UNKNOWN on error * * @param earlyData */ virtual void sendChangedData(const std::vector& earlyData) =0; /** - * this function is used to retrieve a pointer to the dBusConnectionWrapper + * this function is used to retrieve a pointer to the dBusConnectionWrapper * @return E_OK if pointer is valid, E_UKNOWN if AudioManager was compiled without DBus Support * - * @param dbusConnectionWrapper This is a wrapper class that is needed to keep dbus inclusions away from the interface. The DBusWrapperClass will return the pointer to the DbusConnection call (getDBusConnection) + * @param dbusConnectionWrapper This is a wrapper class that is needed to keep dbus inclusions away from the interface. + * The DBusWrapperClass will return the pointer to the DbusConnection call (getDBusConnection) */ virtual am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const =0; /** - * This function returns the pointer to the socketHandler. This can be used to integrate socket-based activites like communication with the mainloop of the AudioManager. + * This function returns the pointer to the socketHandler. This can be used to integrate socket-based activites like + * communication with the mainloop of the AudioManager. * returns E_OK if pointer is valid, E_UNKNOWN in case AudioManager was compiled without socketHandler support, * * @param socketHandler */ virtual am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const =0; - /** - * This function returns the version of the interface - * - * @param version retrieves the verison of the interface - */ - virtual void getInterfaceVersion(std::string& version) const =0; /** * confirms the setRoutingReady Command * * @param handle the handle that was given via setRoutingReady + * @param error E_OK if the ready command succeeded. E_UNKNOWN if an error happened. */ - virtual void confirmRoutingReady(const uint16_t handle) =0; + virtual void confirmRoutingReady(const uint16_t handle, const am_Error_e error) =0; /** * confirms the setRoutingRundown Command * * @param handle handle that was given via setRoutingRundown + * @param error E_OK if the ready command succeeded. E_UNKNOWN if an error happened. + */ + virtual void confirmRoutingRundown(const uint16_t handle, const am_Error_e error) =0; + /** + * updates data of an gateway. @return E_OK on success, E_NON_EXISTENT if the gatewayID is not valid. + * + * @param gatewayID This is the new gateway data that has been updated. Please note that changing source and sink IDs, + * + * @param listSourceFormats + * @param listSinkFormats + * @param convertionMatrix + */ + virtual am_Error_e updateGateway(const am_gatewayID_t gatewayID, std::vector listSourceFormats, const std::vector listSinkFormats, std::vector convertionMatrix) =0; + /** + * updates data of an gateway. @return E_OK on success, E_NON_EXISTENT if the sinkID is not valid. + * + * @param sinkID The sinkID of the sink + * @param sinkClassID + * @param listSoundProperties + * @param listConnectionFormats + * @param listMainSoundProperties + */ + virtual am_Error_e updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector listSoundProperties, const std::vector listConnectionFormats, std::vector listMainSoundProperties) =0; + /** + * updates data of an source. @return E_OK on success, E_NON_EXISTENT if the sourceID in the struct is not valid. + * Please note that only the following data out of am_Source_s have effect when they are changed: + * sourceClassID, + * listSoundProperties, + * listConnectionFormats, + * listMainSoundProperties + * + * @param sourceID the sourceID of the source + * @param sourceClassID + * @param listSoundProperties + * @param listConnectionFormats + * @param listMainSoundProperties + */ + virtual am_Error_e updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, std::vector listSoundProperties, std::vector listConnectionFormats, const std::vector listMainSoundProperties) =0; + /** + * acknowledges a asyncsetSinkVolume + * + * @param handle + * @param listvolumes The list of volumes that have been set. ramp and time values have no meaning when the struct is + * used here. + * @param error E_OK on success, E_ABORTED if action was aborted, E_UNKNOWN on error + */ + virtual void ackSetVolumes(const am_Handle_s handle, const std::vector listvolumes, const am_Error_e error) =0; + /** + * The acknowledge of the SinkNotificationConfiguration + * + * @param handle + * @param error + */ + virtual void ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) =0; + /** + * The acknowledge of the SourceNotificationConfiguration + * + * @param handle + * @param error + */ + virtual void ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) =0; + /** + * is called whenever a notified value needs to be send + * + * @param sinkID The sinkID of the sink where the data changed + * @param payload The payload + */ + virtual void hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s payload) =0; + /** + * is called whenever a notified value needs to be send + * + * @param sourceID The sinkID of the sink where the data changed + * @param payload The payload */ - virtual void confirmRoutingRundown(const uint16_t handle) =0; + virtual void hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s payload) =0; }; } -#endif // !defined(EA_F3B2C6E5_FEAE_42a2_AEB2_59B2AE54EE05__INCLUDED_) +#endif // !defined(EA_36ADD7D1_5B51_4364_9C3B_4839230FAAC2__INCLUDED_) diff --git a/include/routing/IAmRoutingSend.h b/include/routing/IAmRoutingSend.h index 4280931..d077c73 100644 --- a/include/routing/IAmRoutingSend.h +++ b/include/routing/IAmRoutingSend.h @@ -12,15 +12,15 @@ * this file, You can obtain one at http://mozilla.org/MPL/2.0/. * * - * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 + * \author Christian Mueller, christian.linke@bmw.de BMW 2011,2012 * * \file * For further information see http://www.genivi.org/. * * THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN */ -#if !defined(EA_39D31D03_9B43_4dfe_B134_B2A969767ECB__INCLUDED_) -#define EA_39D31D03_9B43_4dfe_B134_B2A969767ECB__INCLUDED_ +#if !defined(EA_3921A27D_CF17_4db4_BE29_6A5BD7C5FE53__INCLUDED_) +#define EA_3921A27D_CF17_4db4_BE29_6A5BD7C5FE53__INCLUDED_ #include #include @@ -30,21 +30,24 @@ namespace am { class IAmRoutingReceive; } +#include "audiomanagertypes.h" #include "IAmRoutingReceive.h" +#include "projecttypes.h" -#define RoutingSendVersion "1.0" +#define RoutingSendVersion "2.0" namespace am { /** - * This class implements everything from Audiomanager -> RoutingAdapter - * There are two rules that have to be kept in mind when implementing against this interface:\n - * \warning - * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n - * 2. YOU MAY NOT THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n - * \details - * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred-call pattern described on the wiki which also helps to implement calls that are forbidden.\n + * This class implements everything from Audiomanager -> RoutingAdapter + * There are two rules that have to be kept in mind when implementing against this interface:\n + * \warning + * 1. CALLS TO THIS INTERFACE ARE NOT THREAD SAFE !!!! \n + * 2. YOU MAY NOT CALL THE CALLING INTERFACE DURING AN SYNCHRONOUS OR ASYNCHRONOUS CALL THAT EXPECTS A RETURN VALUE.\n + * \details + * Violation these rules may lead to unexpected behavior! Nevertheless you can implement thread safe by using the deferred- + * call pattern described on the wiki which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer * @author Christian Mueller - * @created 06-Mar-2012 8:01:09 PM + * @created 16-Dez-2012 15:58:16 */ class IAmRoutingSend { @@ -58,6 +61,12 @@ namespace am { } + /** + * This function returns the version of the interface + * + * @param version + */ + virtual void getInterfaceVersion(std::string& version) const =0; /** * starts up the interface. In the implementations, here is the best place for init routines. * @@ -77,14 +86,14 @@ namespace am { */ virtual void setRoutingRundown(const uint16_t handle) =0; /** - * aborts an asynchronous action. + * aborts an asynchronous action. * @return E_OK on success, E_UNKNOWN on error, E_NON_EXISTENT if handle was not found * * @param handle */ virtual am_Error_e asyncAbort(const am_Handle_s handle) =0; /** - * connects a source to a sink + * connects a source to a sink * @return E_OK on success, E_UNKNOWN on error, E_WRONG_FORMAT in case am_ConnectionFormat_e does not match * * @param handle @@ -95,7 +104,7 @@ namespace am { */ virtual am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) =0; /** - * disconnect a connection with given connectionID + * disconnect a connection with given connectionID * @return E_OK on success, E_UNKNOWN on error, E_NON_EXISTENT if connection was not found * * @param handle @@ -103,7 +112,8 @@ namespace am { */ virtual am_Error_e asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID) =0; /** - * this method is used to set the volume of a sink. This function is used to drive ramps, to mute or unmute or directly set the value. The difference is made through the ramptype. + * this method is used to set the volume of a sink. This function is used to drive ramps, to mute or unmute or directly + * set the value. The difference is made through the ramptype. * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if new volume is out of range * * @param handle @@ -114,8 +124,9 @@ namespace am { */ virtual am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) =0; /** - * sets the volume of a source. This method is used to set the volume of a sink. This function is used to drive ramps, to mute or unmute or directly set the value. The difference is made through the ramptype. - * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if volume is out of range. + * sets the volume of a source. This method is used to set the volume of a sink. This function is used to drive ramps, to + * mute or unmute or directly set the value. The difference is made through the ramptype. + * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE if volume is out of range. * triggers the acknowledge ackSourceVolumeChange * * @param handle @@ -126,7 +137,7 @@ namespace am { */ virtual am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) =0; /** - * This function is used to set the source state of a particular source. + * This function is used to set the source state of a particular source. * @return E_OK on success, E_UNKNOWN on error * * @param handle @@ -135,7 +146,7 @@ namespace am { */ virtual am_Error_e asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state) =0; /** - * this function sets the sinksoundproperty. + * this function sets the sinksoundproperty. * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE in case the propery value is out of range * * @param handle @@ -144,7 +155,7 @@ namespace am { */ virtual am_Error_e asyncSetSinkSoundProperties(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector& listSoundProperties) =0; /** - * this function sets the sinksoundproperty. + * this function sets the sinksoundproperty. * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE in case the propery value is out of range * * @param handle @@ -153,7 +164,7 @@ namespace am { */ virtual am_Error_e asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) =0; /** - * this function sets the sourcesoundproperty. + * this function sets the sourcesoundproperty. * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE in case the propery value is out of range * * @param handle @@ -162,7 +173,7 @@ namespace am { */ virtual am_Error_e asyncSetSourceSoundProperties(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector& listSoundProperties) =0; /** - * this function sets the sourcesoundproperty. + * this function sets the sourcesoundproperty. * @return E_OK on success, E_UNKNOWN on error, E_OUT_OF_RANGE in case the propery value is out of range * * @param handle @@ -171,7 +182,7 @@ namespace am { */ virtual am_Error_e asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) =0; /** - * this function triggers crossfading. + * this function triggers crossfading. * @return E_OK on success, E_UNKNOWN on error * * @param handle @@ -182,7 +193,7 @@ namespace am { */ virtual am_Error_e asyncCrossFade(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) =0; /** - * this function is used for early and late audio functions to set the domain state + * this function is used for early and late audio functions to set the domain state * @return E_OK on success, E_UNKNOWN on error * * @param domainID @@ -190,19 +201,40 @@ namespace am { */ virtual am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) =0; /** - * this method is used to retrieve the busname during startup of the plugin. Needs to be implemented + * this method is used to retrieve the busname during startup of the plugin. Needs to be implemented * @return E_OK on success, E_UNKNOWN on error * * @param BusName */ virtual am_Error_e returnBusName(std::string& BusName) const =0; /** - * This function returns the version of the interface + * This command sets multiple source or and sink volumes within a domain at a time. It can be used to synchronize volume + * setting events. + * @return E_OK on success, E_UNKNOWN on error. * - * @param version + * @param handle the handle + * @param listVolumes a list of volumes that shall be set a the same time */ - virtual void getInterfaceVersion(std::string& version) const =0; + virtual am_Error_e asyncSetVolumes(const am_Handle_s handle, const std::vector& listVolumes) =0; + /** + * sets the notification configuration of a source. + * @return E_OK on success, E_UNKNOWN on error. + * + * @param handle The handle for this operation. + * @param sinkID the sourceID of the source the notification should be set + * @param notificationConfiguration The notification configuration + */ + virtual am_Error_e asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) =0; + /** + * sets the notification configuration of a source. + * @return E_OK on success, E_UNKNOWN on error. + * + * @param handle The handle for this operation. + * @param sourceID the sourceID of the source the notification should be set + * @param notificationConfiguration The notification configuration + */ + virtual am_Error_e asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) =0; }; } -#endif // !defined(EA_39D31D03_9B43_4dfe_B134_B2A969767ECB__INCLUDED_) +#endif // !defined(EA_3921A27D_CF17_4db4_BE29_6A5BD7C5FE53__INCLUDED_) diff --git a/include/shared/CAmSerializer.h b/include/shared/CAmSerializer.h index 98257d0..d840f34 100644 --- a/include/shared/CAmSerializer.h +++ b/include/shared/CAmSerializer.h @@ -1005,7 +1005,6 @@ public: template void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1), Targ argument, Targ1& argument1) { - logInfo("took ref"); CAmDelegagePtr p(new CAmTwoArgDelegateSecondRef(instance, function, argument, argument1)); send(p); } -- cgit v1.2.1