Alexa Auto SDK  2.3.1
AlexaEngineInterfaces.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_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(
99  Initiator initiator,
100  uint64_t keywordBegin,
101  uint64_t keywordEnd,
102  const std::string& keyword) = 0;
103  virtual bool onStopCapture() = 0;
104  virtual bool enableWakewordDetection() = 0;
105  virtual bool disableWakewordDetection() = 0;
106 };
107 
108 inline std::ostream& operator<<(std::ostream& stream, const SpeechRecognizerEngineInterface::Initiator& initiator) {
109  switch (initiator) {
111  stream << "HOLD_TO_TALK";
112  break;
114  stream << "TAP_TO_TALK";
115  break;
117  stream << "WAKEWORD";
118  break;
119  }
120  return stream;
121 }
122 
127 public:
128  virtual void onLocalStop() = 0;
129  virtual void removeAllAlerts() = 0;
130 };
131 
136 public:
140  enum class PlaybackButton {
144  PLAY,
148  PAUSE,
152  NEXT,
156  PREVIOUS,
160  SKIP_FORWARD,
164  SKIP_BACKWARD
165  };
166 
170  enum class PlaybackToggle {
174  SHUFFLE,
178  LOOP,
182  REPEAT,
186  THUMBS_UP,
190  THUMBS_DOWN
191  };
192 
193  virtual void onButtonPressed(PlaybackButton button) = 0;
194  virtual void onTogglePressed(PlaybackToggle toggle, bool action) = 0;
195 };
196 
201 public:
205  enum class AuthState {
206 
210  UNINITIALIZED,
211 
215  REFRESHED,
216 
220  EXPIRED,
221 
225  UNRECOVERABLE_ERROR
226  };
227 
231  enum class AuthError {
232 
236  NO_ERROR,
237 
241  UNKNOWN_ERROR,
242 
246  AUTHORIZATION_FAILED,
247 
251  UNAUTHORIZED_CLIENT,
252 
256  SERVER_ERROR,
257 
261  INVALID_REQUEST,
262 
266  INVALID_VALUE,
267 
271  AUTHORIZATION_EXPIRED,
272 
276  UNSUPPORTED_GRANT_TYPE,
277 
281  INVALID_CODE_PAIR,
282 
286  AUTHORIZATION_PENDING,
287 
291  SLOW_DOWN,
292 
296  INTERNAL_ERROR,
297 
301  INVALID_CBL_CLIENT_ID
302  };
303 
304  virtual void onAuthStateChanged(AuthState state, AuthError error) = 0;
305 };
306 
307 inline std::ostream& operator<<(std::ostream& stream, const AuthProviderEngineInterface::AuthState& state) {
308  switch (state) {
310  stream << "UNINITIALIZED";
311  break;
313  stream << "REFRESHED";
314  break;
316  stream << "EXPIRED";
317  break;
319  stream << "UNRECOVERABLE_ERROR";
320  break;
321  }
322  return stream;
323 }
324 
325 inline std::ostream& operator<<(std::ostream& stream, const AuthProviderEngineInterface::AuthError& error) {
326  switch (error) {
328  stream << "NO_ERROR";
329  break;
331  stream << "UNKNOWN_ERROR";
332  break;
334  stream << "AUTHORIZATION_FAILED";
335  break;
337  stream << "UNAUTHORIZED_CLIENT";
338  break;
340  stream << "SERVER_ERROR";
341  break;
343  stream << "INVALID_REQUEST";
344  break;
346  stream << "INVALID_VALUE";
347  break;
349  stream << "AUTHORIZATION_EXPIRED";
350  break;
352  stream << "UNSUPPORTED_GRANT_TYPE";
353  break;
355  stream << "INVALID_CODE_PAIR";
356  break;
358  stream << "AUTHORIZATION_PENDING";
359  break;
361  stream << "SLOW_DOWN";
362  break;
364  stream << "INTERNAL_ERROR";
365  break;
367  stream << "INVALID_CBL_CLIENT_ID";
368  break;
369  }
370  return stream;
371 }
372 
377 public:
382  public:
384  std::string localPlayerId;
386  std::string spiVersion;
392  std::string validationMethod;
398  std::vector<std::string> validationData;
399  };
400 
401  virtual void onReportDiscoveredPlayers(const std::vector<DiscoveredPlayerInfo>& discoveredPlayers) = 0;
402  virtual void onRequestToken(const std::string& localPlayerId) = 0;
403  virtual void onLoginComplete(const std::string& localPlayerId) = 0;
404  virtual void onLogoutComplete(const std::string& localPlayerId) = 0;
405  virtual void onPlayerEvent(const std::string& localPlayerId, const std::string& eventName) = 0;
406  virtual void onPlayerError(
407  const std::string& localPlayerId,
408  const std::string& errorName,
409  long code,
410  const std::string& description,
411  bool fatal) = 0;
412  virtual void onSetFocus(const std::string& playerId) = 0;
413  virtual void onRemoveDiscoveredPlayer(const std::string& localPlayerId) = 0;
414 };
415 
420 public:
421  virtual void onPlayerEvent(const std::string& eventName) = 0;
422  virtual void onPlayerError(const std::string& errorName, long code, const std::string& description, bool fatal) = 0;
423  virtual void onSetFocus(bool focusAcquire = true) = 0;
424 };
425 
430 public:
438  virtual bool onDoNotDisturbChanged(const bool doNotDisturb) = 0;
439 };
440 
445 public:
449  enum class EqualizerBand {
451  BASS,
453  MIDRANGE,
455  TREBLE
456  };
457 
462  using EqualizerBandLevel = std::pair<EqualizerBand, int>;
463 
471  virtual void onLocalSetBandLevels(const std::vector<EqualizerBandLevel>& bandLevels) = 0;
472 
482  virtual void onLocalAdjustBandLevels(const std::vector<EqualizerBandLevel>& bandAdjustments) = 0;
483 
490  virtual void onLocalResetBands(const std::vector<EqualizerBand>& bands) = 0;
491 };
492 
500  switch (band) {
502  return "BASS";
504  return "MIDRANGE";
506  return "TREBLE";
507  }
508  return "UNKNOWN";
509 }
510 
518 inline std::ostream& operator<<(std::ostream& stream, const EqualizerControllerEngineInterface::EqualizerBand& band) {
519  stream << equalizerBandToString(band);
520  return stream;
521 }
522 
527 public:
536  virtual int64_t onGetPlayerPosition() = 0;
537 
544  virtual int64_t onGetPlayerDuration() = 0;
545 };
546 
551 public:
556  virtual void onDisplayCardCleared() = 0;
557 };
558 
563 public:
564  virtual void onStopForegroundActivity() = 0;
565 };
566 
567 } // namespace alexa
568 } // namespace aace
569 
570 #endif // AACE_ALEXA_ALEXA_ENGINE_INTERFACES_H
Definition: AlexaEngineInterfaces.h:429
Definition: AlexaEngineInterfaces.h:562
Definition: AlexaEngineInterfaces.h:419
AuthState
Definition: AlexaEngineInterfaces.h:205
Definition: AlexaEngineInterfaces.h:72
Definition: AlexaEngineInterfaces.h:444
Definition: AlexaEngineInterfaces.h:126
AuthError
Definition: AlexaEngineInterfaces.h:231
PlaybackButton
Definition: AlexaEngineInterfaces.h:140
std::vector< std::string > validationData
Definition: AlexaEngineInterfaces.h:398
Definition: AlexaEngineInterfaces.h:526
std::string equalizerBandToString(const EqualizerControllerEngineInterface::EqualizerBand &band)
Definition: AlexaEngineInterfaces.h:499
Definition: AddressBook.h:26
Definition: AlexaEngineInterfaces.h:376
std::string localPlayerId
The opaque token that uniquely identifies the local external player app.
Definition: AlexaEngineInterfaces.h:384
Definition: AlexaEngineInterfaces.h:135
std::pair< EqualizerBand, int > EqualizerBandLevel
Definition: AlexaEngineInterfaces.h:462
std::string validationMethod
Definition: AlexaEngineInterfaces.h:392
PlaybackToggle
Definition: AlexaEngineInterfaces.h:170
Definition: AlexaEngineInterfaces.h:550
std::string spiVersion
The only spiVersion that currently exists is "1.0".
Definition: AlexaEngineInterfaces.h:386
Definition: AlexaEngineInterfaces.h:200
SpeakerType
Definition: AlexaEngineInterfaces.h:39
Initiator
Definition: AlexaEngineInterfaces.h:77
Definition: AlexaEngineInterfaces.h:34
EqualizerBand
Definition: AlexaEngineInterfaces.h:449

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