Title: [109005] trunk/Source/WebCore
Revision
109005
Author
ph...@webkit.org
Date
2012-02-27 10:04:18 -0800 (Mon, 27 Feb 2012)

Log Message

[GStreamer] 0.11 support in MediaPlayerPrivateGStreamer
https://bugs.webkit.org/show_bug.cgi?id=77089

Reviewed by Martin Robinson.

Basic port to GStreamer 0.11 APIs. This patch excludes the video
painting changes and the GStreamerGWorld changes which are handled
in two other patches (bugs 77087 and 77088).

* GNUmakefile.list.am: Add GStreamerVersioning files to the build.
* Source/WebCore/PlatformEfl.cmake: Ditto.
* Source/WebCore/Target.pri: Ditto.
* platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
(WTF::GstElement):
(WTF::GstPad):
(WTF::GstPadTemplate):
(WTF::GstTask):
* platform/graphics/gstreamer/GStreamerVersioning.cpp: Added.
(webkit_gst_object_ref_sink):
(webkit_gst_element_get_pad_caps):
* platform/graphics/gstreamer/GStreamerVersioning.h: Added.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::isAvailable):
(WebCore::MediaPlayerPrivateGStreamer::duration):
(WebCore::MediaPlayerPrivateGStreamer::naturalSize):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109004 => 109005)


--- trunk/Source/WebCore/ChangeLog	2012-02-27 18:00:23 UTC (rev 109004)
+++ trunk/Source/WebCore/ChangeLog	2012-02-27 18:04:18 UTC (rev 109005)
@@ -1,3 +1,31 @@
+2012-02-27  Philippe Normand  <pnorm...@igalia.com>
+
+        [GStreamer] 0.11 support in MediaPlayerPrivateGStreamer
+        https://bugs.webkit.org/show_bug.cgi?id=77089
+
+        Reviewed by Martin Robinson.
+
+        Basic port to GStreamer 0.11 APIs. This patch excludes the video
+        painting changes and the GStreamerGWorld changes which are handled
+        in two other patches (bugs 77087 and 77088).
+
+        * GNUmakefile.list.am: Add GStreamerVersioning files to the build.
+        * Source/WebCore/PlatformEfl.cmake: Ditto.
+        * Source/WebCore/Target.pri: Ditto.
+        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+        (WTF::GstElement):
+        (WTF::GstPad):
+        (WTF::GstPadTemplate):
+        (WTF::GstTask):
+        * platform/graphics/gstreamer/GStreamerVersioning.cpp: Added.
+        (webkit_gst_object_ref_sink):
+        (webkit_gst_element_get_pad_caps):
+        * platform/graphics/gstreamer/GStreamerVersioning.h: Added.
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::isAvailable):
+        (WebCore::MediaPlayerPrivateGStreamer::duration):
+        (WebCore::MediaPlayerPrivateGStreamer::naturalSize):
+
 2012-02-27  Philip Rogers  <p...@google.com>
 
         Stop recomputing SVG path data twice during layout

Modified: trunk/Source/WebCore/GNUmakefile.list.am (109004 => 109005)


--- trunk/Source/WebCore/GNUmakefile.list.am	2012-02-27 18:00:23 UTC (rev 109004)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2012-02-27 18:04:18 UTC (rev 109005)
@@ -4530,6 +4530,8 @@
 	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/GStreamerVersioning.cpp \
+	Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h \
 	Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp \
 	Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h \
 	Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \

Modified: trunk/Source/WebCore/PlatformEfl.cmake (109004 => 109005)


