AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MediaType.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_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIATYPE_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIATYPE_H_
18 
19 #include <iostream>
20 #include <string>
21 
22 namespace alexaClientSDK {
23 namespace avsCommon {
24 namespace utils {
25 
29 enum class MediaType {
31  MPEG,
33  WAV,
35  UNKNOWN
36 };
37 
45 inline MediaType MimeTypeToMediaType(const std::string& mimetype) {
46  if (mimetype == "audio/mpeg" || mimetype == "audio/x-mpeg") {
47  return MediaType::MPEG;
48  } else if (mimetype == "audio/wav" || mimetype == "audio/x-wav") {
49  return MediaType::WAV;
50  }
51 
52  return MediaType::UNKNOWN;
53 }
54 
62 inline std::ostream& operator<<(std::ostream& stream, const MediaType& mediatype) {
63  switch (mediatype) {
64  case MediaType::MPEG:
65  stream << "MPEG";
66  break;
67  case MediaType::WAV:
68  stream << "WAV";
69  break;
70  case MediaType::UNKNOWN:
71  default:
72  stream << "UNKNOWN";
73  break;
74  }
75  return stream;
76 }
77 
78 } // namespace utils
79 } // namespace avsCommon
80 } // namespace alexaClientSDK
81 
82 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIATYPE_H_
::std::string string
Definition: gtest-port.h:1097
MediaType
Definition: MediaType.h:29
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::ostream & operator<<(std::ostream &stream, const AudioFormat::Encoding &encoding)
Definition: AudioFormat.h:94
MediaType MimeTypeToMediaType(const std::string &mimetype)
Definition: MediaType.h:45

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