2 * Copyright (C) 2012, BMW AG
4 * This file is part of GENIVI Project AudioManager.
6 * Contributions are licensed to the GENIVI Alliance under one or more
7 * Contribution License Agreements.
10 * This Source Code Form is subject to the terms of the
11 * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
12 * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
17 * \file CAmControlSender.h
18 * For further information see http://www.genivi.org/.
22 #ifndef CONTROLSENDER_H_
23 #define CONTROLSENDER_H_
26 #include "../test/IAmControlBackdoor.h"
29 #include "control/IAmControlSend.h"
30 #include "shared/CAmSocketHandler.h"
37 * sends data to the commandInterface, takes the file of the library that needs to be loaded
39 class CAmControlSender
42 CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler);
45 am_Error_e startupController(IAmControlReceive* controlreceiveinterface) ;
46 void setControllerReady() ;
47 void setControllerRundown(const int16_t signal) ;
48 am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
49 am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ;
50 am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ;
51 am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ;
52 am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ;
53 am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ;
54 am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ;
55 am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
56 am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ;
57 am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ;
58 void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ;
59 am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
60 am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ;
61 am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
62 am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ;
63 am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
64 am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ;
65 am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
66 am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
67 void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ;
68 void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ;
69 void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
70 void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
71 void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
72 void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ;
73 void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data) ;
74 void hookSystemSpeedChange(const am_speed_t speed) ;
75 void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ;
76 void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ;
77 void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ;
78 void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) ;
79 void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
80 void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) ;
81 void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ;
82 void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
83 void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
84 void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
85 void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
86 am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_ConnectionFormat_e> listPossibleConnectionFormats, std::vector<am_ConnectionFormat_e>& listPrioConnectionFormats) ;
87 void confirmCommandReady(const am_Error_e error) ;
88 void confirmRoutingReady(const am_Error_e error) ;
89 void confirmCommandRundown(const am_Error_e error) ;
90 void confirmRoutingRundown(const am_Error_e error) ;
91 void getInterfaceVersion(std::string& version) const ;
92 am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
93 am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
94 am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFromats, const std::vector<bool>& convertionMatrix) ;
95 void cbAckSetVolume(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes, const am_Error_e error) ;
96 void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
97 void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
98 void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload) ;
99 void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ;
100 am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ;
101 am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ;
102 void hookSystemNodeStateChanged(const NsmNodeState_e NodeStateId) ;
103 void hookSystemNodeApplicationModeChanged(const NsmApplicationMode_e ApplicationModeId) ;
104 void hookSystemSessionStateChanged(const std::string& sessionName, const NsmSeat_e seatID, const NsmSessionState_e sessionStateID) ;
105 NsmErrorStatus_e hookSystemLifecycleRequest(const uint32_t Request, const uint32_t RequestId) ;
107 void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
108 bool checkerCallback(const sh_pollHandle_t handle, void* userData);
109 bool dispatcherCallback(const sh_pollHandle_t handle, void* userData);
111 void setControllerRundownSafe(int16_t signal)
114 write(mPipe[1], &p, sizeof(p));
117 TAmShPollFired<CAmControlSender> receiverCallbackT;
118 TAmShPollCheck<CAmControlSender> checkerCallbackT;
119 TAmShPollDispatch<CAmControlSender> dispatcherCallbackT;
121 //todo: add getSessionstate, interface nachbilden von org.genivi.NodeStateManager.LifeCycleConsumer, antwort nach NSM
122 //chek interface version RegisterShutdownClient, UnRegisterShutdownClient, GetSessionState, GetApplicationMode, GetNodeState
124 //we need this here to call the rundown from the signal handler. In case everything screwed up
125 static void CallsetControllerRundown(int16_t signal)
128 mInstance->setControllerRundown(signal);
131 //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.
132 static void CallsetControllerRundownSafe(int16_t signal)
136 mInstance->setControllerRundownSafe(signal);
141 friend class IAmControlBackdoor;
145 void* mlibHandle; //!< pointer to the loaded control plugin interface
146 IAmControlSend* mController; //!< pointer to the ControlSend interface
147 static CAmControlSender* mInstance;
153 #endif /* CONTROLSENDER_H_ */