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

Interface for encoding audio stream. More...

#include <AudioEncoderInterface.h>

Public Member Functions

virtual ~AudioEncoderInterface ()=default
 Virtual destructor. More...
virtual std::shared_ptr< avsCommon::avs::AudioInputStreamstartEncoding (const std::shared_ptr< avsCommon::avs::AudioInputStream > &inputStream, avsCommon::utils::AudioFormat inputFormat, avsCommon::avs::AudioInputStream::Index begin, avsCommon::avs::AudioInputStream::Reader::Reference reference)=0
 Start the new encoding session. More...
virtual void stopEncoding (bool stopImmediately=false)=0
 Stop current encoding session. More...
virtual avsCommon::utils::AudioFormat::Encoding getEncoding ()=0
 Get output encoding type. More...
virtual std::string getAVSFormatName ()=0
 Get output format name for AVS service. More...

Detailed Description

Interface for encoding audio stream.

This class provides generic interface between audio stream encoder implementation and the application who wants to encode audio stream.

Encoder converts input audio stream into encoded format. Each encoder implementation is expected to support one output format which doesn't change over time.

Encoding operation starts with startEncoding() call and finished in one of the following cases:

Encoder supports a single encoding session, but there can be more than one encoder in the system.

See also

Constructor & Destructor Documentation

◆ ~AudioEncoderInterface()

virtual alexaClientSDK::audioEncoderInterfaces::AudioEncoderInterface::~AudioEncoderInterface ( )

Virtual destructor.

Member Function Documentation

◆ getAVSFormatName()

virtual std::string alexaClientSDK::audioEncoderInterfaces::AudioEncoderInterface::getAVSFormatName ( )
pure virtual

Get output format name for AVS service.

This method returns output format name for AVS service. The encoder may change the format depending on configuration when encoding starts with startEncoding() call, and the clients should use this method after it. The AVS format name doesn't change until the next call to startEncoding().

The string interpretation of the output format, that AVS cloud service can recognize.
See also

◆ getEncoding()

virtual avsCommon::utils::AudioFormat::Encoding alexaClientSDK::audioEncoderInterfaces::AudioEncoderInterface::getEncoding ( )
pure virtual

Get output encoding type.

Method returns output encoding type.

Output encoding supported by this encoder.

◆ startEncoding()

virtual std::shared_ptr<avsCommon::avs::AudioInputStream> alexaClientSDK::audioEncoderInterfaces::AudioEncoderInterface::startEncoding ( const std::shared_ptr< avsCommon::avs::AudioInputStream > &  inputStream,
avsCommon::utils::AudioFormat  inputFormat,
avsCommon::avs::AudioInputStream::Index  begin,
avsCommon::avs::AudioInputStream::Reader::Reference  reference 
pure virtual

Start the new encoding session.

Method starts the new encoding session. Object can manage only single session at the same time, thus this call will fail if ongoing encoding session exists.

If the method succeeds, client may request to stop encoding with stopEncoding() call. The encoding session will continue until stopped, end of inputStream is reached, or encoder encounters an error.

When this method is called, encoder may change the format returned with getAVSFormatName() method based on input format.

[in]inputStreamThe AudioStream to stream audio from. (i.e.input stream that has raw PCM frames.)
[in]inputFormatThe AudioFormat to describe the audio format of the input stream.
[in]beginThe index where encoding should begin.
[in]referenceThe reference for the index.
Stream for encoding output. Encoder creates a new stream for storing the encoding results. On error the result is nullptr.

◆ stopEncoding()

virtual void alexaClientSDK::audioEncoderInterfaces::AudioEncoderInterface::stopEncoding ( bool  stopImmediately = false)
pure virtual

Stop current encoding session.

Method stops current encoding session if it exists. If there is an ongoing encoding session, the method returns after the session is terminated.

This method has an execution timeout, and even if stopImmediately is false, encoding will be aborted if it cannot be stopped gracefully.

[in]stopImmediatelyFlag indicating that encoding should stop immediately. If this flag is set to false (the default), encoding will continue until any existing data in the buffer has been encoded. If this flag is set to true, existing data in the buffer which has not already been encoded will be discarded, and encoding will stop immediately.

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

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