(API Change) libobs: Pass type data to get_name callbacks

API changed from:
obs_source_info::get_name(void)
obs_output_info::get_name(void)
obs_encoder_info::get_name(void)
obs_service_info::get_name(void)

API changed to:
obs_source_info::get_name(void *type_data)
obs_output_info::get_name(void *type_data)
obs_encoder_info::get_name(void *type_data)
obs_service_info::get_name(void *type_data)

This allows the type data to be used when getting the name of the
object (useful for plugin wrappers primarily).

NOTE: Though a parameter was added, this is backward-compatible with
older plugins due to calling convention.  The new parameter will simply
be ignored by older plugins, and the stack (if used) will be cleaned up
by the caller.
master
jp9000 2015-09-16 01:30:51 -07:00
parent 0ed913a136
commit 6285a47726
52 changed files with 98 additions and 58 deletions

View File

@ -33,7 +33,7 @@ struct obs_encoder_info *find_encoder(const char *id)
const char *obs_encoder_get_display_name(const char *id)
{
struct obs_encoder_info *ei = find_encoder(id);
return ei ? ei->get_name() : NULL;
return ei ? ei->get_name(ei->type_data) : NULL;
}
static bool init_encoder(struct obs_encoder *encoder, const char *name,

View File

@ -120,9 +120,10 @@ struct obs_encoder_info {
/**
* Gets the full translated name of this encoder
*
* @return Translated name of the encoder
* @param type_data The type_data variable of this structure
* @return Translated name of the encoder
*/
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
/**
* Creates the encoder with the specified settings

View File

@ -35,7 +35,7 @@ const struct obs_output_info *find_output(const char *id)
const char *obs_output_get_display_name(const char *id)
{
const struct obs_output_info *info = find_output(id);
return (info != NULL) ? info->get_name() : NULL;
return (info != NULL) ? info->get_name(info->type_data) : NULL;
}
static const char *output_signals[] = {

View File

@ -36,7 +36,7 @@ struct obs_output_info {
uint32_t flags;
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
void *(*create)(obs_data_t *settings, obs_output_t *output);
void (*destroy)(void *data);

View File

@ -42,9 +42,10 @@ static inline void signal_item_remove(struct obs_scene_item *item)
calldata_free(&params);
}
static const char *scene_getname(void)
static const char *scene_getname(void *unused)
{
/* TODO: locale */
UNUSED_PARAMETER(unused);
return "Scene";
}

View File

@ -30,7 +30,7 @@ const struct obs_service_info *find_service(const char *id)
const char *obs_service_get_display_name(const char *id)
{
const struct obs_service_info *info = find_service(id);
return (info != NULL) ? info->get_name() : NULL;
return (info != NULL) ? info->get_name(info->type_data) : NULL;
}
obs_service_t *obs_service_create(const char *id, const char *name,

View File

@ -32,7 +32,7 @@ struct obs_service_info {
/* required */
const char *id;
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
void *(*create)(obs_data_t *settings, obs_service_t *service);
void (*destroy)(void *data);

View File

@ -112,7 +112,7 @@ const char *obs_source_get_display_name(enum obs_source_type type,
const char *id)
{
const struct obs_source_info *info = get_source_info(type, id);
return (info != NULL) ? info->get_name() : NULL;
return (info != NULL) ? info->get_name(info->type_data) : NULL;
}
/* internal initialization */

View File

@ -133,9 +133,10 @@ struct obs_source_info {
/**
* Get the translated name of the source type
*
* @return The translated name of the source type
* @param type_data The type_data variable of this structure
* @return The translated name of the source type
*/
const char *(*get_name)(void);
const char *(*get_name)(void *type_data);
/**
* Creates the source data for the source

View File

@ -213,7 +213,7 @@ static const char *flush_log(DStr &log)
CA_CO_LOG(level, format "%s%s", ##__VA_ARGS__, \
log->array ? ":\n" : "", flush_log(log))
static const char *aac_get_name(void)
static const char *aac_get_name(void*)
{
return obs_module_text("CoreAudioAAC");
}

View File

@ -57,7 +57,7 @@ static void decklink_get_defaults(obs_data_t *settings)
obs_data_set_default_bool(settings, "buffering", true);
}
static const char *decklink_get_name()
static const char *decklink_get_name(void*)
{
return obs_module_text("BlackmagicDevice");
}

View File

@ -22,8 +22,9 @@ struct image_source {
uint32_t cy;
};
static const char *image_source_get_name(void)
static const char *image_source_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ImageInput");
}

View File

@ -55,7 +55,7 @@ void xcompcap_update(void *data, obs_data_t *settings)
cc->updateSettings(settings);
}
static const char* xcompcap_getname(void)
static const char* xcompcap_getname(void*)
{
return obs_module_text("XCCapture");
}

View File

@ -132,8 +132,9 @@ static int_fast32_t xshm_update_geometry(struct xshm_data *data)
/**
* Returns the name of the plugin
*/
static const char* xshm_getname(void)
static const char* xshm_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("X11SharedMemoryScreenInput");
}

View File

@ -22,8 +22,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/**
* Returns the name of the plugin
*/
static const char *jack_input_getname(void)
static const char *jack_input_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("JACKInput");
}

View File

@ -439,13 +439,15 @@ static void pulse_output_defaults(obs_data_t *settings)
/**
* Returns the name of the plugin
*/
static const char *pulse_input_getname(void)
static const char *pulse_input_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("PulseInput");
}
static const char *pulse_output_getname(void)
static const char *pulse_output_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("PulseOutput");
}

View File

@ -217,8 +217,9 @@ exit:
return NULL;
}
static const char* v4l2_getname(void)
static const char* v4l2_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("V4L2Input");
}

View File

@ -255,8 +255,9 @@ static void av_capture_enable_buffering(struct av_capture *capture,
obs_source_set_flags(source, flags);
}
static const char *av_capture_getname(void)
static const char *av_capture_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_AVCAPTURE;
}

View File

@ -647,13 +647,15 @@ static void coreaudio_uninit(struct coreaudio_data *ca)
/* ------------------------------------------------------------------------- */
static const char *coreaudio_input_getname(void)
static const char *coreaudio_input_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_AUDIO_INPUT;
}
static const char *coreaudio_output_getname(void)
static const char *coreaudio_output_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_AUDIO_OUTPUT;
}

View File

@ -422,8 +422,9 @@ static void display_capture_video_render(void *data, gs_effect_t *effect)
gs_technique_end(tech);
}
static const char *display_capture_getname(void)
static const char *display_capture_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("DisplayCapture");
}

View File

@ -186,8 +186,9 @@ static void window_capture_update(void *data, obs_data_t *settings)
}
}
static const char *window_capture_getname(void)
static const char *window_capture_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("WindowCapture");
}

View File

@ -89,8 +89,9 @@ static inline void handle_application_launch(syphon_t s, NSArray *new)
}
@end
static const char *syphon_get_name()
static const char *syphon_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("Syphon");
}

View File

@ -52,8 +52,9 @@ struct aac_encoder {
int frame_size_bytes;
};
static const char *aac_getname(void)
static const char *aac_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("FFmpegAAC");
}

View File

@ -37,8 +37,9 @@ struct ffmpeg_muxer {
bool capturing;
};
static const char *ffmpeg_mux_getname(void)
static const char *ffmpeg_mux_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("FFmpegMuxer");
}

View File

@ -518,8 +518,9 @@ fail:
/* ------------------------------------------------------------------------- */
static const char *ffmpeg_output_getname(void)
static const char *ffmpeg_output_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("FFmpegOutput");
}

View File

@ -517,8 +517,9 @@ static void ffmpeg_source_update(void *data, obs_data_t *settings)
}
static const char *ffmpeg_source_getname(void)
static const char *ffmpeg_source_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("FFMpegSource");
}

View File

@ -33,8 +33,9 @@ struct async_delay_data {
bool reset_audio;
};
static const char *async_delay_filter_name(void)
static const char *async_delay_filter_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("AsyncDelayFilter");
}

View File

@ -52,8 +52,9 @@ struct chroma_key_filter_data {
float spill;
};
static const char *chroma_key_name(void)
static const char *chroma_key_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ChromaKeyFilter");
}

View File

@ -34,8 +34,9 @@ struct color_filter_data {
float gamma;
};
static const char *color_filter_name(void)
static const char *color_filter_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ColorFilter");
}

View File

@ -45,8 +45,9 @@ struct color_key_filter_data {
float smoothness;
};
static const char *color_key_name(void)
static const char *color_key_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ColorKeyFilter");
}

View File

@ -19,8 +19,9 @@ struct crop_filter_data {
bool absolute;
};
static const char *crop_filter_get_name(void)
static const char *crop_filter_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("CropFilter");
}

View File

@ -19,8 +19,9 @@ struct gain_data {
float multiple;
};
static const char *gain_name(void)
static const char *gain_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("Gain");
}

View File

@ -22,8 +22,9 @@ struct mask_filter_data {
struct vec4 color;
};
static const char *mask_filter_get_name(void)
static const char *mask_filter_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("MaskFilter");
}

View File

@ -44,8 +44,9 @@ struct noise_gate_data {
#define VOL_MIN -96.0f
#define VOL_MAX 0.0f
static const char *noise_gate_name(void)
static const char *noise_gate_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("NoiseGate");
}

