MediaProcessors
Classes | Macros | Typedefs | Functions | Variables
comm.c File Reference
#include "comm.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "log.h"
#include "stat_codes.h"
#include "check_utils.h"
#include "llist.h"
#include "uri_parser.h"
Include dependency graph for comm.c:

Go to the source code of this file.

Classes

struct  comm_module_ctx_s
 

Macros

#define TAG_IS(TAG)   (strcmp(tag, TAG)== 0)
 

Typedefs

typedef struct comm_module_ctx_s comm_module_ctx_t
 

Functions

static int register_comm_if (const comm_if_t *comm_if, log_ctx_t *log_ctx)
 
static int unregister_comm_if (const char *scheme, log_ctx_t *log_ctx)
 
static const comm_if_tget_comm_if_by_scheme (const char *scheme, log_ctx_t *log_ctx)
 
static comm_if_tcomm_if_allocate ()
 
static comm_if_tcomm_if_dup (const comm_if_t *comm_if_arg)
 
static void comm_if_release (comm_if_t **ref_comm_if)
 
static int comm_module_url_probe (const char *url)
 
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)
 

Variables

static comm_module_ctx_tcomm_module_ctx = NULL
 

Detailed Description

Author
Rafael Antoniello

Definition in file comm.c.

Macro Definition Documentation

#define TAG_IS (   TAG)    (strcmp(tag, TAG)== 0)

Returns non-zero if 'tag' string is equal to given TAG string.

Definition at line 56 of file comm.c.

Typedef Documentation

Module's context structure. This structure is statically defined in the program.

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.

Variable Documentation

comm_module_ctx_t* comm_module_ctx = NULL
static

Communication module static instance.

Definition at line 99 of file comm.c.