libobs: Add API to get last OBS version of a source
Allows the ability to change the behavior of a source depending on the previous OBS version.
This commit is contained in:
parent
e200a8a8a9
commit
65c7e2d19d
@ -563,6 +563,7 @@ struct obs_source {
|
||||
/* general exposed flags that can be set for the source */
|
||||
uint32_t flags;
|
||||
uint32_t default_flags;
|
||||
uint32_t last_obs_ver;
|
||||
|
||||
/* indicates ownership of the info.id buffer */
|
||||
bool owns_info_id;
|
||||
@ -737,6 +738,11 @@ struct audio_monitor *audio_monitor_create(obs_source_t *source);
|
||||
void audio_monitor_reset(struct audio_monitor *monitor);
|
||||
extern void audio_monitor_destroy(struct audio_monitor *monitor);
|
||||
|
||||
extern obs_source_t *obs_source_create_set_last_ver(const char *id,
|
||||
const char *name,
|
||||
obs_data_t *settings,
|
||||
obs_data_t *hotkey_data,
|
||||
uint32_t last_obs_ver);
|
||||
extern void obs_source_destroy(struct obs_source *source);
|
||||
|
||||
enum view_type {
|
||||
|
@ -307,11 +307,10 @@ static void obs_source_init_audio_hotkeys(struct obs_source *source)
|
||||
obs_source_hotkey_push_to_talk, source);
|
||||
}
|
||||
|
||||
static obs_source_t *obs_source_create_internal(const char *id,
|
||||
const char *name,
|
||||
obs_data_t *settings,
|
||||
obs_data_t *hotkey_data,
|
||||
bool private)
|
||||
static obs_source_t *
|
||||
obs_source_create_internal(const char *id, const char *name,
|
||||
obs_data_t *settings, obs_data_t *hotkey_data,
|
||||
bool private, uint32_t last_obs_ver)
|
||||
{
|
||||
struct obs_source *source = bzalloc(sizeof(struct obs_source));
|
||||
|
||||
@ -336,6 +335,7 @@ static obs_source_t *obs_source_create_internal(const char *id,
|
||||
source->mute_unmute_key = OBS_INVALID_HOTKEY_PAIR_ID;
|
||||
source->push_to_mute_key = OBS_INVALID_HOTKEY_ID;
|
||||
source->push_to_talk_key = OBS_INVALID_HOTKEY_ID;
|
||||
source->last_obs_ver = last_obs_ver;
|
||||
|
||||
if (!obs_source_init_context(source, settings, name, hotkey_data,
|
||||
private))
|
||||
@ -388,13 +388,23 @@ obs_source_t *obs_source_create(const char *id, const char *name,
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
return obs_source_create_internal(id, name, settings, hotkey_data,
|
||||
false);
|
||||
false, LIBOBS_API_VER);
|
||||
}
|
||||
|
||||
obs_source_t *obs_source_create_private(const char *id, const char *name,
|
||||
obs_data_t *settings)
|
||||
{
|
||||
return obs_source_create_internal(id, name, settings, NULL, true);
|
||||
return obs_source_create_internal(id, name, settings, NULL, true,
|
||||
LIBOBS_API_VER);
|
||||
}
|
||||
|
||||
obs_source_t *obs_source_create_set_last_ver(const char *id, const char *name,
|
||||
obs_data_t *settings,
|
||||
obs_data_t *hotkey_data,
|
||||
uint32_t last_obs_ver)
|
||||
{
|
||||
return obs_source_create_internal(id, name, settings, hotkey_data,
|
||||
false, last_obs_ver);
|
||||
}
|
||||
|
||||
static char *get_new_filter_name(obs_source_t *dst, const char *name)
|
||||
@ -4695,3 +4705,10 @@ bool obs_source_audio_active(const obs_source_t *source)
|
||||
? os_atomic_load_bool(&source->audio_active)
|
||||
: false;
|
||||
}
|
||||
|
||||
uint32_t obs_source_get_last_obs_version(const obs_source_t *source)
|
||||
{
|
||||
return obs_source_valid(source, "obs_source_get_last_obs_version")
|
||||
? source->last_obs_ver
|
||||
: 0;
|
||||
}
|
||||
|
@ -1775,11 +1775,13 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
|
||||
int di_mode;
|
||||
int monitoring_type;
|
||||
|
||||
source = obs_source_create(id, name, settings, hotkeys);
|
||||
prev_ver = (uint32_t)obs_data_get_int(source_data, "prev_ver");
|
||||
|
||||
source = obs_source_create_set_last_ver(id, name, settings, hotkeys,
|
||||
prev_ver);
|
||||
|
||||
obs_data_release(hotkeys);
|
||||
|
||||
prev_ver = (uint32_t)obs_data_get_int(source_data, "prev_ver");
|
||||
caps = obs_source_get_output_flags(source);
|
||||
|
||||
obs_data_set_default_double(source_data, "volume", 1.0);
|
||||
|
@ -1315,6 +1315,8 @@ EXPORT bool obs_source_async_decoupled(const obs_source_t *source);
|
||||
EXPORT void obs_source_set_audio_active(obs_source_t *source, bool show);
|
||||
EXPORT bool obs_source_audio_active(const obs_source_t *source);
|
||||
|
||||
EXPORT uint32_t obs_source_get_last_obs_version(const obs_source_t *source);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Transition-specific functions */
|
||||
enum obs_transition_target {
|
||||
|
Loading…
x
Reference in New Issue
Block a user