Пример #1
0
static void image_source_tick(void *data, float seconds)
{
	struct image_source *context = data;
	uint64_t frame_time = obs_get_video_frame_time();

	if (context->last_time && context->image.is_animated_gif) {
		uint64_t elapsed = frame_time - context->last_time;
		bool updated = gs_image_file_tick(&context->image, elapsed);

		if (updated) {
			obs_enter_graphics();
			gs_image_file_update_texture(&context->image);
			obs_leave_graphics();
		}
	}

	context->last_time = frame_time;

	if (!obs_source_showing(context->source)) return;

	context->update_time_elapsed += seconds;

	if (context->update_time_elapsed >= 1.0f) {
		time_t t = get_modified_timestamp(context->file);
		context->update_time_elapsed = 0.0f;

		if (context->file_timestamp < t) {
			image_source_load(context);
		}
	}
}
Пример #2
0
static void monitor_capture_tick(void *data, float seconds)
{
    struct monitor_capture *capture = data;

    if (!obs_source_showing(capture->source))
        return;

    obs_enter_graphics();
    dc_capture_capture(&capture->data, NULL);
    obs_leave_graphics();

    UNUSED_PARAMETER(seconds);
}
Пример #3
0
static void image_source_update(void *data, obs_data_t *settings)
{
	struct image_source *context = data;
	const char *file = obs_data_get_string(settings, "file");
	const bool unload = obs_data_get_bool(settings, "unload");

	if (context->file)
		bfree(context->file);
	context->file = bstrdup(file);
	context->persistent = !unload;

	/* Load the image if the source is persistent or showing */
	if (context->persistent || obs_source_showing(context->source))
		image_source_load(data);
	else
		image_source_unload(data);
}
static void duplicator_capture_tick(void *data, float seconds)
{
	struct duplicator_capture *capture = data;

	if (!obs_source_showing(capture->source))
		return;

	obs_enter_graphics();

	if (!capture->duplicator) {
		capture->reset_timeout += seconds;

		if (capture->reset_timeout >= RESET_INTERVAL_SEC) {
			capture->duplicator =
				gs_duplicator_create(capture->monitor);

			capture->reset_timeout = 0.0f;
		}
	}

	if (!!capture->duplicator) {
		if (capture->capture_cursor)
			cursor_capture(&capture->cursor_data);

		if (!gs_duplicator_update_frame(capture->duplicator)) {
			gs_duplicator_destroy(capture->duplicator);
			capture->duplicator = NULL;
			capture->width = 0;
			capture->height = 0;
			capture->x = 0;
			capture->y = 0;
			capture->rot = 0;
			capture->reset_timeout = 0.0f;

		} else if (capture->width == 0) {
			reset_capture_data(capture);
		}
	}

	obs_leave_graphics();

	UNUSED_PARAMETER(seconds);
}
Пример #5
0
/**
 * Prepare the capture data
 */
