AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer Class Reference
Inheritance diagram for alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer:
Collaboration graph
[legend]

Public Member Functions

 TestMediaPlayer ()
 
bool play (SourceId id) override
 
bool stop (SourceId id) override
 
SourceId setSource (const std::string &url, std::chrono::milliseconds offset=std::chrono::milliseconds::zero(), const avsCommon::utils::mediaPlayer::SourceConfig &config=avsCommon::utils::mediaPlayer::emptySourceConfig(), bool repeat=false, const avsCommon::utils::mediaPlayer::PlaybackContext &playbackContext=avsCommon::utils::mediaPlayer::PlaybackContext()) override
 
SourceId setSource (std::shared_ptr< std::istream > stream, bool repeat, const avsCommon::utils::mediaPlayer::SourceConfig &config, avsCommon::utils::MediaType format) override
 
SourceId setSource (std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, const avsCommon::utils::AudioFormat *audioFormat, const avsCommon::utils::mediaPlayer::SourceConfig &config) override
 
void setSourceRetVal (SourceId sourceRetVal)
 
void setPlayRetVal (bool playRetVal)
 
void setStopRetVal (bool stopRetVal)
 
std::pair< bool, avsCommon::utils::mediaPlayer::SourceConfigwaitForSourceConfig (std::chrono::milliseconds timeout)
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::test::MockMediaPlayer
 MockMediaPlayer ()
 
 MOCK_METHOD1 (play, bool(SourceId))
 
 MOCK_METHOD1 (pause, bool(SourceId))
 
 MOCK_METHOD1 (resume, bool(SourceId))
 
 MOCK_METHOD3 (seekTo, bool(SourceId, std::chrono::milliseconds location, bool fromStart))
 
 MOCK_METHOD1 (stop, bool(SourceId))
 
 MOCK_METHOD2 (stop, bool(SourceId, std::chrono::seconds))
 
 MOCK_METHOD1 (getOffset, std::chrono::milliseconds(SourceId))
 
 MOCK_METHOD0 (getNumBytesBuffered, uint64_t())
 
 MOCK_METHOD1 (getMediaPlayerState, avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerState >(SourceId))
 
 MOCK_METHOD0 (getPlaybackAttributes, avsCommon::utils::Optional< PlaybackAttributes >())
 
 MOCK_METHOD0 (getPlaybackReports, std::vector< PlaybackReport >())
 
 MOCK_METHOD0 (getFingerprint, Optional< Fingerprint >())
 
 MOCK_METHOD2 (attachmentSetSource, SourceId(std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, const avsCommon::utils::AudioFormat *audioFormat))
 
 MOCK_METHOD2 (streamSetSource, SourceId(std::shared_ptr< std::istream > stream, bool repeat))
 
 MOCK_METHOD1 (urlSetSource, SourceId(const std::string &url))
 
SourceId mockSetSource ()
 
bool mockPlay (SourceId sourceId)
 
bool mockPause (SourceId sourceId)
 
bool mockResume (SourceId sourceId)
 
bool mockStop (SourceId sourceId)
 
bool mockStop2 (SourceId sourceId, std::chrono::seconds closePipleineTime)
 
bool mockFinished (SourceId sourceId)
 
bool mockError (SourceId sourceId)
 
bool mockSetOffset (SourceId sourceId, std::chrono::milliseconds offset)
 
std::chrono::milliseconds mockGetOffset (SourceId id)
 
avsCommon::utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerStatemockGetState (SourceId id)
 
bool mockSeek (SourceId sourceId, std::chrono::milliseconds location, bool fromStart)
 
void resetWaitTimer ()
 
