AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Protected Member Functions | List of all members
alexaClientSDK::mediaPlayer::BaseStreamSource Class Referenceabstract

#include <BaseStreamSource.h>

Inheritance diagram for alexaClientSDK::mediaPlayer::BaseStreamSource:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::mediaPlayer::BaseStreamSource:
Collaboration graph
[legend]

Public Member Functions

 BaseStreamSource (PipelineInterface *pipeline, const std::string &className)
 
 ~BaseStreamSource () override
 
SourceInterface Functions
bool hasAdditionalData () override
 
bool handleEndOfStream () override
 
void preprocess () override
 
void addObserver (std::shared_ptr< SourceObserverInterface > observer) override
 
void removeObserver (std::shared_ptr< SourceObserverInterface > observer) override
 
- Public Member Functions inherited from alexaClientSDK::mediaPlayer::SourceInterface
 SourceInterface (const std::string &className)
 
virtual ~SourceInterface ()=default
 
virtual bool isPlaybackRemote () const =0
 
- 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
 

Protected Member Functions

bool init (const avsCommon::utils::AudioFormat *audioFormat=nullptr)
 
virtual bool isOpen ()=0
 
virtual void close ()=0
 
virtual gboolean handleReadData ()=0
 
virtual gboolean handleSeekData (guint64 offset)=0
 
GstAppSrc * getAppSrc () const
 
void signalEndOfData ()
 
void installOnReadDataHandler ()
 
void updateOnReadDataHandler ()
 
void uninstallOnReadDataHandler ()
 
void clearOnReadDataHandler ()
 
void notifyObserversOnReadData ()
 
- Protected Member Functions inherited from alexaClientSDK::avsCommon::utils::RequiresShutdown
virtual void doShutdown ()=0
 

Constructor & Destructor Documentation

◆ BaseStreamSource()

alexaClientSDK::mediaPlayer::BaseStreamSource::BaseStreamSource ( PipelineInterface pipeline,
const std::string &  className 
)

Constructor.

Parameters
pipelineThe PipelineInterface through which the source of the AudioPipeline may be set.
classNameThe name of the class to be passed to RequiresShutdown.

◆ ~BaseStreamSource()

alexaClientSDK::mediaPlayer::BaseStreamSource::~BaseStreamSource ( )
override

Member Function Documentation

◆ addObserver()

void alexaClientSDK::mediaPlayer::BaseStreamSource::addObserver ( std::shared_ptr< SourceObserverInterface observer)
overridevirtual

Adds an observer to be notified of particular events which occur on this source.

Parameters
observerThe observer to add.

Implements alexaClientSDK::mediaPlayer::SourceInterface.

◆ clearOnReadDataHandler()

void alexaClientSDK::mediaPlayer::BaseStreamSource::clearOnReadDataHandler ( )
protected

Clear out the tracking of the onReadData() handler callback. This is used when gstreamer is known to have uninstalled the handler on its own.

◆ close()

virtual void alexaClientSDK::mediaPlayer::BaseStreamSource::close ( )
protectedpure virtual

Close the audio source.

◆ getAppSrc()

GstAppSrc* alexaClientSDK::mediaPlayer::BaseStreamSource::getAppSrc ( ) const
protected

Get the AppSrc to which this instance should feed audio data.

Returns
The AppSrc to which this instance should feed audio data.

◆ handleEndOfStream()

bool alexaClientSDK::mediaPlayer::BaseStreamSource::handleEndOfStream ( )
overridevirtual

Internally, a source may need additional processing after EOS is reached. This function will process that data.

Returns
A boolean indicating whether the process operation was successful.

Implements alexaClientSDK::mediaPlayer::SourceInterface.

◆ handleReadData()

virtual gboolean alexaClientSDK::mediaPlayer::BaseStreamSource::handleReadData ( )
protectedpure virtual

Reads data from this instance and pushes it into appsrc element.

Returns
false if there is an error or end of data from this source, else true.

◆ handleSeekData()

virtual gboolean alexaClientSDK::mediaPlayer::BaseStreamSource::handleSeekData ( guint64  offset)
protectedpure virtual

Seeks to the appropriate offset. Any data pushed after this should come from the new offset.

Returns
false if the seek failed, or true otherwise.

◆ hasAdditionalData()

bool alexaClientSDK::mediaPlayer::BaseStreamSource::hasAdditionalData ( )
overridevirtual

Internally, a source may have additional data after processing an EOS. This function indicates whether there is additional data, and should be called after handleEndOfStream().

Returns
A boolean indicating whether the source has additional data to be played.

Implements alexaClientSDK::mediaPlayer::SourceInterface.

◆ init()

bool alexaClientSDK::mediaPlayer::BaseStreamSource::init ( const avsCommon::utils::AudioFormat audioFormat = nullptr)
protected

Initializes a source. Creates all the necessary pipeline elements such that audio output from the final element should be decoded output that can be input to the converter of the AudioPipeline. Adding the elements to the pipeline of the AudioPipeline, linking the elements and setting up the callbacks for signals should be handled.

Parameters
audioFormatThe audioFormat to be used when playing raw PCM data.
Returns
true if the initialization was successful else false.

◆ installOnReadDataHandler()

void alexaClientSDK::mediaPlayer::BaseStreamSource::installOnReadDataHandler ( )
protected

Install the onReadData() handler. If it is already installed, reset the retry count.

◆ isOpen()

virtual bool alexaClientSDK::mediaPlayer::BaseStreamSource::isOpen ( )
protectedpure virtual

Return whether the audio source is still open.

Returns
whether the audio source is still open.

◆ notifyObserversOnReadData()

void alexaClientSDK::mediaPlayer::BaseStreamSource::notifyObserversOnReadData ( )
protected

A utility function to notify the observers of this object when data has been read.

◆ preprocess()

void alexaClientSDK::mediaPlayer::BaseStreamSource::preprocess ( )
overridevirtual

Perform preprocessing of the source. Must be called before reading from the source.

Implements alexaClientSDK::mediaPlayer::SourceInterface.

◆ removeObserver()

void alexaClientSDK::mediaPlayer::BaseStreamSource::removeObserver ( std::shared_ptr< SourceObserverInterface observer)
overridevirtual

Removes an observer from being notified of particular events which occur on this source.

Parameters
observerThe observer to remove.

Implements alexaClientSDK::mediaPlayer::SourceInterface.

◆ signalEndOfData()

void alexaClientSDK::mediaPlayer::BaseStreamSource::signalEndOfData ( )
protected

Signal gstreamer about the end of data from this instance.

◆ uninstallOnReadDataHandler()

void alexaClientSDK::mediaPlayer::BaseStreamSource::uninstallOnReadDataHandler ( )
protected

Uninstall the onReadData() handler.

◆ updateOnReadDataHandler()

void alexaClientSDK::mediaPlayer::BaseStreamSource::updateOnReadDataHandler ( )
protected

Update when to call onReadData() handler based upon the number of retries since data was last read.


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