68 char *filter_name = cfg;
69 if(strchr(filter_name,
':')) {
70 options = strchr(filter_name,
':') + 1;
71 *strchr(filter_name,
':') =
'\0';
74 for (
auto &&
item : capture_filters) {
76 if(strcasecmp(
item.first.c_str(), filter_name) == 0) {
82 fprintf(stderr,
"Unable to initialize capture filter: %s\n",
95 fprintf(stderr,
"Unable to find capture filter: %s\n",
104 if (cfg && (strcasecmp(cfg,
"help") == 0 || strcasecmp(cfg,
"fullhelp") == 0)) {
107 printf(
"Available capture filters:\n");
109 if (strcasecmp(cfg,
"fullhelp") != 0) {
110 printf(
"(use \"fullhelp\" to show hidden filters)\n");
116 char *
item, *save_ptr;
118 char *filter_list_str = NULL,
128 filter_list_str = tmp = strdup(cfg);
130 while((
item = strtok_r(filter_list_str,
",", &save_ptr))) {
131 char filter_name[128];
132 strncpy(filter_name,
item,
sizeof filter_name - 1);
141 filter_list_str = NULL;
171 if (strncmp(
"delete ",
msg->text, strlen(
"delete ")) == 0) {
172 int index = atoi(
msg->text + strlen(
"delete "));
176 fprintf(stderr,
"Unable to remove capture filter index %d.\n",
180 printf(
"Capture filter #%d removed successfully.\n", index);
184 }
else if (strcmp(
"flush",
msg->text) == 0) {
190 }
else if (strcmp(
"help",
msg->text) == 0) {
191 printf(
"Capture filter control:\n"
192 "\tflush - remove all filters\n"
193 "\tdelete <x> - delete x-th filter\n"
194 "\t<filter> - append a filter named <filter>\n");
196 char *
fmt = strdup(
msg->text);
198 fprintf(stderr,
"Cannot create capture filter: %s.\n",
203 printf(
"Capture filter \"%s\" created successfully.\n",
struct video_frame * frame
static struct response * process_message(struct capture_filter *s, struct msg_universal *msg)
static int create_filter(struct capture_filter *s, char *cfg)
void capture_filter_destroy(struct capture_filter *state)
struct video_frame * capture_filter(struct capture_filter *state, struct video_frame *frame)
int capture_filter_init(struct module *parent, const char *cfg, struct capture_filter **state)
#define CAPTURE_FILTER_ABI_VERSION
int color_printf(const char *format,...)
void module_init_default(struct module *module_data)
void module_register(struct module *module_data, struct module *parent)
void module_done(struct module *module_data)
map< string, const void * > get_libraries_for_class(enum library_class cls, int abi_version, bool include_hidden)
void list_modules(enum library_class cls, int abi_version, bool full)
@ LIBRARY_CLASS_CAPTURE_FILTER
void simple_linked_list_append(struct simple_linked_list *l, void *data)
void * simple_linked_list_it_next(void **i)
int simple_linked_list_size(struct simple_linked_list *l)
struct simple_linked_list * simple_linked_list_init(void)
void simple_linked_list_destroy(struct simple_linked_list *l)
void * simple_linked_list_pop(struct simple_linked_list *l)
void * simple_linked_list_remove_index(struct simple_linked_list *l, int index)
void * simple_linked_list_it_init(struct simple_linked_list *l)
void free_message(struct message *msg, struct response *r)
struct response * new_response(int status, const char *text)
struct message * check_message(struct module *mod)
#define RESPONSE_INT_SERV_ERR
void(* done)(void *state)
int(* init)(struct module *parent, const char *cfg, void **state)
Initializes capture filter.
struct video_frame *(* filter)(void *state, struct video_frame *f)
Performs filtering.
const struct capture_filter_info * functions
struct simple_linked_list * filters
Struct video_frame represents a video frame and contains video description.
This is an umbrella header for video functions.
static class worker_pool instance