From 242409ad1dea90377f5af24e566d389c0a0a0014 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 4 Aug 2004 11:08:13 +0000 Subject: [PATCH] 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 --- ChangeLog | 8 ++++++ gst/videotestsrc/gstvideotestsrc.c | 40 +++++++++++++++++++----------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2161db69a..f3cfbc3d5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-08-04 Benjamin Otte + + * 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 * gst/multipart/multipartmux.c: (gst_multipart_mux_pad_link): diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 1a39119a80..760722a2e4 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -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); }