Alexa Auto SDK  2.0.0
AlexaEngineInterfaces.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_ALEXA_ENGINE_INTERFACES_H
17 #define AACE_ALEXA_ALEXA_ENGINE_INTERFACES_H
18 
19 #include <fstream>
20 #include <iostream>
21 #include <string>
22 #include <vector>
23 #include <memory>
24 #include <limits>
25 
28 namespace aace {
29 namespace alexa {
30 
35 public:
39  enum class SpeakerType {
40 
45 
50  };
51 
52  virtual void onLocalSetVolume( SpeakerType type, int8_t volume ) = 0;
53  virtual void onLocalAdjustVolume( SpeakerType type, int8_t delta ) = 0;
54  virtual void onLocalSetMute( SpeakerType type, bool mute ) = 0;
55 };
56 
57 inline std::ostream& operator<<(std::ostream& stream, const AlexaSpeakerEngineInterface::SpeakerType& type) {
58  switch (type) {
60  stream << "ALEXA_VOLUME";
61  break;
63  stream << "ALERTS_VOLUME";
64  break;
65  }
66  return stream;
67 }
68 
73 public:
77  enum class Initiator {
78 
82  HOLD_TO_TALK,
86  TAP_TO_TALK,
90  WAKEWORD
91  };
92 
93  /*
94  * Defines an unspecified value for the speech recognizer's audio index.
95  */
96  static constexpr uint64_t UNSPECIFIED_INDEX = std::numeric_limits<uint64_t>::max();
97 
98  virtual bool onStartCapture( Initiator initiator, uint64_t keywordBegin, uint64_t keywordEnd, const std::string& keyword ) = 0;
99  virtual bool onStopCapture() = 0;
100  virtual bool enableWakewordDetection() = 0;
101  virtual bool disableWakewordDetection() = 0;
102 };
103 
104 inline std::ostream& operator<<(std::ostream& stream, const SpeechRecognizerEngineInterface::Initiator& initiator) {
105  switch (initiator) {
107  stream << "HOLD_TO_TALK";
108  break;
110  stream << "TAP_TO_TALK";
111  break;
113  stream << "WAKEWORD";
114  break;
115  }
116  return stream;
117 }
118 
123 public:
124  virtual void onLocalStop() = 0;
125  virtual void removeAllAlerts() = 0;
126 };
127 
132 public:
136  enum class PlaybackButton {
140  PLAY,
144  PAUSE,
148  NEXT,
152  PREVIOUS,
156  SKIP_FORWARD,
160  SKIP_BACKWARD
161  };
162 
166  enum class PlaybackToggle {
170  SHUFFLE,
174  LOOP,
178  REPEAT,
182  THUMBS_UP,
186  THUMBS_DOWN
187  };
188 
189  virtual void onButtonPressed(PlaybackButton button) = 0;
190  virtual void onTogglePressed(PlaybackToggle toggle, bool action) = 0;
191 };
192 
197 public:
201  enum class AuthState {
202 
206  UNINITIALIZED,
207 
211  REFRESHED,
212 
216  EXPIRED,
217 
221  UNRECOVERABLE_ERROR
222  };
223 
227  enum class AuthError {
228 
232  NO_ERROR,
233 
237  UNKNOWN_ERROR,
238 
242  AUTHORIZATION_FAILED,
243 
247  UNAUTHORIZED_CLIENT,
248 
252  SERVER_ERROR,
253 
257  INVALID_REQUEST,
258 
262  INVALID_VALUE,
263 
267  AUTHORIZATION_EXPIRED,
268 
272  UNSUPPORTED_GRANT_TYPE,
273 
277  INVALID_CODE_PAIR,
278 
282  AUTHORIZATION_PENDING,
283 
287  SLOW_DOWN,
288 
292  INTERNAL_ERROR,
293 
297  INVALID_CBL_CLIENT_ID
298  };
299 
300  virtual void onAuthStateChanged( AuthState state, AuthError error ) = 0;
301 };
302 
303 inline std::ostream& operator<<(std::ostream& stream, const AuthProviderEngineInterface::AuthState& state) {
304  switch (state) {
306  stream << "UNINITIALIZED";
307  break;
309  stream << "REFRESHED";
310  break;
312  stream << "EXPIRED";
313  break;
315  stream << "UNRECOVERABLE_ERROR";
316  break;
317  }
318  return stream;
319 }
320 
321 inline std::ostream& operator<<(std::ostream& stream, const AuthProviderEngineInterface::AuthError& error) {
322  switch (error) {
324  stream << "NO_ERROR";
325  break;
327  stream << "UNKNOWN_ERROR";
328  break;
330  stream << "AUTHORIZATION_FAILED";
331  break;
333  stream << "UNAUTHORIZED_CLIENT";
334  break;
336  stream << "SERVER_ERROR";
337  break;
339  stream << "INVALID_REQUEST";
340  break;
342  stream << "INVALID_VALUE";
343  break;
345  stream << "AUTHORIZATION_EXPIRED";
346  break;
348  stream << "UNSUPPORTED_GRANT_TYPE";
349  break;
351  stream << "INVALID_CODE_PAIR";
352  break;
354  stream << "AUTHORIZATION_PENDING";
355  break;
357  stream << "SLOW_DOWN";
358  break;
360  stream << "INTERNAL_ERROR";
361  break;
363  stream << "INVALID_CBL_CLIENT_ID";
364  break;
365  }
366  return stream;
367 }
368 
373 public:
378  public:
380  std::string localPlayerId;
382  std::string spiVersion;
388  std::string validationMethod;
394  std::vector<std::string> validationData;
395  };
396 
397  virtual void onReportDiscoveredPlayers( const std::vector<DiscoveredPlayerInfo>& discoveredPlayers ) = 0;
398  virtual void onRequestToken( const std::string& localPlayerId ) = 0;
399  virtual void onLoginComplete( const std::string& localPlayerId ) = 0;
400  virtual void onLogoutComplete( const std::string& localPlayerId ) = 0;
401  virtual void onPlayerEvent( const std::string& localPlayerId, const std::string& eventName ) = 0;
402  virtual void onPlayerError( const std::string& localPlayerId, const std::string& errorName, long code, const std::string& description, bool fatal ) = 0;
403  virtual void onSetFocus( const std::string& playerId ) = 0;
404  virtual void onRemoveDiscoveredPlayer( const std::string& localPlayerId ) = 0;
405 };
406 
411 public:
412  virtual void onPlayerEvent( const std::string& eventName ) = 0;
413  virtual void onPlayerError( const std::string& errorName, long code, const std::string& description, bool fatal ) = 0;
414  virtual void onSetFocus() = 0;
415 };
416 
421 public:
422 
426  enum class EqualizerBand {
428  BASS,
430  MIDRANGE,
432  TREBLE
433  };
434 
439  using EqualizerBandLevel = std::pair<EqualizerBand,int>;
440 
448  virtual void onLocalSetBandLevels( const std::vector<EqualizerBandLevel>& bandLevels ) = 0;
449 
459  virtual void onLocalAdjustBandLevels( const std::vector<EqualizerBandLevel>& bandAdjustments ) = 0;
460 
467  virtual void onLocalResetBands( const std::vector<EqualizerBand>& bands ) = 0;
468 };
469 
476 inline std::string equalizerBandToString( const EqualizerControllerEngineInterface::EqualizerBand& band ) {
477  switch (band) {
479  return "BASS";
481  return "MIDRANGE";
483  return "TREBLE";
484  }
485  return "UNKNOWN";
486 }
487 
495 inline std::ostream& operator<<( std::ostream& stream, const EqualizerControllerEngineInterface::EqualizerBand& band ) {
496  stream << equalizerBandToString(band);
497  return stream;
498 }
499 
500 } // aace::alexa
501 } // aace
502 
503 #endif // AACE_ALEXA_ALEXA_ENGINE_INTERFACES_H
std::pair< EqualizerBand, int > EqualizerBandLevel
Definition: AlexaEngineInterfaces.h:439
Definition: AlexaEngineInterfaces.h:410
AuthState
Definition: AlexaEngineInterfaces.h:201
Definition: AlexaEngineInterfaces.h:72
Definition: AlexaEngineInterfaces.h:420
Definition: AlexaEngineInterfaces.h:122
AuthError
Definition: AlexaEngineInterfaces.h:227
PlaybackButton
Definition: AlexaEngineInterfaces.h:136
std::vector< std::string > validationData
Definition: AlexaEngineInterfaces.h:394
Definition: AddressBook.h:26
Definition: AlexaEngineInterfaces.h:372
std::string localPlayerId
The opaque token that uniquely identifies the local external player app.
Definition: AlexaEngineInterfaces.h:380
Definition: AlexaEngineInterfaces.h:131
std::string validationMethod
Definition: AlexaEngineInterfaces.h:388
PlaybackToggle
Definition: AlexaEngineInterfaces.h:166
std::string spiVersion
The only spiVersion that currently exists is "1.0".
Definition: AlexaEngineInterfaces.h:382
Definition: AlexaEngineInterfaces.h:196
SpeakerType
Definition: AlexaEngineInterfaces.h:39
Initiator
Definition: AlexaEngineInterfaces.h:77
Definition: AlexaEngineInterfaces.h:34
EqualizerBand
Definition: AlexaEngineInterfaces.h:426

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