Changeset 109005 in webkit


Ignore:
Timestamp:
Feb 27, 2012 10:04:18 AM (12 years ago)
Author:
Philippe Normand
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):

Location:
trunk/Source/WebCore
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109003 r109005  
     12012-02-27  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] 0.11 support in MediaPlayerPrivateGStreamer
     4        https://bugs.webkit.org/show_bug.cgi?id=77089
     5
     6        Reviewed by Martin Robinson.
     7
     8        Basic port to GStreamer 0.11 APIs. This patch excludes the video
     9        painting changes and the GStreamerGWorld changes which are handled
     10        in two other patches (bugs 77087 and 77088).
     11
     12        * GNUmakefile.list.am: Add GStreamerVersioning files to the build.
     13        * Source/WebCore/PlatformEfl.cmake: Ditto.
     14        * Source/WebCore/Target.pri: Ditto.
     15        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
     16        (WTF::GstElement):
     17        (WTF::GstPad):
     18        (WTF::GstPadTemplate):
     19        (WTF::GstTask):
     20        * platform/graphics/gstreamer/GStreamerVersioning.cpp: Added.
     21        (webkit_gst_object_ref_sink):
     22        (webkit_gst_element_get_pad_caps):
     23        * platform/graphics/gstreamer/GStreamerVersioning.h: Added.
     24        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     25        (WebCore::MediaPlayerPrivateGStreamer::isAvailable):
     26        (WebCore::MediaPlayerPrivateGStreamer::duration):
     27        (WebCore::MediaPlayerPrivateGStreamer::naturalSize):
     28
    1292012-02-27  Philip Rogers  <pdr@google.com>
    230
  • trunk/Source/WebCore/GNUmakefile.list.am

    r108985 r109005  
    45314531        Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp \
    45324532        Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h \
     4533        Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp \
     4534        Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h \
    45334535        Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp \
    45344536        Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h \
  • trunk/Source/WebCore/PlatformEfl.cmake

    r108558 r109005  
    189189    platform/graphics/gstreamer/GRefPtrGStreamer.cpp
    190190    platform/graphics/gstreamer/GStreamerGWorld.cpp
     191    platform/graphics/gstreamer/GStreamerVersioning.cpp
    191192    platform/graphics/gstreamer/ImageGStreamerCairo.cpp
    192193    platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
  • trunk/Source/WebCore/Target.pri

    r108982 r109005  
    32323232            platform/graphics/gstreamer/GRefPtrGStreamer.h \
    32333233            platform/graphics/gstreamer/GStreamerGWorld.h \
     3234            platform/graphics/gstreamer/GStreamerVersioning.h \
    32343235            platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h \
    32353236            platform/graphics/gstreamer/VideoSinkGStreamer.h \
     
    32413242            platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
    32423243            platform/graphics/gstreamer/GStreamerGWorld.cpp \
     3244            platform/graphics/gstreamer/GStreamerVersioning.cpp \
    32433245            platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \
    32443246            platform/graphics/gstreamer/VideoSinkGStreamer.cpp \
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp

    r102791 r109005  
    2020#include "config.h"
    2121#include "GRefPtrGStreamer.h"
     22#include "GStreamerVersioning.h"
    2223
    2324#if USE(GSTREAMER)
     
    3435template <> GstElement* refGPtr<GstElement>(GstElement* ptr)
    3536{
    36     if (ptr) {
    37         gst_object_ref(GST_OBJECT(ptr));
    38         gst_object_sink(GST_OBJECT(ptr));
    39     }
     37    if (ptr)
     38        webkitGstObjectRefSink(GST_OBJECT(ptr));
    4039
    4140    return ptr;
     
    5655template <> GstPad* refGPtr<GstPad>(GstPad* ptr)
    5756{
    58     if (ptr) {
    59         gst_object_ref(GST_OBJECT(ptr));
    60         gst_object_sink(GST_OBJECT(ptr));
    61     }
     57    if (ptr)
     58        webkitGstObjectRefSink(GST_OBJECT(ptr));
     59
    6260    return ptr;
    6361}
     
    7775template <> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr)
    7876{
    79     if (ptr) {
    80         gst_object_ref(GST_OBJECT(ptr));
    81         gst_object_sink(GST_OBJECT(ptr));
    82     }
     77    if (ptr)
     78        webkitGstObjectRefSink(GST_OBJECT(ptr));
     79
    8380    return ptr;
    8481}
     
    112109template <> GstTask* refGPtr<GstTask>(GstTask* ptr)
    113110{
    114     if (ptr) {
    115         gst_object_ref(GST_OBJECT(ptr));
    116         gst_object_sink(GST_OBJECT(ptr));
    117     }
     111    if (ptr)
     112        webkitGstObjectRefSink(GST_OBJECT(ptr));
    118113
    119114    return ptr;
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r108524 r109005  
    3333#include "GRefPtrGStreamer.h"
    3434#include "GStreamerGWorld.h"
     35#include "GStreamerVersioning.h"
    3536#include "GraphicsContext.h"
    3637#include "GraphicsTypes.h"
     
    4748#include <GOwnPtr.h>
    4849#include <gst/gst.h>
    49 #include <gst/interfaces/streamvolume.h>
    5050#include <gst/video/video.h>
    5151#include <limits>
    5252#include <math.h>
    5353#include <wtf/text/CString.h>
     54
     55#ifdef GST_API_VERSION_1
     56#include <gst/audio/streamvolume.h>
     57#else
     58#include <gst/interfaces/streamvolume.h>
     59#endif
    5460
    5561// GstPlayFlags flags from playbin2. It is the policy of GStreamer to
     
    6874} GstPlayFlags;
    6975
     76#ifdef GST_API_VERSION_1
     77static const char* gPlaybinName = "playbin";
     78#else
     79static const char* gPlaybinName = "playbin2";
     80#endif
     81
    7082using namespace std;
    7183
     
    187199        return false;
    188200
    189     GstElementFactory* factory = gst_element_factory_find("playbin2");
     201    GstElementFactory* factory = gst_element_factory_find(gPlaybinName);
    190202    if (factory) {
    191203        gst_object_unref(GST_OBJECT(factory));
     
    401413    gint64 timeLength = 0;
    402414
    403     if (!gst_element_query_duration(m_playBin, &timeFormat, &timeLength) || timeFormat != GST_FORMAT_TIME || static_cast<guint64>(timeLength) == GST_CLOCK_TIME_NONE) {
     415#ifdef GST_API_VERSION_1
     416    bool failure = !gst_element_query_duration(m_playBin, timeFormat, &timeLength) || static_cast<guint64>(timeLength) == GST_CLOCK_TIME_NONE;
     417#else
     418    bool failure = !gst_element_query_duration(m_playBin, &timeFormat, &timeLength) || timeFormat != GST_FORMAT_TIME || static_cast<guint64>(timeLength) == GST_CLOCK_TIME_NONE;
     419#endif
     420    if (failure) {
    404421        LOG_VERBOSE(Media, "Time duration query failed.");
    405422        return numeric_limits<float>::infinity();
     
    490507        return IntSize();
    491508
    492     GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
    493     if (!pad)
     509    GstCaps* caps = webkitGstElementGetPadCaps(m_webkitVideoSink, "sink");
     510    if (!caps)
    494511        return IntSize();
    495512
    496     guint64 width = 0, height = 0;
    497     GstCaps* caps = GST_PAD_CAPS(pad.get());
    498513    int pixelAspectRatioNumerator, pixelAspectRatioDenominator;
    499514    int displayWidth, displayHeight, displayAspectRatioGCD;
     
    507522    // Get the video PAR and original size, if this fails the
    508523    // video-sink has likely not yet negotiated its caps.
     524#ifdef GST_API_VERSION_1
     525    GstVideoInfo info;
     526    if (!gst_video_info_from_caps(&info, caps))
     527        return IntSize();
     528
     529    originalWidth = GST_VIDEO_INFO_WIDTH(&info);
     530    originalHeight = GST_VIDEO_INFO_HEIGHT(&info);
     531    pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
     532    pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
     533#else
     534    // Get the video PAR and original size.
    509535    if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
    510536        || !gst_video_format_parse_caps(caps, 0, &originalWidth, &originalHeight)
     
    512538                                                    &pixelAspectRatioDenominator))
    513539        return IntSize();
     540#endif
    514541
    515542    LOG_VERBOSE(Media, "Original video size: %dx%d", originalWidth, originalHeight);
     
    526553
    527554    // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function.
     555    guint64 width = 0, height = 0;
    528556    if (!(originalHeight % displayHeight)) {
    529557        LOG_VERBOSE(Media, "Keeping video original height");
     
    930958    GstFormat fmt = GST_FORMAT_BYTES;
    931959    gint64 length = 0;
     960#ifdef GST_API_VERSION_1
     961    if (gst_element_query_duration(m_source, fmt, &length)) {
     962#else
    932963    if (gst_element_query_duration(m_source, &fmt, &length)) {
     964#endif
    933965        LOG_VERBOSE(Media, "totalBytes %" G_GINT64_FORMAT, length);
    934966        return static_cast<unsigned>(length);
     
    940972    bool done = false;
    941973    while (!done) {
     974#ifdef GST_API_VERSION_1
     975        GValue item = {0, };
     976        switch (gst_iterator_next(iter, &item)) {
     977        case GST_ITERATOR_OK: {
     978            GstPad* pad = static_cast<GstPad*>(g_value_get_object(&item));
     979            gint64 padLength = 0;
     980            if (gst_pad_query_duration(pad, fmt, &padLength) && padLength > length)
     981                length = padLength;
     982            break;
     983        }
     984#else
    942985        gpointer data;
    943986
     
    946989            GRefPtr<GstPad> pad = adoptGRef(GST_PAD_CAST(data));
    947990            gint64 padLength = 0;
    948             if (gst_pad_query_duration(pad.get(), &fmt, &padLength)
    949                 && padLength > length)
     991            if (gst_pad_query_duration(pad.get(), &fmt, &padLength) && padLength > length)
    950992                length = padLength;
    951993            break;
    952994        }
     995#endif
    953996        case GST_ITERATOR_RESYNC:
    954997            gst_iterator_resync(iter);
     
    9601003            break;
    9611004        }
    962     }
     1005
     1006#ifdef GST_API_VERSION_1
     1007        g_value_unset(&item);
     1008#endif
     1009    }
     1010
    9631011    gst_iterator_free(iter);
    9641012
     
    16721720{
    16731721    ASSERT(!m_playBin);
    1674     m_playBin = gst_element_factory_make("playbin2", "play");
     1722    m_playBin = gst_element_factory_make(gPlaybinName, "play");
    16751723
    16761724    m_gstGWorld = GStreamerGWorld::createGWorld(m_playBin);
     
    16931741    g_signal_connect(m_webkitVideoSink, "repaint-requested", G_CALLBACK(mediaPlayerPrivateRepaintCallback), this);
    16941742
     1743
     1744#ifndef GST_API_VERSION_1
    16951745    m_videoSinkBin = gst_bin_new("sink");
     1746
    16961747    GstElement* videoTee = gst_element_factory_make("tee", "videoTee");
    16971748    GstElement* queue = gst_element_factory_make("queue", 0);
     
    17111762    GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink"));
    17121763    gst_pad_link(srcPad.get(), sinkPad.get());
     1764#endif
    17131765
    17141766    GstElement* actualVideoSink = 0;
     
    17291781            if (g_object_class_find_property(G_OBJECT_GET_CLASS(m_fpsSink), "video-sink")) {
    17301782                g_object_set(m_fpsSink, "video-sink", m_webkitVideoSink, NULL);
     1783#ifndef GST_API_VERSION_1
    17311784                gst_bin_add(GST_BIN(m_videoSinkBin), m_fpsSink);
     1785#endif
    17321786                actualVideoSink = m_fpsSink;
    17331787            } else
     
    17381792
    17391793    if (!m_fpsSink) {
     1794#ifndef GST_API_VERSION_1
    17401795        gst_bin_add(GST_BIN(m_videoSinkBin), m_webkitVideoSink);
     1796#endif
    17411797        actualVideoSink = m_webkitVideoSink;
    17421798    }
     
    17441800    ASSERT(actualVideoSink);
    17451801
     1802#ifndef GST_API_VERSION_1
    17461803    // Faster elements linking.
    17471804    gst_element_link_pads_full(queue, "src", actualVideoSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
     
    17531810    // Set the bin as video sink of playbin.
    17541811    g_object_set(m_playBin, "video-sink", m_videoSinkBin, NULL);
    1755 
    1756     pad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
    1757     if (pad)
    1758         g_signal_connect(pad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
     1812#else
     1813    g_object_set(m_playBin, "video-sink", actualVideoSink, NULL);
     1814#endif
     1815
     1816    GRefPtr<GstPad> videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
     1817    if (videoSinkPad)
     1818        g_signal_connect(videoSinkPad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
    17591819
    17601820}
Note: See TracChangeset for help on using the changeset viewer.