Diff
Modified: trunk/Source/WebCore/ChangeLog (131386 => 131387)
--- trunk/Source/WebCore/ChangeLog 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/ChangeLog 2012-10-16 00:35:17 UTC (rev 131387)
@@ -1,3 +1,31 @@
+2012-10-15 Arnaud Renevier <[email protected]>
+
+ [GStreamer] GstCaps are leaked when building with gstreamer-1.0
+ https://bugs.webkit.org/show_bug.cgi?id=99362
+
+ Reviewed by Martin Robinson.
+
+ Implement GRefPtr<GstCaps> adoptGRef(GstCaps*).
+
+ Change webkitGstGetPadCaps signature to return a GRefPtr<GstCaps>, and
+ use GRefPtr<GstCaps> also in webkitVideoSinkRender to simply GstCaps
+ refeference count.
+
+ Covered by existing tests.
+
+ * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+ (WTF::adoptGRef):
+ (WTF):
+ * platform/graphics/gstreamer/GRefPtrGStreamer.h:
+ (WTF):
+ * platform/graphics/gstreamer/GStreamerVersioning.cpp:
+ (webkitGstGetPadCaps):
+ * platform/graphics/gstreamer/GStreamerVersioning.h:
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::naturalSize):
+ * platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
+ (webkitVideoSinkRender):
+
2012-10-15 Tony Chang <[email protected]>
Unreviewed, rolling out r131367.
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (131386 => 131387)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2012-10-16 00:35:17 UTC (rev 131387)
@@ -86,6 +86,12 @@
gst_object_unref(GST_OBJECT(ptr));
}
+template <> GRefPtr<GstCaps> adoptGRef(GstCaps* ptr)
+{
+ ASSERT(!ptr || !gstObjectIsFloating(GST_OBJECT(ptr)));
+ return GRefPtr<GstCaps>(ptr, GRefPtrAdopt);
+}
+
template <> GstCaps* refGPtr<GstCaps>(GstCaps* ptr)
{
if (ptr)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h (131386 => 131387)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2012-10-16 00:35:17 UTC (rev 131387)
@@ -45,6 +45,7 @@
template<> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr);
template<> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr);
+template<> GRefPtr<GstCaps> adoptGRef(GstCaps* ptr);
template<> GstCaps* refGPtr<GstCaps>(GstCaps* ptr);
template<> void derefGPtr<GstCaps>(GstCaps* ptr);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp (131386 => 131387)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp 2012-10-16 00:35:17 UTC (rev 131387)
@@ -34,20 +34,19 @@
#endif
}
-GstCaps* webkitGstGetPadCaps(GstPad* pad)
+GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad* pad)
{
if (!pad)
return 0;
- GstCaps* caps;
#ifdef GST_API_VERSION_1
- caps = gst_pad_get_current_caps(pad);
+ GstCaps* caps = gst_pad_get_current_caps(pad);
if (!caps)
caps = gst_pad_query_caps(pad, 0);
+ return adoptGRef(caps); // gst_pad_query_caps and gst_pad_get_current_caps return a new reference.
#else
- caps = GST_PAD_CAPS(pad);
+ return GST_PAD_CAPS(pad);
#endif
- return caps;
}
bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h (131386 => 131387)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h 2012-10-16 00:35:17 UTC (rev 131387)
@@ -20,6 +20,7 @@
#ifndef GStreamerVersioning_h
#define GStreamerVersioning_h
+#include "GRefPtrGStreamer.h"
#include <gst/gst.h>
#include <gst/video/video.h>
@@ -28,7 +29,7 @@
};
void webkitGstObjectRefSink(GstObject*);
-GstCaps* webkitGstGetPadCaps(GstPad*);
+GRefPtr<GstCaps> webkitGstGetPadCaps(GstPad*);
bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
GstBuffer* createGstBuffer(GstBuffer*);
void setGstElementClassMetadata(GstElementClass*, const char* name, const char* longName, const char* description, const char* author);
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (131386 => 131387)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2012-10-16 00:35:17 UTC (rev 131387)
@@ -540,7 +540,7 @@
if (!m_videoSize.isEmpty())
return m_videoSize;
- GstCaps* caps = webkitGstGetPadCaps(m_videoSinkPad.get());
+ GRefPtr<GstCaps> caps = webkitGstGetPadCaps(m_videoSinkPad.get());
if (!caps)
return IntSize();
@@ -555,7 +555,7 @@
int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
IntSize originalSize;
GstVideoFormat format;
- if (!getVideoSizeAndFormatFromCaps(caps, originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
+ if (!getVideoSizeAndFormatFromCaps(caps.get(), originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
return IntSize();
LOG_MEDIA_MESSAGE("Original video size: %dx%d", originalSize.width(), originalSize.height());
@@ -1566,11 +1566,11 @@
if (!m_buffer)
return;
- GstCaps* caps = webkitGstGetPadCaps(m_videoSinkPad.get());
+ GRefPtr<GstCaps> caps = webkitGstGetPadCaps(m_videoSinkPad.get());
if (!caps)
return;
- RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps);
+ RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps.get());
if (!gstImage)
return;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp (131386 => 131387)
--- trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp 2012-10-16 00:20:08 UTC (rev 131386)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp 2012-10-16 00:35:17 UTC (rev 131387)
@@ -29,6 +29,7 @@
#if USE(GSTREAMER)
#include "VideoSinkGStreamer.h"
+#include "GRefPtrGStreamer.h"
#include "GStreamerVersioning.h"
#include "IntSize.h"
#include <glib.h>
@@ -172,27 +173,20 @@
gst_buffer_set_caps(priv->buffer, GST_PAD_CAPS(GST_BASE_SINK_PAD(baseSink)));
}
- GstCaps* caps = GST_BUFFER_CAPS(buffer);
+ GRefPtr<GstCaps> caps = GST_BUFFER_CAPS(buffer);
#else
- GstCaps* caps = gst_video_info_to_caps(&priv->info);
+ GRefPtr<GstCaps> caps = adoptGRef(gst_video_info_to_caps(&priv->info));
#endif
GstVideoFormat format;
WebCore::IntSize size;
int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
- if (!getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
+ if (!getVideoSizeAndFormatFromCaps(caps.get(), size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
gst_buffer_unref(buffer);
-#ifdef GST_API_VERSION_1
- gst_caps_unref(caps);
-#endif
g_mutex_unlock(priv->bufferMutex);
return GST_FLOW_ERROR;
}
-#ifdef GST_API_VERSION_1
- gst_caps_unref(caps);
-#endif
-
// Cairo's ARGB has pre-multiplied alpha while GStreamer's doesn't.
// Here we convert to Cairo's ARGB.
if (format == GST_VIDEO_FORMAT_ARGB || format == GST_VIDEO_FORMAT_BGRA) {