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

#include <EncoderContext.h>

Inheritance diagram for alexaClientSDK::speechencoder::EncoderContext:
Inheritance graph
[legend]

Public Member Functions

virtual bool init (alexaClientSDK::avsCommon::utils::AudioFormat inputFormat)=0
 
virtual size_t getInputFrameSize ()=0
 
virtual size_t getOutputFrameSize ()=0
 
virtual bool requiresFullyRead ()=0
 
virtual alexaClientSDK::avsCommon::utils::AudioFormat getAudioFormat ()=0
 
virtual std::string getAVSFormatName ()=0
 
virtual bool start ()=0
 
virtual ssize_t processSamples (void *samples, size_t numberOfWords, uint8_t *buffer)=0
 
virtual void close ()=0
 
virtual ~EncoderContext ()=default
 

Detailed Description

Interface class between SpeechEncoder and the backend codec library. This class must be implemented by customer for each encoder codecs.

Constructor & Destructor Documentation

◆ ~EncoderContext()

virtual alexaClientSDK::speechencoder::EncoderContext::~EncoderContext ( )
virtualdefault

Destructor.

Member Function Documentation

◆ close()

virtual void alexaClientSDK::speechencoder::EncoderContext::close ( )
pure virtual

Notify end of the session. Any backend library then may be deinitialized so it cleans memory and threads.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ getAudioFormat()

virtual alexaClientSDK::avsCommon::utils::AudioFormat alexaClientSDK::speechencoder::EncoderContext::getAudioFormat ( )
pure virtual

The AudioFormat describes the encoded audio stream.

Returns
The AudioFormat describes the encoded audio stream.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ getAVSFormatName()

virtual std::string alexaClientSDK::speechencoder::EncoderContext::getAVSFormatName ( )
pure virtual

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

Returns
Output format string.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ getInputFrameSize()

virtual size_t alexaClientSDK::speechencoder::EncoderContext::getInputFrameSize ( )
pure virtual

The maximum number of sample can be processed at the same time. In other words, this will limits input PCM stream buffering. Thus nWords of processSamples call will never exceeds this limit.

Returns
The number of sample (in words).

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ getOutputFrameSize()

virtual size_t alexaClientSDK::speechencoder::EncoderContext::getOutputFrameSize ( )
pure virtual

The maximum length of the single encoded frame.

Returns
The maximum output length (in bytes).

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ init()

virtual bool alexaClientSDK::speechencoder::EncoderContext::init ( alexaClientSDK::avsCommon::utils::AudioFormat  inputFormat)
pure virtual

Pre-initialization before actual encoding session has began. Note that this function will be called everytime before new encoding session is starting.

Parameters
inputFormatThe AudioFormat describes the audio format of the future incoming PCM frames.
Returns
true when initialization success.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ processSamples()

virtual ssize_t alexaClientSDK::speechencoder::EncoderContext::processSamples ( void *  samples,
size_t  numberOfWords,
uint8_t *  buffer 
)
pure virtual

Encode next PCM samples. This function will be called continuously throughout the session.

Parameters
samplesPCM samples to be encoded. The word size should be known via AudioFormat that has provided at pre-init function.
numberOfWordsThe number of samples (in words).
bufferThe buffer where the encoded frames should be written.
Returns
The total bytes of encoded frames has been written into buffer. Negative value when error is occurred.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ requiresFullyRead()

virtual bool alexaClientSDK::speechencoder::EncoderContext::requiresFullyRead ( )
pure virtual

Determine whether PCM stream should be fully buffered with the maximum number of samples provided at getInputFrameSize function. This value will change the behavior of how processSamples is called during the encoding session. This is useful when backend encoder requires fixed length of input samples.

In case the encoding session has been shutdown before the buffere is filled fully, this will cause any partial data to be discarded. (e.g. stopEncoding has been called, or reaches the end of the data stream.)

Returns
true if processSamples should be called with fixed length of input samples during the session.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.

◆ start()

virtual bool alexaClientSDK::speechencoder::EncoderContext::start ( )
pure virtual

When an encoding session has began, this function start will be called. The backend library then may be initialized for begin encoding.

Returns
true when success.

Implemented in alexaClientSDK::speechencoder::OpusEncoderContext.


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

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