Maestro Audio Framework v 1.7
NXP Semiconductors
Loading...
Searching...
No Matches
streamer.h File Reference

Contains common types and functions used throughout the streamer. More...

#include <stdint.h>
#include "error.h"
#include "maestro_logging.h"
#include "streamer_api.h"

Data Structures

struct  PacketHeader
 PacketHeader. More...
 
struct  AudioPacketHeader
 
struct  RawPacketHeader
 Raw packet header. More...
 
struct  StreamBuffer
 Stream buffer information. More...
 
struct  STREAMER_MSG_HANDLER_T
 
struct  StreamMessage
 
struct  StreamQuery
 

Macros

#define DBG_ON   (0x80)
 Flag enable debug messages.
 
#define DBG_OFF   (0x00)
 Flag disable debug messages.
 
#define DBG_CORE   DBG_ON
 Flag enable core debug messages.
 
#define DBG_AUDIO_SINK   DBG_ON
 Flag enable audio sink debug messages.
 
#define DBG_AUDIO_SRC   DBG_ON
 Flag enable audio source debug messages.
 
#define DBG_QUEUE   DBG_OFF
 Flag enable queue debug messages.
 
#define DBG_FILESRC   DBG_ON
 Flag enable file source debug messages.
 
#define DBG_FILE_SINK   DBG_ON
 Flag enable file sink debug messages.
 
#define DBG_DECODER   DBG_ON
 Flag enable decoder debug messages.
 
#define DBG_ENCODER   DBG_ON
 Flag enable encoder debug messages.
 
#define DBG_MP3D   DBG_ON
 Flag enable mp3 decoder debug messages.
 
#define DBG_MEMSRC   DBG_ON
 Flag enable memory source debug messages.
 
#define DBG_NETBUFSRC   DBG_ON
 Flag enable netbuf source debug messages.
 
#define DBG_MEM_SINK   DBG_ON
 Flag enable memory sink debug messages.
 
#define DBG_VIT_SINK   DBG_ON
 Flag enable vit sink debug messages.
 
#define DBG_AUDIO_PROC   DBG_ON
 Flag enable audio_proc debug messages.
 
#define DBG_CCID   DBG_ON
 Flag enable cci decoder debug messages.
 
#define DBG_THREAD   DBG_ON
 Flag enable thread debug messages.
 
#define NUM_SINKS(type)   ((type >> 14) & 0x3)
 Number of sink pads.
 
#define NUM_SRCS(type)   ((type >> 12) & 0x3)
 Number of source pads.
 
#define IS_SRC_ELEMENT(type)   (NUM_SRCS(type) > 0 && NUM_SINKS(type) == 0)
 Is source element.
 
#define IS_SINK_ELEMENT(type)   (NUM_SINKS(type) > 0 && NUM_SRCS(type) == 0)
 Is sink element.
 
#define STREAMER_LOG_CATA(on, error, ...)
 
#define STREAMER_LOG_ERR(on, error, ...)
 Log error.
 
#define STREAMER_LOG_WARN(on, error, ...)
 Log warning.
 
#define STREAMER_LOG_DEBUG(on, ...)
 Log debug message.
 
#define STREAMER_LOG_INFO(...)   ilprintf(LOGMDL_STREAMER, __VA_ARGS__)
 Log information.
 
#define STREAMER_FUNC_ENTER(on)
 Debug log function enter.
 
#define STREAMER_FUNC_EXIT(on)
 Debug log function exit.
 
#define MEM4_ALIGN(n)   ((uintptr_t)(n) + (-(uintptr_t)(n)&3))
 Macro for aligning memory.
 
#define MEM_ALIGN(var, alignbytes)    ((unsigned int)((var) + ((alignbytes)-1U)) & (unsigned int)(~(unsigned int)((alignbytes)-1U)))
 Macro to change a value to a given size aligned value.
 
#define CHK_ARGS(check, error)
 Check arguments.
 
#define AF_LITTLE_ENDIAN   false
 Little endiannes.
 
#define AF_BIG_ENDIAN   true
 Big endiannes.
 
#define FILE_RAW_WRITE   1
 File raw write.
 
#define STREAMER_DEFAULT_OUT_DEVICE   AUDIO_SINK_DEVICE_TYPE_PCMRTOS
 
#define STREAMER_DEFAULT_CHUNK_SIZE   (2048)
 
#define STREAMER_WAVE_FILE_CHUNK_SIZE   (4096)
 
#define STREAMER_DEFAULT_UPDATE_DURATION   (1000)
 
#define STREAMER_VERSION   "1.7"
 

Enumerations

