AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SampleApplication.h
Go to the documentation of this file.
1 /*
2  * Copyright 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 ALEXA_CLIENT_SDK_SAMPLEAPP_INCLUDE_SAMPLEAPP_SAMPLEAPPLICATION_H_
17 #define ALEXA_CLIENT_SDK_SAMPLEAPP_INCLUDE_SAMPLEAPP_SAMPLEAPPLICATION_H_
18 
19 #include <fstream>
20 #include <map>
21 #include <memory>
22 #include <tuple>
23 #include <unordered_map>
24 #include <utility>
25 #include <vector>
26 
37 
38 #ifdef AUTH_MANAGER
41 #endif
42 
43 #include "ConsolePrinter.h"
44 #include "ConsoleReader.h"
45 
46 #include "SampleApp/GuiRenderer.h"
48 #include "UserInputManager.h"
49 
50 #ifdef KWD
52 #endif
53 
54 #ifdef GSTREAMER_MEDIA_PLAYER
56 #elif defined(ANDROID_MEDIA_PLAYER)
58 #endif
59 
60 #ifdef BLUETOOTH_BLUEZ_PULSEAUDIO_OVERRIDE_ENDPOINTS
62 #endif
63 
64 namespace alexaClientSDK {
65 namespace sampleApp {
66 
69 public:
80  static std::unique_ptr<SampleApplication> create(
81  std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader,
82  const std::vector<std::string>& configFiles,
83  const std::string& logLevel = "",
84  std::shared_ptr<avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface> diagnostics = nullptr);
85 
92 
93 #ifdef DIAGNOSTICS
94 
101  bool initiateRestart();
102 #endif
103 
106 
112  std::shared_ptr<alexaClientSDK::defaultClient::DefaultClient> getDefaultClient();
113 
122  const std::shared_ptr<avsCommon::sdkInterfaces::HTTPContentFetcherInterfaceFactoryInterface>&
123  httpContentFetcherFactory,
124  std::shared_ptr<defaultClient::EqualizerRuntimeSetup> equalizerRuntimeSetup);
125 
131  public:
139  const std::string& playerId,
141  };
142 
149  public:
157  const std::string& playerId,
159  };
160 
161 private:
172  bool initialize(
173  std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader,
174  const std::vector<std::string>& configFiles,
175  const std::string& logLevel,
176  std::shared_ptr<avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface> diagnostics);
177 
187  std::shared_ptr<avsCommon::sdkInterfaces::ApplicationMediaInterfaces> createApplicationMediaPlayer(
188  const std::shared_ptr<avsCommon::sdkInterfaces::HTTPContentFetcherInterfaceFactoryInterface>&
189  httpContentFetcherFactory,
190  bool enableEqualizer,
191  const std::string& name,
192  bool enableLiveMode = false);
193 
194 #ifdef ENABLE_ENDPOINT_CONTROLLERS
195 
203  bool addControllersToDefaultEndpoint(
204  std::shared_ptr<avsCommon::sdkInterfaces::endpoints::EndpointBuilderInterface> defaultEndpointBuilder);
205 
214  bool addControllersToPeripheralEndpoint(
215  std::shared_ptr<avsCommon::sdkInterfaces::endpoints::EndpointBuilderInterface> peripheralEndpointBuilder,
216  std::shared_ptr<avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface> diagnostics);
217 #endif
218  std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownManagerInterface> m_shutdownManager;
220 
222  std::shared_ptr<avsCommon::avs::initialization::AlexaClientSDKInit> m_sdkInit;
223 
225  std::shared_ptr<alexaClientSDK::defaultClient::DefaultClient> m_client;
226 
228  std::shared_ptr<InteractionManager> m_interactionManager;
229 
231  std::shared_ptr<UserInputManager> m_userInputManager;
232 
234  std::shared_ptr<GuiRenderer> m_guiRenderer;
235 
237  std::unordered_map<std::string, std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>>
238  m_externalMusicProviderMediaPlayersMap;
239 
241  std::unordered_map<std::string, std::shared_ptr<avsCommon::sdkInterfaces::SpeakerInterface>>
242  m_externalMusicProviderSpeakersMap;
243 
245  std::vector<std::shared_ptr<avsCommon::utils::RequiresShutdown>> m_shutdownRequiredList;
246 
248  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_speakMediaPlayer;
249 
251  std::vector<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>> m_audioMediaPlayerPool;
252 
254  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_alertsMediaPlayer;
255 
257  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_notificationsMediaPlayer;
258 
260  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_bluetoothMediaPlayer;
261 
263  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_systemSoundMediaPlayer;
264 
265 #ifdef ENABLE_COMMS_AUDIO_PROXY
266  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_commsMediaPlayer;
268 #endif
269 
270 #ifdef ENABLE_PCC
271  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_phoneMediaPlayer;
273 #endif
274 
276  std::shared_ptr<alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate> m_capabilitiesDelegate;
277 
279  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_ringtoneMediaPlayer;
280 
282  static std::unordered_map<std::string, avsCommon::sdkInterfaces::ChannelVolumeInterface::Type>
283  m_playerToSpeakerTypeMap;
284 
287 
288 #ifdef KWD
289  std::shared_ptr<acsdkKWDImplementations::AbstractKeywordDetector> m_keywordDetector;
291 #endif
292 
293 #if defined(ANDROID_MEDIA_PLAYER) || defined(ANDROID_MICROPHONE)
294  std::shared_ptr<applicationUtilities::androidUtilities::AndroidSLESEngine> m_openSlEngine;
296 #endif
297 
298 #ifdef BLUETOOTH_BLUEZ_PULSEAUDIO_OVERRIDE_ENDPOINTS
299  std::shared_ptr<bluetoothImplementations::blueZ::PulseAudioBluetoothInitializer> m_pulseAudioInitializer;
301 #endif
302 
303 #ifdef POWER_CONTROLLER
304  std::shared_ptr<PeripheralEndpointPowerControllerHandler> m_peripheralEndpointPowerHandler;
306 #endif
307 
308 #ifdef TOGGLE_CONTROLLER
309  std::shared_ptr<PeripheralEndpointToggleControllerHandler> m_peripheralEndpointToggleHandler;
311 #endif
312 
313 #ifdef RANGE_CONTROLLER
314  std::shared_ptr<PeripheralEndpointRangeControllerHandler> m_peripheralEndpointRangeHandler;
316 #endif
317 
318 #ifdef MODE_CONTROLLER
319  std::shared_ptr<PeripheralEndpointModeControllerHandler> m_peripheralEndpointModeHandler;
321 #endif
322 
323 #ifdef AUTH_MANAGER
324  std::shared_ptr<acsdkAuthorization::AuthorizationManager> m_authManager;
326 
328  std::shared_ptr<acsdkAuthorization::lwa::LWAAuthorizationAdapter> m_lwaAdapter;
329 #endif
330 };
331 
332 } // namespace sampleApp
333 } // namespace alexaClientSDK
334 
335 #endif // ALEXA_CLIENT_SDK_SAMPLEAPP_INCLUDE_SAMPLEAPP_SAMPLEAPPLICATION_H_
CryptoFactoryInterface.h
AbstractKeywordDetector.h
GuiRenderer.h
DiagnosticsInterface.h
alexaClientSDK::sampleApp::SampleApplication::create
static std::unique_ptr< SampleApplication > create(std::shared_ptr< alexaClientSDK::sampleApp::ConsoleReader > consoleReader, const std::vector< std::string > &configFiles, const std::string &logLevel="", std::shared_ptr< avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface > diagnostics=nullptr)
Definition: SampleApplication.cpp:673
alexaClientSDK::acsdkExternalMediaPlayer::ExternalMediaPlayer::AdapterCreationMap
std::unordered_map< std::string, AdapterCreateFunction > AdapterCreationMap
Definition: ExternalMediaPlayer.h:106
alexaClientSDK::sampleApp::SampleApplication::AdapterRegistration
Definition: SampleApplication.h:130
alexaClientSDK::sampleApp::SampleApplication::getDefaultClient
std::shared_ptr< alexaClientSDK::defaultClient::DefaultClient > getDefaultClient()
Definition: SampleApplication.cpp:744
KeyStoreInterface.h
PulseAudioBluetoothInitializer.h
SampleApplicationReturnCodes.h
LWAAuthorizationAdapter.h
alexaClientSDK::sampleApp::SampleApplication::MediaPlayerRegistration
Definition: SampleApplication.h:148
alexaClientSDK::sampleApp::SampleApplication::createMediaPlayersForAdapters
bool createMediaPlayersForAdapters(const std::shared_ptr< avsCommon::sdkInterfaces::HTTPContentFetcherInterfaceFactoryInterface > &httpContentFetcherFactory, std::shared_ptr< defaultClient::EqualizerRuntimeSetup > equalizerRuntimeSetup)
Definition: SampleApplication.cpp:748
EqualizerRuntimeSetup.h
alexaClientSDK::sampleApp::SampleApplication::~SampleApplication
~SampleApplication()
Destructor which manages the SampleApplication shutdown sequence.
Definition: SampleApplication.cpp:724
PooledMediaPlayerFactory.h
ConsolePrinter.h
MediaPlayer.h
CapabilitiesDelegate.h
alexaClientSDK::sampleApp::SampleApplication
Class to manage the top-level components of the AVS Client Application.
Definition: SampleApplication.h:68
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::acsdkExternalMediaPlayer::ExternalMediaPlayer::AdapterCreateFunction
std::shared_ptr< acsdkExternalMediaPlayerInterfaces::ExternalMediaAdapterInterface >(*)(std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface >, std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerInterface > mediaPlayer, std::shared_ptr< avsCommon::sdkInterfaces::ChannelVolumeInterface > speaker, std::shared_ptr< avsCommon::sdkInterfaces::SpeakerManagerInterface > speakerManager, std::shared_ptr< avsCommon::sdkInterfaces::MessageSenderInterface > messageSender, std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface > focusManager, std::shared_ptr< avsCommon::sdkInterfaces::ContextManagerInterface > contextManager, std::shared_ptr< acsdkExternalMediaPlayerInterfaces::ExternalMediaPlayerInterface > externalMediaPlayer) AdapterCreateFunction
Definition: ExternalMediaPlayer.h:103
AlexaClientSDKInit.h
alexaClientSDK::sampleApp::SampleAppReturnCode
SampleAppReturnCode
Definition: SampleApplicationReturnCodes.h:24
UserInputManager.h
AndroidSLESMediaPlayer.h
ApplicationMediaInterfaces.h
alexaClientSDK::avsCommon::sdkInterfaces::ChannelVolumeInterface::Type
Type
Definition: ChannelVolumeInterface.h:37
alexaClientSDK::sampleApp::SampleApplication::AdapterRegistration::AdapterRegistration
AdapterRegistration(const std::string &playerId, acsdkExternalMediaPlayer::ExternalMediaPlayer::AdapterCreateFunction createFunction)
Definition: SampleApplication.cpp:691
alexaClientSDK::sampleApp::SampleApplication::run
SampleAppReturnCode run()
Definition: SampleApplication.cpp:713
ExternalMediaPlayer.h
ConsoleReader.h
ChannelVolumeInterface.h
AuthorizationManager.h
alexaClientSDK::sampleApp::SampleApplication::MediaPlayerRegistration::MediaPlayerRegistration
MediaPlayerRegistration(const std::string &playerId, avsCommon::sdkInterfaces::ChannelVolumeInterface::Type speakerType)
Definition: SampleApplication.cpp:702

AlexaClientSDK 1.26.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0