gst/videotestsrc/gstvideotestsrc.c: generate the list of supported caps at startup...
authorBenjamin Otte <otte@gnome.org>
Wed, 4 Aug 2004 11:08:13 +0000 (11:08 +0000)
committerBenjamin Otte <otte@gnome.org>
Wed, 4 Aug 2004 11:08:13 +0000 (11:08 +0000)
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
gst/videotestsrc/gstvideotestsrc.c

index d2161db..f3cfbc3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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):
index 1a39119..760722a 100644 (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);
+    }
 
-  return caps;
+    capslist = 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);
 }