2011-02-21 Philippe Normand <pnormand@igalia.com>
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Feb 2011 12:47:40 +0000 (12:47 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Feb 2011 12:47:40 +0000 (12:47 +0000)
        Reviewed by Martin Robinson.

        [GStreamer] GRefPtr support for GstElement
        https://bugs.webkit.org/show_bug.cgi?id=54870

        * CMakeListsEfl.txt:
        * GNUmakefile.am:
        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp: Added.
        (WTF::GstElement):
        * platform/graphics/gstreamer/GRefPtrGStreamer.h: Added.
        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
        (webKitWebSrcQuery):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79546 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/CMakeListsEfl.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h [new file with mode: 0644]
Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp

index 8af1a14..ba7b554 100644 (file)
@@ -173,6 +173,7 @@ IF (ENABLE_VIDEO)
   )
   LIST(APPEND WebCore_SOURCES
     platform/graphics/gstreamer/GOwnPtrGStreamer.cpp
+    platform/graphics/gstreamer/GRefPtrGStreamer.cpp
     platform/graphics/gstreamer/GStreamerGWorld.cpp
     platform/graphics/gstreamer/ImageGStreamerCairo.cpp
     platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
index 217ea69..4316b10 100644 (file)
@@ -1,3 +1,18 @@
+2011-02-21  Philippe Normand  <pnormand@igalia.com>
+
+        Reviewed by Martin Robinson.
+
+        [GStreamer] GRefPtr support for GstElement
+        https://bugs.webkit.org/show_bug.cgi?id=54870
+
+        * CMakeListsEfl.txt:
+        * GNUmakefile.am:
+        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp: Added.
+        (WTF::GstElement):
+        * platform/graphics/gstreamer/GRefPtrGStreamer.h: Added.
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (webKitWebSrcQuery):
+
 2011-02-24  Emil A Eklund  <eae@chromium.org>
 
         Reviewed by Eric Seidel.
index 184d42c..5def65f 100644 (file)
@@ -3707,6 +3707,8 @@ webcoregtk_sources += \
        Source/WebCore/platform/graphics/cairo/TransformationMatrixCairo.cpp \
        Source/WebCore/platform/graphics/gstreamer/GOwnPtrGStreamer.cpp \
        Source/WebCore/platform/graphics/gstreamer/GOwnPtrGStreamer.h \
+       Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
+       Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h \
        Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp \
        Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h \
        Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp \
diff --git a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
new file mode 100644 (file)
index 0000000..91b65d8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (C) 2011 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+
+#include "config.h"
+#include "GRefPtrGStreamer.h"
+
+#if USE(GSTREAMER)
+#include <gst/gstelement.h>
+
+namespace WTF {
+
+template <> GstElement* refGPtr<GstElement>(GstElement* ptr)
+{
+    if (ptr)
+        gst_object_ref(ptr);
+    return ptr;
+}
+
+template <> void derefGPtr<GstElement>(GstElement* ptr)
+{
+    if (ptr)
+        gst_object_unref(ptr);
+}
+
+}
+#endif // USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h b/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
new file mode 100644 (file)
index 0000000..fdc6f30
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ *  Copyright (C) 2011 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GRefPtrGStreamer_h
+#define GRefPtrGStreamer_h
+#if USE(GSTREAMER)
+
+#include "GRefPtr.h"
+
+typedef struct _GstElement GstElement;
+
+namespace WTF {
+
+template<> GstElement* refGPtr<GstElement>(GstElement* ptr);
+template<> void derefGPtr<GstElement>(GstElement* ptr);
+
+}
+
+#endif // USE(GSTREAMER)
+#endif
index 819c5d0..86e3e7a 100644 (file)
@@ -23,6 +23,7 @@
 #include "Document.h"
 #include "GOwnPtr.h"
 #include "GRefPtr.h"
+#include "GRefPtrGStreamer.h"
 #include "NetworkingContext.h"
 #include "Noncopyable.h"
 #include "NotImplemented.h"
@@ -500,7 +501,8 @@ static GstStateChangeReturn webKitWebSrcChangeState(GstElement* element, GstStat
 
 static gboolean webKitWebSrcQuery(GstPad* pad, GstQuery* query)
 {
-    WebKitWebSrc* src = WEBKIT_WEB_SRC(gst_pad_get_parent(pad));
+    GRefPtr<GstElement> src = adoptGRef(gst_pad_get_parent_element(pad));
+    WebKitWebSrc* webkitSrc = WEBKIT_WEB_SRC(src.get());
     gboolean result = FALSE;
 
     switch (GST_QUERY_TYPE(query)) {
@@ -510,16 +512,16 @@ static gboolean webKitWebSrcQuery(GstPad* pad, GstQuery* query)
 
         gst_query_parse_duration(query, &format, NULL);
 
-        GST_DEBUG_OBJECT(src, "duration query in format %s", gst_format_get_name(format));
-        if ((format == GST_FORMAT_BYTES) && (src->priv->size > 0)) {
-            gst_query_set_duration(query, format, src->priv->size);
+        GST_DEBUG_OBJECT(webkitSrc, "duration query in format %s", gst_format_get_name(format));
+        if ((format == GST_FORMAT_BYTES) && (webkitSrc->priv->size > 0)) {
+            gst_query_set_duration(query, format, webkitSrc->priv->size);
             result = TRUE;
         }
         break;
     }
     case GST_QUERY_URI:
     {
-        gst_query_set_uri(query, src->priv->uri);
+        gst_query_set_uri(query, webkitSrc->priv->uri);
         result = TRUE;
         break;
     }
@@ -530,7 +532,6 @@ static gboolean webKitWebSrcQuery(GstPad* pad, GstQuery* query)
     if (!result)
         result = gst_pad_query_default(pad, query);
 
-    gst_object_unref(src);
     return result;
 }