camera: add force_active
option to make camera always hot
This commit is contained in:
parent
6d30270b16
commit
34ff200ceb
@ -99,6 +99,7 @@ option_t all_options[] = {
|
|||||||
DEFINE_OPTION_PTR(camera, options, list, "Set the camera options. List all available options with `-camera-list_options`."),
|
DEFINE_OPTION_PTR(camera, options, list, "Set the camera options. List all available options with `-camera-list_options`."),
|
||||||
DEFINE_OPTION(camera, auto_reconnect, uint, "Set the camera auto-reconnect delay in seconds."),
|
DEFINE_OPTION(camera, auto_reconnect, uint, "Set the camera auto-reconnect delay in seconds."),
|
||||||
DEFINE_OPTION_DEFAULT(camera, auto_focus, bool, "1", "Do auto-focus on start-up (does not work with all camera)."),
|
DEFINE_OPTION_DEFAULT(camera, auto_focus, bool, "1", "Do auto-focus on start-up (does not work with all camera)."),
|
||||||
|
DEFINE_OPTION_DEFAULT(camera, force_active, bool, "1", "Force camera to be always active."),
|
||||||
DEFINE_OPTION_DEFAULT(camera, vflip, bool, "1", "Do vertical image flip (does not work with all camera)."),
|
DEFINE_OPTION_DEFAULT(camera, vflip, bool, "1", "Do vertical image flip (does not work with all camera)."),
|
||||||
DEFINE_OPTION_DEFAULT(camera, hflip, bool, "1", "Do horizontal image flip (does not work with all camera)."),
|
DEFINE_OPTION_DEFAULT(camera, hflip, bool, "1", "Do horizontal image flip (does not work with all camera)."),
|
||||||
|
|
||||||
|
@ -117,5 +117,5 @@ int camera_set_params(camera_t *camera)
|
|||||||
int camera_run(camera_t *camera)
|
int camera_run(camera_t *camera)
|
||||||
{
|
{
|
||||||
bool running = false;
|
bool running = false;
|
||||||
return links_loop(camera->links, &running);
|
return links_loop(camera->links, camera->options.force_active, &running);
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ typedef struct camera_options_s {
|
|||||||
float low_res_factor;
|
float low_res_factor;
|
||||||
bool auto_focus;
|
bool auto_focus;
|
||||||
unsigned auto_reconnect;
|
unsigned auto_reconnect;
|
||||||
|
bool force_active;
|
||||||
union {
|
union {
|
||||||
bool vflip;
|
bool vflip;
|
||||||
unsigned vflip_align;
|
unsigned vflip_align;
|
||||||
|
@ -58,7 +58,7 @@ static int links_count(link_t *all_links)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void links_process_paused(link_t *all_links)
|
static void links_process_paused(link_t *all_links, bool force_active)
|
||||||
{
|
{
|
||||||
// This traverses in reverse order as it requires to first fix outputs
|
// This traverses in reverse order as it requires to first fix outputs
|
||||||
// and go back into captures
|
// and go back into captures
|
||||||
@ -69,6 +69,10 @@ static void links_process_paused(link_t *all_links)
|
|||||||
|
|
||||||
bool paused = true;
|
bool paused = true;
|
||||||
|
|
||||||
|
if (force_active) {
|
||||||
|
paused = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (link_needs_buffer_by_callbacks(link)) {
|
if (link_needs_buffer_by_callbacks(link)) {
|
||||||
paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
@ -280,7 +284,7 @@ static void print_pollfds(struct pollfd *fds, int n)
|
|||||||
printf("pollfds = %d\n", n);
|
printf("pollfds = %d\n", n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int links_step(link_t *all_links, int timeout_now_ms, int *timeout_next_ms)
|
static int links_step(link_t *all_links, bool force_active, int timeout_now_ms, int *timeout_next_ms)
|
||||||
{
|
{
|
||||||
link_pool_t pool = {
|
link_pool_t pool = {
|
||||||
.fds = {{0}},
|
.fds = {{0}},
|
||||||
@ -289,7 +293,7 @@ static int links_step(link_t *all_links, int timeout_now_ms, int *timeout_next_m
|
|||||||
.output_lists = {0}
|
.output_lists = {0}
|
||||||
};
|
};
|
||||||
|
|
||||||
links_process_paused(all_links);
|
links_process_paused(all_links, force_active);
|
||||||
links_process_capture_buffers(all_links, timeout_next_ms);
|
links_process_capture_buffers(all_links, timeout_next_ms);
|
||||||
|
|
||||||
int n = links_build_fds(all_links, &pool);
|
int n = links_build_fds(all_links, &pool);
|
||||||
@ -413,7 +417,7 @@ static void links_refresh_stats(link_t *all_links, uint64_t *last_refresh_us)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int links_loop(link_t *all_links, bool *running)
|
int links_loop(link_t *all_links, bool force_active, bool *running)
|
||||||
{
|
{
|
||||||
*running = true;
|
*running = true;
|
||||||
|
|
||||||
@ -429,7 +433,7 @@ int links_loop(link_t *all_links, bool *running)
|
|||||||
int timeout_now_ms = timeout_ms;
|
int timeout_now_ms = timeout_ms;
|
||||||
timeout_ms = LINKS_LOOP_INTERVAL;
|
timeout_ms = LINKS_LOOP_INTERVAL;
|
||||||
|
|
||||||
ret = links_step(all_links, timeout_now_ms, &timeout_ms);
|
ret = links_step(all_links, force_active, timeout_now_ms, &timeout_ms);
|
||||||
links_refresh_stats(all_links, &last_refresh_us);
|
links_refresh_stats(all_links, &last_refresh_us);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,5 +30,5 @@ typedef struct link_s {
|
|||||||
int n_callbacks;
|
int n_callbacks;
|
||||||
} link_t;
|
} link_t;
|
||||||
|
|
||||||
int links_loop(link_t *all_links, bool *running);
|
int links_loop(link_t *all_links, bool force_active, bool *running);
|
||||||
void links_dump(link_t *all_links);
|
void links_dump(link_t *all_links);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user