MediaProcessors
proc_if.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, 2018 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 
26 #ifndef MEDIAPROCESSORS_SRC_PROC_IF_H_
27 #define MEDIAPROCESSORS_SRC_PROC_IF_H_
28 
29 #include <sys/types.h>
30 #include <inttypes.h>
31 #include <stdarg.h>
32 
33 /* **** Definitions **** */
34 
35 /* Forward definitions */
36 typedef struct proc_ctx_s proc_ctx_t;
37 typedef struct proc_if_s proc_if_t;
38 typedef struct log_ctx_s log_ctx_t;
39 typedef struct fifo_ctx_s fifo_ctx_t;
40 
44 #define PROC_FRAME_MAX_WIDTH 4096
45 
48 #define PROC_FRAME_MAX_HEIGHT 4096
49 
53 typedef enum proc_sample_fmt_enum {
56  //PROC_IF_FMT_RGB24, ///< Packed RGB 8:8:8 with 24bpp (video) //Reserved for future use
60 
66 typedef struct proc_sample_fmt_lut_s {
67  int id;
68  char desc[256];
70 
78 typedef struct proc_frame_ctx_s {
79 #define PROC_FRAME_NUM_DATA_POINTERS 8
80 
84  uint8_t *data;
94  const uint8_t *p_data[PROC_FRAME_NUM_DATA_POINTERS];
107  int linesize[PROC_FRAME_NUM_DATA_POINTERS];
113  size_t width[PROC_FRAME_NUM_DATA_POINTERS];
119  size_t height[PROC_FRAME_NUM_DATA_POINTERS];
138  int64_t pts;
144  int64_t dts;
149  int es_id;
151 
157 typedef enum proc_if_rest_fmt_enum {
161  PROC_IF_REST_FMT_ENUM_MAX
163 
169 typedef struct proc_if_s {
174  const char *proc_name;
179  const char *proc_type;
186  const char *proc_mime;
191 #define PROC_FEATURE_BITRATE 1 //< Implements i/o bitrate statistics.
192 #define PROC_FEATURE_REGISTER_PTS 2 //< Implements i/o PTS statistics
193 #define PROC_FEATURE_LATENCY 4 //< Implements latency statistics.
194 
207  proc_ctx_t* (*open)(const proc_if_t *proc_if, const char *settings_str,
208  log_ctx_t *log_ctx, va_list arg);
217  void (*close)(proc_ctx_t **ref_proc_ctx);
222  int (*send_frame)(proc_ctx_t *proc_ctx,
223  const proc_frame_ctx_t *proc_frame_ctx);
224  int (*send_frame_nodup)(proc_ctx_t *proc_ctx,
225  proc_frame_ctx_t **ref_proc_frame_ctx);
230  int (*recv_frame)(proc_ctx_t *proc_ctx,
231  proc_frame_ctx_t **ref_proc_frame_ctx);
235  int (*unblock)(proc_ctx_t *proc_ctx);
248  int (*rest_put)(proc_ctx_t *proc_ctx, const char *str);
265  int (*rest_get)(proc_ctx_t *proc_ctx, const proc_if_rest_fmt_t rest_fmt,
266  void **ref_reponse);
279  int (*process_frame)(proc_ctx_t *proc_ctx, fifo_ctx_t *fifo_ctx_iput,
280  fifo_ctx_t *fifo_ctx_oput);
295  int (*opt)(proc_ctx_t *proc_ctx, const char *tag, va_list arg);
311  void* (*iput_fifo_elem_opaque_dup)(const proc_frame_ctx_t* proc_frame_ctx);
324  void (*iput_fifo_elem_opaque_release)(void **ref_t);
339  proc_frame_ctx_t* (*oput_fifo_elem_opaque_dup)(const void *t);
340 } proc_if_t;
341 
342 /* **** Prototypes **** */
343 
348 
355 
364  const proc_frame_ctx_t *proc_frame_ctx_arg);
365 
371 void proc_frame_ctx_release(proc_frame_ctx_t **ref_proc_frame_ctx);
372 
379 
387 proc_if_t* proc_if_dup(const proc_if_t *proc_if_arg);
388 
398 int proc_if_cmp(const proc_if_t* proc_if1, const proc_if_t* proc_if2);
399 
405 void proc_if_release(proc_if_t **ref_proc_if);
406 
407 #endif /* MEDIAPROCESSORS_SRC_PROC_IF_H_ */
C structure or block of binary data.
Definition: proc_if.h:160
struct proc_if_s proc_if_t
Definition: proc_if.h:37
struct proc_frame_ctx_s proc_frame_ctx_t
const char * proc_mime
Definition: proc_if.h:186
int proc_sampling_rate
Definition: proc_if.h:134
proc_frame_ctx_t * proc_frame_ctx_allocate()
Definition: proc_if.c:47
int proc_sample_fmt
Definition: proc_if.h:127
proc_sample_fmt_enum
Definition: proc_if.h:53
int64_t dts
Definition: proc_if.h:144
const char * proc_type
Definition: proc_if.h:179
proc_frame_ctx_t * proc_frame_ctx_dup(const proc_frame_ctx_t *proc_frame_ctx_arg)
Definition: proc_if.c:52
void proc_if_release(proc_if_t **ref_proc_if)
Definition: proc_if.c:232
uint64_t flag_proc_features
Definition: proc_if.h:190
struct proc_sample_fmt_lut_s proc_sample_fmt_lut_t
int proc_if_cmp(const proc_if_t *proc_if1, const proc_if_t *proc_if2)
Definition: proc_if.c:187
Character string response.
Definition: proc_if.h:158
enum proc_sample_fmt_enum proc_sample_fmt_t
Planar YUV 4:2:0 with 12bpp (video)
Definition: proc_if.h:55
enum proc_if_rest_fmt_enum proc_if_rest_fmt_t
cJSON structure response
Definition: proc_if.h:159
const proc_sample_fmt_lut_t proc_sample_fmt_lut[]
Definition: proc_if.c:38
Planar signed 16 bits (typically audio)
Definition: proc_if.h:58
Undefined format.
Definition: proc_if.h:54
void proc_frame_ctx_release(proc_frame_ctx_t **ref_proc_frame_ctx)
Definition: proc_if.c:125
proc_if_t * proc_if_allocate()
Definition: proc_if.c:142
Interleaved signed 16 bits (typically audio)
Definition: proc_if.h:57
proc_if_rest_fmt_enum
Definition: proc_if.h:157
Definition: log.c:102
proc_if_t * proc_if_dup(const proc_if_t *proc_if_arg)
Definition: proc_if.c:147
const char * proc_name
Definition: proc_if.h:174
uint8_t * data
Definition: proc_if.h:84
int64_t pts
Definition: proc_if.h:138