Alexa Auto SDK  2.3.1
AudioOutput.h
1 /*
2  * Copyright 2017-2020 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_OUTPUT_H
17 #define AACE_AUDIO_AUDIO_OUTPUT_H
18 
19 #include <memory>
20 
21 #include "AudioEngineInterfaces.h"
22 #include "AudioStream.h"
23 
26 namespace aace {
27 namespace audio {
28 
47 class AudioOutput {
48 protected:
49  AudioOutput() = default;
50 
51 public:
56  using MediaState = aace::audio::AudioOutputEngineInterface::MediaState;
57 
62  using MediaError = aace::audio::AudioOutputEngineInterface::MediaError;
63 
67  static const int64_t TIME_UNKNOWN = -1;
68 
69  enum class MutedState {
73  MUTED,
74 
78  UNMUTED
79  };
80 
81  virtual ~AudioOutput();
82 
94  virtual bool prepare(std::shared_ptr<AudioStream> stream, bool repeating) = 0;
95 
106  virtual bool prepare(const std::string& url, bool repeating) = 0;
107 
116  virtual bool play() = 0;
117 
128  virtual bool stop() = 0;
129 
140  virtual bool pause() = 0;
141 
150  virtual bool resume() = 0;
151 
160  virtual int64_t getPosition() = 0;
161 
170  virtual bool setPosition(int64_t position) = 0;
171 
178  virtual int64_t getDuration() = 0;
179 
185  virtual int64_t getNumBytesBuffered();
186 
196  virtual bool volumeChanged(float volume) = 0;
197 
207  virtual bool mutedStateChanged(MutedState state) = 0;
208 
216  void mediaStateChanged(MediaState state);
217 
225  void mediaError(MediaError error, const std::string& description = "");
226 
233  void setEngineInterface(std::shared_ptr<aace::audio::AudioOutputEngineInterface> audioOutputEngineInterface);
234 
235 private:
236  std::weak_ptr<aace::audio::AudioOutputEngineInterface> m_audioOutputEngineInterface;
237 };
238 
239 inline std::ostream& operator<<(std::ostream& stream, const AudioOutput::MutedState& state) {
240  switch (state) {
242  stream << "MUTED";
243  break;
245  stream << "UNMUTED";
246  break;
247  }
248  return stream;
249 }
250 
251 } // namespace audio
252 } // namespace aace
253 
254 #endif // AACE_AUDIO_AUDIO_OUTPUT_H
MutedState
Definition: AudioOutput.h:69
virtual bool resume()=0
virtual bool prepare(std::shared_ptr< AudioStream > stream, bool repeating)=0
virtual bool play()=0
virtual int64_t getNumBytesBuffered()
Definition: AudioOutput.cpp:23
Definition: AudioOutput.h:47
void mediaError(MediaError error, const std::string &description="")
Definition: AudioOutput.cpp:33
static const int64_t TIME_UNKNOWN
Definition: AudioOutput.h:67
Definition: AddressBook.h:26
virtual bool volumeChanged(float volume)=0
virtual bool pause()=0
virtual bool mutedStateChanged(MutedState state)=0
void mediaStateChanged(MediaState state)
Definition: AudioOutput.cpp:27
virtual bool setPosition(int64_t position)=0
virtual int64_t getDuration()=0
virtual bool stop()=0
virtual int64_t getPosition()=0

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