UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
capture_filter.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  capture_filter_info
 

Macros

#define CAPTURE_FILTER_ABI_VERSION   3
 

Functions

struct video_frame * capture_filter (struct capture_filter *state, struct video_frame *frame)
 
void capture_filter_destroy (struct capture_filter *state)
 
int capture_filter_init (struct module *parent, const char *cfg, struct capture_filter **state)
 

Detailed Description

Macro Definition Documentation

◆ CAPTURE_FILTER_ABI_VERSION

#define CAPTURE_FILTER_ABI_VERSION   3

Definition at line 41 of file capture_filter.h.

Referenced by capture_filter_init(), and create_filter().

Function Documentation

◆ capture_filter()

struct video_frame * capture_filter ( struct capture_filter * state,
struct video_frame * frame )

Definition at line 212 of file capture_filter.cpp.

212 {
213 struct capture_filter *s = state;
214
215 struct message *msg;
216 while ((msg = check_message(&s->mod))) {
217 struct response *r = process_message(s, (struct msg_universal *) msg);
218 free_message(msg, r);
219 }
220
221 for(void *it = simple_linked_list_it_init(s->filters);
222 it != NULL;
223 ) {
225 frame = inst->functions->filter(inst->state, frame);
226 if(!frame)
227 return NULL;
228 }
229 return frame;
230}
void ** state
struct video_frame * frame
static struct response * process_message(struct capture_filter *s, struct msg_universal *msg)
void * simple_linked_list_it_next(void **i)
Definition list.cpp:119
void * simple_linked_list_it_init(struct simple_linked_list *l)
Definition list.cpp:108
void free_message(struct message *msg, struct response *r)
struct message * check_message(struct module *mod)
struct msghdr msg
struct video_frame *(* filter)(void *state, struct video_frame *f)
Performs filtering.
const struct capture_filter_info * functions
struct module mod
struct simple_linked_list * filters

References check_message(), capture_filter_info::filter, capture_filter::filters, frame, free_message(), capture_filter_instance::functions, capture_filter::mod, msg, process_message(), simple_linked_list_it_init(), simple_linked_list_it_next(), capture_filter_instance::state, and state.

Referenced by hd_rum_decompress::state_transcoder_decompress::frame_arrived(), and vidcap_grab().

Here is the call graph for this function:

◆ capture_filter_destroy()

void capture_filter_destroy ( struct capture_filter * state)

Definition at line 152 of file capture_filter.cpp.

153{
154 struct capture_filter *s = state;
155
156 while(simple_linked_list_size(s->filters) > 0) {
158 inst->functions->done(inst->state);
159 free(inst);
160 }
161
163
164 module_done(&s->mod);
165
166 free(state);
167}
void module_done(struct module *module_data)
Definition module.c:93
int simple_linked_list_size(struct simple_linked_list *l)
Definition list.cpp:93
void simple_linked_list_destroy(struct simple_linked_list *l)
Definition list.cpp:58
void * simple_linked_list_pop(struct simple_linked_list *l)
Definition list.cpp:82
void(* done)(void *state)

References capture_filter_info::done, capture_filter::filters, capture_filter_instance::functions, capture_filter::mod, module_done(), simple_linked_list_destroy(), simple_linked_list_pop(), simple_linked_list_size(), capture_filter_instance::state, and state.

Referenced by hd_rum_decompress_done(), and vidcap_done().

Here is the call graph for this function:

◆ capture_filter_init()

int capture_filter_init ( struct module * parent,
const char * cfg,
struct capture_filter ** state )
See also
display_init

Definition at line 102 of file capture_filter.cpp.

103{
104 if (cfg && (strcasecmp(cfg, "help") == 0 || strcasecmp(cfg, "fullhelp") == 0)) {
105 printf("Usage:\n");
106 color_printf(TERM_BOLD "\t--capture-filter <filter1>[:opts][,<filter2>[:opts][,<filter3>[:<opts>]]]" TERM_RESET " -t <capture>\n\n");
107 printf("Available capture filters:\n");
108 list_modules(LIBRARY_CLASS_CAPTURE_FILTER, CAPTURE_FILTER_ABI_VERSION, strcasecmp(cfg, "fullhelp") == 0);
109 if (strcasecmp(cfg, "fullhelp") != 0) {
110 printf("(use \"fullhelp\" to show hidden filters)\n");
111 }
112 return 1;
113 }
114
115 struct capture_filter *s = (struct capture_filter *) calloc(1, sizeof(struct capture_filter));
116 char *item, *save_ptr;
117 assert(s);
118 char *filter_list_str = NULL,
119 *tmp = NULL;
120
122
126
127 if(cfg) {
128 filter_list_str = tmp = strdup(cfg);
129
130 while((item = strtok_r(filter_list_str, ",", &save_ptr))) {
131 char filter_name[128];
132 strncpy(filter_name, item, sizeof filter_name - 1);
133
134 int ret = create_filter(s, filter_name);
135 if (ret != 0) {
136 module_done(&s->mod);
137 free(tmp);
138 free(s);
139 return ret;
140 }
141 filter_list_str = NULL;
142 }
143 }
144
145 free(tmp);
146
147 *state = s;
148
149 return 0;
150}
static int create_filter(struct capture_filter *s, char *cfg)
#define CAPTURE_FILTER_ABI_VERSION
int color_printf(const char *format,...)
#define TERM_BOLD
Definition color_out.h:48
#define TERM_RESET
Definition color_out.h:47
void module_init_default(struct module *module_data)
Definition module.c:48
void module_register(struct module *module_data, struct module *parent)
Definition module.c:82
@ MODULE_CLASS_FILTER
Definition module.h:93
void list_modules(enum library_class cls, int abi_version, bool full)
@ LIBRARY_CLASS_CAPTURE_FILTER
Definition lib_common.h:75
struct simple_linked_list * simple_linked_list_init(void)
Definition list.cpp:53
const char * parent
Definition settings.cpp:198
Definition hd-rum.c:27
enum module_class cls
Definition module.h:115

References CAPTURE_FILTER_ABI_VERSION, module::cls, color_printf(), create_filter(), capture_filter::filters, LIBRARY_CLASS_CAPTURE_FILTER, list_modules(), capture_filter::mod, MODULE_CLASS_FILTER, module_done(), module_init_default(), module_register(), parent, simple_linked_list_init(), state, TERM_BOLD, and TERM_RESET.

Referenced by hd_rum_decompress_init(), and initialize_video_capture().

Here is the call graph for this function: