16 #ifndef ALEXA_CLIENT_SDK_CAPABILITYAGENTS_TEMPLATERUNTIME_INCLUDE_TEMPLATERUNTIME_TEMPLATERUNTIME_H_
17 #define ALEXA_CLIENT_SDK_CAPABILITYAGENTS_TEMPLATERUNTIME_INCLUDE_TEMPLATERUNTIME_TEMPLATERUNTIME_H_
23 #include <unordered_map>
24 #include <unordered_set>
40 namespace capabilityAgents {
41 namespace templateRuntime {
62 ,
public std::enable_shared_from_this<TemplateRuntime> {
73 const std::shared_ptr<avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderRegistrarInterface>&
74 renderPlayerInfoCardsInterfaces,
75 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
76 std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender);
86 static std::shared_ptr<TemplateRuntime>
create(
87 const std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface>>&
88 renderPlayerInfoCardsInterfaces,
89 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
90 std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender);
128 void addObserver(std::shared_ptr<avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface> observer);
136 void removeObserver(std::shared_ptr<avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface> observer);
156 std::shared_ptr<avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface> cardsProvider);
195 struct AudioItemPair {
199 AudioItemPair() =
default;
209 std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo> renderPlayerInfoDirective) :
211 directive{renderPlayerInfoDirective} {};
214 std::string audioItemId;
217 std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo> directive;
228 const std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface>>&
229 renderPlayerInfoCardsInterfaces,
230 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> focusManager,
231 std::shared_ptr<avsCommon::sdkInterfaces::ExceptionEncounteredSenderInterface> exceptionSender);
235 void doShutdown()
override;
248 void removeDirective(std::shared_ptr<DirectiveInfo> info);
255 void setHandlingCompleted(std::shared_ptr<DirectiveInfo> info);
262 void handleRenderTemplateDirective(std::shared_ptr<DirectiveInfo> info);
269 void handleRenderPlayerInfoDirective(std::shared_ptr<DirectiveInfo> info);
276 void handleUnknownDirective(std::shared_ptr<DirectiveInfo> info);
300 void executeRenderPlayerInfoCallbacks(
bool isClearCard);
306 void executeRenderTemplateCallbacks(
bool isClearCard);
312 void executeDisplayCard();
318 void executeClearCard();
325 void executeStartTimer(std::chrono::milliseconds timeout);
330 void executeStopTimer();
335 std::string stateToString(
const TemplateRuntime::State state);
340 void executeTimerEvent();
350 void executeDisplayCardEvent(
351 const std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo> info);
356 void executeCardClearedEvent();
367 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::TemplateRuntimeObserverInterface>> m_observers;
375 std::unordered_map<std::shared_ptr<avsCommon::sdkInterfaces::MediaPropertiesInterface>, AudioItemPair>
376 m_audioItemsInExecution;
379 std::shared_ptr<avsCommon::sdkInterfaces::MediaPropertiesInterface> m_activeRenderPlayerInfoCardsProvider;
385 std::deque<AudioItemPair> m_audioItems;
389 std::shared_ptr<avsCommon::sdkInterfaces::MediaPropertiesInterface>,
394 std::shared_ptr<alexaClientSDK::avsCommon::avs::CapabilityAgent::DirectiveInfo> m_lastDisplayedDirective;
397 bool m_isRenderTemplateLastReceived;
410 std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::RenderPlayerInfoCardsProviderInterface>>
411 m_renderPlayerInfoCardsInterfaces;
414 std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface> m_focusManager;
417 std::unordered_set<std::shared_ptr<avsCommon::avs::CapabilityConfiguration>> m_capabilityConfigurations;
423 std::chrono::milliseconds m_ttsFinishedTimeout;
426 std::chrono::milliseconds m_audioPlaybackFinishedTimeout;
429 std::chrono::milliseconds m_audioPlaybackStoppedPausedTimeout;
436 #endif // ALEXA_CLIENT_SDK_CAPABILITYAGENTS_TEMPLATERUNTIME_INCLUDE_TEMPLATERUNTIME_TEMPLATERUNTIME_H_