Zephyr Project API 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Element injecting application data into a pipeline. More...

Files

file  mpipe_app_src.h
 Application source element.

Data Structures

struct  mpipe_app_src
 Application source element structure. More...

Enumerations

enum  { MPIPE_PROP_BASE_APP_SRC_CAPS = MPIPE_PROP_SRC_LAST }
 Application source property identifiers. More...

Functions

int mpipe_app_src_init (struct mpipe_app_src *app_src, uint8_t id)
 Initialize an application source element.
int mpipe_app_src_alloc (struct mpipe_app_src *app_src, uint32_t size, k_timeout_t timeout, struct net_buf **buf)
 Take a buffer of the element's pool to fill in place.
int mpipe_app_src_push_buf (struct mpipe_app_src *app_src, struct net_buf *buf, uint32_t size, k_timeout_t timeout)
 Queue a filled buffer into the pipeline.
int mpipe_app_src_push (struct mpipe_app_src *app_src, const void *data, uint32_t size, k_timeout_t timeout)
 Push one payload into the pipeline, by copy.
int mpipe_app_src_eos (struct mpipe_app_src *app_src, k_timeout_t timeout)
 Declare end of stream.

Detailed Description

Element injecting application data into a pipeline.

The application boundary on the producing side. Payloads either travel by copy, with mpipe_app_src_push, or in place: mpipe_app_src_alloc hands out a buffer of the element's pool for the application to fill, and mpipe_app_src_push_buf queues it.

Push once the pipeline is at least PAUSED: whatever was queued while READY is discarded when the pipeline starts. End of stream is declared with mpipe_app_src_eos; alternatively MPIPE_PROP_SRC_NUM_BUFS ends the stream after a number of buffers.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#include <mpipe_app_src.h>

Application source property identifiers.

Enumerator
MPIPE_PROP_BASE_APP_SRC_CAPS 

Capability of the produced stream, a const struct mpipe_structure pointer, copied.

It is what negotiation offers downstream; what the application pushes must match it, the element cannot check. Until it is set the element offers a capability constraining nothing.

Function Documentation

◆ mpipe_app_src_alloc()

int mpipe_app_src_alloc ( struct mpipe_app_src * app_src,
uint32_t size,
k_timeout_t timeout,
struct net_buf ** buf )

#include <mpipe_app_src.h>

Take a buffer of the element's pool to fill in place.

The buffer holds up to CONFIG_MPIPE_BASE_APP_SRC_BUF_SZ bytes. The application writes its payload into the buffer data and hands the buffer to mpipe_app_src_push_buf, or releases it with net_buf_unref() if it changes its mind.

Parameters
app_srcThe application source
sizeNumber of payload bytes the buffer must hold
timeoutHow long to wait for a free buffer
bufFilled with the buffer
Return values
0Success
-EINVALBad arguments, or size above the buffer size
-ENOBUFSNo buffer became free within timeout

◆ mpipe_app_src_eos()

int mpipe_app_src_eos ( struct mpipe_app_src * app_src,
k_timeout_t timeout )

#include <mpipe_app_src.h>

Declare end of stream.

Buffers pushed before this call are still delivered; the pipeline then receives EOS.

Parameters
app_srcThe application source
timeoutHow long to wait for a queue slot
Return values
0Success
-EINVALapp_src is NULL
-EAGAINThe queue stayed full within timeout

◆ mpipe_app_src_init()

int mpipe_app_src_init ( struct mpipe_app_src * app_src,
uint8_t id )

#include <mpipe_app_src.h>

Initialize an application source element.

Parameters
app_srcPointer to the element to initialize.
idUnique element identifier.
Returns
0 on success, negative errno otherwise.

◆ mpipe_app_src_push()

int mpipe_app_src_push ( struct mpipe_app_src * app_src,
const void * data,
uint32_t size,
k_timeout_t timeout )

#include <mpipe_app_src.h>

Push one payload into the pipeline, by copy.

Takes a buffer, copies size bytes into it and queues it: the two waits may each last up to timeout.

Parameters
app_srcThe application source
dataPayload bytes
sizeNumber of bytes, bounded by CONFIG_MPIPE_BASE_APP_SRC_BUF_SZ
timeoutHow long to wait for a free buffer, and for a queue slot
Return values
0Success
-EINVALBad arguments
-ENOBUFSNo buffer became free within timeout
-EAGAINThe queue stayed full within timeout

◆ mpipe_app_src_push_buf()

int mpipe_app_src_push_buf ( struct mpipe_app_src * app_src,
struct net_buf * buf,
uint32_t size,
k_timeout_t timeout )

#include <mpipe_app_src.h>

Queue a filled buffer into the pipeline.

The buffer comes from mpipe_app_src_alloc. On success the pipeline owns it; on failure it stays the caller's, to retry or release.

Parameters
app_srcThe application source
bufThe buffer to queue
sizeNumber of valid payload bytes in the buffer
timeoutHow long to wait for a queue slot
Return values
0Success
-EINVALBad arguments, or size above what the buffer holds
-EAGAINThe queue stayed full within timeout