gst/videotestsrc/gstvideotestsrc.c: generate the list of supported caps at startup and reuse it instead of always gen...

Original commit message from CVS:
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_get_capslist), (generate_capslist),
(plugin_init):
generate the list of supported caps at startup and reuse it instead
of always generating it
This commit is contained in:
Benjamin Otte 2004-08-04 11:08:13 +00:00
parent c00fdabf0a
commit 242409ad1d
2 changed files with 34 additions and 14 deletions

View file

@ -1,3 +1,11 @@
2004-08-04 Benjamin Otte <otte@gnome.org>
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_get_capslist), (generate_capslist),
(plugin_init):
generate the list of supported caps at startup and reuse it instead
of always generating it
2004-07-30 Benjamin Otte <in7y118@public.uni-hamburg.de>
* gst/multipart/multipartmux.c: (gst_multipart_mux_pad_link):

View file

@ -55,6 +55,8 @@ enum
/* FILL ME */
};
static GstCaps *capslist = NULL;
static void gst_videotestsrc_base_init (gpointer g_class);
static void gst_videotestsrc_class_init (GstVideotestsrcClass * klass);
static void gst_videotestsrc_init (GstVideotestsrc * videotestsrc);
@ -294,22 +296,30 @@ gst_videotestsrc_change_state (GstElement * element)
static GstCaps *
gst_videotestsrc_get_capslist (void)
{
GstCaps *caps;
GstStructure *structure;
int i;
return gst_caps_copy (capslist);
}
caps = gst_caps_new_empty ();
for (i = 0; i < n_fourccs; i++) {
structure = paint_get_structure (fourcc_list + i);
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
static void
generate_capslist (void)
{
if (!capslist) {
GstCaps *caps;
GstStructure *structure;
int i;
caps = gst_caps_new_empty ();
for (i = 0; i < n_fourccs; i++) {
structure = paint_get_structure (fourcc_list + i);
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT,
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
"framerate", GST_TYPE_DOUBLE_RANGE, 0.0, G_MAXDOUBLE, NULL);
gst_caps_append_structure (caps, structure);
}
capslist = caps;
}
return caps;
}
#if 0
@ -664,6 +674,8 @@ plugin_init (GstPlugin * plugin)
oil_init ();
#endif
generate_capslist ();
return gst_element_register (plugin, "videotestsrc", GST_RANK_NONE,
GST_TYPE_VIDEOTESTSRC);
}