UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
video_capture_params.cpp File Reference
#include <string>
#include "utils/config_file.h"
#include "video_capture_params.h"
Include dependency graph for video_capture_params.cpp:

Go to the source code of this file.

Classes

struct  vidcap_params
 

Functions

static bool vidcap_dispatch_alias (struct vidcap_params *params)
 
void vidcap_params_add_flags (struct vidcap_params *params, unsigned int flags)
 
struct vidcap_params * vidcap_params_allocate (void)
 
struct vidcap_params * vidcap_params_allocate_next (struct vidcap_params *curr)
 
struct vidcap_params * vidcap_params_copy (const struct vidcap_params *params)
 
void vidcap_params_free_struct (struct vidcap_params *buf)
 
const char * vidcap_params_get_capture_filter (const struct vidcap_params *params)
 
const char * vidcap_params_get_driver (const struct vidcap_params *params)
 
unsigned int vidcap_params_get_flags (const struct vidcap_params *params)
 
const char * vidcap_params_get_fmt (const struct vidcap_params *params)
 
const char * vidcap_params_get_name (const struct vidcap_params *params)
 
struct vidcap_params * vidcap_params_get_next (const struct vidcap_params *curr)
 
struct vidcap_params * vidcap_params_get_nth (struct vidcap_params *curr, int index)
 
struct module * vidcap_params_get_parent (const struct vidcap_params *params)
 
void vidcap_params_set_capture_filter (struct vidcap_params *params, const char *req_capture_filter)
 
void vidcap_params_set_device (struct vidcap_params *params, const char *config)
 
void vidcap_params_set_driver (struct vidcap_params *params, const char *driver)
 
void vidcap_params_set_flags (struct vidcap_params *params, unsigned int flags)
 
void vidcap_params_set_parent (struct vidcap_params *params, struct module *mod)
 

Detailed Description

Function Documentation

◆ vidcap_dispatch_alias()

static bool vidcap_dispatch_alias ( struct vidcap_params * params)
static

This function does 2 things:

Definition at line 75 of file video_capture_params.cpp.

76{
77 bool ret;
78 char buf[1024];
79 string real_capture;
80 struct config_file *conf =
82 sizeof(buf)));
83 if (conf == NULL)
84 return false;
85 real_capture = config_file_get_alias(conf, "capture", params->name);
86 if (real_capture.empty()) {
87 ret = false;
88 } else {
89 params->driver = strdup(real_capture.c_str());
90 if (strchr(params->driver, ':')) {
91 char *delim = strchr(params->driver, ':');
92 params->fmt = strdup(delim + 1);
93 *delim = '\0';
94 } else {
95 params->fmt = strdup("");
96 }
97 ret = true;
98 }
99
100
101 if (params->requested_capture_filter == NULL) {
102 string matched_cap_filter = config_file_get_capture_filter_for_alias(conf,
103 params->name);
104 if (!matched_cap_filter.empty())
105 params->requested_capture_filter = strdup(matched_cap_filter.c_str());
106 }
107
108 config_file_close(conf);
109
110 return ret;
111}
struct config_file * config_file_open(const char *name)
void config_file_close(struct config_file *s)
string config_file_get_capture_filter_for_alias(struct config_file *s, const char *alias)
char * default_config_file(char *buf, int buf_len)
string config_file_get_alias(struct config_file *s, const char *req_item_class, const char *requested_name)

References config_file_close(), config_file_get_alias(), config_file_get_capture_filter_for_alias(), config_file_open(), and default_config_file().

Referenced by vidcap_params_set_device().

Here is the call graph for this function:

◆ vidcap_params_add_flags()

void vidcap_params_add_flags ( struct vidcap_params * params,
unsigned int flags )

Definition at line 208 of file video_capture_params.cpp.

209{
210 params->flags |= flags;
211}
const char unsigned int flags

References flags.

Referenced by parse_audio_capture().

