16 #ifndef ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_ALEXAPRESENTATION_APLCLIENTBRIDGE_H_ 17 #define ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_ALEXAPRESENTATION_APLCLIENTBRIDGE_H_ 25 #pragma GCC diagnostic push 26 #pragma GCC diagnostic ignored "-Wsign-compare" 27 #pragma GCC diagnostic ignored "-Wunused-variable" 28 #include <APLClient/AplClientBinding.h> 29 #include <APLClient/AplRenderingEvent.h> 30 #include <APLClient/AplRenderingEventObserver.h> 31 #include <APLClient/Extensions/AplCoreExtensionInterface.h> 32 #include <APLClient/Extensions/AudioPlayer/AplAudioPlayerExtension.h> 33 #include <APLClient/Extensions/AudioPlayer/AplAudioPlayerExtensionObserverInterface.h> 34 #include <APLClient/Extensions/Backstack/AplBackstackExtension.h> 35 #include <APLClient/Extensions/Backstack/AplBackstackExtensionObserver.h> 36 #pragma GCC diagnostic pop 49 namespace sampleApplications {
50 namespace ipcServerSampleApp {
61 :
public APLClient::AplOptionsInterface
67 ,
public APLClient::Extensions::Backstack::AplBackstackExtensionObserverInterface
68 ,
public APLClient::Extensions::AudioPlayer::AplAudioPlayerExtensionObserverInterface
71 ,
public std::enable_shared_from_this<AplClientBridge> {
73 static std::shared_ptr<AplClientBridge> create(
74 std::shared_ptr<CachingDownloadManager> contentDownloadManager,
75 std::shared_ptr<gui::GUIClientInterface> guiClient,
80 void doShutdown()
override;
87 void resetViewhost(
const std::string& token)
override;
91 std::chrono::milliseconds getTimezoneOffset()
override;
99 void onCommandExecutionComplete(
101 APLClient::AplCommandExecutionEvent event,
106 void onVisualContextAvailable(
const std::string& token,
unsigned int stateRequestToken,
const std::string& context)
109 void onSetDocumentIdleTimeout(
const std::string& token,
const std::chrono::milliseconds& timeout)
override;
111 void onRenderingEvent(
const std::string& token, APLClient::AplRenderingEvent event)
override;
120 void onExtensionEvent(
127 std::shared_ptr<APLClient::Extensions::AplCoreExtensionEventCallbackResultInterface> resultCallback)
override;
129 void logMessage(APLClient::LogLevel level,
const std::string& source,
const std::string& message)
override;
131 int getMaxNumberOfConcurrentDownloads()
override;
137 void onConnectionOpened()
override;
139 void onConnectionClosed()
override;
149 void renderTemplateCard(
const std::string& jsonPayload)
override;
150 void renderPlayerInfoCard(
153 void clearRenderTemplateCard()
override;
154 void clearPlayerInfoCard()
override;
159 void onLoginStateProvided(
163 void onPlaybackStateProvided(
170 void onRestoreDocumentState(std::shared_ptr<APLClient::AplDocumentState> documentState)
override;
175 void onAudioPlayerPlay()
override;
177 void onAudioPlayerPause()
override;
179 void onAudioPlayerNext()
override;
181 void onAudioPlayerPrevious()
override;
183 void onAudioPlayerSeekToPosition(
int offsetInMilliseconds)
override;
185 void onAudioPlayerToggle(
const std::string& name,
bool checked)
override;
187 void onAudioPlayerSkipForward()
override;
189 void onAudioPlayerSkipBackward()
override;
191 void onAudioPlayerLyricDataFlushed(
193 long durationInMilliseconds,
197 void onUpdateTimer();
199 void setGUIManager(std::shared_ptr<gui::GUIServerInterface> guiManager);
211 void clearDocument(
const std::string& token)
override;
215 void interruptCommandSequence(
const std::string& token)
override;
224 void onRenderDirectiveReceived(
const std::string& token,
const std::chrono::steady_clock::time_point& receiveTime)
229 void setMetricRecorder(std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface>
metricRecorder)
override;
231 void provideState(
const std::string& aplToken,
const unsigned int stateRequestToken)
override;
233 bool handleBack(
const std::string& windowId)
override;
238 void initializeRenderersRequest(
const std::string& message)
override;
239 void metricsReport(
const std::string& message)
override;
240 void viewhostEvent(
const std::string& message)
override;
241 void renderCompleted(
const std::string& message)
override;
242 void renderDocumentRequest(
const std::string& message)
override;
243 void executeCommandsRequest(
const std::string& message)
override;
244 void clearDocumentRequest(
const std::string& message)
override;
249 void handleRenderingEvent(
const std::string& token, APLClient::AplRenderingEvent event);
258 void initializeRenderer(
const std::string& windowId,
const std::set<std::string>& supportedExtensions);
265 void registerSharedExtension(
const std::shared_ptr<APLClient::Extensions::AplCoreExtensionInterface>& extension);
274 std::shared_ptr<APLClient::AplClientRenderer> getAplClientRendererFromAplToken(
const std::string& aplToken);
283 std::shared_ptr<APLClient::AplClientRenderer> getAplClientRendererFromWindowId(
const std::string& windowId);
289 void setMediaProperties(std::shared_ptr<avsCommon::sdkInterfaces::MediaPropertiesInterface> mediaProperties);
298 std::shared_ptr<CachingDownloadManager> contentDownloadManager,
299 std::shared_ptr<gui::GUIClientInterface> guiClient,
315 static std::shared_ptr<APLClient::Extensions::Backstack::AplBackstackExtension> getBackExtensionForRenderer(
316 const std::shared_ptr<APLClient::AplClientRenderer>& aplClientRenderer);
319 template <
typename...
Args>
329 template <
typename... Args1,
typename... Args2>
330 void executeNotifyObservers(APLViewhostObserverFunc<Args1...> func, Args2&&...
args);
337 void executeOnPresentationSessionChanged(
342 class TokenWindowBiMap {
350 m_tokenToWindow[token] = window;
351 m_windowToToken[window].insert(token);
359 auto tokenToWindowIt = m_tokenToWindow.find(token);
360 if (tokenToWindowIt == m_tokenToWindow.end()) {
364 auto windowId = tokenToWindowIt->second;
365 m_tokenToWindow.erase(tokenToWindowIt);
366 m_windowToToken[windowId].erase(token);
374 for (
auto& token : m_windowToToken[window]) {
375 m_tokenToWindow.erase(token);
377 m_windowToToken.erase(window);
386 auto tokenToWindowIt = m_tokenToWindow.find(token);
387 if (tokenToWindowIt == m_tokenToWindow.end()) {
391 return tokenToWindowIt->second;
396 std::unordered_map<std::string, std::string> m_tokenToWindow;
399 std::unordered_map<std::string, std::unordered_set<std::string>> m_windowToToken;
403 std::shared_ptr<CachingDownloadManager> m_contentDownloadManager;
409 std::unique_ptr<APLClient::AplClientBinding> m_aplClientBinding;
412 std::shared_ptr<gui::GUIServerInterface> m_guiManager;
415 std::shared_ptr<gui::GUIClientInterface> m_guiClient;
418 std::shared_ptr<ipc::APLClientHandler> m_aplClientHandler;
421 std::atomic_bool m_renderQueued;
427 std::vector<std::shared_ptr<APLClient::Extensions::AudioPlayer::AplAudioPlayerExtension>> m_audioPlayerExtensions;
433 std::unordered_map<std::string, std::shared_ptr<APLClient::AplClientRenderer>> m_aplClientRendererMap;
436 std::unordered_map<std::string, aplCapabilityCommonInterfaces::PresentationSession> m_windowIdToPresentationSession;
439 std::unordered_map<std::string, std::shared_ptr<APLClient::Extensions::AplCoreExtensionInterface>>
440 m_sharedRegisteredExtensions;
443 std::vector<std::weak_ptr<APLViewhostObserverInterface>> m_observers;
446 TokenWindowBiMap m_windowTokenMapping;
452 std::shared_ptr<avsCommon::sdkInterfaces::MediaPropertiesInterface> m_mediaProperties;
459 #endif // ALEXA_CLIENT_SDK_LIBIPCSERVERSAMPLEAPP_INCLUDE_IPCSERVERSAMPLEAPP_ALEXAPRESENTATION_APLCLIENTBRIDGE_H_
int maxNumberOfConcurrentDownloads
Definition: AplClientBridge.h:57
def args
Definition: android_test.py:111
Definition: PresentationSession.h:40
std::shared_ptr< APLViewhostObserverInterface > APLViewhostObserverInterfacePtr
Definition: APLViewhostObserverInterface.h:155
Definition: TemplateRuntimeObserverInterface.h:39
::std::string string
Definition: gtest-port.h:1097
Definition: AplClientBridge.h:55
Single-thread executor implementation.
Definition: Executor.h:45
The context of the AudioPlayer when the observer is notified of the PlayerActivity state change...
Definition: AudioPlayerObserverInterface.h:39
Definition: RequiresShutdown.h:32
Definition: APLClientHandlerInterface.h:29
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
Definition: gmock-generated-matchers.h:481
Definition: AudioPlayerObserverInterface.h:31
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
Definition: APLViewhostInterface.h:37
Definition: AplClientBridge.h:60
Timer to schedule task for delayed and periodic execution.
Definition: Timer.h:39
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
type
Definition: upload.py:443
PlayerActivity
Identifies the player state.
Definition: PlayerActivity.h:27
Definition: MessagingServerObserverInterface.h:27
tuple message
Definition: gtest_output_test.py:331
Definition: TemplateRuntimePresentationAdapterObserverInterface.h:30
Definition: APLViewhostObserverInterface.h:30