Generic processors (PROC) module.
More...
#include <sys/types.h>
#include <inttypes.h>
#include <stdarg.h>
Go to the source code of this file.
|
int | procs_module_open (log_ctx_t *log_ctx) |
|
void | procs_module_close () |
|
int | procs_module_opt (const char *tag,...) |
|
procs_ctx_t * | procs_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) |
|
Generic processors (PROC) module.
- Author
- Rafael Antoniello
Definition in file procs.h.
De-initialize and release the processors (PROCS) module instance context structure.
- Parameters
-
ref_procs_ctx | Reference 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.
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_ctx | Pointer 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
-
tag | Processors option tag, namely, option identifier string. The following options are available:
- "PROCS_REGISTER_TYPE"
- "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_if | Pointer to the processor interface structure (static and unambiguous interface of the type of processor we are registering). Code example: 2 const proc_if_t proc_if_bypass_proc= { 8 bypass_proc_process_frame, 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_name | Pointer 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_name | Pointer to a character string with the unambiguous processor type name. |
ref_proc_if_cpy | Reference 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; 3 ret_code= procs_module_opt("PROCS_GET_TYPE", "bypass_processor", |
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_ctx | Pointer to the LOG module context structure. |
max_procs_num | Maximum number of processors that can be created (and managed) by this instance. |
prefix_name | Module'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_href | Module'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;
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_ctx | Pointer to the processors (PROCS) module instance context structure. |
tag | Processors option tag, namely, option identifier string. The following options are available:
- "PROCS_POST"
- "PROCS_GET"
- "PROCS_ID_DELETE"
- "PROCS_ID_GET"
- "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_name | Pointer to a character string with the unambiguous processor type name. |
settings_str | Character string containing initial settings for the processor. String format can be either a query-string or JSON. |
rest_str | Reference to the pointer to a character string returning the processor identifier in JSON format as follows: '{"proc_id":id_number}' Code example: 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_str | Reference to the pointer to a character string returning the processors list representational state. |
filter_str | Character 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:
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_id | Processor 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_id | Processor instance unambiguous Id. |
ref_str | Reference to the pointer to a character string returning the processor's representational state. Code example: 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_id | Processor instance unambiguous Id. |
str | Pointer 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.
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_ctx | Pointer to the processors (PROCS) module instance context structure. |
proc_id | Processor instance unambiguous Id. |
ref_proc_frame_ctx | Reference 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.
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_ctx | Pointer to the processors (PROCS) module instance context structure. |
proc_id | Processor instance unambiguous Id. |
proc_frame_ctx | Pointer 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.