MediaProcessors
Classes | Typedefs | Enumerations | Functions
comm.h File Reference

Generic communication module. More...

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

Go to the source code of this file.

Classes

struct  comm_if_s
 
struct  comm_ctx_s
 

Typedefs

typedef struct log_ctx_s log_ctx_t
 
typedef struct comm_ctx_s comm_ctx_t
 
typedef enum comm_mode_enum comm_mode_t
 
typedef struct comm_if_s comm_if_t
 

Enumerations

enum  comm_mode_enum { COMM_MODE_IPUT = 0, COMM_MODE_OPUT, COMM_MODE_MAX }
 

Functions

int comm_module_open (log_ctx_t *log_ctx)
 
void comm_module_close ()
 
int comm_module_opt (const char *tag,...)
 
comm_ctx_tcomm_open (const char *url, const char *local_url, comm_mode_t comm_mode, log_ctx_t *log_ctx,...)
 
void comm_close (comm_ctx_t **ref_comm_ctx)
 
int comm_send (comm_ctx_t *comm_ctx, const void *buf, size_t count, struct timeval *timeout)
 
int comm_recv (comm_ctx_t *comm_ctx, void **ref_buf, size_t *ref_count, char **ref_from, struct timeval *timeout)
 
int comm_unblock (comm_ctx_t *comm_ctx)
 
int comm_open_external (pthread_mutex_t *comm_ctx_mutex_external, const char *url, const char *local_url, comm_mode_t comm_mode, log_ctx_t *log_ctx, comm_ctx_t **ref_comm_ctx,...)
 
void comm_close_external (pthread_mutex_t *comm_ctx_mutex_external, comm_ctx_t **ref_comm_ctx, log_ctx_t *log_ctx)
 
int comm_reset_external (pthread_mutex_t *comm_ctx_mutex_external, const char *new_url, const char *local_url, comm_mode_t comm_mode, log_ctx_t *log_ctx, comm_ctx_t **ref_comm_ctx_curr,...)
 
int comm_recv_external (pthread_mutex_t *comm_ctx_mutex_external, comm_ctx_t **ref_comm_ctx, void **ref_buf, size_t *ref_count, char **ref_from, struct timeval *timeout, log_ctx_t *log_ctx)
 

Detailed Description

Generic communication module.

Author
Rafael Antoniello

Definition in file comm.h.

Typedef Documentation

typedef struct comm_ctx_s comm_ctx_t

Communication module instance context structure ('handler').

Definition at line 48 of file comm.h.

typedef struct comm_if_s comm_if_t

Communication protocol interface structure prototype. Each specific communication module implementation will define a static and unambiguous interface of this type.

Indicates the communication module instance mode: input or output.

Enumeration Type Documentation

Indicates the communication module instance mode: input or output.

Definition at line 53 of file comm.h.

Function Documentation

void comm_module_close ( )

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

Definition at line 129 of file comm.c.

int comm_module_open ( log_ctx_t log_ctx)

Open communication 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 101 of file comm.c.

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

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

Parameters
tagOption tag, namely, option identifier string. The following options are available:
  1. "COMM_REGISTER_PROTO"
  2. "COMM_UNREGISTER_PROTO"
...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 "COMM_REGISTER_PROTO":
    Register the interface of an specific communication protocol.
    Additional variable arguments for function comm_module_opt() are:
    Parameters
    comm_ifPointer to the protocol interface structure (static and unambiguous interface implementation of the type 'comm_if_t'). Code example:
    1 ...
    2 const comm_if_t comm_if_udp= {
    3  "udp",
    4  comm_udp_open,
    5  comm_udp_close,
    6  comm_udp_send,
    7  comm_udp_recv,
    8  comm_udp_unblock
    9 };
    10 ...
    11 ret_code= comm_module_opt("COMM_REGISTER_PROTO", &comm_if_udp);
  • Tag "COMM_UNREGISTER_PROTO":
    Unregister the interface of an specific communication protocol.
    Additional variable arguments for function comm_module_opt() are:
    Parameters
    schemePointer to a character string with the unambiguous protocol scheme name (for example: "udp", "file", ...). Code example:
    1 ret_code= comm_module_opt("COMM_UNREGISTER_PROTO", "udp");

Definition at line 150 of file comm.c.