AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
alexaClientSDK::avsCommon::avs::DialogUXStateAggregator Class Reference

#include <DialogUXStateAggregator.h>

Inheritance diagram for alexaClientSDK::avsCommon::avs::DialogUXStateAggregator:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::avsCommon::avs::DialogUXStateAggregator:
Collaboration graph
[legend]

Public Member Functions

 DialogUXStateAggregator (std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr, std::chrono::milliseconds timeoutForThinkingToIdle=LONG_TIMEOUT_FOR_THINKING_TO_IDLE, std::chrono::milliseconds timeoutForListeningToIdle=LONG_TIMEOUT_FOR_LISTENING_TO_IDLE, std::chrono::milliseconds shortTimeoutForThinkingToIdle=SHORT_TIMEOUT_FOR_THINKING_TO_IDLE)
 
void addObserver (std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface > observer)
 
void removeObserver (std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface > observer)
 
AudioInputProcessorObserverInterface Functions
void onStateChanged (sdkInterfaces::AudioInputProcessorObserverInterface::State state) override
 
SpeechSynthesizerObserverInterface Functions
void onStateChanged (sdkInterfaces::SpeechSynthesizerObserverInterface::SpeechSynthesizerState state, const avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId mediaSourceId, const avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState > &mediaPlayerState, const std::vector< avsCommon::utils::audioAnalyzer::AudioAnalyzerState > &audioAnalyzerState) override
 
InteractionModelRequestProcessingObserverInterface Functions
void onRequestProcessingStarted () override
 
void onRequestProcessingCompleted () override
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
virtual ~AudioInputProcessorObserverInterface ()=default
 Destructor. More...
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::SpeechSynthesizerObserverInterface
virtual ~SpeechSynthesizerObserverInterface ()=default
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
virtual ~ConnectionStatusObserverInterface ()=default
 
virtual void onConnectionStatusChanged (const Status status, const std::vector< EngineConnectionStatus > &engineStatuses)
 
- Public Member Functions inherited from alexaClientSDK::acsdkInteractionModelInterfaces::InteractionModelRequestProcessingObserverInterface
virtual ~InteractionModelRequestProcessingObserverInterface ()=default
 Destructor. More...
 

Static Public Member Functions

static std::shared_ptr< DialogUXStateAggregatorcreateDialogUXStateAggregator (const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &metricRecorder, const std::shared_ptr< avsCommon::sdkInterfaces::AVSConnectionManagerInterface > &connectionManager, const std::shared_ptr< acsdkInteractionModelInterfaces::InteractionModelNotifierInterface > &interactionModelNotifier)
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
static std::string stateToString (State state)
 

Static Public Attributes

static constexpr std::chrono::milliseconds SHORT_TIMEOUT_FOR_THINKING_TO_IDLE = std::chrono::milliseconds{200}
 
static constexpr std::chrono::seconds LONG_TIMEOUT_FOR_THINKING_TO_IDLE = std::chrono::seconds{8}
 
static constexpr std::chrono::seconds LONG_TIMEOUT_FOR_LISTENING_TO_IDLE = std::chrono::seconds{8}
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface
enum  State { State::IDLE, State::EXPECTING_SPEECH, State::RECOGNIZING, State::BUSY }
 The different states the AudioInputProcessor can be in. More...
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::SpeechSynthesizerObserverInterface
enum  SpeechSynthesizerState {
  SpeechSynthesizerState::PLAYING, SpeechSynthesizerState::FINISHED, SpeechSynthesizerState::INTERRUPTED, SpeechSynthesizerState::GAINING_FOCUS,
  SpeechSynthesizerState::LOSING_FOCUS
}
 
- Public Types inherited from alexaClientSDK::avsCommon::sdkInterfaces::ConnectionStatusObserverInterface
enum  Status { Status::DISCONNECTED, Status::PENDING, Status::CONNECTED }
 
enum  ChangedReason {
  ChangedReason::NONE, ChangedReason::SUCCESS, ChangedReason::UNRECOVERABLE_ERROR, ChangedReason::ACL_CLIENT_REQUEST,
  ChangedReason::ACL_DISABLED, ChangedReason::DNS_TIMEDOUT, ChangedReason::CONNECTION_TIMEDOUT, ChangedReason::CONNECTION_THROTTLED,
  ChangedReason::INVALID_AUTH, ChangedReason::PING_TIMEDOUT, ChangedReason::WRITE_TIMEDOUT, ChangedReason::READ_TIMEDOUT,
  ChangedReason::FAILURE_PROTOCOL_ERROR, ChangedReason::INTERNAL_ERROR, ChangedReason::SERVER_INTERNAL_ERROR, ChangedReason::SERVER_SIDE_DISCONNECT,
  ChangedReason::SERVER_ENDPOINT_CHANGED
}
 

Detailed Description

This class serves as a component to aggregate other observer interfaces into one UX component that notifies observers of AVS dialog specific UX changes based on events that occur within these components.

Constructor & Destructor Documentation

◆ DialogUXStateAggregator()

alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::DialogUXStateAggregator ( std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface metricRecorder = nullptr,
std::chrono::milliseconds  timeoutForThinkingToIdle = LONG_TIMEOUT_FOR_THINKING_TO_IDLE,
std::chrono::milliseconds  timeoutForListeningToIdle = LONG_TIMEOUT_FOR_LISTENING_TO_IDLE,
std::chrono::milliseconds  shortTimeoutForThinkingToIdle = SHORT_TIMEOUT_FOR_THINKING_TO_IDLE 
)