◆ vidcap_params_allocate()

struct vidcap_params * vidcap_params_allocate ( void )

@brier Allocates blank vidcap_params structure.

Definition at line 117 of file video_capture_params.cpp.

118{
119 return (struct vidcap_params *) calloc(1, sizeof(struct vidcap_params));
120}

Referenced by test_video_capture(), vidcap_params_allocate_next(), and vidcap_screen_win_init().

◆ vidcap_params_allocate_next()

struct vidcap_params * vidcap_params_allocate_next ( struct vidcap_params * curr)

@brier Allocates blank vidcap_params structure.

Follows curr struct in the virtual list.

Parameters
currstructure to be appended after
Returns
pointer to newly created structure

Definition at line 129 of file video_capture_params.cpp.

130{
132 return curr->next;
133}
struct vidcap_params * next
struct vidcap_params * vidcap_params_allocate(void)

References vidcap_params::next, and vidcap_params_allocate().

Referenced by adjust_params(), and parse_options_internal().

Here is the call graph for this function:

◆ vidcap_params_copy()

struct vidcap_params * vidcap_params_copy ( const struct vidcap_params * params)

Creates deep copy of vidcap_params structure.

Definition at line 255 of file video_capture_params.cpp.

256{
257 if (!params)
258 return NULL;
259
260 struct vidcap_params *ret = (struct vidcap_params *) calloc(1, sizeof(struct vidcap_params));
261
262 if (params->driver)
263 ret->driver = strdup(params->driver);
264 if (params->fmt)
265 ret->fmt = strdup(params->fmt);
266 if (params->requested_capture_filter)
268 strdup(params->requested_capture_filter);
269 if (params->name)
270 ret->name = strdup(params->name);
271 if (params->flags)
272 ret->flags = params->flags;
273
274 ret->next = NULL; // there is high probability that the pointer will be invalid
275
276 return ret;
277}
char * driver
driver name
char * fmt
driver options
char * name
input name (capture alias in config file or complete config if not alias)
unsigned int flags
one of vidcap_flags

References vidcap_params::driver, vidcap_params::flags, vidcap_params::fmt, vidcap_params::name, vidcap_params::next, and vidcap_params::requested_capture_filter.

Referenced by parse(), and vidcap_screen_linux_init().

◆ vidcap_params_free_struct()

void vidcap_params_free_struct ( struct vidcap_params * buf)

Frees all members of the given structure as well as its members.

Parameters
[in]bufstructure to be feed

Definition at line 284 of file video_capture_params.cpp.

285{
286 if (!buf)
287 return;
288
289 free(buf->driver);
290 free(buf->fmt);
291 free(buf->requested_capture_filter);
292 free(buf->name);
293
294 free(buf);
295}

References vidcap_params::driver, vidcap_params::fmt, vidcap_params::name, and vidcap_params::requested_capture_filter.

Referenced by ug_options::~ug_options(), test_video_capture(), vidcap_screen_linux_init(), vidcap_screen_win_init(), and vidcap_swmix_done().

◆ vidcap_params_get_capture_filter()

const char * vidcap_params_get_capture_filter ( const struct vidcap_params * params)

Definition at line 198 of file video_capture_params.cpp.

199{
200 return params->requested_capture_filter;
201}

Referenced by initialize_video_capture(), and parse_options_internal().

◆ vidcap_params_get_driver()

const char * vidcap_params_get_driver ( const struct vidcap_params * params)
Returns
capture driver name (eg. decklink), not NULL if vidcap_params_set_device() called

Definition at line 216 of file video_capture_params.cpp.

217{
218 return params->driver;
219}

Referenced by adjust_params(), grab_worker(), initialize_video_capture(), main(), parse(), slave_worker(), vidcap_aggregate_init(), vidcap_gpustitch_init(), and vidcap_switcher_init().

◆ vidcap_params_get_flags()

◆ vidcap_params_get_fmt()