bool waitUntilNextSetSource (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackStarted (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackStarted (SourceId id, const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackPaused (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackResumed (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackStopped (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackFinished (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilPlaybackError (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
bool waitUntilSeeked (const std::chrono::milliseconds timeout=std::chrono::milliseconds(DEFAULT_TIME))
 
SourceId getCurrentSourceId ()
 
SourceId getSourceId ()
 
SourceId getLatestSourceId ()
 
std::unordered_set< std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > > getObservers () const
 
SourceId setSource (std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, const avsCommon::utils::AudioFormat *audioFormat=nullptr, const SourceConfig &config=emptySourceConfig())
 
SourceId setSource (std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, std::chrono::milliseconds offsetAdjustment, const avsCommon::utils::AudioFormat *audioFormat=nullptr, const SourceConfig &config=emptySourceConfig())
 
void addObserver (std::shared_ptr< observer > playerObserver)
 
void removeObserver (std::shared_ptr< observer > playerObserver)
 
void doShutdown ()
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::test::MockMediaPlayerHelper
virtual SourceId attachmentSetSource (std::shared_ptr< avsCommon::avs::attachment::AttachmentReader > attachmentReader, const avsCommon::utils::AudioFormat *audioFormat)=0
 
virtual SourceId streamSetSource (std::shared_ptr< std::istream > stream, bool repeat)=0
 
virtual SourceId urlSetSource (const std::string &url)=0
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerInterface
virtual ~MediaPlayerInterface ()=default
 
virtual bool stop (SourceId id, std::chrono::seconds timeToPipelineShutdown)
 
virtual bool pause (SourceId id)=0
 
virtual bool resume (SourceId id)=0
 
virtual bool seekTo (SourceId id, std::chrono::milliseconds location, bool fromStart)
 
virtual std::chrono::milliseconds getOffset (SourceId id)=0
 
virtual uint64_t getNumBytesBuffered ()=0
 
virtual utils::Optional< avsCommon::utils::mediaPlayer::MediaPlayerStategetMediaPlayerState (SourceId id)=0
 
virtual void addObserver (std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > playerObserver)=0
 
virtual void removeObserver (std::shared_ptr< avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface > playerObserver)=0
 
virtual utils::Optional< PlaybackAttributesgetPlaybackAttributes ()
 
virtual std::vector< PlaybackReportgetPlaybackReports ()
 
virtual utils::Optional< FingerprintgetFingerprint ()
 
- Public Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
 RequiresShutdown (const std::string &name)
 
virtual ~RequiresShutdown ()
 Destructor. More...
 
const std::string & name () const
 
void shutdown ()
 
bool isShutdown () const
 

Static Public Member Functions

static std::shared_ptr< testing::NiceMock< TestMediaPlayer > > create ()
 
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::test::MockMediaPlayer
static std::shared_ptr< testing::NiceMock< MockMediaPlayer > > create ()
 
static void enableConcurrentMediaPlayers ()
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::test::MockMediaPlayer
using observer = avsCommon::utils::mediaPlayer::MediaPlayerObserverInterface
 
using MediaPlayerState = avsCommon::utils::mediaPlayer::MediaPlayerState
 
- Public Types inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerInterface
using SourceId = uint64_t
 A type that identifies which source is currently being operated on. This must be unique across all instances. More...
 
- Static Public Attributes inherited from alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerInterface
static const SourceId ERROR = 0
 An SourceId used to represent an error from calls to setSource(). More...
 

Constructor & Destructor Documentation

◆ TestMediaPlayer()

alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::TestMediaPlayer ( )
inline

Member Function Documentation

◆ create()

static std::shared_ptr<testing::NiceMock<TestMediaPlayer> > alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::create ( )
inlinestatic

◆ play()

bool alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::play ( SourceId  id)
inlineoverridevirtual

Starts playing audio specified by the setSource() call.

The source must be set before issuing play().

If play() is called

  • without making a setSource(), false will be returned.
  • when audio is already playing, false will be returned.
  • after a play() call has already been made but no callback or return code has been issued yet, false will be returned.

If the id does not match the id of the active source, then false will be returned. If the play() succeeded, true will be returned. When true is returned, a callback will be made to either MediaPlayerObserverInterface::onPlaybackStarted() or to MediaPlayerObserverInterface::onPlaybackError().

Parameters
idThe unique id of the source on which to operate.
Returns
true if the call succeeded, in which case a callback will be made, or false otherwise.

Implements alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerInterface.

◆ setPlayRetVal()

void alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::setPlayRetVal ( bool  playRetVal)
inline

◆ setSource() [1/3]

SourceId alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::setSource ( const std::string &  url,
std::chrono::milliseconds  offset = std::chrono::milliseconds::zero(),
const avsCommon::utils::mediaPlayer::SourceConfig config = avsCommon::utils::mediaPlayer::emptySourceConfig(),
bool  repeat = false,
const avsCommon::utils::mediaPlayer::PlaybackContext playbackContext = avsCommon::utils::mediaPlayer::PlaybackContext() 
)
inlineoverridevirtual

Set a url source to play. The source should be set before making calls to any of the playback control APIs. If any source was set prior to this call, that source will be discarded.

Note
A MediaPlayerInterface implementation must handle only one source at a time. An implementation must call MediaPlayerObserverInterface::onPlaybackStopped() with the previous source's id if there was a source set. Also, an implementation must call MediaPlayerObserverInterface::onBufferingComplete() when this source has been fully buffered
Parameters
urlThe url to set as the source.
offsetAn optional offset parameter to start playing from when a play() call is made.
configMedia configuration of source.
repeatAn optional parameter to play the url source in a loop.
playbackContextAn optional parameter used for sending headers needed for data requests.
Returns
The SourceId that represents the source being handled as a result of this call. ERROR will be returned if the source failed to be set. Must be unique across all instances.

Reimplemented from alexaClientSDK::avsCommon::utils::mediaPlayer::test::MockMediaPlayer.

◆ setSource() [2/3]

SourceId alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::setSource ( std::shared_ptr< std::istream >  stream,
bool  repeat,
const avsCommon::utils::mediaPlayer::SourceConfig config,
avsCommon::utils::MediaType  format 
)
inlineoverridevirtual

Set an istream source to play. The source should be set before making calls to any of the playback control APIs. If any source was set prior to this call, that source will be discarded.

Note
A MediaPlayerInterface implementation must handle only one source at a time. An implementation must call MediaPlayerObserverInterface::onPlaybackStopped() with the previous source's id if there was a source set. Also, an implementation must call MediaPlayerObserverInterface::onBufferingComplete() when this source has been fully buffered
Parameters
streamObject from which to read an incoming audio stream.
repeatWhether the audio stream should be played in a loop until stopped.
configMedia configuration of source.
formatThe MediaType audio encoding format of the incoming audio stream.
Returns
The SourceId that represents the source being handled as a result of this call. ERROR will be returned if the source failed to be set. Must be unique across all instances.

Reimplemented from alexaClientSDK::avsCommon::utils::mediaPlayer::test::MockMediaPlayer.

◆ setSource() [3/3]

SourceId alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::setSource ( std::shared_ptr< avsCommon::avs::attachment::AttachmentReader attachmentReader,
const avsCommon::utils::AudioFormat audioFormat,
const avsCommon::utils::mediaPlayer::SourceConfig config 
)
inlineoverride

◆ setSourceRetVal()

void alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::setSourceRetVal ( SourceId  sourceRetVal)
inline

◆ setStopRetVal()

void alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::setStopRetVal ( bool  stopRetVal)
inline

◆ stop()

bool alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::stop ( SourceId  id)
inlineoverridevirtual

Stops playing the audio specified by the setSource() call.

The source must be set before issuing stop().

Once stop() has been called, subsequent play() calls will fail. If stop() is called when audio has already stopped, false will be returned. If the id does not match the id of the active source, then false will be returned. If the stop() succeeded, true will be returned. When true is returned, a callback will be made to either MediaPlayerObserverInterface::onPlaybackStopped() or to MediaPlayerObserverInterface::onPlaybackError().

Parameters
idThe unique id of the source on which to operate.
Returns
true if the call succeeded, in which case a callback will be made, or false otherwise.

Implements alexaClientSDK::avsCommon::utils::mediaPlayer::MediaPlayerInterface.

◆ waitForSourceConfig()

std::pair<bool, avsCommon::utils::mediaPlayer::SourceConfig> alexaClientSDK::acsdkAlerts::renderer::test::TestMediaPlayer::waitForSourceConfig ( std::chrono::milliseconds  timeout)
inline

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