AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Public Member Functions | List of all members
alexaClientSDK::afml::Channel Class Reference

#include <Channel.h>

Classes

struct  State
 

Public Member Functions

 Channel (const std::string &name, const unsigned int priority, bool isVirtual=false)
 
const std::string & getName () const
 
unsigned int getPriority () const
 
bool setFocus (avsCommon::avs::FocusState focus, avsCommon::avs::MixingBehavior behavior, bool forceUpdate=false)
 
void setPrimaryActivity (std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::Activity > activity)
 
bool releaseActivity (std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface > observer)
 
bool releaseActivity (const std::string &interfaceName)
 
bool isActive ()
 
bool operator> (const Channel &rhs) const
 
std::string getInterface () const
 
Channel::State getState () const
 
std::vector< Channel::StategetActivityUpdates ()
 
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::ActivitygetPrimaryActivity ()
 
std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::ActivitygetActivity (const std::string &interfaceName)
 
std::vector< std::string > getInterfaceList () const
 

Detailed Description

A Channel represents a focusable layer with a priority, allowing the observer which has acquired the Channel to understand focus changes. A Channel can be acquired by multiple Activities, but only a single Activity can be the primary activity. All other Activities that are not the primary Activity will be backgrounded.

A Channel can optionally be virtual. Activity changes will not be captured for virtual channels.

Constructor & Destructor Documentation

◆ Channel()

alexaClientSDK::afml::Channel::Channel ( const std::string &  name,
const unsigned int  priority,
bool  isVirtual = false 
)

Constructs a new Channel object with the provided priority.

Parameters
nameThe channel's name.
priorityThe priority of the channel.
isVirtualbool to indicate if this channel is a virtual channel.
Note
refer to the class level doc on virtual channel paramter.

Member Function Documentation

◆ getActivity()

std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface::Activity> alexaClientSDK::afml::Channel::getActivity ( const std::string &  interfaceName)

Gets the activity associated with a given interfaceName.

Parameters
interfaceNameinterface name associated with the activity being searched
Returns
activity associated with
Parameters
interfaceName,nullptrif not found.

◆ getActivityUpdates()

std::vector<Channel::State> alexaClientSDK::afml::Channel::getActivityUpdates ( )

Returns a list of Channel::State updates. This API will internally clear the stored updates when called.

Returns
vector containing all Channel::State Updates

◆ getInterface()

std::string alexaClientSDK::afml::Channel::getInterface ( ) const

Returns the name of the interface of the Primary Activity occupying the Channel.

Returns
The name of the AVS interface.

◆ getInterfaceList()

std::vector<std::string> alexaClientSDK::afml::Channel::getInterfaceList ( ) const

Retrieve vector of interfaces of all Activites on the Channel.

◆ getName()

const std::string& alexaClientSDK::afml::Channel::getName ( ) const

Returns the name of a channel.

Returns
The channel's name.

◆ getPrimaryActivity()

std::shared_ptr<avsCommon::sdkInterfaces::FocusManagerInterface::Activity> alexaClientSDK::afml::Channel::getPrimaryActivity ( )

Returns the primary activity associated with this channel

Returns
the primary activity associated with the channel.

◆ getPriority()

unsigned int alexaClientSDK::afml::Channel::getPriority ( ) const

Returns the priority of a Channel.

Returns
The Channel priority.

◆ getState()

Channel::State alexaClientSDK::afml::Channel::getState ( ) const

Returns the State of the Channel.

Returns
The State.

◆ isActive()

bool alexaClientSDK::afml::Channel::isActive ( )

Returns if channel is active. A Channel is considered active if there is any Activity on the Channel.

Returns
true if Channel is active, false otherwise.

◆ operator>()

bool alexaClientSDK::afml::Channel::operator> ( const Channel rhs) const

Compares this Channel and another Channel and checks which is higher priority. A Channel is considered higher priority than another Channel if its m_priority is lower than the other Channel's.

Parameters
rhsThe Channel to compare with this Channel.

◆ releaseActivity() [1/2]

bool alexaClientSDK::afml::Channel::releaseActivity ( std::shared_ptr< avsCommon::sdkInterfaces::ChannelObserverInterface observer)

Activity to be released by observer.

Parameters
observerChannel Observer to release.
Returns
true if Activity was found and released, false otherwise.

◆ releaseActivity() [2/2]

bool alexaClientSDK::afml::Channel::releaseActivity ( const std::string &  interfaceName)

Activity to be released by interface.

Parameters
interfaceNameThe interface name of the Activity to release.

◆ setFocus()

bool alexaClientSDK::afml::Channel::setFocus ( avsCommon::avs::FocusState  focus,
avsCommon::avs::MixingBehavior  behavior,
bool  forceUpdate = false 
)

Updates the focus and notifies all activities associated with the Channel of the focus change. If FocusState is FOREGROUND, then the most recent Activity added to the Channel will be moved to foreground state, and all other Activites will remain in background state. This method does not return until the ChannelObserverInterface##onFocusChanged() callbacks to all the associated activities return. If the focus is NONE, the Activity will be removed from the Channel.

Note
the MixingBehavior should pertain to the primary Activity for the Channel.
Parameters
focusThe focus of the Channel.
behaviorThe MixingBehavior of the Channel.
forceUpdatebool to indicate if the operation must be forced (irrespective of focus/behavior change).
Returns
true if focus changed, else false.

◆ setPrimaryActivity()

void alexaClientSDK::afml::Channel::setPrimaryActivity ( std::shared_ptr< avsCommon::sdkInterfaces::FocusManagerInterface::Activity activity)

Set the Primary Activity on the Channel given the Activity Object. The function must be called after the correct FocusState of the Channel is set. Any other Activities on the Channel will be moved to the background state.

Parameters
activityActivity to be set as Primary Activity.

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

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