View File

@ -18,8 +18,9 @@ struct scroll_filter_data {
struct vec2 offset;
};
static const char *scroll_filter_get_name(void)
static const char *scroll_filter_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ScrollFilter");
}

View File

@ -14,8 +14,9 @@ struct sharpness_data {
float texwidth, texheight;
};
static const char *sharpness_getname(void)
static const char *sharpness_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("SharpnessFilter");
}

View File

@ -59,8 +59,9 @@ typedef struct libfdk_encoder {
int packet_buffer_size;
} libfdk_encoder_t;
static const char *libfdk_getname(void)
static const char *libfdk_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("LibFDK");
}

View File

@ -40,8 +40,9 @@ struct flv_output {
int64_t last_packet_ts;
};
static const char *flv_output_getname(void)
static const char *flv_output_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("FLVOutput");
}

View File

@ -71,8 +71,9 @@ struct rtmp_stream {
RTMP rtmp;
};
static const char *rtmp_stream_getname(void)
static const char *rtmp_stream_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("RTMPStream");
}

View File

@ -56,8 +56,9 @@ struct obs_x264 {
/* ------------------------------------------------------------------------- */
static const char *obs_x264_getname(void)
static const char *obs_x264_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return "x264";
}

View File

@ -10,8 +10,9 @@ struct rtmp_common {
char *key;
};
static const char *rtmp_common_getname(void)
static const char *rtmp_common_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("StreamingServices");
}

View File

@ -6,8 +6,9 @@ struct rtmp_custom {
char *username, *password;
};
static const char *rtmp_custom_name(void)
static const char *rtmp_custom_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("CustomStreamingServer");
}

View File

@ -68,8 +68,9 @@ void obs_module_unload(void)
FT_Done_FreeType(ft2_lib);
}
static const char *ft2_source_get_name(void)
static const char *ft2_source_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("TextFreetype2");
}

View File

@ -79,7 +79,7 @@ static uint32_t ft2_source_get_height(void *data);
static obs_properties_t *ft2_source_properties(void *unused);
static const char *ft2_source_get_name(void);
static const char *ft2_source_get_name(void *unused);
uint32_t get_ft2_text_width(wchar_t *text, struct ft2_source *srcdata);

View File

@ -60,8 +60,9 @@ static inline void update_settings(struct duplicator_capture *capture,
/* ------------------------------------------------------------------------- */
static const char *duplicator_capture_getname(void)
static const char *duplicator_capture_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_MONITOR_CAPTURE;
}

View File

@ -1369,8 +1369,9 @@ static uint32_t game_capture_height(void *data)
return gc->active ? gc->global_hook_info->cy : 0;
}
static const char *game_capture_name(void)
static const char *game_capture_name(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_GAME_CAPTURE;
}

View File

@ -88,8 +88,9 @@ static inline void update_settings(struct monitor_capture *capture,
/* ------------------------------------------------------------------------- */
static const char *monitor_capture_getname(void)
static const char *monitor_capture_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_MONITOR_CAPTURE;
}

View File

@ -50,8 +50,9 @@ static void update_settings(struct window_capture *wc, obs_data_t *s)
/* ------------------------------------------------------------------------- */
static const char *wc_getname(void)
static const char *wc_getname(void *unused)
{
UNUSED_PARAMETER(unused);
return TEXT_WINDOW_CAPTURE;
}

View File

@ -42,12 +42,12 @@ struct DShowEncoder {
struct encoder_packet *packet, bool *received_packet);
};
static const char *GetC985EncoderName(void)
static const char *GetC985EncoderName(void*)
{
return obs_module_text("Encoder.C985");
}
static const char *GetC353EncoderName(void)
static const char *GetC353EncoderName(void*)
{
return obs_module_text("Encoder.C353");
}

View File

@ -983,7 +983,7 @@ inline void DShowInput::Deactivate()
/* ------------------------------------------------------------------------- */
static const char *GetDShowInputName(void)
static const char *GetDShowInputName(void*)
{
return TEXT_INPUT_NAME;
}

View File

@ -8,7 +8,7 @@
using namespace MFAAC;
static const char *MFAAC_GetName()
static const char *MFAAC_GetName(void*)
{
return obs_module_text("MFAACEnc");
}

View File

@ -476,12 +476,12 @@ DWORD WINAPI WASAPISource::CaptureThread(LPVOID param)
/* ------------------------------------------------------------------------- */
static const char *GetWASAPIInputName(void)
static const char *GetWASAPIInputName(void*)
{
return obs_module_text("AudioInput");
}
static const char *GetWASAPIOutputName(void)
static const char *GetWASAPIOutputName(void*)
{
return obs_module_text("AudioOutput");
}