AlexaClientSDK  3.0.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 
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 
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 
146  rapidjson::Document::AllocatorType& allocator);
147 
158  rapidjson::Document::AllocatorType& allocator);
159 
169 bool buildDefaultPlayerState(rapidjson::Value* document, rapidjson::Document::AllocatorType& allocator);
170 
178 
179 } // namespace acsdkExternalMediaPlayerInterfaces
180 } // namespace alexaClientSDK
181 
182 #endif // end
183 // ALEXA_CLIENT_SDK_ACSDKEXTERNALMEDIAPLAYERINTERFACES_INCLUDE_ACSDKEXTERNALMEDIAPLAYERINTERFACES_ADAPTERUTILS_H_
rapidjson::Value buildPlaybackState(const acsdkExternalMediaPlayerInterfaces::AdapterPlaybackState &playbackState, rapidjson::Document::AllocatorType &allocator)
rapidjson::Value buildSessionState(const acsdkExternalMediaPlayerInterfaces::AdapterSessionState &sessionState, rapidjson::Document::AllocatorType &allocator)
Definition: NamespaceAndName.h:32
bool buildMediaState(rapidjson::Value *document, const AdapterPlaybackState &playbackState, rapidjson::Document::AllocatorType &allocator)
rapidjson::Value buildSupportedOperations(const std::set< acsdkExternalMediaPlayerInterfaces::SupportedPlaybackOperation > &supportedOperations, rapidjson::Document::AllocatorType &allocator)
::std::string string
Definition: gtest-port.h:1097
std::map< AdapterEvent, std::pair< std::string, std::string > > eventNameSpaceNameMap
ChangeReport event sent after adapter&#39;s initialization succeeds/fails.
Definition: ExternalMediaAdapterInterface.h:495
avsCommon::utils::RetryTimer SESSION_RETRY_TIMER
The retry timer for session management (token fetch/changeReport send).
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
bool buildDefaultPlayerState(rapidjson::Value *document, rapidjson::Document::AllocatorType &allocator)
PlayerErrorEvent to report all errors from the adapters.
AdapterEvent
Enumeration class for events sent by adapters to AVS.
Definition: AdapterUtils.h:33
std::string getEmpContextString(acsdkExternalMediaPlayerInterfaces::AdapterState adapterState)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::string adapterEventToString(AdapterEvent event)
Definition: AdapterUtils.h:59
std::ostream & operator<<(std::ostream &stream, const AdapterEvent &event)
Definition: AdapterUtils.h:85

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