◆ vidcap_params_get_name()

const char * vidcap_params_get_name ( const struct vidcap_params * params)
Returns
<driver>[:<configuration>] as given on command-line
See also
vidcap_params_get_driver, vidcap_params_get_fmt

Definition at line 238 of file video_capture_params.cpp.

239{
240 return params->name;
241}

Referenced by init_slave_data(), and slave_worker().

◆ vidcap_params_get_next()

struct vidcap_params * vidcap_params_get_next ( const struct vidcap_params * curr)

@brier Returns next item in virtual vidcap_params list.

Definition at line 138 of file video_capture_params.cpp.

139{
140 return curr->next;
141}

References vidcap_params::next.

Referenced by ug_options::~ug_options(), initialize_video_capture(), parse(), vidcap_aggregate_init(), vidcap_gpustitch_init(), and vidcap_switcher_init().

◆ vidcap_params_get_nth()

struct vidcap_params * vidcap_params_get_nth ( struct vidcap_params * curr,
int index )

@brier Returns n-th item in vidcap_params list.

Definition at line 146 of file video_capture_params.cpp.

147{
148 struct vidcap_params *ret = curr;
149 for (int i = 0; i < index; i++) {
150 ret = ret->next;
151 if (ret == NULL) {
152 return NULL;
153 }
154 }
155 if (ret->driver == NULL) {
156 // this is just the stopper of the list...
157 return NULL;
158 }
159 return ret;
160}

References vidcap_params::driver, and vidcap_params::next.

Referenced by vidcap_switcher_grab().

◆ vidcap_params_get_parent()

struct module * vidcap_params_get_parent ( const struct vidcap_params * params)

◆ vidcap_params_set_capture_filter()

void vidcap_params_set_capture_filter ( struct vidcap_params * params,
const char * req_capture_filter )

Definition at line 192 of file video_capture_params.cpp.

194{
195 params->requested_capture_filter = strdup(req_capture_filter);
196}

Referenced by initialize_video_capture(), and parse_options_internal().

◆ vidcap_params_set_device()

void vidcap_params_set_device ( struct vidcap_params * params,
const char * config )

Fills the structure with device config string in format either driver[:params] or alias.

Definition at line 166 of file video_capture_params.cpp.

167{
168 free(params->name);
169 free(params->driver);
170 free(params->fmt);
171
172 params->name = strdup(config);
173
175 params->driver = strdup(config);
176 if (strchr(params->driver, ':')) {
177 char *delim = strchr(params->driver, ':');
178 *delim = '\0';
179 params->fmt = strdup(delim + 1);
180 } else {
181 params->fmt = strdup("");
182 }
183 }
184}
static bool vidcap_dispatch_alias(struct vidcap_params *params)

References vidcap_dispatch_alias().

Referenced by ug_options::ug_options(), adjust_params(), parse_options_internal(), test_video_capture(), and vidcap_screen_win_init().

Here is the call graph for this function:

◆ vidcap_params_set_driver()

void vidcap_params_set_driver ( struct vidcap_params * params,
const char * driver )

Definition at line 186 of file video_capture_params.cpp.

187{
188 free(params->driver);
189 params->driver = strdup(driver);
190}

References vidcap_params::driver.

Referenced by vidcap_screen_linux_init().

◆ vidcap_params_set_flags()

void vidcap_params_set_flags ( struct vidcap_params * params,
unsigned int flags )

Definition at line 203 of file video_capture_params.cpp.

204{
205 params->flags = flags;
206}

References flags.

Referenced by initialize_video_capture(), vidcap_aggregate_init(), and vidcap_switcher_init().

◆ vidcap_params_set_parent()

void vidcap_params_set_parent ( struct vidcap_params * params,
struct module * mod )

Definition at line 248 of file video_capture_params.cpp.

248 {
249 params->parent = mod;
250}

Referenced by initialize_video_capture(), and vidcap_screen_win_init().