enum  StreamDataType {
  DATA_TYPE_UINT32 = 1 ,
  DATA_TYPE_UINT16 ,
  DATA_TYPE_UINT8 ,
  DATA_TYPE_INT32 ,
  DATA_TYPE_INT16 ,
  DATA_TYPE_INT8 ,
  DATA_TYPE_bool ,
  DATA_TYPE_STRING ,
  DATA_TYPE_IMAGE ,
  DATA_TYPE_LAST
}
 
enum  StreamDataFormat {
  DATA_FORMAT_UNDEFINED ,
  DATA_FORMAT_BYTES ,
  DATA_FORMAT_TIME ,
  DATA_FORMAT_PERCENT ,
  DATA_FORMAT_UNKNOWN
}
 

Functions

void streamer_task (void *arg)
 Streamer Task.
 
void streamer_init (STREAMER_T *streamer)
 Streamer Initialize.
 
int streamer_msg_handler (STREAMER_T *streamer, STREAMER_MSG_T *msg)
 Streamer Message Handler.
 
int streamer_process_pipelines (STREAMER_T *streamer)
 Streamer Process Pipelines.
 
int streamer_msg_get_track_info (STREAMER_T *streamer, void *msg_data)
 Streamer Get Track Inforamtion from a pipeline.
 
int streamer_msg_set_state (STREAMER_T *streamer, void *data)
 Streamer Set Pipeline State.
 
int streamer_msg_get_state (STREAMER_T *streamer, void *data)
 Streamer Get State.
 
int streamer_msg_send_query (STREAMER_T *streamer, void *data)
 Streamer Send Query.
 
int streamer_msg_seek_pipeline (STREAMER_T *streamer, void *data)
 Streamer Seek Pipeline.
 
int streamer_msg_set_property (STREAMER_T *streamer, void *data)
 Streamer Set Property.
 
int streamer_msg_get_property (STREAMER_T *streamer, void *data)
 Streamer Get Property.
 
int streamer_msg_set_file (STREAMER_T *streamer, void *data)
 Streamer message set file.
 
int streamer_msg_set_repeat (STREAMER_T *streamer, void *msg_data)
 Streamer Set Pipeline State.
 

Macro Definition Documentation

◆ STREAMER_LOG_CATA

#define STREAMER_LOG_CATA ( on,
error,
... )
Value:
if (on & DBG_ON) \
lprintf(LOGMDL_STREAMER, LOGLVL_CATASTROPHIC, error, __VA_ARGS__)
#define LOGLVL_CATASTROPHIC
Serious error. System cannot recover.
Definition maestro_logging.h:22
#define LOGMDL_STREAMER
Streamer module.
Definition maestro_logging.h:64
#define DBG_ON
Flag enable debug messages.
Definition streamer.h:29

Debug printf macros.

Parameters
onis one of the DBG_ categories listed above. If it has been defined as DBG_ON, then the message will print.
errorError to be print

◆ STREAMER_LOG_ERR

#define STREAMER_LOG_ERR ( on,
error,
... )
Value:
if (on & DBG_ON) \
lprintf(LOGMDL_STREAMER, LOGLVL_ERROR, error, __VA_ARGS__)
#define LOGLVL_ERROR
An error has occurred. The system should \ be able to continue but an individual \ module may not be ...
Definition maestro_logging.h:23

◆ STREAMER_LOG_WARN

#define STREAMER_LOG_WARN ( on,
error,
... )
Value:
if (on & DBG_ON) \
lprintf(LOGMDL_STREAMER, LOGLVL_WARNING, error, __VA_ARGS__)
#define LOGLVL_WARNING
A warning about a potential problem.
Definition maestro_logging.h:27

◆ STREAMER_LOG_DEBUG

#define STREAMER_LOG_DEBUG ( on,
... )
Value:
if (on & DBG_ON) \
dlprintf(LOGMDL_STREAMER, __VA_ARGS__)

◆ STREAMER_FUNC_ENTER

#define STREAMER_FUNC_ENTER ( on)
Value:
if (on > 0) \
LOG_ENTER(LOGMDL_STREAMER)

◆ STREAMER_FUNC_EXIT

#define STREAMER_FUNC_EXIT ( on)
Value:
if (on > 0) \
LOG_EXIT(LOGMDL_STREAMER)

◆ CHK_ARGS

#define CHK_ARGS ( check,
error )
Value:
do \
{ \
if ((check)) \
{ \
return error; \
} \
} while (0)

◆ STREAMER_DEFAULT_OUT_DEVICE

#define STREAMER_DEFAULT_OUT_DEVICE   AUDIO_SINK_DEVICE_TYPE_PCMRTOS

Default output device

◆ STREAMER_DEFAULT_CHUNK_SIZE

#define STREAMER_DEFAULT_CHUNK_SIZE   (2048)

