AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
TemplateRuntimePresentationAdapter.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 ACSDK_SAMPLE_TEMPLATERUNTIME_TEMPLATERUNTIMEPRESENTATIONADAPTER_H_
17 #define ACSDK_SAMPLE_TEMPLATERUNTIME_TEMPLATERUNTIMEPRESENTATIONADAPTER_H_
18 
19 #include <string>
20 #include <utility>
21 
22 #include <rapidjson/document.h>
23 #include <rapidjson/writer.h>
24 
32 
34 
35 namespace alexaClientSDK {
36 namespace sampleApplications {
37 namespace common {
38 
46  , public std::enable_shared_from_this<TemplateRuntimePresentationAdapter> {
47 public:
52  static std::shared_ptr<TemplateRuntimePresentationAdapter> create();
53 
57  virtual ~TemplateRuntimePresentationAdapter() = default;
58 
63  std::shared_ptr<presentationOrchestratorInterfaces::PresentationInterface> presentation) override;
69 
72  void renderTemplateCard(const std::string& jsonPayload) override;
73 
75  const std::string& jsonPayload,
77 
79 
86 
93  void setExecutor(std::shared_ptr<avsCommon::utils::threading::Executor> executor);
94 
100  const std::weak_ptr<TemplateRuntimePresentationAdapterObserverInterface>& observer);
101 
107  const std::weak_ptr<TemplateRuntimePresentationAdapterObserverInterface>& observer);
108 
113  void setRenderTemplateWindowId(const std::string& renderTemplateWindowId);
114 
119  void setRenderPlayerInfoWindowId(const std::string& renderPlayerInfoWindowId);
120 
126  std::shared_ptr<presentationOrchestratorInterfaces::PresentationOrchestratorClientInterface> poClient);
127 
128 private:
133 
137  bool initialize();
138 
142 
146  struct DisplayCardSession {
150  DisplayCardSession() = default;
151 
156  explicit DisplayCardSession(std::string jsonPayload) :
157  jsonPayload{std::move(jsonPayload)},
158  presentation{nullptr},
160 
162  std::string jsonPayload;
163 
165  std::shared_ptr<presentationOrchestratorInterfaces::PresentationInterface> presentation;
166 
169  };
170 
172  using DisplayCardSessionPtr = std::shared_ptr<DisplayCardSession>;
173 
177  struct PlayerInfoCardSession : DisplayCardSession {
181  PlayerInfoCardSession() = default;
182 
188  PlayerInfoCardSession(
189  std::string jsonPayload,
191  jsonPayload{std::move(jsonPayload)},
192  audioPlayerInfo{std::move(audioPlayerInfo)} {};
193 
195  std::string jsonPayload;
196 
199  };
200 
202  using PlayerInfoCardSessionPtr = std::shared_ptr<PlayerInfoCardSession>;
203 
208  void executeOnPlayerActivityChanged(alexaClientSDK::avsCommon::avs::PlayerActivity state);
209 
211  std::shared_ptr<TemplateRuntimePresentationAdapterNotifier> m_templateRuntimePresentationAdapterNotifier;
212 
214  std::shared_ptr<presentationOrchestratorInterfaces::PresentationOrchestratorClientInterface>
215  m_presentationOrchestratorClient;
216 
219 
222 
224  DisplayCardSessionPtr m_displayCardSession;
225 
227  PlayerInfoCardSessionPtr m_playerInfoCardSession;
228 
230  std::chrono::milliseconds m_audioPlaybackFinishedTimeout;
231 
233  std::chrono::milliseconds m_audioPlaybackStoppedPausedTimeout;
234 
236  std::string m_renderTemplateWindowId;
237 
239  std::string m_renderPlayerInfoWindowId;
240 
242  std::shared_ptr<avsCommon::utils::threading::Executor> m_executor;
243 };
244 
245 } // namespace common
246 } // namespace sampleApplications
247 } // namespace alexaClientSDK
248 #endif // ACSDK_SAMPLE_TEMPLATERUNTIME_TEMPLATERUNTIMEPRESENTATIONADAPTER_H_
void onPresentationStateChanged(presentationOrchestratorInterfaces::PresentationRequestToken id, presentationOrchestratorInterfaces::PresentationState newState) override
::std::string string
Definition: gtest-port.h:1097
void renderPlayerInfoCard(const std::string &jsonPayload, templateRuntimeInterfaces::TemplateRuntimeObserverInterface::AudioPlayerInfo audioPlayerInfo) override
void removeTemplateRuntimePresentationAdapterObserver(const std::weak_ptr< TemplateRuntimePresentationAdapterObserverInterface > &observer)
The context of the AudioPlayer when the observer is notified of the PlayerActivity state change...
Definition: AudioPlayerObserverInterface.h:39
void setRenderPlayerInfoWindowId(const std::string &renderPlayerInfoWindowId)
void onPlayerActivityChanged(avsCommon::avs::PlayerActivity state, const acsdkAudioPlayerInterfaces::AudioPlayerObserverInterface::Context &context) override
void onPresentationAvailable(presentationOrchestratorInterfaces::PresentationRequestToken id, std::shared_ptr< presentationOrchestratorInterfaces::PresentationInterface > presentation) override
Generic implementation of NotifierInterface.
Definition: Notifier.h:38
void setPresentationOrchestrator(std::shared_ptr< presentationOrchestratorInterfaces::PresentationOrchestratorClientInterface > poClient)
PresentationState
Definition: PresentationTypes.h:48
Definition: common.py:1
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static std::shared_ptr< TemplateRuntimePresentationAdapter > create()
bool onNavigateBack(presentationOrchestratorInterfaces::PresentationRequestToken id) override
uint64_t PresentationRequestToken
Definition: PresentationTypes.h:25
void addTemplateRuntimePresentationAdapterObserver(const std::weak_ptr< TemplateRuntimePresentationAdapterObserverInterface > &observer)
void setRenderTemplateWindowId(const std::string &renderTemplateWindowId)
void setExecutor(std::shared_ptr< avsCommon::utils::threading::Executor > executor)
PlayerActivity
Identifies the player state.
Definition: PlayerActivity.h:27
const T & move(const T &t)
Definition: gtest-port.h:1317

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