Constructor.

Note: Additional parameters to this class must be added before the timeout parameters

Parameters
metricRecorderThe metric recorder.
timeoutForThinkingToIdleThis timeout will be used to time out from the THINKING state in case no messages arrive from AVS.
timeoutForListeningToIdleThis timeout will be used to time out from the LISTENING state in case the Request Processing Started (RPS) directive is not received from AVS.
shortTimeoutForThinkingToIdleThis timeout will be used to avoid going to the IDLE state immediately

Member Function Documentation

◆ addObserver()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::addObserver ( std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface observer)

Adds an observer to be notified of UX state changes.

Warning
The user of this class must make sure that the observer remains valid until the destruction of this object as state changes may come in at any time, leading to callbacks to the observer. Failure to do so may result in crashes when this class attempts to access its observers.
Parameters
observerThe new observer to notify of UX state changes.

◆ createDialogUXStateAggregator()

std::shared_ptr< DialogUXStateAggregator > alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::createDialogUXStateAggregator ( const std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > &  metricRecorder,
const std::shared_ptr< avsCommon::sdkInterfaces::AVSConnectionManagerInterface > &  connectionManager,
const std::shared_ptr< acsdkInteractionModelInterfaces::InteractionModelNotifierInterface > &  interactionModelNotifier 
)
static

Factory method for the DialogUXStateAggregator.

Note
This factory method uses the default timeout values for DialogUXStateAggregator.
Parameters
metricRecorderThe metric recorder.
connectionManagerThe connection manager that this DialogUXStateAggregator will observe.
interactionModelNotifierThe object that will relay InteractionModel notifications to this DialogUXStateAggregator.
Returns
A std::shared_ptr<DialogUXStateAggregator>.

◆ onRequestProcessingCompleted()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onRequestProcessingCompleted ( )
overridevirtual

Used to notify the observer that a Request Processing Completed was received.

It is possible that the cloud sends RPC without sending RPS. In those situations, if we are in LISTENING state, switch back to IDLE.

Implements alexaClientSDK::acsdkInteractionModelInterfaces::InteractionModelRequestProcessingObserverInterface.

◆ onRequestProcessingStarted()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onRequestProcessingStarted ( )
overridevirtual

Used to notify the observer that a Request Processing Started was received.

Implements alexaClientSDK::acsdkInteractionModelInterfaces::InteractionModelRequestProcessingObserverInterface.

◆ onStateChanged() [1/2]

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onStateChanged ( sdkInterfaces::AudioInputProcessorObserverInterface::State  state)
overridevirtual

This function is called when the state of the observed AudioInputProcessor changes. This function will block processing of audio inputs, so implementations should return quickly.

Parameters
stateThe new state of the AudioInputProcessor.

Implements alexaClientSDK::avsCommon::sdkInterfaces::AudioInputProcessorObserverInterface.

◆ onStateChanged() [2/2]

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::onStateChanged ( sdkInterfaces::SpeechSynthesizerObserverInterface::SpeechSynthesizerState  state,
const avsCommon::utils::mediaPlayer::MediaPlayerInterface::SourceId  mediaSourceId,
const avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState > &  mediaPlayerState,
const std::vector< avsCommon::utils::audioAnalyzer::AudioAnalyzerState > &  audioAnalyzerState 
)
overridevirtual

Notification that the SpeechSynthesizer state has changed. Callback functions must return as soon as possible.

Parameters
stateThe new state of the speechSynthesizer.
mediaSourceIdThe current media source id for SpeechSynthesizer
mediaPlayerStateOptional state of the media player as of this state change. The Optional is blank if the state is unavailable.
audioAnalyzerStatestates of the audio analyzers related to the speech output.

Implements alexaClientSDK::avsCommon::sdkInterfaces::SpeechSynthesizerObserverInterface.

◆ removeObserver()

void alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::removeObserver ( std::shared_ptr< sdkInterfaces::DialogUXStateObserverInterface observer)

Removes an observer from the internal collection of observers synchronously. If the observer is not present, nothing will happen.

Note
This is a synchronous call which can not be made by an observer callback. Attempting to call removeObserver() from DialogUXStateObserverInterface::onDialogUXStateChanged() will result in a deadlock.
Parameters
observerThe observer to remove.

Member Data Documentation

◆ LONG_TIMEOUT_FOR_LISTENING_TO_IDLE

constexpr std::chrono::seconds alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::LONG_TIMEOUT_FOR_LISTENING_TO_IDLE = std::chrono::seconds{8}
static

This timeout will be used to time out from the LISTENING state in case the Request Processing Started (RPS) directive is not received from AVS so that the client may move back to an IDLE state.

◆ LONG_TIMEOUT_FOR_THINKING_TO_IDLE

constexpr std::chrono::seconds alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::LONG_TIMEOUT_FOR_THINKING_TO_IDLE = std::chrono::seconds{8}
static

This timeout will be used to time out from the THINKING state in case no messages arrive from AVS so that the client may move back to an IDLE state.

◆ SHORT_TIMEOUT_FOR_THINKING_TO_IDLE

constexpr std::chrono::milliseconds alexaClientSDK::avsCommon::avs::DialogUXStateAggregator::SHORT_TIMEOUT_FOR_THINKING_TO_IDLE = std::chrono::milliseconds{200}
static

This timeout will be used to avoid going to the IDLE state immediately after receiving a message from AVS so that other UX states (such as speech starting) may be processed and propagated before going to IDLE.


The documentation for this class was generated from the following files:

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