Maestro Audio Framework v 1.7
NXP Semiconductors
Loading...
Searching...
No Matches
decoder.c File Reference

This file contains the decoder element functionality. More...

#include "streamer.h"
#include "decoder.h"
#include "decoder_pads.h"
#include "pipeline.h"
#include "streamer_element_properties.h"
#include "audio_cfg.h"

Functions

uint8_t ccidec_src_pad_event_handler (StreamPad *, StreamEvent *)
 ccidec_src_pad_event_handler
 
uint8_t ccidec_src_pad_query_handler (StreamPad *, StreamQuery *)
 ccidec_src_pad_query_handler
 
uint8_t ccidec_sink_pad_activation_handler (StreamPad *, uint8_t)
 ccidec_sink_pad_activation_handler
 
uint8_t ccidec_sink_pad_event_handler (StreamPad *, StreamEvent *)
 ccidec_sink_pad_event_handler
 
int32_t ccidec_sink_pad_process_handler (StreamPad *)
 Process handler for the CCI decoder.
 
int32_t decoder_change_state (StreamElement *element, PipelineState new_dec_state)
 This function changes the decoder state by calling STATE_TRANSITION pipeline macro. If the new state is NULL_TO_READY, it verifies the decoder type is known and handler is setup.
 
uint32_t decoder_get_duration (ElementDecoder *element, StreamDataFormat format)
 Returns the duration of a source PadQueryFunc is called to return the element duration in the format defined by the StreamDataFormat parameter.
 
bool decoder_is_source_seekable (ElementDecoder *decoder, StreamDataFormat format)
 Is current source seekable.
 
void decoder_set_duration (ElementDecoder *element, uint32_t stream_size, uint32_t bit_rate)
 Calculate and set the duration of a source This function calculates the duration in bytes using the stream size and stream bitrate, and sets it in bytes in the ElementDecoder variable.
 
int32_t decoder_init_element (StreamElement *element)
 This function initializes the decoder element, and loads the pad source and sink functions.
 
int32_t decoder_set_type (ElementHandle element, DecoderType dec_type)
 Set the decoder type for the input element. This function maps the generic decoder element pad handlers to the specific decoder implementation using DecoderHandlersType.
 
int32_t decoder_activate_parse_tag (ElementHandle element, uint8_t activate)
 Enable/Disable the tag parsing Sets the parse_tag variable to the value passed in via activate variable.
 
void vUpdateAverageBitrate (ElementDecoder *element)
 Update a running average of bit rate.
 
int32_t decoder_set_property (StreamElement *element, uint16_t prop_id, uint32_t prop_value)
 Set a property of a decoder element.
 
int32_t decoder_get_property (StreamElement *element, uint16_t prop_id, uint32_t *prop_value)
 Get a property of a decoder element.
 

Variables

static const DecoderHandlersType handlers_cci
 Decoder handler function pointers.
 

Detailed Description

This file implements the Opus encoder stream element.

Function Documentation

◆ ccidec_src_pad_event_handler()

uint8_t ccidec_src_pad_event_handler ( StreamPad * pad,
StreamEvent * event )
extern

This function handles the src events for the cci decoder. These events are upstream events and all events will be pushed to the peer pad.

Parameters
padpad handle
eventevent enumeration
Returns
pad error return

◆ ccidec_src_pad_query_handler()

uint8_t ccidec_src_pad_query_handler ( StreamPad * pad,
StreamQuery * query )
extern

This function handles the src queries for the cci decoder.

Parameters
padpad handle
queryevent enumeration
Returns
pad error return

◆ ccidec_sink_pad_activation_handler()

uint8_t ccidec_sink_pad_activation_handler ( StreamPad * pad,
uint8_t active )
extern

This function activates the sink pad and allocates memory for the cci decoder structure and initializes this structure. Activates or deactivates the sink pad for incoming data.

Parameters
padpad handle
activeboolean o activate/disactivate pad
Returns
pad error return

◆ ccidec_sink_pad_event_handler()

uint8_t ccidec_sink_pad_event_handler ( StreamPad * pad,
StreamEvent * event )
extern

This function handles the pipeline events for the cci decoder. These events are downstream events and all events will be pushed to the peer pad.

Parameters
padpad handle
eventevent enumeration
Returns
pad error return

◆ ccidec_sink_pad_process_handler()

int32_t ccidec_sink_pad_process_handler ( StreamPad * pad)
extern

Used in pull mode, the filesrc process handler should be NULL so this function will be called instead. This function will call the CCI functions to initialize and decode the file. The CCI callback will be used to pull data from the filesrc when needed.

Parameters
padpad handle
Returns
pad error return

◆ decoder_change_state()