static void xshm_video_tick(void *vptr, float seconds)
{
	UNUSED_PARAMETER(seconds);
	XSHM_DATA(vptr);

	if (!data->texture)
		return;
	if (!obs_source_showing(data->source))
		return;

	xcb_shm_get_image_cookie_t           img_c;
	xcb_shm_get_image_reply_t            *img_r;
	xcb_xfixes_get_cursor_image_cookie_t cur_c;
	xcb_xfixes_get_cursor_image_reply_t  *cur_r;

	img_c = xcb_shm_get_image_unchecked(data->xcb, data->xcb_screen->root,
			data->x_org, data->y_org, data->width, data->height,
			~0, XCB_IMAGE_FORMAT_Z_PIXMAP, data->xshm->seg, 0);
	cur_c = xcb_xfixes_get_cursor_image_unchecked(data->xcb);

	img_r = xcb_shm_get_image_reply(data->xcb, img_c, NULL);
	cur_r = xcb_xfixes_get_cursor_image_reply(data->xcb, cur_c, NULL);

	if (!img_r)
		goto exit;

	obs_enter_graphics();

	gs_texture_set_image(data->texture, (void *) data->xshm->data,
		data->width * 4, false);
	xcb_xcursor_update(data->cursor, cur_r);

	obs_leave_graphics();

exit:
	free(img_r);
	free(cur_r);
}
Пример #6
0
void XCompcapMain::tick(float seconds)
{
	if (!obs_source_showing(p->source))
		return;

	PLock lock(&p->lock, true);

	if (!lock.isLocked())
		return;

	XCompcap::processEvents();

	if (p->win && XCompcap::windowWasReconfigured(p->win)) {
		p->window_check_time = FIND_WINDOW_INTERVAL;
		p->win = 0;
	}

	XDisplayLock xlock;
	XWindowAttributes attr;

	if (!p->win || !XGetWindowAttributes(xdisp, p->win, &attr)) {
		p->window_check_time += (double)seconds;

		if (p->window_check_time < FIND_WINDOW_INTERVAL)
			return;

		Window newWin = getWindowFromString(p->windowName);

		p->window_check_time = 0.0;

		if (newWin && XGetWindowAttributes(xdisp, newWin, &attr)) {
			p->win = newWin;
			updateSettings(0);
		} else {
			return;
		}
	}

	if (!p->tex || !p->gltex)
		return;

	obs_enter_graphics();

	if (p->lockX) {
		XLockDisplay(xdisp);
		XSync(xdisp, 0);
	}

	if (p->include_border) {
		gs_copy_texture_region(
				p->tex, 0, 0,
				p->gltex,
				p->cur_cut_left,
				p->cur_cut_top,
				width(), height());
	} else {
		gs_copy_texture_region(
				p->tex, 0, 0,
				p->gltex,
				p->cur_cut_left + p->border,
				p->cur_cut_top + p->border,
				width(), height());
	}

	if (p->cursor && p->show_cursor) {
		xcursor_tick(p->cursor);

		p->cursor_outside =
			p->cursor->x < p->cur_cut_left                   ||
			p->cursor->y < p->cur_cut_top                    ||
			p->cursor->x > int(p->width  - p->cur_cut_right) ||
			p->cursor->y > int(p->height - p->cur_cut_bot);
	}

	if (p->lockX)
		XUnlockDisplay(xdisp);

	obs_leave_graphics();
}
Пример #7
0
void XCompcapMain::tick(float seconds)
{
	UNUSED_PARAMETER(seconds);

	if (!obs_source_showing(p->source))
		return;

	PLock lock(&p->lock, true);

	if (!lock.isLocked())
		return;

	XCompcap::processEvents();

	if (XCompcap::windowWasReconfigured(p->win))
		updateSettings(0);

	XErrorLock xlock;
	xlock.resetError();
	XWindowAttributes attr;

	if (!XGetWindowAttributes(xdisp, p->win, &attr)) {
		Window newWin = getWindowFromString(p->windowName);

		if (XGetWindowAttributes(xdisp, newWin, &attr)) {
			p->win = newWin;
			updateSettings(0);
		}
		return;
	}

	if (!p->tex || !p->gltex)
		return;

	obs_enter_graphics();

	if (p->lockX) {
		XLockDisplay(xdisp);
		XSync(xdisp, 0);
	}

	if (p->include_border) {
		gs_copy_texture_region(
				p->tex, 0, 0,
				p->gltex,
				p->cur_cut_left,
				p->cur_cut_top,
				width(), height());
	} else {
		gs_copy_texture_region(
				p->tex, 0, 0,
				p->gltex,
				p->cur_cut_left + p->border,
				p->cur_cut_top + p->border,
				width(), height());
	}

	if (p->cursor && p->show_cursor) {
		xcursor_tick(p->cursor);

		p->cursor_outside =
			p->cursor->x < p->cur_cut_left                   ||
			p->cursor->y < p->cur_cut_top                    ||
			p->cursor->x > int(p->width  - p->cur_cut_right) ||
			p->cursor->y > int(p->height - p->cur_cut_bot);
	}

	if (p->lockX)
		XUnlockDisplay(xdisp);

	obs_leave_graphics();
}