MediaProcessors
Typedefs | Functions
procs.h File Reference

Generic processors (PROC) module. More...

#include <sys/types.h>
#include <inttypes.h>
#include <stdarg.h>
Include dependency graph for procs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct log_ctx_s log_ctx_t
 
typedef struct procs_ctx_s procs_ctx_t
 
typedef struct proc_frame_ctx_s proc_frame_ctx_t
 

Functions

int procs_module_open (log_ctx_t *log_ctx)
 
void procs_module_close ()
 
int procs_module_opt (const char *tag,...)
 
procs_ctx_tprocs_open (log_ctx_t *log_ctx, size_t max_procs_num, const char *prefix_name, const char *procs_href)
 
void procs_close (procs_ctx_t **ref_procs_ctx)
 
int procs_opt (procs_ctx_t *procs_ctx, const char *tag,...)
 
int procs_send_frame (procs_ctx_t *procs_ctx, int proc_id, const proc_frame_ctx_t *proc_frame_ctx)
 
int procs_recv_frame (procs_ctx_t *procs_ctx, int proc_id, proc_frame_ctx_t **ref_proc_frame_ctx)
 

Detailed Description

Generic processors (PROC) module.

Author
Rafael Antoniello

Definition in file procs.h.

Function Documentation

void procs_close ( procs_ctx_t **  ref_procs_ctx)

De-initialize and release the processors (PROCS) module instance context structure.

Parameters
ref_procs_ctxReference to the pointer to the processors (PROCS) module instance context structure to be release, obtained in a previous call to the 'procs_open()' function. Pointer is set to NULL on return.

Definition at line 417 of file procs.c.

void procs_module_close ( )

Close PROCS module. This is a global function and should be called only once at the end of the life of the application.

Definition at line 273 of file procs.c.

int procs_module_open ( log_ctx_t log_ctx)

Open PROCS module. This is a global function and should be called only once at the very beginning and during the life of the application.

Parameters
log_ctxPointer to a externally defined LOG module context structure.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 244 of file procs.c.

int procs_module_opt ( const char *  tag,
  ... 
)

Processors module options. This function represents the API of the PROCS module. This function is thread-safe and can be called concurrently.

Parameters
tagProcessors option tag, namely, option identifier string. The following options are available:
  1. "PROCS_REGISTER_TYPE"
  2. "PROCS_UNREGISTER_TYPE"
...Variable list of parameters according to selected option. Refer to Tags description below to see the different additional parameters corresponding to each option tag.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Tags description (additional variable arguments per tag)

  • Tag "PROCS_REGISTER_TYPE":
    Register the interface of an specific processor type.
    Additional variable arguments for function procs_module_opt() are:
    Parameters
    proc_ifPointer to the processor interface structure (static and unambiguous interface of the type of processor we are registering). Code example:
    1 ...
    2 const proc_if_t proc_if_bypass_proc= {
    3  "bypass_processor",
    4  bypass_proc_open,
    5  bypass_proc_close,
    6  bypass_proc_rest_put,
    7  bypass_proc_rest_get,
    8  bypass_proc_process_frame,
    9  bypass_proc_opt,
    10  NULL, NULL, NULL
    11 };
    12 ...
    13 ret_code= procs_module_opt("PROCS_REGISTER_TYPE", &proc_if_bypass_proc);
  • Tag "PROCS_UNREGISTER_TYPE":
    Unregister interface of an specific processor type.
    Additional variable arguments for function procs_module_opt() are:
    Parameters
    proc_namePointer to a character string with the unambiguous processor type name. Code example:
    1 ret_code= procs_module_opt("PROCS_UNREGISTER_TYPE", "bypass_processor");

Tag "PROCS_GET_TYPE":
Get a copy of the interface of an specific processor type.
Additional variable arguments for function procs_module_opt() are:

Parameters
proc_namePointer to a character string with the unambiguous processor type name.
ref_proc_if_cpyReference to the pointer to the copy of the requested processor interface context structure. If the requested processor exist, a copy of the context structure will be returned by this argument; otherwise, reference content will be set to NULL. Code example:
1 proc_if_t *proc_if_cpy= NULL;
2 ...
3 ret_code= procs_module_opt("PROCS_GET_TYPE", "bypass_processor",
4  &proc_if_cpy);

Definition at line 294 of file procs.c.

procs_ctx_t* procs_open ( log_ctx_t log_ctx,
size_t  max_procs_num,
const char *  prefix_name,
const char *  procs_href 
)

Allocates and initializes processors (PROCS) module instance context structure.

Parameters
log_ctxPointer to the LOG module context structure.
max_procs_numMaximum number of processors that can be created (and managed) by this instance.
prefix_nameModule's API REST prefix name (256 characters maximum). This parameter is optional (NULL may be passed); if not specified, the default name "procs" is used.
procs_hrefModule's API REST href attribute specifying the URL path the API refers to. This parameter is optional (NULL may be passed).
Returns
Pointer to the processors context structure on success, NULL if fails. Code example:
The following call creates a "processors module instance" capable of handling 16 processors. Prefix name "video_processors" suggest we will use this module instance to handle only "video processors", and we give an href such that the module's API may be used applying on the following URL: GET/PUT/POST/DELETE -> 127.0.0.1/video_processors.json
1 procs_ctx_t *procs_ctx;
2 ...
3 procs_ctx= procs_open(log_ctx, 16, "video_processors", "127.0.0.1");

