AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
StreamFormat.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 ACSDKAUDIOPLAYER_STREAMFORMAT_H_
17 #define ACSDKAUDIOPLAYER_STREAMFORMAT_H_
18 
19 #include <ostream>
20 
23 
24 namespace alexaClientSDK {
25 namespace acsdkAudioPlayer {
26 
28 enum class StreamFormat {
30  AUDIO_MPEG,
32  UNKNOWN
33 };
34 
42  switch (streamFormat) {
44  return "AUDIO_MPEG";
46  break;
47  }
48  return "unknown StreamFormat";
49 }
50 
58 inline bool stringToStreamFormat(const std::string& text, StreamFormat* streamFormat) {
59  if (nullptr == streamFormat) {
60  return false;
61  } else if (text == streamFormatToString(StreamFormat::AUDIO_MPEG)) {
62  *streamFormat = StreamFormat::AUDIO_MPEG;
63  return true;
64  }
65  return false;
66 }
67 
75 inline std::ostream& operator<<(std::ostream& stream, const StreamFormat& streamFormat) {
76  return stream << streamFormatToString(streamFormat);
77 }
78 
86 inline bool convertToValue(const rapidjson::Value& documentNode, StreamFormat* streamFormat) {
87  std::string text;
88  if (!avsCommon::utils::json::jsonUtils::convertToValue(documentNode, &text)) {
89  return false;
90  }
91  return stringToStreamFormat(text, streamFormat);
92 }
93 
94 } // namespace acsdkAudioPlayer
95 } // namespace alexaClientSDK
96 
97 #endif // ACSDKAUDIOPLAYER_STREAMFORMAT_H_
bool stringToStreamFormat(const std::string &text, StreamFormat *streamFormat)
Definition: StreamFormat.h:58
StreamFormat
Specifies the format of a binary audio attachment in a Play directive.
Definition: StreamFormat.h:28
bool convertToValue(const rapidjson::Value &documentNode, ClearBehavior *clearBehavior)
Definition: ClearBehavior.h:90
::std::string string
Definition: gtest-port.h:1097
Audio is an unknown/unsupported format.
std::ostream & operator<<(std::ostream &stream, const ClearBehavior &clearBehavior)
Definition: ClearBehavior.h:79
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
std::string streamFormatToString(StreamFormat streamFormat)
Definition: StreamFormat.h:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
bool convertToValue(const rapidjson::Value &documentNode, std::string *value)

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