--- trunk/Source/WebCore/PlatformEfl.cmake	2012-02-27 18:00:23 UTC (rev 109004)
+++ trunk/Source/WebCore/PlatformEfl.cmake	2012-02-27 18:04:18 UTC (rev 109005)
@@ -188,6 +188,7 @@
   LIST(APPEND WebCore_SOURCES
     platform/graphics/gstreamer/GRefPtrGStreamer.cpp
     platform/graphics/gstreamer/GStreamerGWorld.cpp
+    platform/graphics/gstreamer/GStreamerVersioning.cpp
     platform/graphics/gstreamer/ImageGStreamerCairo.cpp
     platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
     platform/graphics/gstreamer/PlatformVideoWindowEfl.cpp

Modified: trunk/Source/WebCore/Target.pri (109004 => 109005)


--- trunk/Source/WebCore/Target.pri	2012-02-27 18:00:23 UTC (rev 109004)
+++ trunk/Source/WebCore/Target.pri	2012-02-27 18:04:18 UTC (rev 109005)
@@ -3231,6 +3231,7 @@
         HEADERS += \
             platform/graphics/gstreamer/GRefPtrGStreamer.h \
             platform/graphics/gstreamer/GStreamerGWorld.h \
+            platform/graphics/gstreamer/GStreamerVersioning.h \
             platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h \
             platform/graphics/gstreamer/VideoSinkGStreamer.h \
             platform/graphics/gstreamer/WebKitWebSourceGStreamer.h \
@@ -3240,6 +3241,7 @@
         SOURCES += \
             platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
             platform/graphics/gstreamer/GStreamerGWorld.cpp \
+            platform/graphics/gstreamer/GStreamerVersioning.cpp \
             platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \
             platform/graphics/gstreamer/VideoSinkGStreamer.cpp \
             platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp \

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (109004 => 109005)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp	2012-02-27 18:00:23 UTC (rev 109004)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp	2012-02-27 18:04:18 UTC (rev 109005)
@@ -19,6 +19,7 @@
 
 #include "config.h"
 #include "GRefPtrGStreamer.h"
+#include "GStreamerVersioning.h"
 
 #if USE(GSTREAMER)
 #include <gst/gstelement.h>
@@ -33,10 +34,8 @@
 
 template <> GstElement* refGPtr<GstElement>(GstElement* ptr)
 {
-    if (ptr) {
-        gst_object_ref(GST_OBJECT(ptr));
-        gst_object_sink(GST_OBJECT(ptr));
-    }
+    if (ptr)
+        webkitGstObjectRefSink(GST_OBJECT(ptr));
 
     return ptr;
 }
@@ -55,10 +54,9 @@
 
 template <> GstPad* refGPtr<GstPad>(GstPad* ptr)
 {
-    if (ptr) {
-        gst_object_ref(GST_OBJECT(ptr));
-        gst_object_sink(GST_OBJECT(ptr));
-    }
+    if (ptr)
+        webkitGstObjectRefSink(GST_OBJECT(ptr));
+
     return ptr;
 }
 
@@ -76,10 +74,9 @@
 
 template <> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr)
 {
-    if (ptr) {
-        gst_object_ref(GST_OBJECT(ptr));
-        gst_object_sink(GST_OBJECT(ptr));
-    }
+    if (ptr)
+        webkitGstObjectRefSink(GST_OBJECT(ptr));
+
     return ptr;
 }
 
@@ -111,10 +108,8 @@
 
 template <> GstTask* refGPtr<GstTask>(GstTask* ptr)
 {
-    if (ptr) {
-        gst_object_ref(GST_OBJECT(ptr));
-        gst_object_sink(GST_OBJECT(ptr));
-    }
+    if (ptr)
+        webkitGstObjectRefSink(GST_OBJECT(ptr));
 
     return ptr;
 }

Added: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp (0 => 109005)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp	2012-02-27 18:04:18 UTC (rev 109005)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#include "config.h"
+
+#include "GStreamerVersioning.h"
+
+void webkitGstObjectRefSink(GstObject* gstObject)
+{
+#ifdef GST_API_VERSION_1
+    gst_object_ref_sink(gstObject);
+#else
+    gst_object_ref(gstObject);
+    gst_object_sink(gstObject);
+#endif
+}
+
+GstCaps* webkitGstElementGetPadCaps(GstElement* element, const char* direction)
+{
+    GstPad* pad = gst_element_get_static_pad(element, direction);
+    if (!pad)
+        return 0;
+
+    GstCaps* caps;
+#ifdef GST_API_VERSION_1
+    caps = gst_pad_get_current_caps(pad);
+    if (!caps)
+        caps = gst_pad_query_caps(pad, 0);
+#else
+    caps = GST_PAD_CAPS(pad);
+#endif
+    gst_object_unref(GST_OBJECT(pad));
+    return caps;
+}

Added: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h (0 => 109005)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h	2012-02-27 18:04:18 UTC (rev 109005)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 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 GStreamerVersioning_h
+#define GStreamerVersioning_h
+
+#include <gst/gst.h>
+
+void webkitGstObjectRefSink(GstObject*);
+GstCaps* webkitGstElementGetPadCaps(GstElement*, const char*);
+
+#endif // GStreamerVersioning_h

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (109004 => 109005)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2012-02-27 18:00:23 UTC (rev 109004)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2012-02-27 18:04:18 UTC (rev 109005)
@@ -32,6 +32,7 @@
 #include "FrameView.h"
 #include "GRefPtrGStreamer.h"
 #include "GStreamerGWorld.h"
