AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
GUIManager.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_GUI_GUIMANAGER_H_
17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_GUI_GUIMANAGER_H_
18 
20 #include <AFML/FocusManager.h>
33 #ifdef ENABLE_COMMS
35 #endif
44 
70 
71 #ifdef UWP_BUILD
72 #include <SSSDKCommon/NullMicrophone.h>
73 #endif
74 
75 namespace alexaClientSDK {
76 namespace sampleApplications {
77 namespace ipcServerSampleApp {
78 namespace gui {
79 
97 #ifdef ENABLE_COMMS
99 #endif
100  , public std::enable_shared_from_this<GUIManager> {
101 public:
113  static std::shared_ptr<GUIManager> create(
114  std::shared_ptr<gui::GUIClientInterface> guiClient,
115  std::shared_ptr<gui::GUIActivityEventNotifierInterface> activityEventNotifier,
116  std::shared_ptr<applicationUtilities::resources::audio::MicrophoneInterface> micWrapper,
117  std::shared_ptr<common::InteractionManager> interactionManager,
118  std::shared_ptr<common::EndpointAlexaLauncherHandler> launcherHandler);
119 
122  void handleRecognizeSpeechRequest(capabilityAgents::aip::Initiator initiator, bool start) override;
123 
124  void handleMicrophoneToggle() override;
125 
126  void handlePlaybackPlay() override;
127 
128  void handlePlaybackPause() override;
129 
130  void handlePlaybackNext() override;
131 
132  void handlePlaybackPrevious() override;
133 
134  void handlePlaybackSeekTo(int offset) override;
135 
136  void handlePlaybackSkipForward() override;
137 
138  void handlePlaybackSkipBackward() override;
139 
140  void handlePlaybackToggle(const std::string& name, bool checked) override;
141 
142  void onUserEvent() override;
143 
145  std::string avsInterface,
146  std::string channelName,
147  avsCommon::avs::ContentType contentType,
148  std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver) override;
149 
151  std::string avsInterface,
152  std::string channelName,
153  std::shared_ptr<avsCommon::sdkInterfaces::ChannelObserverInterface> channelObserver) override;
154 
156  override;
157 
158  void handleNavigationEvent(NavigationEvent event) override;
159 
160  std::vector<visualCharacteristicsInterfaces::WindowTemplate> getWindowTemplates() override;
161 
162  std::vector<visualCharacteristicsInterfaces::InteractionMode> getInteractionModes() override;
163 
165 
166  void setWindowInstances(
167  const std::vector<presentationOrchestratorInterfaces::PresentationOrchestratorWindowInstance>& instances,
168  const std::string& defaultWindowInstanceId,
169  const std::string& audioPlaybackUIWindowId) override;
170 
171  bool addWindowInstance(
173 
174  bool removeWindowInstance(const std::string& windowInstanceId) override;
175 
178 
179  bool setDefaultWindowInstance(const std::string& windowInstanceId) override;
180 
182  const std::vector<visualCharacteristicsInterfaces::InteractionMode>& interactionModes,
183  std::string& serializedJson) override;
184 
186  const std::vector<visualCharacteristicsInterfaces::WindowTemplate>& windowTemplates,
187  std::string& serializedJson) override;
188 
191  std::string& serializedJson) override;
192 
193  void forceExit() override;
194 
195  std::chrono::milliseconds getDeviceTimezoneOffset() override;
196 
198 
199  void handleDocumentTerminated(const std::string& token, bool failed) override;
200 
201  void acceptCall() override;
202 
203  void stopCall() override;
204 
205  void enableLocalVideo() override;
206 
207  void disableLocalVideo() override;
208 
209 #ifdef ENABLE_COMMS
210  void sendDtmf(avsCommon::sdkInterfaces::CallManagerInterface::DTMFTone dtmfTone) override;
211 #endif
212 
213  void handleLocaleChange() override;
214 
215  void initClient() override;
217 
220  void doNotDisturbStateChanged(const std::string& message) override;
221  void doNotDisturbStateRequest(const std::string& message) override;
223 
226  void namespaceVersionsReport(const std::string& message) override;
227  void clientInitialized(const std::string& message) override;
228  void clientConfigRequest(const std::string& message) override;
230 
233  void visualCharacteristicsRequest(const std::string& message) override;
234  void defaultWindowInstanceChanged(const std::string& message) override;
235  void windowInstancesReport(const std::string& message) override;
236  void windowInstancesAdded(const std::string& message) override;
237  void windowInstancesRemoved(const std::string& message) override;
238  void windowInstancesUpdated(const std::string& message) override;
240 
243  void recognizeSpeechRequest(const std::string& message) override;
244  void navigationEvent(const std::string& message) override;
245  void guiActivityEvent(const std::string& message) override;
247 
250  void logEvent(const std::string& message) override;
252 
255  void onFocusChanged(const std::string& channelName, avsCommon::avs::FocusState newFocus) override;
257 
260  void onPlayerActivityChanged(avsCommon::avs::PlayerActivity state, const Context& context) override;
262 
265  void onStateChanged(
266  const std::string& windowId,
269 
273  void onDialogUXStateChanged(DialogUXState newState) override;
274 
279 
282 #ifdef ENABLE_COMMS
283  void onCallStateInfoChange(
285  void onCallStateChange(avsCommon::sdkInterfaces::CallStateObserverInterface::CallState newCallState) override;
286 #endif
287 
293  void setClient(std::shared_ptr<sdkClient::SDKClientRegistry> clientRegistry);
294 
301 
307  void setIpcVersionManager(std::shared_ptr<ipc::IPCVersionManager> ipcVersionManager);
308 
315  bool parseWindowInstance(
316  const rapidjson::Value& payload,
318 
319 #ifdef UWP_BUILD
320  void inputAudioFile(const std::string& audioFile);
321 #endif
322 
328 
333 
338  void setAPLRuntimePresentationAdapter(std::shared_ptr<APLRuntimePresentationAdapter> aplRuntimePresentationAdapter);
339 
345  std::shared_ptr<TemplateRuntimePresentationAdapterBridge> templateRuntimePresentationAdapterBridge);
346 
350  void initialize();
351 
352 private:
362  GUIManager(
363  std::shared_ptr<gui::GUIClientInterface> guiClient,
364  std::shared_ptr<gui::GUIActivityEventNotifierInterface> activityEventNotifier,
365  std::shared_ptr<applicationUtilities::resources::audio::MicrophoneInterface> micWrapper,
366  std::shared_ptr<common::InteractionManager> interactionManager,
367  std::shared_ptr<common::EndpointAlexaLauncherHandler> launcherHandler);
368 
371  void doShutdown() override;
373 
377  void executeBackNavigation();
378 
382  void executeExitNavigation();
383 
389  void setFirmwareVersion(avsCommon::sdkInterfaces::softwareInfo::FirmwareVersion firmwareVersion);
390 
394  void adjustVolume(avsCommon::sdkInterfaces::ChannelVolumeInterface::Type, int8_t delta);
395 
400 
406  void setDefaultWindowId(const std::string& windowId);
407 
413  void setAudioPlaybackUIWindowId(const std::string& windowId);
414 
418  void resetDevice();
419 
423  std::shared_ptr<gui::GUIClientInterface> m_guiClient;
424 
428  std::shared_ptr<gui::GUIActivityEventNotifierInterface> m_activityEventNotifier;
429 
433  std::shared_ptr<alexaClientSDK::defaultClient::DefaultClient> m_defaultClient;
434 
436  bool m_isSpeakingOrListening;
437 
439 #ifdef UWP_BUILD
440  std::shared_ptr<alexaSmartScreenSDK::sssdkCommon::NullMicrophone> m_micWrapper;
441 #else
442  std::shared_ptr<applicationUtilities::resources::audio::MicrophoneInterface> m_micWrapper;
443 #endif
444 
446  avsCommon::avs::PlayerActivity m_playerActivityState;
447 
450 
452  std::unordered_map<std::string, avsCommon::avs::FocusState> m_channelFocusStates;
453 
455  bool m_clearAlertChannelOnForegrounded;
456 
458  std::shared_ptr<settings::SettingCallbacks<settings::DeviceSettingsManager>> m_callbacks;
459 
461  std::shared_ptr<settings::DeviceSettingsManager> m_settingsManager;
462 
464  std::shared_ptr<ipc::DoNotDisturbHandler> m_doNotDisturbIPCHandler;
465 
467  std::shared_ptr<ipc::InteractionManagerHandler> m_interactionManagerIPCHandler;
468 
470  std::shared_ptr<ipc::LoggerHandler> m_loggerIPCHandler;
471 
473  std::shared_ptr<ipc::SessionSetupHandler> m_sessionSetupIPCHandler;
474 
476  std::shared_ptr<ipc::IPCVersionManager> m_ipcVersionManager;
477 
479  std::shared_ptr<common::EndpointAlexaLauncherHandler> m_launcherHandler;
480 
482  std::shared_ptr<ipc::WindowManagerHandler> m_windowManagerIPCHandler;
483 
485  std::string m_defaultWindowId;
486 
488  std::string m_audioPlaybackUIWindowId;
489 
491  GUILogBridge m_guiLogBridge;
492 
494  std::string m_interfaceHoldingAudioFocus;
495 
497  std::shared_ptr<TimezoneHelper> m_timezoneHelper;
498 
500  std::shared_ptr<common::InteractionManager> m_interactionManager;
501 
503  std::shared_ptr<presentationOrchestratorInterfaces::PresentationOrchestratorStateTrackerInterface>
504  m_presentationOrchestratorStateTracker;
505 
507  std::shared_ptr<visualCharacteristicsInterfaces::VisualCharacteristicsInterface> m_visualCharacteristics;
508 
510  std::shared_ptr<visualCharacteristicsInterfaces::VisualCharacteristicsSerializerInterface>
511  m_visualCharacteristicsSerializer;
512 
514  std::shared_ptr<presentationOrchestratorInterfaces::PresentationOrchestratorInterface> m_presentationOrchestrator;
515 
517  std::shared_ptr<aplCapabilityCommonInterfaces::APLCapabilityAgentInterface> m_alexaPresentationAPL;
518 
520  std::shared_ptr<APLRuntimePresentationAdapter> m_aplRuntimePresentationAdapter;
521 
523  std::shared_ptr<TemplateRuntimePresentationAdapterBridge> m_templateRuntimePresentationAdapterBridge;
524 
527 };
528 
529 } // namespace gui
530 } // namespace ipcServerSampleApp
531 } // namespace sampleApplications
532 } // namespace alexaClientSDK
533 
534 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_GUI_GUIMANAGER_H_
MixingBehavior
Definition: MixingBehavior.h:25
static std::shared_ptr< GUIManager > create(std::shared_ptr< gui::GUIClientInterface > guiClient, std::shared_ptr< gui::GUIActivityEventNotifierInterface > activityEventNotifier, std::shared_ptr< applicationUtilities::resources::audio::MicrophoneInterface > micWrapper, std::shared_ptr< common::InteractionManager > interactionManager, std::shared_ptr< common::EndpointAlexaLauncherHandler > launcherHandler)
An interface providing APIs to be used by GUIClient.
Definition: GUIServerInterface.h:40
An interface that clients can extend to register to observe focus changes.
Definition: FocusManagerObserverInterface.h:26
::std::string string
Definition: gtest-port.h:1097
Definition: VisualCharacteristicsInterface.h:262
void setTemplateRuntimePresentationAdapterBridge(std::shared_ptr< TemplateRuntimePresentationAdapterBridge > templateRuntimePresentationAdapterBridge)
Single-thread executor implementation.
Definition: Executor.h:45
void handleGUIActivityEvent(avsCommon::sdkInterfaces::GUIActivityEvent event, const std::string &source="") override
The context of the AudioPlayer when the observer is notified of the PlayerActivity state change...
Definition: AudioPlayerObserverInterface.h:39
bool addWindowInstance(const presentationOrchestratorInterfaces::PresentationOrchestratorWindowInstance &instance) override
FocusState
Definition: FocusState.h:29
void namespaceVersionsReport(const std::string &message) override
DialogUXState
The different dialog specific AVS UX states.
Definition: DialogUXStateObserverInterface.h:32
std::vector< visualCharacteristicsInterfaces::WindowTemplate > getWindowTemplates() override
State
The different states the AudioInputProcessor can be in.
Definition: AudioInputProcessorObserverInterface.h:30
visualCharacteristicsInterfaces::DisplayCharacteristics getDisplayCharacteristics() override
void windowInstancesAdded(const std::string &message) override
void recognizeSpeechRequest(const std::string &message) override
CallState
An enumeration representing the state of a call.
Definition: CallStateObserverInterface.h:31
bool serializeDisplayCharacteristics(const visualCharacteristicsInterfaces::DisplayCharacteristics &display, std::string &serializedJson) override
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
Initiator
Definition: Initiator.h:28
An struct containing call state information.
Definition: CallStateObserverInterface.h:45
bool serializeWindowTemplate(const std::vector< visualCharacteristicsInterfaces::WindowTemplate > &windowTemplates, std::string &serializedJson) override
bool parseWindowInstance(const rapidjson::Value &payload, presentationOrchestratorInterfaces::PresentationOrchestratorWindowInstance &windowInstance)
void updateWindowInstance(const presentationOrchestratorInterfaces::PresentationOrchestratorWindowInstance &instance) override
void onStateChanged(const std::string &windowId, const presentationOrchestratorInterfaces::PresentationMetadata &metadata) override
DTMFTone
An enum used to define the characters that dtmf tone can be.
Definition: CallManagerInterface.h:59
void windowInstancesReport(const std::string &message) override
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
void setAPLRuntimePresentationAdapter(std::shared_ptr< APLRuntimePresentationAdapter > aplRuntimePresentationAdapter)
}
A state observer for an AudioInputProcessor.
Definition: AudioInputProcessorObserverInterface.h:27
bool removeWindowInstance(const std::string &windowInstanceId) override
GUIActivityEvent
Enumeration of activity events used to indicate the state of a GUI.
Definition: GUIActivityEvent.h:27
ContentType
Definition: ContentType.h:25
int32_t FirmwareVersion
Type to use to communicate a firmware version.
Definition: SoftwareInfoSenderObserverInterface.h:29
void visualCharacteristicsRequest(const std::string &message) override
std::vector< visualCharacteristicsInterfaces::InteractionMode > getInteractionModes() override
type
Definition: upload.py:443
void setWindowInstances(const std::vector< presentationOrchestratorInterfaces::PresentationOrchestratorWindowInstance > &instances, const std::string &defaultWindowInstanceId, const std::string &audioPlaybackUIWindowId) override
void windowInstancesRemoved(const std::string &message) override
void handleRecognizeSpeechRequest(capabilityAgents::aip::Initiator initiator, bool start) override
void handlePlaybackToggle(const std::string &name, bool checked) override
bool handleFocusReleaseRequest(std::string avsInterface, std::string channelName, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver) override
void windowInstancesUpdated(const std::string &message) override
void setClient(std::shared_ptr< sdkClient::SDKClientRegistry > clientRegistry)
bool handleFocusAcquireRequest(std::string avsInterface, std::string channelName, avsCommon::avs::ContentType contentType, std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > channelObserver) override
bool setDefaultWindowInstance(const std::string &windowInstanceId) override
void setIpcVersionManager(std::shared_ptr< ipc::IPCVersionManager > ipcVersionManager)
bool serializeInteractionMode(const std::vector< visualCharacteristicsInterfaces::InteractionMode > &interactionModes, std::string &serializedJson) override
void doNotDisturbStateRequest(const std::string &message) override
void onFocusChanged(const std::string &channelName, avsCommon::avs::FocusState newFocus) override
PlayerActivity
Identifies the player state.
Definition: PlayerActivity.h:27
void handleDocumentTerminated(const std::string &token, bool failed) override
tuple message
Definition: gtest_output_test.py:331
void doNotDisturbStateChanged(const std::string &message) override
void onPlayerActivityChanged(avsCommon::avs::PlayerActivity state, const Context &context) override
NavigationEvent
Enumeration of navigation events that could be sent from GUI App to SampleApp.
Definition: NavigationEvent.h:25
void defaultWindowInstanceChanged(const std::string &message) override
A dialog specific UX state observer.
Definition: DialogUXStateObserverInterface.h:29

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0