#include "proc.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <time.h>
#include <errno.h>
#include <libcjson/cJSON.h>
#include <libmediaprocsutils/log.h>
#include <libmediaprocsutils/stat_codes.h>
#include <libmediaprocsutils/check_utils.h>
#include <libmediaprocsutils/schedule.h>
#include <libmediaprocsutils/fifo.h>
#include <libmediaprocsutils/fair_lock.h>
#include <libmediaprocsutils/interr_usleep.h>
#include "proc_if.h"
Go to the source code of this file.
|
|
static int | procs_id_get (proc_ctx_t *proc_ctx, log_ctx_t *log_ctx, proc_if_rest_fmt_t rest_fmt, void **ref_reponse) |
| |
|
static void * | proc_stats_thr (void *t) |
| |
|
static void * | proc_thr (void *t) |
| |
| static void | proc_stats_register_frame_pts (proc_ctx_t *proc_ctx, const proc_frame_ctx_t *proc_frame_ctx, const proc_io_t proc_io) |
| |
| static void | proc_stats_register_accumulated_io_bits (proc_ctx_t *proc_ctx, const proc_frame_ctx_t *proc_frame_ctx, const proc_io_t proc_io) |
| |
| proc_ctx_t * | proc_open (const proc_if_t *proc_if, const char *settings_str, int proc_instance_index, uint32_t fifo_ctx_maxsize[PROC_IO_NUM], log_ctx_t *log_ctx, va_list arg) |
| |
| void | proc_close (proc_ctx_t **ref_proc_ctx) |
| |
| int | proc_send_frame (proc_ctx_t *proc_ctx, const proc_frame_ctx_t *proc_frame_ctx) |
| |
| int | proc_recv_frame (proc_ctx_t *proc_ctx, proc_frame_ctx_t **ref_proc_frame_ctx) |
| |
| int | proc_opt (proc_ctx_t *proc_ctx, const char *tag,...) |
| |
| int | proc_vopt (proc_ctx_t *proc_ctx, const char *tag, va_list arg) |
| |
|
int | proc_send_frame_default1 (proc_ctx_t *proc_ctx, const proc_frame_ctx_t *proc_frame_ctx) |
| |
|
int | proc_recv_frame_default1 (proc_ctx_t *proc_ctx, proc_frame_ctx_t **ref_proc_frame_ctx) |
| |
|
void | proc_stats_register_accumulated_latency (proc_ctx_t *proc_ctx, const int64_t oput_frame_pts) |
| |
- Author
- Rafael Antoniello
Definition in file proc.c.
| #define PROC_STATS_THR_MEASURE_PERIOD_USECS (1000000) |
Processor's statistic thread period (1 second).
Definition at line 70 of file proc.c.
| #define TAG_HAS |
( |
|
NEEDLE | ) |
(strstr(tag, NEEDLE)!= NULL) |
Returns non-zero if given 'tag' string contains 'needle' sub-string.
Definition at line 60 of file proc.c.
| #define TAG_IS |
( |
|
TAG | ) |
(strcmp(tag, TAG)== 0) |
Returns non-zero if 'tag' string is equal to given TAG string.
Definition at line 65 of file proc.c.
Ends processing thread, de-initialize and release the generic processor (PROC) context structure and all the related resources.
- Parameters
-
| ref_proc_ctx | Reference to the pointer to the processor (PROC) context structure to be release, that was obtained in a previous call to the 'proc_open()' function. Pointer is set to NULL on return. |
Definition at line 208 of file proc.c.
| proc_ctx_t* proc_open |
( |
const proc_if_t * |
proc_if, |
|
|
const char * |
settings_str, |
|
|
int |
proc_instance_index, |
|
|
uint32_t |
fifo_ctx_maxsize[PROC_IO_NUM], |
|
|
log_ctx_t * |
log_ctx, |
|
|
va_list |
arg |
|
) |
| |
Allocates generic processor (PROC) context structure, initializes, and launches processing thread.
- Parameters
-
| proc_if | Pointer to the processor interface structure (static and unambiguous interface of the type of processor we are opening). |
| settings_str | Character string containing initial settings for the processor. String format can be either a query-string or JSON. |
| proc_instance_index | Each PROC instance is registered in an instance array with a specific index (managed and assigned from outside this module). The idea behind using an array is to fetch as fast as possible the PROC instance to perform i/o operations. |
| fifo_ctx_maxsize | Maximum size, in number of queued elements, for the input and output FIFOs of the processor. |
| log_ctx | Pointer to the LOG module context structure. |
| arg | Variable list of parameters defined by user. |
- Returns
- Pointer to the generic processor context structure on success, NULL if fails.
Definition at line 87 of file proc.c.
| int proc_opt |
( |
proc_ctx_t * |
proc_ctx, |
|
|
const char * |
tag, |
|
|
|
... |
|
) |
| |
Processor options. This function is thread-safe and can be called concurrently.
- Parameters
-
| proc_ctx | Pointer to the processor (PROC) context structure obtained in a previous call to the 'proc_open()' function. |
| tag | Processor option tag, namely, option identifier string. The following options are available:
- PROC_UNBLOCK
- PROC_GET
- PROC_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 "PROC_UNBLOCK":
Unblock processor input/output FIFO buffers.
No additional variable arguments are needed for calling function proc_opt() with this tag.
Tag "PROC_GET":
Get processor representational state (including current settings).
Additional variable arguments for function proc_opt() are:
- Parameters
-
| rest_fmt | Indicates the format in which the response data is to be returned. Available formats are enumerated at 'proc_if_rest_fmt_t'. |
| ref_reponse | Reference to the pointer to a data structure returning the processor's representational state. The returned data structure is formatted according to what is indicated in the parameter 'rest_fmt'. |
Tag "PROC_PUT":
Put (pass) new settings to processor.
Additional variable arguments for function proc_opt() are:
- Parameters
-
| str | Pointer to a character string containing new settings for the processor. String format can be either a query-string or JSON. |
Definition at line 368 of file proc.c.
Get new processed frame of data from the processor's output buffer. Unless unblocked (see processor options 'proc_opt()'), this function blocks until a new frame is available to be read from the processor's output buffer. This function is thread-safe and can be called concurrently.
- Parameters
-
| proc_ctx | Pointer to the processor (PROC) context structure obtained in a previous call to the 'proc_open()' function. |
| 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 323 of file proc.c.
Put new frame of data to be processed in the processor's input buffer. Unless unblocked (see processor options 'proc_opt()'), this function blocks until a slot is available to be able to push the new frame into the processor's input buffer. This function is thread-safe and can be called concurrently.
- Parameters
-
| proc_ctx | Pointer to the processor (PROC) context structure obtained in a previous call to the 'proc_open()' function. |
| proc_frame_ctx | Pointer to the structure characterizing the input frame to be processed. The frame is duplicated and inserted in the input buffer. |
- Returns
- Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).
Definition at line 287 of file proc.c.
Register accumulated input/output bits. This is used to compute bitrate statistics.
Definition at line 828 of file proc.c.
Register frame presentation time stamp (PTS).
Definition at line 793 of file proc.c.
| int proc_vopt |
( |
proc_ctx_t * |
proc_ctx, |
|
|
const char * |
tag, |
|
|
va_list |
arg |
|
) |
| |
The function 'proc_vopt()' is the same as proc_opt() except that it is called with a va_list instead of a variable number of arguments. This function does not call the va_end macro. Because it invoke the va_arg macro, the value of the argument pointer is undefined after the call.
Definition at line 382 of file proc.c.