16 #ifndef ALEXA_CLIENT_SDK_AFML_INCLUDE_AFML_FOCUSMANAGER_H_ 17 #define ALEXA_CLIENT_SDK_AFML_INCLUDE_AFML_FOCUSMANAGER_H_ 23 #include <unordered_map> 24 #include <unordered_set> 83 return "name:'" +
name +
"', priority:" + std::to_string(
priority);
102 std::vector<afml::FocusManager::ChannelConfiguration>* virtualChannelConfigurations);
120 const std::vector<ChannelConfiguration>& channelConfigurations,
121 std::shared_ptr<ActivityTrackerInterface> activityTrackerInterface =
nullptr,
122 const std::vector<ChannelConfiguration>& virtualChannelConfigurations = std::vector<ChannelConfiguration>(),
123 std::shared_ptr<interruptModel::InterruptModel> interruptModel =
nullptr);
127 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver,
132 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface::Activity> channelActivity)
override;
136 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver)
override;
142 void addObserver(
const std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerObserverInterface>& observer)
override;
145 const std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerObserverInterface>& observer)
override;
168 using ChannelsToInterfaceNamesMap = std::map<std::shared_ptr<Channel>,
std::string>;
172 struct ChannelPtrComparator {
181 bool operator()(
const std::shared_ptr<Channel>& first,
const std::shared_ptr<Channel>& second)
const {
182 return *first > *second;
204 void setChannelFocus(
205 const std::shared_ptr<Channel>& channel,
208 bool forceUpdate =
false);
217 void acquireChannelHelper(
218 std::shared_ptr<Channel> channelToAcquire,
219 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface::Activity> channelActivity);
230 void releaseChannelHelper(
231 std::shared_ptr<Channel> channelToRelease,
232 std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver,
233 std::shared_ptr<std::promise<bool>> releaseChannelSuccess,
234 const std::string& channelName);
244 void stopForegroundActivityHelper(
245 std::shared_ptr<Channel> foregroundChannel,
246 std::string foregroundChannelInterface);
257 void stopAllActivitiesHelper(
const ChannelsToInterfaceNamesMap& channelsOwnersMap);
265 std::shared_ptr<Channel> getChannel(
const std::string& channelName)
const;
272 std::shared_ptr<Channel> getHighestPriorityActiveChannelLocked()
const;
280 bool isChannelForegroundedLocked(
const std::shared_ptr<Channel>& channel)
const;
289 bool doesChannelNameExist(
const std::string&
name)
const;
298 bool doesChannelPriorityExist(
const unsigned int priority)
const;
303 void foregroundHighestPriorityActiveChannel();
309 void notifyActivityTracker();
320 std::shared_ptr<Channel> lowPrioChannel,
321 std::shared_ptr<Channel> highPrioChannel);
330 void setBackgroundChannelMixingBehavior(std::shared_ptr<Channel> foregroundChannel);
336 std::unordered_map<std::string, std::shared_ptr<Channel>> m_allChannels;
339 std::set<std::shared_ptr<Channel>, ChannelPtrComparator> m_activeChannels;
342 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerObserverInterface>> m_observers;
349 std::vector<Channel::State> m_activityUpdates;
352 std::shared_ptr<ActivityTrackerInterface> m_activityTracker;
355 std::shared_ptr<interruptModel::InterruptModel> m_interruptModel;
369 #endif // ALEXA_CLIENT_SDK_AFML_INCLUDE_AFML_FOCUSMANAGER_H_ std::future< bool > releaseChannel(const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver) override
Definition: FocusManager.h:57
void stopForegroundActivity() override
MixingBehavior
Definition: MixingBehavior.h:25
void stopAllActivities() override
bool acquireChannel(const std::string &channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver, const std::string &interfaceName) override
Definition: FocusManager.h:63
::std::string string
Definition: gtest-port.h:1097
std::string toString() const
Definition: FocusManager.h:82
Single-thread executor implementation.
Definition: Executor.h:45
static bool readChannelConfiguration(const std::string &channelTypeKey, std::vector< afml::FocusManager::ChannelConfiguration > *virtualChannelConfigurations)
void addObserver(const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &observer) override
void modifyContentType(const std::string &channelName, const std::string &interfaceName, avsCommon::avs::ContentType contentType) override
ChannelConfiguration(const std::string &configName, unsigned int configPriority)
Definition: FocusManager.h:72
FocusManager(const std::vector< ChannelConfiguration > &channelConfigurations, std::shared_ptr< ActivityTrackerInterface > activityTrackerInterface=nullptr, const std::vector< ChannelConfiguration > &virtualChannelConfigurations=std::vector< ChannelConfiguration >(), std::shared_ptr< interruptModel::InterruptModel > interruptModel=nullptr)
unsigned int priority
The priority of the channel.
Definition: FocusManager.h:90
FocusState
Definition: FocusState.h:29
Definition: FocusManagerInterface.h:54
static const std::vector< FocusManager::ChannelConfiguration > getDefaultVisualChannels()
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static const std::vector< FocusManager::ChannelConfiguration > getDefaultAudioChannels()
ContentType
Definition: ContentType.h:25
void removeObserver(const std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerObserverInterface > &observer) override
std::string name
The name of the channel.
Definition: FocusManager.h:87