Definition at line 336 of file procs.c.

int procs_opt ( procs_ctx_t procs_ctx,
const char *  tag,
  ... 
)

Processors module instance options. This function represents the API of the PROCS module instance, and exposes all the available options to operate the different processors instances. This function is thread-safe and can be called concurrently.

Parameters
procs_ctxPointer to the processors (PROCS) module instance context structure.
tagProcessors option tag, namely, option identifier string. The following options are available:
  1. "PROCS_POST"
  2. "PROCS_GET"
  3. "PROCS_ID_DELETE"
  4. "PROCS_ID_GET"
  5. "PROCS_ID_PUT"
...Variable list of parameters according to selected option. Refer to Tags description below to see the different additional parameters corresponding to each option tag.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Tags description (additional variable arguments per tag)

  • Tag "PROCS_POST":
    Instantiate and register new processor.
    Additional variable arguments for function procs_opt() are:
    Parameters
    proc_namePointer to a character string with the unambiguous processor type name.
    settings_strCharacter string containing initial settings for the processor. String format can be either a query-string or JSON.
    rest_strReference to the pointer to a character string returning the processor identifier in JSON format as follows: '{"proc_id":id_number}' Code example:
    1 char *rest_str= NULL;
    2 ...
    3 ret_code= procs_opt(procs_ctx, "PROCS_POST", "bypass_processor",
    4  "setting1=100", &rest_str);
  • Tag "PROCS_GET":
    Get the representational state of the processors instances list.
    Additional variable arguments for function procs_opt() are:
    Parameters
    ref_strReference to the pointer to a character string returning the processors list representational state.
    filter_strCharacter string indicating one of the following filters apply:
    • "proc_name==x": Filter the returning list discarding all the processors that are not of the type 'x';
    • "proc_name!=x": Filter the returning list discarding all the processors that are of the type 'x'. This parameter is optional, and can be set to NULL (no filter apply). Code example:
      1 char *rest_str= NULL;
      2 ...
      3 ret_code= procs_opt(procs_ctx, "PROCS_GET", &rest_str, NULL);
  • Tag "PROCS_ID_DELETE":
    Unregister and release a processor instance.
    Additional variable arguments for function procs_opt() are:
    Parameters
    proc_idProcessor instance unambiguous Id. Code example:
    1 ret_code= procs_opt(procs_ctx, "PROCS_ID_DELETE", proc_id);
  • Tag "PROCS_ID_GET":
    Get the representational state of a processor instance (including current settings).
    Additional variable arguments for function procs_opt() are:
    Parameters
    proc_idProcessor instance unambiguous Id.
    ref_strReference to the pointer to a character string returning the processor's representational state. Code example:
    1 char *rest_str= NULL;
    2 ...
    3 ret_code= procs_opt(procs_ctx, "PROCS_ID_GET", proc_id, &rest_str);
  • Tag "PROCS_ID_PUT":
    Put (pass) new settings to a processor instance.
    Additional variable arguments for function procs_opt() are:
    Parameters
    proc_idProcessor instance unambiguous Id.
    strPointer to a character string containing new settings for the processor instance. String format can be either a query-string or JSON. Code example:
    1 ret_code= procs_opt(procs_ctx, "PROCS_ID_PUT", proc_id, "setting1=100");

Definition at line 474 of file procs.c.

int procs_recv_frame ( procs_ctx_t procs_ctx,
int  proc_id,
proc_frame_ctx_t **  ref_proc_frame_ctx 
)

Get new processed frame of data from the indicated processor's output FIFO buffer (the processor instance is indicated by the processor Id.). This function blocks until a new frame is available to be read from the processor's output FIFO. To unblock this function, the corresponding processor instance should be deleted. This function is thread-safe and can be called concurrently.

Parameters
procs_ctxPointer to the processors (PROCS) module instance context structure.
proc_idProcessor instance unambiguous Id.
ref_proc_frame_ctxReference to the pointer to a structure characterizing the output processed frame. This function will return the processed frame passing its structure pointer by argument.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 545 of file procs.c.

int procs_send_frame ( procs_ctx_t procs_ctx,
int  proc_id,
const proc_frame_ctx_t proc_frame_ctx 
)

Put new frame of data to be processed in the indicated processor's input FIFO buffer (the processor instance is indicated by the processor Id.). This function blocks until a slot is available to be able to push the new frame into the processor's input FIFO. To unblock this function, the corresponding processor instance should be deleted. This function is thread-safe and can be called concurrently.

Parameters
procs_ctxPointer to the processors (PROCS) module instance context structure.
proc_idProcessor instance unambiguous Id.
proc_frame_ctxPointer to the structure characterizing the input frame to be processed. The frame is duplicated and inserted in the FIFO buffer.
Returns
Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).

Definition at line 504 of file procs.c.