Alexa Auto SDK  2.0.0
LocalMediaSource.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_ALEXA_LOCAL_MEDIA_SOURCE_H
17 #define AACE_ALEXA_LOCAL_MEDIA_SOURCE_H
18 
19 #include <chrono>
20 #include <string>
21 
22 #include "AACE/Core/PlatformInterface.h"
23 
24 #include "ExternalMediaAdapter.h"
25 
28 namespace aace {
29 namespace alexa {
30 
39 public:
43  enum class Source {
47  BLUETOOTH,
51  USB,
55  FM_RADIO,
59  AM_RADIO,
67  LINE_IN,
75  SIRIUS_XM,
79  DAB
80  };
81 
85  enum class ContentSelector {
89  FREQUENCY,
93  CHANNEL,
97  PRESET
98  };
99 
101  using PlayControlType = ExternalMediaAdapter::PlayControlType;
103  using SupportedPlaybackOperation = ExternalMediaAdapter::SupportedPlaybackOperation;
104  using Favorites = ExternalMediaAdapter::Favorites;
105  using MediaType = ExternalMediaAdapter::MediaType;
106 
110  class SessionState {
111  public:
112  /*
113  * Default Constructor.
114  */
115  SessionState();
116 
118  std::string endpointId;
119 
121  bool loggedIn;
122 
124  std::string userName;
125 
127  bool isGuest;
128 
130  bool launched;
131 
136  bool active;
137 
142  std::string accessToken;
143 
145  std::chrono::milliseconds tokenRefreshInterval;
146 
148  std::vector<ContentSelector> supportedContentSelectors;
149 
151  std::string spiVersion;
152  };
153 
158  public:
160  PlaybackState();
161 
163  std::string state;
164 
166  std::vector<SupportedPlaybackOperation> supportedOperations;
167 
169  std::chrono::milliseconds trackOffset;
170 
173 
176 
178  Favorites favorites;
179 
181  std::string type;
182 
184  std::string playbackSource;
185 
188  std::string playbackSourceId;
189 
191  std::string trackName;
192 
194  std::string trackId;
195 
198  std::string trackNumber;
199 
201  std::string artistName;
202 
205  std::string artistId;
206 
208  std::string albumName;
209 
212  std::string albumId;
213 
215  std::string tinyURL;
216 
218  std::string smallURL;
219 
221  std::string mediumURL;
222 
224  std::string largeURL;
225 
228  std::string coverId;
229 
232  std::string mediaProvider;
233 
235  MediaType mediaType;
236 
238  std::chrono::milliseconds duration;
239  };
240 
245  public:
248 
251 
254  };
255 
256 protected:
257  LocalMediaSource( Source source );
258 
259 public:
260  virtual ~LocalMediaSource();
261 
272  virtual bool play( ContentSelector contentSelectorType, const std::string& payload ) = 0;
273 
284  virtual bool playControl( PlayControlType controlType ) = 0;
285 
294  virtual bool seek( std::chrono::milliseconds offset ) = 0;
295 
304  virtual bool adjustSeek( std::chrono::milliseconds deltaOffset ) = 0;
305 
309  virtual LocalMediaSourceState getState() = 0;
310 
320  virtual bool volumeChanged( float volume ) = 0;
321 
331  virtual bool mutedStateChanged( MutedState state ) = 0;
332 
336  Source getSource();
337 
338  // LocalMediaSourceEngineInterface
339 
345  void playerEvent( const std::string& eventName );
346 
358  void playerError( const std::string& errorName, long code, const std::string& description, bool fatal );
359 
363  void setFocus();
364 
371  void setEngineInterface( std::shared_ptr<aace::alexa::LocalMediaSourceEngineInterface> localMediaSourceEngineInterface );
372 
373 private:
374  std::weak_ptr<aace::alexa::LocalMediaSourceEngineInterface> m_localMediaSourceEngineInterface;
375 
376  Source m_source;
377 
378 };
379 
380 inline std::ostream& operator<<(std::ostream& stream, const LocalMediaSource::Source& source) {
381  switch (source) {
383  stream << "BLUETOOTH";
384  break;
386  stream << "USB";
387  break;
389  stream << "FM_RADIO";
390  break;
392  stream << "AM_RADIO";
393  break;
395  stream << "SATELLITE_RADIO";
396  break;
398  stream << "LINE_IN";
399  break;
401  stream << "COMPACT_DISC";
402  break;
404  stream << "SIRIUS_XM";
405  break;
407  stream << "DAB";
408  break;
409  }
410  return stream;
411 }
412 
413 inline std::ostream& operator<<(std::ostream& stream, const LocalMediaSource::ContentSelector& contentSelectorType) {
414  switch (contentSelectorType) {
416  stream << "CHANNEL";
417  break;
419  stream << "FREQUENCY";
420  break;
422  stream << "PRESET";
423  break;
424  }
425  return stream;
426 }
427 
428 } // aace::alexa
429 } // aace
430 
431 #endif // AACE_ALEXA_LOCAL_MEDIA_SOURCE_H
MutedState
Definition: AudioOutput.h:69
std::string artistId
Definition: LocalMediaSource.h:205
std::string albumId
Definition: LocalMediaSource.h:212
bool launched
Flag that identifies if an application has been launched.
Definition: LocalMediaSource.h:130
PlaybackState playbackState
Variable to hold the playback state.
Definition: LocalMediaSource.h:253
std::string tinyURL
The URL for tiny cover art image resource} .
Definition: LocalMediaSource.h:215
bool repeatEnabled
Bool to identify if looping of songs is enabled.
Definition: LocalMediaSource.h:175
std::string coverId
Definition: LocalMediaSource.h:228
void playerEvent(const std::string &eventName)
Definition: LocalMediaSource.cpp:53
virtual bool volumeChanged(float volume)=0
std::string type
The type of the media item. For now hard-coded to ExternalMediaAdapterMusicItem.
Definition: LocalMediaSource.h:181
Source getSource()
Definition: LocalMediaSource.cpp:45
std::string spiVersion
The only spiVersion that currently exists is "1.0".
Definition: LocalMediaSource.h:151
Definition: PlatformInterface.h:29
void playerError(const std::string &errorName, long code, const std::string &description, bool fatal)
Definition: LocalMediaSource.cpp:59
std::chrono::milliseconds duration
Media item duration in milliseconds.
Definition: LocalMediaSource.h:238
std::string playbackSource
The display name for current playback context, e.g. playlist name.
Definition: LocalMediaSource.h:184
void setFocus()
Definition: LocalMediaSource.cpp:65
std::string state
The state of the default player - IDLE/STOPPED/PAUSED/PLAYING/FINISHED/FAST_FORWARDING/REWINDING/BUFF...
Definition: LocalMediaSource.h:163
virtual bool seek(std::chrono::milliseconds offset)=0
std::vector< SupportedPlaybackOperation > supportedOperations
The set of states the default player can move into from its current state.
Definition: LocalMediaSource.h:166
virtual bool mutedStateChanged(MutedState state)=0
std::string trackNumber
Definition: LocalMediaSource.h:198
Definition: AddressBook.h:26
std::string playbackSourceId
Definition: LocalMediaSource.h:188
std::string artistName
The display name for the currently playing artist.
Definition: LocalMediaSource.h:201
std::string smallURL
The URL for small cover art image resource} .
Definition: LocalMediaSource.h:218
bool isGuest
Flag that identifies if the user currently logged in is a guest.
Definition: LocalMediaSource.h:127
std::string accessToken
Definition: LocalMediaSource.h:142
MediaType mediaType
The Media type enum value from {TRACK, PODCAST, STATION, AD, SAMPLE, OTHER} type of the media...
Definition: LocalMediaSource.h:235
virtual bool playControl(PlayControlType controlType)=0
std::string mediaProvider
Definition: LocalMediaSource.h:232
std::string mediumURL
The URL for medium cover art image resource} .
Definition: LocalMediaSource.h:221
ContentSelector
Definition: LocalMediaSource.h:85
bool active
Definition: LocalMediaSource.h:136
std::string trackId
The arbitrary identifier for currently playing trackid of the track as per the music provider...
Definition: LocalMediaSource.h:194
virtual bool play(ContentSelector contentSelectorType, const std::string &payload)=0
Favorites favorites
The favorite status {"FAVORITED"/"UNFAVORITED"/"NOT_RATED"}.
Definition: LocalMediaSource.h:178
std::chrono::milliseconds trackOffset
The offset of the track in milliseconds.
Definition: LocalMediaSource.h:169
SessionState sessionState
Variable to hold the session state.
Definition: LocalMediaSource.h:250
bool loggedIn
Flag that identifies if a user is currently logged in.
Definition: LocalMediaSource.h:121
std::vector< ContentSelector > supportedContentSelectors
Array of content selector types supported by the player.
Definition: LocalMediaSource.h:148
bool shuffleEnabled
Bool to identify if shuffling is enabled.
Definition: LocalMediaSource.h:172
std::chrono::milliseconds tokenRefreshInterval
The validity period of the token in milliseconds.
Definition: LocalMediaSource.h:145
Definition: LocalMediaSource.h:110
Source
Definition: LocalMediaSource.h:43
Definition: LocalMediaSource.h:38
std::string userName
The username of the user currently logged in via a Login directive from Alexa.
Definition: LocalMediaSource.h:124
std::string albumName
The display name of the currently playing album.
Definition: LocalMediaSource.h:208
std::string trackName
The display name for the currently playing trackname of the track.
Definition: LocalMediaSource.h:191
std::string endpointId
The unique device endpoint.
Definition: LocalMediaSource.h:118
std::string largeURL
The URL for large cover art image resource} .
Definition: LocalMediaSource.h:224
Definition: LocalMediaSource.h:157
virtual LocalMediaSourceState getState()=0
virtual bool adjustSeek(std::chrono::milliseconds deltaOffset)=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