static void image_source_show(void *data) { struct image_source *context = data; if (!context->persistent) image_source_load(context); }
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); } } }
static void image_source_tick(void *data, float seconds) { struct image_source *context = data; uint64_t frame_time = obs_get_video_frame_time(); if (obs_source_active(context->source)) { if (!context->active) { if (context->image.is_animated_gif) context->last_time = frame_time; context->active = true; } } else { if (context->active) { if (context->image.is_animated_gif) { context->image.cur_frame = 0; context->image.cur_loop = 0; context->image.cur_time = 0; obs_enter_graphics(); gs_image_file_update_texture(&context->image); obs_leave_graphics(); } context->active = false; } return; } 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; 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); } } }
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); }