Add a way to get default settings
- Implement a means of obtaining default settings for an input/output/encoder. obs_source_defaults for example will return the default settings for a particular source type. - Because C++ doesn't have designated initializers, use functions in the WASAPI plugin to register the sources instead.
This commit is contained in:
@@ -88,6 +88,19 @@ void obs_encoder_destroy(obs_encoder_t encoder)
|
||||
}
|
||||
}
|
||||
|
||||
obs_data_t obs_encoder_defaults(const char *id)
|
||||
{
|
||||
const struct obs_encoder_info *info = get_encoder_info(id);
|
||||
if (info) {
|
||||
obs_data_t settings = obs_data_create();
|
||||
if (info->defaults)
|
||||
info->defaults(settings);
|
||||
return settings;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obs_properties_t obs_encoder_properties(const char *id, const char *locale)
|
||||
{
|
||||
const struct obs_encoder_info *ei = get_encoder_info(id);
|
||||
|
@@ -134,6 +134,13 @@ struct obs_encoder_info {
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Optional implementation */
|
||||
|
||||
/**
|
||||
* Gets the default settings for this encoder
|
||||
*
|
||||
* @param[out] settings Data to assign default settings to
|
||||
*/
|
||||
void (*defaults)(obs_data_t settings);
|
||||
|
||||
/**
|
||||
* Gets the property information of this encoder
|
||||
*
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/******************************************************************************
|
||||
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
||||
Copyright (C) 2013-2014 by Hugh Bailey <obs.jim@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -93,6 +93,19 @@ bool obs_output_active(obs_output_t output)
|
||||
return (output != NULL) ? output->info.active(output) : false;
|
||||
}
|
||||
|
||||
obs_data_t obs_output_defaults(const char *id)
|
||||
{
|
||||
const struct obs_output_info *info = find_output(id);
|
||||
if (info) {
|
||||
obs_data_t settings = obs_data_create();
|
||||
if (info->defaults)
|
||||
info->defaults(settings);
|
||||
return settings;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obs_properties_t obs_output_properties(const char *id, const char *locale)
|
||||
{
|
||||
const struct obs_output_info *info = find_output(id);
|
||||
|
@@ -34,6 +34,8 @@ struct obs_output_info {
|
||||
/* optional */
|
||||
void (*update)(void *data, obs_data_t settings);
|
||||
|
||||
void (*defaults)(obs_data_t settings);
|
||||
|
||||
obs_properties_t (*properties)(const char *locale);
|
||||
|
||||
void (*pause)(void *data);
|
||||
|
@@ -298,6 +298,19 @@ bool obs_source_removed(obs_source_t source)
|
||||
return source ? source->removed : true;
|
||||
}
|
||||
|
||||
obs_data_t obs_source_settings(enum obs_source_type type, const char *id)
|
||||
{
|
||||
const struct obs_source_info *info = get_source_info(type, id);
|
||||
if (info) {
|
||||
obs_data_t settings = obs_data_create();
|
||||
if (info->defaults)
|
||||
info->defaults(settings);
|
||||
return settings;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
obs_properties_t obs_source_properties(enum obs_source_type type,
|
||||
const char *id, const char *locale)
|
||||
{
|
||||
|
@@ -135,6 +135,13 @@ struct obs_source_info {
|
||||
/* ----------------------------------------------------------------- */
|
||||
/* Optional implementation */
|
||||
|
||||
/**
|
||||
* Gets the default settings for this source
|
||||
*
|
||||
* @param[out] settings Data to assign default settings to
|
||||
*/
|
||||
void (*defaults)(obs_data_t settings);
|
||||
|
||||
/**
|
||||
* Gets the property information of this source
|
||||
*
|
||||
|
16
libobs/obs.h
16
libobs/obs.h
@@ -434,13 +434,13 @@ EXPORT bool obs_source_removed(obs_source_t source);
|
||||
|
||||
/**
|
||||
* Retrieves flags that specify what type of data the source presents/modifies.
|
||||
*
|
||||
* SOURCE_VIDEO if it presents/modifies video_frame
|
||||
* SOURCE_ASYNC if the video is asynchronous.
|
||||
* SOURCE_AUDIO if it presents/modifies audio (always async)
|
||||
*/
|
||||
EXPORT uint32_t obs_source_get_output_flags(obs_source_t source);
|
||||
|
||||
/** Gets the default settings for a source type */
|
||||
EXPORT obs_data_t obs_source_defaults(enum obs_source_type type,
|
||||
const char *id);
|
||||
|
||||
/** Returns the property list, if any. Free with obs_properties_destroy */
|
||||
EXPORT obs_properties_t obs_source_properties(enum obs_source_type type,
|
||||
const char *id, const char *locale);
|
||||
@@ -658,6 +658,9 @@ EXPORT void obs_output_stop(obs_output_t output);
|
||||
/** Returns whether the output is active */
|
||||
EXPORT bool obs_output_active(obs_output_t output);
|
||||
|
||||
/** Gets the default settings for an output type */
|
||||
EXPORT obs_data_t obs_output_defaults(const char *id);
|
||||
|
||||
/** Returns the property list, if any. Free with obs_properties_destroy */
|
||||
EXPORT obs_properties_t obs_output_properties(const char *id,
|
||||
const char *locale);
|
||||
@@ -698,8 +701,11 @@ EXPORT void obs_encoder_stop(obs_encoder_t encoder,
|
||||
void (*new_packet)(void *param, struct encoder_packet *packet),
|
||||
void *param);
|
||||
|
||||
/** Gets the default settings for an encoder type */
|
||||
EXPORT obs_data_t obs_encoder_defaults(const char *id);
|
||||
|
||||
/** Returns the property list, if any. Free with obs_properties_destroy */
|
||||
EXPORT obs_properties_t obs_output_properties(const char *id,
|
||||
EXPORT obs_properties_t obs_encoder_properties(const char *id,
|
||||
const char *locale);
|
||||
|
||||
EXPORT void obs_encoder_update(obs_encoder_t encoder, obs_data_t settings);
|
||||
|
Reference in New Issue
Block a user