Alexa Auto SDK  2.0.0
AudioOutput.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_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
70  {
74  MUTED,
75 
79  UNMUTED
80  };
81 
82  virtual ~AudioOutput();
83 
95  virtual bool prepare( std::shared_ptr<AudioStream> stream, bool repeating ) = 0;
96 
107  virtual bool prepare( const std::string& url, bool repeating ) = 0;
108 
117  virtual bool play() = 0;
118 
129  virtual bool stop() = 0;
130 
141  virtual bool pause() = 0;
142 
151  virtual bool resume() = 0;
152 
161  virtual int64_t getPosition() = 0;
162 
171  virtual bool setPosition( int64_t position ) = 0;
172 
179  virtual int64_t getDuration() = 0;
180 
190  virtual bool volumeChanged( float volume ) = 0;
191 
201  virtual bool mutedStateChanged( MutedState state ) = 0;
202 
210  void mediaStateChanged( MediaState state );
211 
219  void mediaError( MediaError error, const std::string& description = "" );
220 
227  void setEngineInterface( std::shared_ptr<aace::audio::AudioOutputEngineInterface> audioOutputEngineInterface );
228 
229 private:
230  std::weak_ptr<aace::audio::AudioOutputEngineInterface> m_audioOutputEngineInterface;
231 };
232 
233 inline std::ostream& operator<<(std::ostream& stream, const AudioOutput::MutedState& state) {
234  switch (state) {
236  stream << "MUTED";
237  break;
239  stream << "UNMUTED";
240  break;
241  }
242  return stream;
243 }
244 
245 } // aace::audio
246 } // aace
247 
248 #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
Definition: AudioOutput.h:47
void mediaError(MediaError error, const std::string &description="")
Definition: AudioOutput.cpp:29
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:23
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.0.0 - Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0