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

#include <FFmpegDecoder.h>

Inheritance diagram for alexaClientSDK::mediaPlayer::android::FFmpegDecoder:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::mediaPlayer::android::FFmpegDecoder:
Collaboration graph
[legend]

Public Member Functions

bool shouldInterruptFFmpeg ()
 
DecoderInterface method overrides.
std::pair< Status, size_t > read (Byte *buffer, size_t size) override
 
void abort () override
 
- Public Member Functions inherited from alexaClientSDK::mediaPlayer::android::DecoderInterface
virtual ~DecoderInterface ()=default
 

Static Public Member Functions

static std::unique_ptr< FFmpegDecodercreate (std::unique_ptr< FFmpegInputControllerInterface > inputController, const PlaybackConfiguration &outputConfig, const avsCommon::utils::mediaPlayer::SourceConfig &config=avsCommon::utils::mediaPlayer::emptySourceConfig())
 

Friends

std::ostream & operator<< (std::ostream &stream, const DecodingState state)
 Friend relationship to allow accessing State to convert it to a string for logging. More...
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::mediaPlayer::android::DecoderInterface
enum  Status { Status::OK, Status::DONE, Status::ERROR }
 Represent the decoder read status. More...
 
using Byte = uint8_t
 Represents one byte of data. More...
 

Detailed Description

Class responsible for decoding and re-sampling the audio from an input controller.

The decoding is performed on demand. Every time the read method is called, the decoder will read the input, and decode it until the provided buffer is full.

Decoding is done when the DecodingState is equal to DONE or INVALID.

Warning
This class is not thread safe, except for the abort() method.

Member Function Documentation

◆ abort()

void alexaClientSDK::mediaPlayer::android::FFmpegDecoder::abort ( )
overridevirtual

Abort the decoding process.

This method can be called in parallel with read. The read will fail in this case. Future reads will also fail.

Implements alexaClientSDK::mediaPlayer::android::DecoderInterface.

◆ create()

static std::unique_ptr<FFmpegDecoder> alexaClientSDK::mediaPlayer::android::FFmpegDecoder::create ( std::unique_ptr< FFmpegInputControllerInterface inputController,
const PlaybackConfiguration outputConfig,
const avsCommon::utils::mediaPlayer::SourceConfig config = avsCommon::utils::mediaPlayer::emptySourceConfig() 
)
static

Creates a new decoder buffer queue that reads input data using the given controller.

Parameters
inputControllerThe controller used to retrieve input data.
outputConfigThe decoder output configuration.
Returns
The new decoder buffer queue if create succeeds, nullptr otherwise.

◆ read()

std::pair<Status, size_t> alexaClientSDK::mediaPlayer::android::FFmpegDecoder::read ( Byte buffer,
size_t  size 
)
overridevirtual

Fill buffer with decoded audio data.

Parameters
[out]Bufferwhere the data will be copied to.
sizeThe buffer size in number of bytes.
Returns
The decoding status and the number of bytes read.

Implements alexaClientSDK::mediaPlayer::android::DecoderInterface.

◆ shouldInterruptFFmpeg()

bool alexaClientSDK::mediaPlayer::android::FFmpegDecoder::shouldInterruptFFmpeg ( )

Callback function used by FFmpeg to check when a blocking operation should be interrupted.

We interrupt FFmpeg in two different scenarios:

  • FFmpegDecoder state is INVALID (usually due to a call to abort).
  • FFmpeg initialization is taking too long.
Note
: The second option is a work around for ACSDK-1679. FFmpeg doesn't seem to be handling EAGAIN as expected. If an EAGAIN occurs during avformat_find_stream_info, the method gets stuck. Thus, this method will interrupt FFmpeg if initialization is taking too long.
Returns
true if FFmpeg should be interrupted; false otherwise.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const DecodingState  state 
)
friend

Friend relationship to allow accessing State to convert it to a string for logging.


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