Default source read chunk size for push mode

◆ STREAMER_WAVE_FILE_CHUNK_SIZE

#define STREAMER_WAVE_FILE_CHUNK_SIZE   (4096)

Lossless formats need a bit large chunk size to play smoothly

◆ STREAMER_DEFAULT_UPDATE_DURATION

#define STREAMER_DEFAULT_UPDATE_DURATION   (1000)

Automatically report duration

Enumeration Type Documentation

◆ StreamDataType

StreamDataType Specifies the datatype of query information

◆ StreamDataFormat

Standard predefined event data formats

Function Documentation

◆ streamer_task()

void streamer_task ( void * arg)

This is the streamer task function that processes the main streamer loop. The loop will look to receive messages from the application and to initiate the processing of data through active pipelines.

Parameters
[in]argPointer to input argument structure (STREAMER_ARGS_T)
Returns
N/A

◆ streamer_init()

void streamer_init ( STREAMER_T * streamer)

Initialize data structure associated with Streamer Task

Parameters
[in]streamerPointer to streamer task data structure

◆ streamer_msg_handler()

int streamer_msg_handler ( STREAMER_T * streamer,
STREAMER_MSG_T * msg )

Processes a single message that was received in the streamer task message queue. Messages should follow the format defined in STREAMER_MSG_T structure.

Parameters
[in]streamerPointer to streamer task data structure
[in]msgPointer to message data.
Return values
ERRCODE_NO_ERRORMessage was successfully processed
ERRCODE_INVALID_ARGUMENTInvalid Message
Returns
int

◆ streamer_process_pipelines()

int streamer_process_pipelines ( STREAMER_T * streamer)

Loops through the pipelines present in the streamer task and if the pipeline is in Playing state calls the process pipeline function to start the flow of data.

Parameters
[in]streamerPointer to streamer task data structure
Return values
ERRCODE_NO_ERRORMessage was successfully processed
ERRCODE_INVALID_ARGUMENTInvalid Message
Returns
int

◆ streamer_msg_get_track_info()

int streamer_msg_get_track_info ( STREAMER_T * streamer,
void * msg_data )

Handles request to get track information from a pipeline object.

Parameters
[in]streamerPointer to streamer structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKState retrieved successfully.
STREAM_ERR_INVALID_ARGSInvalid pipeline object

◆ streamer_msg_set_state()

int streamer_msg_set_state ( STREAMER_T * task_data,
void * msg_data )

Handles request to set the state of a pipeline object.

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKState retrieved successfully.
STREAM_ERR_INVALID_ARGSInvalid pipeline object

◆ streamer_msg_get_state()

int streamer_msg_get_state ( STREAMER_T * task_data,
void * msg_data )

Handles request to get the state of a pipeline object. State will be sent back to the application through the callback function.

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKSuccess
STREAM_ERR_INVALID_ARGSInvalid argument

◆ streamer_msg_send_query()

int streamer_msg_send_query ( STREAMER_T * task_data,
void * msg_data )

Handles request to send a query to a pipeline object. Query data is returned through the callback function.

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKQuery successful
STREAM_ERR_INFO_ABSENTQuery unsuccessful. Info not present
STREAM_ERR_INVALID_ARGSInvalid pipeline object

◆ streamer_msg_seek_pipeline()

int streamer_msg_seek_pipeline ( STREAMER_T * task_data,
void * msg_data )

Handles request to seek to a specified time in an audio stream

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKSeek successful
STREAM_ERR_INVALID_ARGSInvalid Pipeline object
STREAM_ERR_NOT_SEEKABLEPipeline does not support seeking

◆ streamer_msg_set_property()

int streamer_msg_set_property ( STREAMER_T * task_data,
void * msg_data )

Set an element specific property value

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKProperty successfully set.
STREAM_ERR_INVALID_ARGSInvalid arguments

◆ streamer_msg_get_property()

int streamer_msg_get_property ( STREAMER_T * task_data,
void * msg_data )

Get an element specific property value

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKProperty successfully retrieved.
STREAM_ERR_INVALID_ARGSInvalid arguments

◆ streamer_msg_set_file()

int streamer_msg_set_file ( STREAMER_T * task_data,
void * msg_data )
Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKProperty successfully retrieved.
STREAM_ERR_INVALID_ARGSInvalid arguments

◆ streamer_msg_set_repeat()

int streamer_msg_set_repeat ( STREAMER_T * task_data,
void * msg_data )

Handles request to set the state of a pipeline object.

Parameters
[in]task_dataPointer to task data structure
[in]msg_dataPointer to Message Data
Returns
Error Status
Return values
STREAM_OKState retrieved successfully.
STREAM_ERR_INVALID_ARGSInvalid pipeline object