AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
PlayBehavior.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_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_PLAYBEHAVIOR_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_PLAYBEHAVIOR_H_
18 
19 #include <string>
20 #include <ostream>
21 
23 
24 namespace alexaClientSDK {
25 namespace avsCommon {
26 namespace avs {
27 
29 enum class PlayBehavior {
35 
37  ENQUEUE,
38 
41 };
42 
49 inline std::string playBehaviorToString(PlayBehavior playBehavior) {
50  switch (playBehavior) {
52  return "REPLACE_ALL";
54  return "ENQUEUE";
56  return "REPLACE_ENQUEUED";
57  }
58  return "unknown PlayBehavior";
59 }
60 
68 inline bool stringToPlayBehavior(const std::string& text, PlayBehavior* playBehavior) {
69  if (nullptr == playBehavior) {
70  return false;
71  } else if (playBehaviorToString(PlayBehavior::REPLACE_ALL) == text) {
72  *playBehavior = PlayBehavior::REPLACE_ALL;
73  return true;
74  } else if (playBehaviorToString(PlayBehavior::ENQUEUE) == text) {
75  *playBehavior = PlayBehavior::ENQUEUE;
76  return true;
78  *playBehavior = PlayBehavior::REPLACE_ENQUEUED;
79  return true;
80  }
81  return false;
82 }
83 
91 inline std::ostream& operator<<(std::ostream& stream, const PlayBehavior& playBehavior) {
92  return stream << playBehaviorToString(playBehavior);
93 }
94 
102 inline bool convertToValue(const rapidjson::Value& documentNode, PlayBehavior* playBehavior) {
103  std::string text;
104  if (!avsCommon::utils::json::jsonUtils::convertToValue(documentNode, &text)) {
105  return false;
106  }
107  return stringToPlayBehavior(text, playBehavior);
108 }
109 
110 } // namespace avs
111 } // namespace avsCommon
112 } // namespace alexaClientSDK
113 
114 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_PLAYBEHAVIOR_H_
bool stringToPlayBehavior(const std::string &text, PlayBehavior *playBehavior)
Definition: PlayBehavior.h:68
PlayBehavior
Used to determine how a client must handle queueing and playback of a stream.
Definition: PlayBehavior.h:29
std::string playBehaviorToString(PlayBehavior playBehavior)
Definition: PlayBehavior.h:49
bool convertToValue(const rapidjson::Value &documentNode, PlayBehavior *playBehavior)
Definition: PlayBehavior.h:102
Replace all streams in the queue. This does not impact the currently playing stream.
std::ostream & operator<<(std::ostream &stream, AlexaResponseType responseType)
Definition: AlexaResponseType.h:93
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool convertToValue(const rapidjson::Value &documentNode, std::string *value)
Definition: JSONUtils.cpp:146
Adds a stream to the end of the current queue.

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