AlexaClientSDK  3.0.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 SAMPLEAPP_SAMPLEAPPLICATION_H_
17 #define 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 
40 
41 #include "ConsoleReader.h"
42 
43 #include "SampleApp/GuiRenderer.h"
45 #include "UserInputManager.h"
46 
47 #ifdef GSTREAMER_MEDIA_PLAYER
49 #elif defined(ANDROID_MEDIA_PLAYER)
51 #endif
52 
53 #ifdef BLUETOOTH_BLUEZ_PULSEAUDIO_OVERRIDE_ENDPOINTS
55 #endif
56 
57 namespace alexaClientSDK {
58 namespace sampleApp {
59 
62 public:
73  static std::unique_ptr<SampleApplication> create(
74  std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader,
75  const std::vector<std::string>& configFiles,
76  const std::string& logLevel = "",
77  std::shared_ptr<avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface> diagnostics = nullptr);
78 
85 
86 #ifdef DIAGNOSTICS
87 
94  bool initiateRestart();
95 #endif
96 
99 
105  std::shared_ptr<alexaClientSDK::defaultClient::DefaultClient> getDefaultClient();
106 
115  const std::shared_ptr<avsCommon::sdkInterfaces::HTTPContentFetcherInterfaceFactoryInterface>&
116  httpContentFetcherFactory,
117  std::shared_ptr<defaultClient::EqualizerRuntimeSetup> equalizerRuntimeSetup);
118 
124  public:
132  const std::string& playerId,
134  };
135 
142  public:
150  const std::string& playerId,
152  };
153 
154 private:
165  bool initialize(
166  std::shared_ptr<alexaClientSDK::sampleApp::ConsoleReader> consoleReader,
167  const std::vector<std::string>& configFiles,
168  const std::string& logLevel,
169  std::shared_ptr<avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface> diagnostics);
170 
180  std::shared_ptr<avsCommon::sdkInterfaces::ApplicationMediaInterfaces> createApplicationMediaPlayer(
181  const std::shared_ptr<avsCommon::sdkInterfaces::HTTPContentFetcherInterfaceFactoryInterface>&
182  httpContentFetcherFactory,
183  bool enableEqualizer,
184  const std::string& name,
185  bool enableLiveMode = false);
186 
187 #ifdef ENABLE_ENDPOINT_CONTROLLERS
188 
196  bool addControllersToDefaultEndpoint(
197  std::shared_ptr<avsCommon::sdkInterfaces::endpoints::EndpointBuilderInterface> defaultEndpointBuilder);
198 
207  bool addControllersToPeripheralEndpoint(
208  std::shared_ptr<avsCommon::sdkInterfaces::endpoints::EndpointBuilderInterface> peripheralEndpointBuilder,
209  std::shared_ptr<avsCommon::sdkInterfaces::diagnostics::DiagnosticsInterface> diagnostics);
210 #endif
211  std::shared_ptr<acsdkShutdownManagerInterfaces::ShutdownManagerInterface> m_shutdownManager;
213 
215  std::shared_ptr<avsCommon::avs::initialization::AlexaClientSDKInit> m_sdkInit;
216 
218  std::shared_ptr<alexaClientSDK::defaultClient::DefaultClient> m_client;
219 
221  std::shared_ptr<sampleApplications::common::InteractionManager> m_interactionManager;
222 
224  std::shared_ptr<UserInputManager> m_userInputManager;
225 
227  std::shared_ptr<GuiRenderer> m_guiRenderer;
228 
230  std::unordered_map<std::string, std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>>
231  m_externalMusicProviderMediaPlayersMap;
232 
234  std::unordered_map<std::string, std::shared_ptr<avsCommon::sdkInterfaces::SpeakerInterface>>
235  m_externalMusicProviderSpeakersMap;
236 
238  std::vector<std::shared_ptr<avsCommon::utils::RequiresShutdown>> m_shutdownRequiredList;
239 
241  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_speakMediaPlayer;
242 
244  std::vector<std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface>> m_audioMediaPlayerPool;
245 
247  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_alertsMediaPlayer;
248 
250  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_notificationsMediaPlayer;
251 
253  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_bluetoothMediaPlayer;
254 
256  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_systemSoundMediaPlayer;
257 
258 #ifdef ENABLE_COMMS_AUDIO_PROXY
259  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_commsMediaPlayer;
261 #endif
262 
263 #ifdef ENABLE_PCC
264  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_phoneMediaPlayer;
266 #endif
267 
269  std::shared_ptr<alexaClientSDK::capabilitiesDelegate::CapabilitiesDelegate> m_capabilitiesDelegate;
270 
272  std::shared_ptr<avsCommon::utils::mediaPlayer::MediaPlayerInterface> m_ringtoneMediaPlayer;
273 
275  static std::unordered_map<std::string, avsCommon::sdkInterfaces::ChannelVolumeInterface::Type>
276  m_playerToSpeakerTypeMap;
277 
280 
281 #if defined(ANDROID_MEDIA_PLAYER) || defined(ANDROID_MICROPHONE)
282  std::shared_ptr<applicationUtilities::androidUtilities::AndroidSLESEngine> m_openSlEngine;
284 #endif
285 
286 #ifdef BLUETOOTH_BLUEZ_PULSEAUDIO_OVERRIDE_ENDPOINTS
287  std::shared_ptr<bluetoothImplementations::blueZ::PulseAudioBluetoothInitializer> m_pulseAudioInitializer;
289 #endif
290 
291 #ifdef POWER_CONTROLLER
292  std::shared_ptr<sampleApplications::common::PeripheralEndpointPowerControllerHandler>
294  m_peripheralEndpointPowerHandler;
295 #endif
296 
297 #ifdef TOGGLE_CONTROLLER
298  std::shared_ptr<sampleApplications::common::PeripheralEndpointToggleControllerHandler>
300  m_peripheralEndpointToggleHandler;
301 #endif
302 
303 #ifdef RANGE_CONTROLLER
304  std::shared_ptr<sampleApplications::common::PeripheralEndpointRangeControllerHandler>
306  m_peripheralEndpointRangeHandler;
307 #endif
308 
309 #ifdef MODE_CONTROLLER
310  std::shared_ptr<sampleApplications::common::PeripheralEndpointModeControllerHandler>
312  m_peripheralEndpointModeHandler;
313 #endif
314 
316  std::shared_ptr<acsdkAuthorization::AuthorizationManager> m_authManager;
317 
319  std::shared_ptr<acsdkAuthorization::lwa::LWAAuthorizationAdapter> m_lwaAdapter;
320 };
321 
322 } // namespace sampleApp
323 } // namespace alexaClientSDK
324 
325 #endif // SAMPLEAPP_SAMPLEAPPLICATION_H_
std::shared_ptr< alexaClientSDK::defaultClient::DefaultClient > getDefaultClient()
::std::string string
Definition: gtest-port.h:1097
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
~SampleApplication()
Destructor which manages the SampleApplication shutdown sequence.
std::unordered_map< std::string, AdapterCreateFunction > AdapterCreationMap
Definition: ExternalMediaPlayer.h:106
SampleAppReturnCode
Definition: SampleApplicationReturnCodes.h:24
AdapterRegistration(const std::string &playerId, acsdkExternalMediaPlayer::ExternalMediaPlayer::AdapterCreateFunction createFunction)
Class to manage the top-level components of the AVS Client Application.
Definition: SampleApplication.h:61
bool createMediaPlayersForAdapters(const std::shared_ptr< avsCommon::sdkInterfaces::HTTPContentFetcherInterfaceFactoryInterface > &httpContentFetcherFactory, std::shared_ptr< defaultClient::EqualizerRuntimeSetup > equalizerRuntimeSetup)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
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)

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