* Bug #100 - removed projecttypes.h which causes compiling conflicts
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / include / CAmRoutingReceiver.h
1 /**
2  * Copyright (C) 2012, BMW AG
3  *
4  * This file is part of GENIVI Project AudioManager.
5  *
6  * Contributions are licensed to the GENIVI Alliance under one or more
7  * Contribution License Agreements.
8  *
9  * \copyright
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/.
13  *
14  *
15  * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
16  *
17  * \file CAmRoutingReceiver.h
18  * For further information see http://www.genivi.org/.
19  *
20  */
21
22 #ifndef ROUTINGRECEIVER_H_
23 #define ROUTINGRECEIVER_H_
24
25 #include "routing/IAmRoutingReceive.h"
26
27 namespace am
28 {
29
30 class CAmSocketHandler;
31 class CAmDbusWrapper;
32 class IAmDatabaseHandler;
33 class CAmRoutingSender;
34 class CAmControlSender;
35
36 /**
37  * Implements the Receiving side of the RoutingPlugins.
38  */
39 class CAmRoutingReceiver: public IAmRoutingReceive
40 {
41 public:
42     CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler);
43     CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper);
44     ~CAmRoutingReceiver();
45     void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error);
46     void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error);
47     void ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
48     void ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
49     void ackSetSourceState(const am_Handle_s handle, const am_Error_e error);
50     void ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error);
51     void ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error);
52     void ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error);
53     void ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error);
54     void ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error);
55     void ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume);
56     void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume);
57     am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
58     am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID);
59     am_Error_e deregisterDomain(const am_domainID_t domainID);
60     am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
61     am_Error_e deregisterGateway(const am_gatewayID_t gatewayID);
62     am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
63     am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
64     am_Error_e deregisterSink(const am_sinkID_t sinkID);
65     am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
66     am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID);
67     am_Error_e deregisterSource(const am_sourceID_t sourceID);
68     am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
69     am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID);
70     am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID);
71     am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID);
72     void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState);
73     void hookDomainRegistrationComplete(const am_domainID_t domainID);
74     void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability);
75     void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s& availability);
76     void hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState);
77     void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay);
78     void sendChangedData(const std::vector<am_EarlyData_s>& earlyData);
79     am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const;
80     am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const;
81     void getInterfaceVersion(std::string& version) const;
82     void confirmRoutingReady(const uint16_t handle, const am_Error_e error);
83     void confirmRoutingRundown(const uint16_t handle, const am_Error_e error);
84     am_Error_e updateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkFormats, const std::vector<bool>& convertionMatrix) ;
85     am_Error_e updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
86     am_Error_e updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
87     void ackSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listvolumes, const am_Error_e error) ;
88     void ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
89     void ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
90     void hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload) ;
91     void hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ;
92
93     uint16_t getStartupHandle(); //!< returns a startup handle
94     uint16_t getRundownHandle(); //!< returns a rundown handle
95
96     void waitOnStartup(bool startup); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed
97     void waitOnRundown(bool rundown); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed
98
99 private:
100     IAmDatabaseHandler *mpDatabaseHandler; //!< pointer to the databaseHandler
101     CAmRoutingSender *mpRoutingSender; //!< pointer to the routingSender
102     CAmControlSender *mpControlSender; //!< pointer to the controlSender
103     CAmSocketHandler *mpSocketHandler; //!< pointer to sockethandler
104     CAmDbusWrapper *mpDBusWrapper; //!< pointer to dbuswrapper
105
106     std::vector<uint16_t> mListStartupHandles; //!< list of handles that wait for a confirm
107     std::vector<uint16_t> mListRundownHandles; //!< list of handles that wait for a confirm
108     uint16_t handleCount; //!< counts all handles
109     bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0
110     bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0
111
112     am_Error_e mLastStartupError;
113     am_Error_e mLastRundownError;
114
115 };
116
117 }
118
119 #endif /* ROUTINGRECEIVER_H_ */