AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AdapterUtils.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_ACSDKEXTERNALMEDIAPLAYERINTERFACES_INCLUDE_ACSDKEXTERNALMEDIAPLAYERINTERFACES_ADAPTERUTILS_H_
17 #define ALEXA_CLIENT_SDK_ACSDKEXTERNALMEDIAPLAYERINTERFACES_INCLUDE_ACSDKEXTERNALMEDIAPLAYERINTERFACES_ADAPTERUTILS_H_
18 
19 #include <rapidjson/document.h>
20 #include <rapidjson/error/en.h>
21 #include <rapidjson/stringbuffer.h>
22 #include <rapidjson/writer.h>
23 #include <map>
24 
28 
29 namespace alexaClientSDK {
30 namespace acsdkExternalMediaPlayerInterfaces {
31 
33 enum class AdapterEvent {
36 
39 
41  LOGIN,
42 
44  LOGOUT,
45 
49 
52 };
53 
59 inline std::string adapterEventToString(AdapterEvent event) {
60  switch (event) {
62  return "CHANGE_REPORT";
64  return "REQUEST_TOKEN";
66  return "LOGIN";
68  return "LOGOUT";
70  return "PLAYER_EVENT";
72  return "PLAYER_ERROR_EVENT";
73  }
74  // To satisfy errant compiler warnings, returning empty string
75  return "";
76 }
77 
85 inline std::ostream& operator<<(std::ostream& stream, const AdapterEvent& event) {
86  return stream << adapterEventToString(event);
87 }
88 
91 extern const std::vector<int> SESSION_RETRY_TABLE;
92 
95 
96 // The NamespaceAndName for events sent from the adapter to AVS.
103 
104 // helper map for mapping adapter event type to its namespace and name
105 extern std::map<AdapterEvent, std::pair<std::string, std::string>> eventNameSpaceNameMap;
106 
117 rapidjson::Value buildSupportedOperations(
118  const std::set<acsdkExternalMediaPlayerInterfaces::SupportedPlaybackOperation>& supportedOperations,
119  rapidjson::Document::AllocatorType& allocator);
120 
131 bool buildMediaState(
132  rapidjson::Value* document,
133  const AdapterPlaybackState& playbackState,
134  rapidjson::Document::AllocatorType& allocator);
135 
144 rapidjson::Value buildPlaybackState(
146  rapidjson::Document::AllocatorType& allocator);
147 
156 rapidjson::Value buildSessionState(
158  rapidjson::Document::AllocatorType& allocator);
159 
169 bool buildDefaultPlayerState(rapidjson::Value* document, rapidjson::Document::AllocatorType& allocator);
170 
178 
179 #ifdef MEDIA_PORTABILITY_ENABLED
180 
183 enum class MpMode {
185  LEGACY,
188  MEDIA_CONVERGENCE,
190  MEDIA_PORTABILITY
191 };
192 
199 bool requestTypeIncludesMediaSessionId(RequestType type);
200 
205 MpMode getMediaPortabilityMode();
206 
212 bool mediaPortabilityEnabled();
213 
214 #endif
215 
216 } // namespace acsdkExternalMediaPlayerInterfaces
217 } // namespace alexaClientSDK
218 
219 #endif // end
220 // ALEXA_CLIENT_SDK_ACSDKEXTERNALMEDIAPLAYERINTERFACES_INCLUDE_ACSDKEXTERNALMEDIAPLAYERINTERFACES_ADAPTERUTILS_H_
alexaClientSDK::avsCommon::utils::RetryTimer
Definition: RetryTimer.h:30
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::adapterEventToString
std::string adapterEventToString(AdapterEvent event)
Definition: AdapterUtils.h:59
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::LOGIN
const avsCommon::avs::NamespaceAndName LOGIN
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::getEmpContextString
std::string getEmpContextString(acsdkExternalMediaPlayerInterfaces::AdapterState adapterState)
Definition: AdapterUtils.cpp:191
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent::PLAYER_EVENT
@ PLAYER_EVENT
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::PLAYER_EVENT
const avsCommon::avs::NamespaceAndName PLAYER_EVENT
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent::CHANGE_REPORT
@ CHANGE_REPORT
ChangeReport event sent after adapter's initialization succeeds/fails.
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::buildPlaybackState
rapidjson::Value buildPlaybackState(const acsdkExternalMediaPlayerInterfaces::AdapterPlaybackState &playbackState, rapidjson::Document::AllocatorType &allocator)
Definition: AdapterUtils.cpp:136
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent
AdapterEvent
Enumeration class for events sent by adapters to AVS.
Definition: AdapterUtils.h:33
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterState
Definition: ExternalMediaAdapterInterface.h:501
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::buildMediaState
bool buildMediaState(rapidjson::Value *document, const AdapterPlaybackState &playbackState, rapidjson::Document::AllocatorType &allocator)
Definition: AdapterUtils.cpp:96
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::eventNameSpaceNameMap
std::map< AdapterEvent, std::pair< std::string, std::string > > eventNameSpaceNameMap
Definition: AdapterUtils.cpp:63
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::buildSessionState
rapidjson::Value buildSessionState(const acsdkExternalMediaPlayerInterfaces::AdapterSessionState &sessionState, rapidjson::Document::AllocatorType &allocator)
Definition: AdapterUtils.cpp:156
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::operator<<
std::ostream & operator<<(std::ostream &stream, const AdapterEvent &event)
Definition: AdapterUtils.h:85
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::CHANGE_REPORT
const avsCommon::avs::NamespaceAndName CHANGE_REPORT
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterPlaybackState
Definition: ExternalMediaAdapterInterface.h:395
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent::PLAYER_ERROR_EVENT
@ PLAYER_ERROR_EVENT
PlayerErrorEvent to report all errors from the adapters.
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent::REQUEST_TOKEN
@ REQUEST_TOKEN
Event to request token from third party.
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::SESSION_RETRY_TABLE
const std::vector< int > SESSION_RETRY_TABLE
Definition: AdapterUtils.cpp:45
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::LOGOUT
const avsCommon::avs::NamespaceAndName LOGOUT
RetryTimer.h
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::REQUEST_TOKEN
const avsCommon::avs::NamespaceAndName REQUEST_TOKEN
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::SESSION_RETRY_TIMER
avsCommon::utils::RetryTimer SESSION_RETRY_TIMER
The retry timer for session management (token fetch/changeReport send).
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent::LOGOUT
@ LOGOUT
Logout event when a user logs out.
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::PLAYER_ERROR_EVENT
const avsCommon::avs::NamespaceAndName PLAYER_ERROR_EVENT
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::RequestType
RequestType
Definition: ExternalMediaAdapterInterface.h:32
ExternalMediaAdapterInterface.h
alexaClientSDK::avsCommon::avs::NamespaceAndName
Definition: NamespaceAndName.h:32
NamespaceAndName.h
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterSessionState
Definition: ExternalMediaAdapterInterface.h:322
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::buildDefaultPlayerState
bool buildDefaultPlayerState(rapidjson::Value *document, rapidjson::Document::AllocatorType &allocator)
Definition: AdapterUtils.cpp:176
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::buildSupportedOperations
rapidjson::Value buildSupportedOperations(const std::set< acsdkExternalMediaPlayerInterfaces::SupportedPlaybackOperation > &supportedOperations, rapidjson::Document::AllocatorType &allocator)
alexaClientSDK::acsdkExternalMediaPlayerInterfaces::AdapterEvent::LOGIN
@ LOGIN
Login event when a guest user logs in.

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