Title: [135705] trunk/Source/WebCore
Revision
135705
Author
[email protected]
Date
2012-11-26 04:10:28 -0800 (Mon, 26 Nov 2012)

Log Message

[GStreamer] Floating reference handling fix
https://bugs.webkit.org/show_bug.cgi?id=101349

Patch by Thiago Santos <[email protected]> on 2012-11-26
Reviewed by Philippe Normand.

GStreamer 0.10 and 1.0 differ when creating GstGhostPad from pad
templates, the 1.0 doesn't take ownership on the passed
GstPadTemplate, while 0.10 does. So this patch adds a
GStreamerVersioning function to handle this different approach
transparently in Webkit gstreamer elements.

Existing media tests cover this change.

* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webkit_web_audio_src_init):
* platform/graphics/gstreamer/GStreamerVersioning.cpp:
(webkitGstGhostPadFromStaticTemplate):
* platform/graphics/gstreamer/GStreamerVersioning.h:
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webkit_web_src_init):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135704 => 135705)


--- trunk/Source/WebCore/ChangeLog	2012-11-26 11:44:56 UTC (rev 135704)
+++ trunk/Source/WebCore/ChangeLog	2012-11-26 12:10:28 UTC (rev 135705)
@@ -1,3 +1,26 @@
+2012-11-26  Thiago Santos  <[email protected]>
+
+        [GStreamer] Floating reference handling fix
+        https://bugs.webkit.org/show_bug.cgi?id=101349
+
+        Reviewed by Philippe Normand.
+
+        GStreamer 0.10 and 1.0 differ when creating GstGhostPad from pad
+        templates, the 1.0 doesn't take ownership on the passed
+        GstPadTemplate, while 0.10 does. So this patch adds a
+        GStreamerVersioning function to handle this different approach
+        transparently in Webkit gstreamer elements.
+
+        Existing media tests cover this change.
+
+        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
+        (webkit_web_audio_src_init):
+        * platform/graphics/gstreamer/GStreamerVersioning.cpp:
+        (webkitGstGhostPadFromStaticTemplate):
+        * platform/graphics/gstreamer/GStreamerVersioning.h:
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (webkit_web_src_init):
+
 2012-11-26  Kentaro Hara  <[email protected]>
 
         [V8] Remove WorkerContextExecutionProxy

Modified: trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp (135704 => 135705)


--- trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2012-11-26 11:44:56 UTC (rev 135704)
+++ trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2012-11-26 12:10:28 UTC (rev 135705)
@@ -26,6 +26,7 @@
 #include "AudioIOCallback.h"
 #include <wtf/gobject/GOwnPtr.h>
 #include "GRefPtrGStreamer.h"
+#include "GStreamerVersioning.h"
 #include <gst/audio/multichannel.h>
 #include <gst/pbutils/pbutils.h>
 
@@ -178,8 +179,7 @@
     src->priv = priv;
     new (priv) WebKitWebAudioSourcePrivate();
 
-    GRefPtr<GstPadTemplate> padTemplate = adoptGRef(gst_static_pad_template_get(&srcTemplate));
-    priv->sourcePad = gst_ghost_pad_new_no_target_from_template("src", padTemplate.get());
+    priv->sourcePad = webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src", 0);
     gst_element_add_pad(GST_ELEMENT(src), priv->sourcePad);
 
     priv->provider = 0;

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp (135704 => 135705)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp	2012-11-26 11:44:56 UTC (rev 135704)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp	2012-11-26 12:10:28 UTC (rev 135705)
@@ -34,6 +34,23 @@
 #endif
 }
 
+GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate* staticPadTemplate, const gchar* name, GstPad* target)
+{
+    GstPad* pad;
+    GstPadTemplate* padTemplate = gst_static_pad_template_get(staticPadTemplate);
+
+    if (target)
+        pad = gst_ghost_pad_new_from_template(name, target, padTemplate);
+    else
+        pad = gst_ghost_pad_new_no_target_from_template(name, padTemplate);
+
+#ifdef GST_API_VERSION_1
+    gst_object_unref(padTemplate);
+#endif
+
+    return pad;
+}
+
 GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad* pad)
 {
     if (!pad)

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h (135704 => 135705)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h	2012-11-26 11:44:56 UTC (rev 135704)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h	2012-11-26 12:10:28 UTC (rev 135705)
@@ -29,6 +29,7 @@
 };
 
 void webkitGstObjectRefSink(GstObject*);
+GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate*, const gchar* name, GstPad* target);
 GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad*);
 bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
 GstBuffer* createGstBuffer(GstBuffer*);

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (135704 => 135705)


--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2012-11-26 11:44:56 UTC (rev 135704)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp	2012-11-26 12:10:28 UTC (rev 135705)
@@ -217,7 +217,6 @@
 
 static void webkit_web_src_init(WebKitWebSrc* src)
 {
-    GRefPtr<GstPadTemplate> padTemplate = adoptGRef(gst_static_pad_template_get(&srcTemplate));
     WebKitWebSrcPrivate* priv = WEBKIT_WEB_SRC_GET_PRIVATE(src);
 
     src->priv = priv;
@@ -237,7 +236,7 @@
 
 
     GRefPtr<GstPad> targetPad = adoptGRef(gst_element_get_static_pad(GST_ELEMENT(priv->appsrc), "src"));
-    priv->srcpad = gst_ghost_pad_new_from_template("src", targetPad.get(), padTemplate.get());
+    priv->srcpad = webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src", targetPad.get());
 
     gst_element_add_pad(GST_ELEMENT(src), priv->srcpad);
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to