MediaProcessors
proc_muxer.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Rafael Antoniello
3  *
4  * This file is part of MediaProcessors.
5  *
6  * MediaProcessors is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * MediaProcessors is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with MediaProcessors. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
25 #include "proc_muxer.h"
26 
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <string.h>
31 #include <errno.h>
32 #include <pthread.h>
33 
34 #include <libcjson/cJSON.h>
35 
36 #include <libmediaprocsutils/log.h>
37 #include <libmediaprocsutils/stat_codes.h>
38 #include <libmediaprocsutils/check_utils.h>
39 #include <libmediaprocs/procs.h>
40 
41 /* **** Definitions **** */
42 
46 #define PROC_MUXER_MAX_ES_NUM 64
47 
48 /* **** Implementations **** */
49 
51  log_ctx_t *log_ctx)
52 {
53  int end_code= STAT_ERROR;
54  LOG_CTX_INIT(log_ctx);
55 
56  /* Check arguments */
57  CHECK_DO(proc_muxer_mux_ctx!= NULL, goto end);
58 
59  proc_muxer_mux_ctx->procs_ctx_es_muxers= procs_open(LOG_CTX_GET(),
60  PROC_MUXER_MAX_ES_NUM, NULL, NULL);
61  CHECK_DO(proc_muxer_mux_ctx->procs_ctx_es_muxers!= NULL, goto end);
62 
63  end_code= STAT_SUCCESS;
64 end:
65  if(end_code!= STAT_SUCCESS)
66  proc_muxer_mux_ctx_deinit(proc_muxer_mux_ctx, LOG_CTX_GET());
67  return STAT_SUCCESS;
68 }
69 
71  log_ctx_t *log_ctx)
72 {
73  if(proc_muxer_mux_ctx== NULL)
74  return;
75 
76  if(proc_muxer_mux_ctx->procs_ctx_es_muxers!= NULL)
77  procs_close(&proc_muxer_mux_ctx->procs_ctx_es_muxers);
78 }
Generic processor module context (see type proc_ctx_t) extension for multiplexers and de-multiplexers...
procs_ctx_t * procs_ctx_es_muxers
Definition: proc_muxer.h:49
#define PROC_MUXER_MAX_ES_NUM
Definition: proc_muxer.c:46
void proc_muxer_mux_ctx_deinit(proc_muxer_mux_ctx_t *proc_muxer_mux_ctx, log_ctx_t *log_ctx)
Definition: proc_muxer.c:70
#define CHECK_DO(COND, ACTION)
Definition: check_utils.h:57
void procs_close(procs_ctx_t **ref_procs_ctx)
Definition: procs.c:417
Definition: log.c:102
procs_ctx_t * procs_open(log_ctx_t *log_ctx, size_t max_procs_num, const char *prefix_name, const char *procs_href)
Definition: procs.c:336
int proc_muxer_mux_ctx_init(proc_muxer_mux_ctx_t *proc_muxer_mux_ctx, log_ctx_t *log_ctx)
Definition: proc_muxer.c:50