+#include "GStreamerVersioning.h"
 #include "GraphicsContext.h"
 #include "GraphicsTypes.h"
 #include "ImageGStreamer.h"
@@ -46,12 +47,17 @@
 #include "WebKitWebSourceGStreamer.h"
 #include <GOwnPtr.h>
 #include <gst/gst.h>
-#include <gst/interfaces/streamvolume.h>
 #include <gst/video/video.h>
 #include <limits>
 #include <math.h>
 #include <wtf/text/CString.h>
 
+#ifdef GST_API_VERSION_1
+#include <gst/audio/streamvolume.h>
+#else
+#include <gst/interfaces/streamvolume.h>
+#endif
+
 // GstPlayFlags flags from playbin2. It is the policy of GStreamer to
 // not publicly expose element-specific enums. That's why this
 // GstPlayFlags enum has been copied here.
@@ -67,6 +73,12 @@
     GST_PLAY_FLAG_BUFFERING     = 0x000000100
 } GstPlayFlags;
 
+#ifdef GST_API_VERSION_1
+static const char* gPlaybinName = "playbin";
+#else
+static const char* gPlaybinName = "playbin2";
+#endif
+
 using namespace std;
 
 namespace WebCore {
@@ -186,7 +198,7 @@
     if (!doGstInit())
         return false;
 
-    GstElementFactory* factory = gst_element_factory_find("playbin2");
+    GstElementFactory* factory = gst_element_factory_find(gPlaybinName);
     if (factory) {
         gst_object_unref(GST_OBJECT(factory));
         return true;
@@ -400,7 +412,12 @@
     GstFormat timeFormat = GST_FORMAT_TIME;
     gint64 timeLength = 0;
 
-    if (!gst_element_query_duration(m_playBin, &timeFormat, &timeLength) || timeFormat != GST_FORMAT_TIME || static_cast<guint64>(timeLength) == GST_CLOCK_TIME_NONE) {
+#ifdef GST_API_VERSION_1
+    bool failure = !gst_element_query_duration(m_playBin, timeFormat, &timeLength) || static_cast<guint64>(timeLength) == GST_CLOCK_TIME_NONE;
+#else
+    bool failure = !gst_element_query_duration(m_playBin, &timeFormat, &timeLength) || timeFormat != GST_FORMAT_TIME || static_cast<guint64>(timeLength) == GST_CLOCK_TIME_NONE;
+#endif
+    if (failure) {
         LOG_VERBOSE(Media, "Time duration query failed.");
         return numeric_limits<float>::infinity();
     }
@@ -489,12 +506,10 @@
     if (!hasVideo())
         return IntSize();
 
-    GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
-    if (!pad)
+    GstCaps* caps = webkitGstElementGetPadCaps(m_webkitVideoSink, "sink");
+    if (!caps)
         return IntSize();
 
-    guint64 width = 0, height = 0;
-    GstCaps* caps = GST_PAD_CAPS(pad.get());
     int pixelAspectRatioNumerator, pixelAspectRatioDenominator;
     int displayWidth, displayHeight, displayAspectRatioGCD;
     int originalWidth = 0, originalHeight = 0;
@@ -506,11 +521,23 @@
 
     // Get the video PAR and original size, if this fails the
     // video-sink has likely not yet negotiated its caps.
+#ifdef GST_API_VERSION_1
+    GstVideoInfo info;
+    if (!gst_video_info_from_caps(&info, caps))
+        return IntSize();
+
+    originalWidth = GST_VIDEO_INFO_WIDTH(&info);
+    originalHeight = GST_VIDEO_INFO_HEIGHT(&info);
+    pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
+    pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
+#else
+    // Get the video PAR and original size.
     if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
         || !gst_video_format_parse_caps(caps, 0, &originalWidth, &originalHeight)
         || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
                                                     &pixelAspectRatioDenominator))
         return IntSize();
+#endif
 
     LOG_VERBOSE(Media, "Original video size: %dx%d", originalWidth, originalHeight);
     LOG_VERBOSE(Media, "Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
@@ -525,6 +552,7 @@
     displayHeight /= displayAspectRatioGCD;
 
     // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function.
+    guint64 width = 0, height = 0;
     if (!(originalHeight % displayHeight)) {
         LOG_VERBOSE(Media, "Keeping video original height");
         width = gst_util_uint64_scale_int(originalHeight, displayWidth, displayHeight);
@@ -929,7 +957,11 @@
 
     GstFormat fmt = GST_FORMAT_BYTES;
     gint64 length = 0;
+#ifdef GST_API_VERSION_1
+    if (gst_element_query_duration(m_source, fmt, &length)) {
+#else
     if (gst_element_query_duration(m_source, &fmt, &length)) {
+#endif
         LOG_VERBOSE(Media, "totalBytes %" G_GINT64_FORMAT, length);
         return static_cast<unsigned>(length);
     }
@@ -939,17 +971,28 @@
     GstIterator* iter = gst_element_iterate_src_pads(m_source);
     bool done = false;
     while (!done) {
+#ifdef GST_API_VERSION_1
+        GValue item = {0, };
+        switch (gst_iterator_next(iter, &item)) {
+        case GST_ITERATOR_OK: {
+            GstPad* pad = static_cast<GstPad*>(g_value_get_object(&item));
+            gint64 padLength = 0;
+            if (gst_pad_query_duration(pad, fmt, &padLength) && padLength > length)
+                length = padLength;
+            break;
+        }
+#else
         gpointer data;
 
         switch (gst_iterator_next(iter, &data)) {
         case GST_ITERATOR_OK: {
             GRefPtr<GstPad> pad = adoptGRef(GST_PAD_CAST(data));
             gint64 padLength = 0;
-            if (gst_pad_query_duration(pad.get(), &fmt, &padLength)
-                && padLength > length)
+            if (gst_pad_query_duration(pad.get(), &fmt, &padLength) && padLength > length)
                 length = padLength;
             break;
         }
+#endif
         case GST_ITERATOR_RESYNC:
             gst_iterator_resync(iter);
             break;
@@ -959,7 +1002,12 @@
             done = true;
             break;
         }
+
+#ifdef GST_API_VERSION_1
+        g_value_unset(&item);
+#endif
     }
+
     gst_iterator_free(iter);
 
     LOG_VERBOSE(Media, "totalBytes %" G_GINT64_FORMAT, length);
@@ -1671,7 +1719,7 @@
 void MediaPlayerPrivateGStreamer::createGSTPlayBin()
 {
     ASSERT(!m_playBin);
-    m_playBin = gst_element_factory_make("playbin2", "play");
+    m_playBin = gst_element_factory_make(gPlaybinName, "play");
 
     m_gstGWorld = GStreamerGWorld::createGWorld(m_playBin);
 
@@ -1692,7 +1740,10 @@
 
     g_signal_connect(m_webkitVideoSink, "repaint-requested", G_CALLBACK(mediaPlayerPrivateRepaintCallback), this);
 
+
+#ifndef GST_API_VERSION_1
     m_videoSinkBin = gst_bin_new("sink");
+
     GstElement* videoTee = gst_element_factory_make("tee", "videoTee");
     GstElement* queue = gst_element_factory_make("queue", 0);
 
@@ -1710,6 +1761,7 @@
     GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(videoTee, "src%d"));
     GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink"));
     gst_pad_link(srcPad.get(), sinkPad.get());
+#endif
 
     GstElement* actualVideoSink = 0;
     m_fpsSink = gst_element_factory_make("fpsdisplaysink", "sink");
@@ -1728,7 +1780,9 @@
 
             if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink), "video-sink")) {
                 g_object_set(m_fpsSink, "video-sink", m_webkitVideoSink, NULL);
+#ifndef GST_API_VERSION_1
                 gst_bin_add(GST_BIN(m_videoSinkBin), m_fpsSink);
+#endif
                 actualVideoSink = m_fpsSink;
             } else
                 m_fpsSink = 0;
@@ -1737,12 +1791,15 @@
     }
 
     if (!m_fpsSink) {
+#ifndef GST_API_VERSION_1
         gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink);
+#endif
         actualVideoSink = m_webkitVideoSink;
     }
 
     ASSERT(actualVideoSink);
 
+#ifndef GST_API_VERSION_1
     // Faster elements linking.
     gst_element_link_pads_full(queue, "src", actualVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
 
@@ -1752,10 +1809,13 @@
 
     // Set the bin as video sink of playbin.
     g_object_set(m_playBin, "video-sink", m_videoSinkBin, NULL);
+#else
+    g_object_set(m_playBin, "video-sink", actualVideoSink, NULL);
+#endif
 
-    pad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
-    if (pad)
-        g_signal_connect(pad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
+    GRefPtr<GstPad> videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
+    if (videoSinkPad)
+        g_signal_connect(videoSinkPad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
 
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to