plugins: don't use one-time array in plugin_init

This commit is contained in:
Tim-Philipp Müller 2012-07-14 20:28:54 +01:00
parent 22d78bad25
commit 92cba34e0b

View file

@ -45,54 +45,65 @@
#include "gsttypefindelement.h"
#include "gstvalve.h"
struct _elements_entry
{
const gchar *name;
guint rank;
GType (*type) (void);
};
static struct _elements_entry _elements[] = {
{"capsfilter", GST_RANK_NONE, gst_capsfilter_get_type},
{"fakesrc", GST_RANK_NONE, gst_fake_src_get_type},
{"fakesink", GST_RANK_NONE, gst_fake_sink_get_type},
#if defined(HAVE_SYS_SOCKET_H) || defined(_MSC_VER)
{"fdsrc", GST_RANK_NONE, gst_fd_src_get_type},
{"fdsink", GST_RANK_NONE, gst_fd_sink_get_type},
#endif
{"filesrc", GST_RANK_PRIMARY, gst_file_src_get_type},
{"funnel", GST_RANK_NONE, gst_funnel_get_type},
{"identity", GST_RANK_NONE, gst_identity_get_type},
{"input-selector", GST_RANK_NONE, gst_input_selector_get_type},
{"output-selector", GST_RANK_NONE, gst_output_selector_get_type},
{"queue", GST_RANK_NONE, gst_queue_get_type},
{"queue2", GST_RANK_NONE, gst_queue2_get_type},
{"filesink", GST_RANK_PRIMARY, gst_file_sink_get_type},
{"tee", GST_RANK_NONE, gst_tee_get_type},
{"typefind", GST_RANK_NONE, gst_type_find_element_get_type},
{"multiqueue", GST_RANK_NONE, gst_multi_queue_get_type},
{"valve", GST_RANK_NONE, gst_valve_get_type},
{NULL, 0},
};
static gboolean
plugin_init (GstPlugin * plugin)
{
struct _elements_entry *my_elements = _elements;
while ((*my_elements).name) {
if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank,
((*my_elements).type) ()))
return FALSE;
my_elements++;
}
if (!gst_element_register (plugin, "capsfilter", GST_RANK_NONE,
gst_capsfilter_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "fakesrc", GST_RANK_NONE,
gst_fake_src_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "fakesink", GST_RANK_NONE,
gst_fake_sink_get_type ()))
return FALSE;
#if defined(HAVE_SYS_SOCKET_H) || defined(_MSC_VER)
if (!gst_element_register (plugin, "fdsrc", GST_RANK_NONE,
gst_fd_src_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "fdsink", GST_RANK_NONE,
gst_fd_sink_get_type ()))
return FALSE;
#endif
if (!gst_element_register (plugin, "filesrc", GST_RANK_PRIMARY,
gst_file_src_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "funnel", GST_RANK_NONE,
gst_funnel_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "identity", GST_RANK_NONE,
gst_identity_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "input-selector", GST_RANK_NONE,
gst_input_selector_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "output-selector", GST_RANK_NONE,
gst_output_selector_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "queue", GST_RANK_NONE,
gst_queue_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "queue2", GST_RANK_NONE,
gst_queue2_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "filesink", GST_RANK_PRIMARY,
gst_file_sink_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "tee", GST_RANK_NONE, gst_tee_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "typefind", GST_RANK_NONE,
gst_type_find_element_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "multiqueue", GST_RANK_NONE,
gst_multi_queue_get_type ()))
return FALSE;
if (!gst_element_register (plugin, "valve", GST_RANK_NONE,
gst_valve_get_type ()))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
coreelements,
"standard GStreamer elements",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, coreelements,
" GStreamer core elements", plugin_init, VERSION, GST_LICENSE,
GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);