Alexa Auto SDK  2.0.0
AudioEngineInterfaces.h
1 /*
2  * Copyright 2017-2019 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 AACE_AUDIO_AUDIO_INTERFACES_H
17 #define AACE_AUDIO_AUDIO_INTERFACES_H
18 
21 #include <iostream>
22 
23 namespace aace {
24 namespace audio {
25 
26 class AudioInputEngineInterface {
27 public:
28  virtual ssize_t write( const int16_t* data, const size_t size ) = 0;
29 };
30 
31 class AudioOutputEngineInterface {
32 public:
36  enum class MediaError {
37 
41  MEDIA_ERROR_UNKNOWN,
42 
46  MEDIA_ERROR_INVALID_REQUEST,
47 
51  MEDIA_ERROR_SERVICE_UNAVAILABLE,
52 
56  MEDIA_ERROR_INTERNAL_SERVER_ERROR,
57 
61  MEDIA_ERROR_INTERNAL_DEVICE_ERROR
62  };
63 
67  enum class MediaState {
68 
72  STOPPED,
73 
77  PLAYING,
78 
82  BUFFERING
83  };
84 
85  // media player interface
86  virtual void onMediaStateChanged( MediaState state ) = 0;
87  virtual void onMediaError( MediaError error, const std::string& description ) = 0;
88 };
89 
90 inline std::ostream& operator<<(std::ostream& stream, const AudioOutputEngineInterface::MediaState& state) {
91  switch (state) {
92  case AudioOutputEngineInterface::MediaState::STOPPED:
93  stream << "STOPPED";
94  break;
95  case AudioOutputEngineInterface::MediaState::PLAYING:
96  stream << "PLAYING";
97  break;
98  case AudioOutputEngineInterface::MediaState::BUFFERING:
99  stream << "BUFFERING";
100  break;
101  }
102  return stream;
103 }
104 
105 inline std::ostream& operator<<(std::ostream& stream, const AudioOutputEngineInterface::MediaError& error) {
106  switch (error) {
107  case AudioOutputEngineInterface::MediaError::MEDIA_ERROR_UNKNOWN:
108  stream << "MEDIA_ERROR_UNKNOWN";
109  break;
110  case AudioOutputEngineInterface::MediaError::MEDIA_ERROR_INVALID_REQUEST:
111  stream << "MEDIA_ERROR_INVALID_REQUEST";
112  break;
113  case AudioOutputEngineInterface::MediaError::MEDIA_ERROR_SERVICE_UNAVAILABLE:
114  stream << "MEDIA_ERROR_SERVICE_UNAVAILABLE";
115  break;
116  case AudioOutputEngineInterface::MediaError::MEDIA_ERROR_INTERNAL_SERVER_ERROR:
117  stream << "MEDIA_ERROR_INTERNAL_SERVER_ERROR";
118  break;
119  case AudioOutputEngineInterface::MediaError::MEDIA_ERROR_INTERNAL_DEVICE_ERROR:
120  stream << "MEDIA_ERROR_INTERNAL_DEVICE_ERROR";
121  break;
122  }
123  return stream;
124 }
125 
126 } // aace::audio
127 } // aace
128 
129 #endif // AACE_AUDIO_AUDIO_INTERFACES_H
Definition: AddressBook.h:26

Alexa Auto SDK 2.0.0 - Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0