bilboed gst-plugins-base: gst-plugins-base/ gst-plugins-base/ext/vorbis/

[email protected] Thu, 11 Dec 2008 23:17:35 -0800 (PST)
Newsgroups gmane.comp.video.gstreamer.cvs
Message-ID <[email protected]>
CVS Root:       /cvs/gstreamer
Module:         gst-plugins-base
Changes by:     bilboed
Date:           Fri Dec 12 2008  07:17:35 UTC

Log message:
* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_base_init),
(gst_vorbis_enc_init):
Make vorbisenc's pad template behave like vorbisdec's. Fixes a leak with
pad templates.

Modified files:
    .               : ChangeLog
    ext/vorbis      : vorbisenc.c

Links:
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.4247&r2=1.4248
http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ext/vorbis/vorbisenc.c.diff?r1=1.129&r2=1.130

====Begin Diffs====
Index: ChangeLog
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v
retrieving revision 1.4247
retrieving revision 1.4248
diff -u -d -r1.4247 -r1.4248
--- ChangeLog	12 Dec 2008 07:15:21 -0000	1.4247
+++ ChangeLog	12 Dec 2008 07:17:19 -0000	1.4248
@@ -1,5 +1,12 @@
 2008-12-12  Edward Hervey  <[email protected]>
 
+	* ext/vorbis/vorbisenc.c: (gst_vorbis_enc_base_init),
+	(gst_vorbis_enc_init):
+	Make vorbisenc's pad template behave like vorbisdec's. Fixes a leak with
+	pad templates.
+
+2008-12-12  Edward Hervey  <[email protected]>
 	* gst-libs/gst/riff/riff-media.c: (gst_riff_create_video_caps),
 	(gst_riff_create_video_template_caps):
 	Add mapping for VP6 in avi/riff.
Index: vorbisenc.c
RCS file: /cvs/gstreamer/gst-plugins-base/ext/vorbis/vorbisenc.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- vorbisenc.c	10 Oct 2008 15:21:38 -0000	1.129
+++ vorbisenc.c	12 Dec 2008 07:17:21 -0000	1.130
@@ -56,8 +56,23 @@
 GST_DEBUG_CATEGORY_EXTERN (vorbisenc_debug);
 #define GST_CAT_DEFAULT vorbisenc_debug
-static GstPadTemplate *gst_vorbis_enc_src_template,
-    *gst_vorbis_enc_sink_template;
+static GstStaticPadTemplate vorbis_enc_sink_factory =
+GST_STATIC_PAD_TEMPLATE ("sink",
+    GST_PAD_SINK,
+    GST_PAD_ALWAYS,
+    GST_STATIC_CAPS ("audio/x-raw-float, "
+        "rate = (int) [ 1, 200000 ], "
+        "channels = (int) [ 1, 256 ], " "endianness = (int) BYTE_ORDER, "
+        "width = (int) 32")
+    );
+static GstStaticPadTemplate vorbis_enc_src_factory =
+GST_STATIC_PAD_TEMPLATE ("src",
+    GST_PAD_SRC,
+    GST_STATIC_CAPS ("audio/x-vorbis")
 /* elementfactory information */
 static const GstElementDetails vorbisenc_details =
@@ -134,41 +149,18 @@
       &tag_setter_info);
 }
-static GstCaps *
-vorbis_caps_factory (void)
-{
-  return gst_caps_new_simple ("audio/x-vorbis", NULL);
-}
-
-raw_caps_factory (void)
-  /* lowest, highest sample rates come from vorbis/lib/modes/setup_X.h:
-   * 1-200000 Hz */
-  return
-      gst_caps_new_simple ("audio/x-raw-float",
-      "rate", GST_TYPE_INT_RANGE, 1, 200000,
-      "channels", GST_TYPE_INT_RANGE, 1, 256,
-      "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL);
 static void
 gst_vorbis_enc_base_init (gpointer g_class)
 {
   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
-  GstCaps *raw_caps, *vorbis_caps;
+  GstPadTemplate *src_template, *sink_template;
-  raw_caps = raw_caps_factory ();
-  vorbis_caps = vorbis_caps_factory ();
-  gst_vorbis_enc_sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
-      GST_PAD_ALWAYS, raw_caps);
-  gst_vorbis_enc_src_template = gst_pad_template_new ("src", GST_PAD_SRC,
-      GST_PAD_ALWAYS, vorbis_caps);
-  gst_element_class_add_pad_template (element_class,
-      gst_vorbis_enc_sink_template);
-      gst_vorbis_enc_src_template);
+  src_template = gst_static_pad_template_get (&vorbis_enc_src_factory);
+  gst_element_class_add_pad_template (element_class, src_template);
+  sink_template = gst_static_pad_template_get (&vorbis_enc_sink_factory);
+  gst_element_class_add_pad_template (element_class, sink_template);
   gst_element_class_set_details (element_class, &vorbisenc_details);
@@ -636,7 +628,7 @@
 gst_vorbis_enc_init (GstVorbisEnc * vorbisenc, GstVorbisEncClass * klass)
   vorbisenc->sinkpad =
-      gst_pad_new_from_template (gst_vorbis_enc_sink_template, "sink");
+      gst_pad_new_from_static_template (&vorbis_enc_sink_factory, "sink");
   gst_pad_set_event_function (vorbisenc->sinkpad,
       GST_DEBUG_FUNCPTR (gst_vorbis_enc_sink_event));
   gst_pad_set_chain_function (vorbisenc->sinkpad,
@@ -650,7 +642,7 @@
   gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->sinkpad);
   vorbisenc->srcpad =
-      gst_pad_new_from_template (gst_vorbis_enc_src_template, "src");
+      gst_pad_new_from_static_template (&vorbis_enc_src_factory, "src");
   gst_pad_set_query_function (vorbisenc->srcpad,
       GST_DEBUG_FUNCPTR (gst_vorbis_enc_src_query));
   gst_pad_set_query_type_function (vorbisenc->srcpad,

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/