int32_t decoder_change_state ( StreamElement * element,
PipelineState new_dec_state )
Parameters
elementStreamElement will be used to create ElementDecoder
new_dec_statenew decoder state to change to
Return values
STREAM_ERR_INVALID_ARGSinvalid parameters
STREAM_ERR_GENERALif moved to ready state and decoders not setup
STREAM_OKsuccessful

◆ decoder_get_duration()

uint32_t decoder_get_duration ( ElementDecoder * element,
StreamDataFormat data )
Parameters
elementElementDecoder pointer will be used to create StreamPad sink
dataStreamDataFormat defines the format of the data to return.
Returns
duration or 0 if failed

◆ decoder_is_source_seekable()

bool decoder_is_source_seekable ( ElementDecoder * decoder,
StreamDataFormat format )

This function sends a query to sink pad of the decoder element to check if check if seek is possible in the specified format.

Parameters
decoderElementDecoder pointer will be use to create a sink StreamPad
formatformat type used to create the query.
Returns
bool
Return values
truesource is seekable
falsesouce is not seekable

◆ decoder_set_duration()

void decoder_set_duration ( ElementDecoder * element,
uint32_t stream_size,
uint32_t bit_rate )
Parameters
elementElementDecoder pointer will hold the calculated duration value
stream_sizeSize of the stream
bit_rateBit rate of the stream
Returns
None

◆ decoder_init_element()

int32_t decoder_init_element ( StreamElement * element)

The following Pad Functions are used in this implementation: SRC FUNCTIONS pad->event_handler = decoder_src_pad_event_handler() pad->query_handler = decoder_src_pad_query_handler() pad->activation_handler = NULL pad->activate_pull = pad->activate_push = decoder_src_pad_activation_handler() pad->process_handler = NULL pad->process_precheck = NULL pad->pull_handler = NULL SINK FUNCTIONS pad->event_handler = decoder_sink_pad_event_handler() pad->query_handler = NULL pad->activation_handler = decoder_sink_pad_activation_handler() pad->activate_pull = ??? pad->activate_push = ??? pad->process_handler = decoder_sink_pad_process_handler() pad->process_precheck = NULL pad->chain_handler = decoder_sink_pad_chain_handler() This function is loaded in the ElementInit element_list[] table and called during create_element()

Parameters
elementStreamElement pointer will be used to create ElementDecoder
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ decoder_set_type()

int32_t decoder_set_type ( ElementHandle element,
DecoderType dec_type )
Parameters
elementElementHandle that will be used as ElementDecoder to set the handlers to the input decoder type
dec_typeDecoderType value that will be used to map the appropriate handler functions.
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments
STREAM_ERR_GENERALis returned if dec_type is not handled

◆ decoder_activate_parse_tag()

int32_t decoder_activate_parse_tag ( ElementHandle element,
uint8_t activate )
Parameters
elementElementHandle that will be used as ElementDecoder
activatevalue used to set parse_tag in decoder element.
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ vUpdateAverageBitrate()

void vUpdateAverageBitrate ( ElementDecoder * element)
Parameters
elementElementDecoder pointer that will contain the calculated average bit rate.
Returns
None

◆ decoder_set_property()

int32_t decoder_set_property ( StreamElement * element,
uint16_t prop_id,
uint32_t prop_value )

This is a new interface to replace the original decoder_set_type().

Parameters
elementStreamElement pointer
prop_idid number of a element's property
prop_valuethe property value to be set
Returns
StreamReturnType
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

◆ decoder_get_property()

int32_t decoder_get_property ( StreamElement * element,
uint16_t prop_id,
uint32_t * prop_value )
Parameters
elementStreamElement pointer that will be used as ElementHandle
prop_idid number of a element's property
prop_valuethe property value to be saved in
Return values
STREAM_OKif successful
STREAM_ERR_INVALID_ARGSmeans invalid arguments

Variable Documentation

◆ handlers_cci

const DecoderHandlersType handlers_cci
static
Initial value:
= {
uint8_t ccidec_src_pad_event_handler(StreamPad *, StreamEvent *)
ccidec_src_pad_event_handler
Definition ccidec.c:754
uint8_t ccidec_src_pad_query_handler(StreamPad *, StreamQuery *)
ccidec_src_pad_query_handler
Definition ccidec.c:899
int32_t ccidec_sink_pad_process_handler(StreamPad *)
Process handler for the CCI decoder.
Definition ccidec.c:973
uint8_t ccidec_sink_pad_activation_handler(StreamPad *, uint8_t)
ccidec_sink_pad_activation_handler
Definition ccidec.c:479
uint8_t ccidec_sink_pad_event_handler(StreamPad *, StreamEvent *)
ccidec_sink_pad_event_handler
Definition ccidec.c:676