Changeset 120790 in webkit


Ignore:
Timestamp:
Jun 19, 2012 7:25:14 PM (12 years ago)
Author:
Philippe Normand
Message:

[GStreamer] 0.11 video-sink
https://bugs.webkit.org/show_bug.cgi?id=77087

Reviewed by Martin Robinson.

  • configure.ac: Fix required gstreamer 0.11 version

Source/WebCore:

Port the video sink to GStreamer 0.11 APIs. There is no change in
functionality compared to 0.10, for now.

  • platform/graphics/gstreamer/GStreamerVersioning.cpp:

(webkitGetVideoSizeAndFormatFromCaps):
(webkitGstCreateBuffer):

  • platform/graphics/gstreamer/GStreamerVersioning.h:

(WebCore):

  • platform/graphics/gstreamer/ImageGStreamer.h:

(WebCore::ImageGStreamer::createImage):
(WebCore::ImageGStreamer::setCropRect):
(WebCore::ImageGStreamer::rect):
(ImageGStreamer):

  • platform/graphics/gstreamer/ImageGStreamerCairo.cpp:

(ImageGStreamer::ImageGStreamer):

  • platform/graphics/gstreamer/ImageGStreamerQt.cpp:

(ImageGStreamer::ImageGStreamer):

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::naturalSize):

  • platform/graphics/gstreamer/VideoSinkGStreamer.cpp:

(_WebKitVideoSinkPrivate):
(webkitVideoSinkRender):
(webkitVideoSinkProposeAllocation):
(webkit_video_sink_class_init):

  • platform/graphics/gstreamer/VideoSinkGStreamer.h:
  • platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r120713 r120790  
     12012-06-18  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] 0.11 video-sink
     4        https://bugs.webkit.org/show_bug.cgi?id=77087
     5
     6        Reviewed by Martin Robinson.
     7
     8        * configure.ac: Fix required gstreamer 0.11 version
     9
    1102012-06-19  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    211
  • trunk/Source/WebCore/ChangeLog

    r120789 r120790  
     12012-06-18  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] 0.11 video-sink
     4        https://bugs.webkit.org/show_bug.cgi?id=77087
     5
     6        Reviewed by Martin Robinson.
     7
     8        Port the video sink to GStreamer 0.11 APIs. There is no change in
     9        functionality compared to 0.10, for now.
     10
     11        * platform/graphics/gstreamer/GStreamerVersioning.cpp:
     12        (webkitGetVideoSizeAndFormatFromCaps):
     13        (webkitGstCreateBuffer):
     14        * platform/graphics/gstreamer/GStreamerVersioning.h:
     15        (WebCore):
     16        * platform/graphics/gstreamer/ImageGStreamer.h:
     17        (WebCore::ImageGStreamer::createImage):
     18        (WebCore::ImageGStreamer::setCropRect):
     19        (WebCore::ImageGStreamer::rect):
     20        (ImageGStreamer):
     21        * platform/graphics/gstreamer/ImageGStreamerCairo.cpp:
     22        (ImageGStreamer::ImageGStreamer):
     23        * platform/graphics/gstreamer/ImageGStreamerQt.cpp:
     24        (ImageGStreamer::ImageGStreamer):
     25        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
     26        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
     27        (WebCore::MediaPlayerPrivateGStreamer::naturalSize):
     28        * platform/graphics/gstreamer/VideoSinkGStreamer.cpp:
     29        (_WebKitVideoSinkPrivate):
     30        (webkitVideoSinkRender):
     31        (webkitVideoSinkProposeAllocation):
     32        (webkit_video_sink_class_init):
     33        * platform/graphics/gstreamer/VideoSinkGStreamer.h:
     34        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
     35
    1362012-06-19  Tony Payne  <tpayne@chromium.org>
    237
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp

    r120563 r120790  
    2222#include "GStreamerVersioning.h"
    2323
    24 #include <gst/gst.h>
     24#include "IntSize.h"
    2525
    2626void webkitGstObjectRefSink(GstObject* gstObject)
     
    4949    return caps;
    5050}
     51
     52bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride)
     53{
     54#ifdef GST_API_VERSION_1
     55    GstVideoInfo info;
     56    if (!gst_video_info_from_caps(&info, caps))
     57        return false;
     58
     59    format = GST_VIDEO_INFO_FORMAT(&info);
     60    size.setWidth(GST_VIDEO_INFO_WIDTH(&info));
     61    size.setHeight(GST_VIDEO_INFO_HEIGHT(&info));
     62    pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
     63    pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
     64    stride = GST_VIDEO_INFO_PLANE_STRIDE(&info, 0);
     65#else
     66    gint width, height;
     67    if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
     68        || !gst_video_format_parse_caps(caps, &format, &width, &height)
     69        || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
     70                                                    &pixelAspectRatioDenominator))
     71        return false;
     72    size.setWidth(width);
     73    size.setHeight(height);
     74    stride = size.width() * 4;
     75#endif
     76
     77    return true;
     78}
     79
     80GstBuffer* createGstBuffer(GstBuffer* buffer)
     81{
     82#ifndef GST_API_VERSION_1
     83    GstBuffer* newBuffer = gst_buffer_try_new_and_alloc(GST_BUFFER_SIZE(buffer));
     84#else
     85    gsize bufferSize = gst_buffer_get_size(buffer);
     86    GstBuffer* newBuffer = gst_buffer_new_and_alloc(bufferSize);
     87#endif
     88
     89    if (!newBuffer)
     90        return 0;
     91
     92#ifndef GST_API_VERSION_1
     93    gst_buffer_copy_metadata(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_ALL));
     94#else
     95    gst_buffer_copy_into(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_METADATA), 0, bufferSize);
     96#endif
     97    return newBuffer;
     98}
     99
     100void setGstElementClassMetadata(GstElementClass* elementClass, const char* name, const char* longName, const char* description, const char* author)
     101{
     102#ifdef GST_API_VERSION_1
     103    gst_element_class_set_metadata(elementClass, name, longName, description, author);
     104#else
     105    gst_element_class_set_details_simple(elementClass, name, longName, description, author);
     106#endif
     107}
  • trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h

    r120563 r120790  
    2121#define GStreamerVersioning_h
    2222
    23 typedef struct _GstCaps GstCaps;
    24 typedef struct _GstObject GstObject;
    25 typedef struct _GstPad GstPad;
     23#include <gst/gst.h>
     24#include <gst/video/video.h>
     25
     26namespace WebCore {
     27class IntSize;
     28};
    2629
    2730void webkitGstObjectRefSink(GstObject*);
    2831GstCaps* webkitGstGetPadCaps(GstPad*);
    29 
     32bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride);
     33GstBuffer* createGstBuffer(GstBuffer*);
     34void setGstElementClassMetadata(GstElementClass*, const char* name, const char* longName, const char* description, const char* author);
    3035#endif // GStreamerVersioning_h
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h

    r118610 r120790  
    11/*
    2  * Copyright (C) 2010 Igalia S.L
     2 * Copyright (C) 2010, 2011, 2012 Igalia S.L
    33 *
    44 * This library is free software; you can redistribute it and/or
     
    2424
    2525#include "BitmapImage.h"
    26 #include <gst/gst.h>
    27 #include <gst/video/video.h>
     26#include "FloatRect.h"
     27#include "GStreamerVersioning.h"
    2828#include <wtf/PassRefPtr.h>
    29 
    30 #if USE(CAIRO)
    31 #include <cairo.h>
    32 #endif
     29#include <wtf/RefCounted.h>
     30#include <wtf/RefPtr.h>
    3331
    3432namespace WebCore {
     
    3735class ImageGStreamer : public RefCounted<ImageGStreamer> {
    3836    public:
    39         static PassRefPtr<ImageGStreamer> createImage(GstBuffer*);
     37        static PassRefPtr<ImageGStreamer> createImage(GstBuffer* buffer, GstCaps* caps)
     38        {
     39            return adoptRef(new ImageGStreamer(buffer, caps));
     40        }
    4041        ~ImageGStreamer();
    4142
     
    4647        }
    4748
     49        void setCropRect(FloatRect rect) { m_cropRect = rect; }
     50        FloatRect rect()
     51        {
     52            if (!m_cropRect.isEmpty())
     53                return FloatRect(m_cropRect);
     54
     55            // Default rectangle used by GraphicsContext::drawImage().
     56            return FloatRect(0, 0, -1, -1);
     57        }
     58
    4859    private:
     60        ImageGStreamer(GstBuffer*, GstCaps*);
    4961        RefPtr<BitmapImage> m_image;
    50 
    51 #if USE(CAIRO)
    52         ImageGStreamer(GstBuffer*&, IntSize, cairo_format_t&);
    53 #endif
    54 
    55 #if PLATFORM(QT)
    56         ImageGStreamer(GstBuffer*&, IntSize, QImage::Format);
    57 #endif
    58 
     62        FloatRect m_cropRect;
    5963    };
    6064}
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp

    r111354 r120790  
    2323#if ENABLE(VIDEO) && USE(GSTREAMER)
    2424
     25#include <cairo.h>
     26#include <gst/gst.h>
     27#include <gst/video/video.h>
    2528#include <wtf/gobject/GOwnPtr.h>
     29
     30#ifdef GST_API_VERSION_1
     31#include <gst/video/gstvideometa.h>
     32#endif
     33
    2634
    2735using namespace std;
    2836using namespace WebCore;
    2937
    30 PassRefPtr<ImageGStreamer> ImageGStreamer::createImage(GstBuffer* buffer)
     38ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
    3139{
    32     int width = 0, height = 0;
    33     GstCaps* caps = gst_buffer_get_caps(buffer);
    3440    GstVideoFormat format;
    35     if (!gst_video_format_parse_caps(caps, &format, &width, &height)) {
    36         gst_caps_unref(caps);
    37         return 0;
    38     }
     41    IntSize size;
     42    int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
     43    getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride);
    3944
    40     gst_caps_unref(caps);
     45#ifdef GST_API_VERSION_1
     46    GstMapInfo mapInfo;
     47    gst_buffer_map(buffer, &mapInfo, GST_MAP_READ);
     48    unsigned char* bufferData = reinterpret_cast<unsigned char*>(mapInfo.data);
     49#else
     50    unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_BUFFER_DATA(buffer));
     51#endif
    4152
    4253    cairo_format_t cairoFormat;
    43     if (format == GST_VIDEO_FORMAT_ARGB || format == GST_VIDEO_FORMAT_BGRA)
    44         cairoFormat = CAIRO_FORMAT_ARGB32;
    45     else
    46         cairoFormat = CAIRO_FORMAT_RGB24;
     54#if G_BYTE_ORDER == G_LITTLE_ENDIAN
     55    cairoFormat = (format == GST_VIDEO_FORMAT_BGRA) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
     56#else
     57    cairoFormat = (format == GST_VIDEO_FORMAT_ARGB) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
     58#endif
    4759
    48     return adoptRef(new ImageGStreamer(buffer, IntSize(width, height), cairoFormat));
    49 }
    50 
    51 ImageGStreamer::ImageGStreamer(GstBuffer*& buffer, IntSize size, cairo_format_t& cairoFormat)
    52     : m_image(0)
    53 {
    54     cairo_surface_t* surface = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), cairoFormat,
    55                                                     size.width(), size.height(),
    56                                                     cairo_format_stride_for_width(cairoFormat, size.width()));
     60    cairo_surface_t* surface = cairo_image_surface_create_for_data(bufferData, cairoFormat, size.width(), size.height(), stride);
    5761    ASSERT(cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS);
    5862    m_image = BitmapImage::create(surface);
     63
     64#ifdef GST_API_VERSION_1
     65    if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer))
     66        setCropRect(FloatRect(cropMeta->x, cropMeta->y, cropMeta->width, cropMeta->height));
     67
     68    gst_buffer_unmap(buffer, &mapInfo);
     69#endif
    5970}
    6071
  • trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp

    r111354 r120790  
    2222
    2323#if ENABLE(VIDEO) && USE(GSTREAMER)
     24#include <gst/gst.h>
     25#include <gst/video/video.h>
     26
     27#ifdef GST_API_VERSION_1
     28#include <gst/video/gstvideometa.h>
     29#endif
     30
    2431#include <wtf/gobject/GOwnPtr.h>
    2532
     
    2734using namespace WebCore;
    2835
    29 PassRefPtr<ImageGStreamer> ImageGStreamer::createImage(GstBuffer* buffer)
    30 {
    31     int width = 0, height = 0;
    32     GstCaps* caps = gst_buffer_get_caps(buffer);
    33     GstVideoFormat format;
    34     if (!gst_video_format_parse_caps(caps, &format, &width, &height)) {
    35         gst_caps_unref(caps);
    36         return 0;
    37     }
    38 
    39     gst_caps_unref(caps);
    40 
    41     QImage::Format imageFormat;
    42     if (format == GST_VIDEO_FORMAT_RGB)
    43         imageFormat = QImage::Format_RGB888;
    44     else
    45         imageFormat = QImage::Format_RGB32;
    46 
    47     return adoptRef(new ImageGStreamer(buffer, IntSize(width, height), imageFormat));
    48 }
    49 
    50 ImageGStreamer::ImageGStreamer(GstBuffer*& buffer, IntSize size, QImage::Format imageFormat)
     36ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps)
    5137    : m_image(0)
    5238{
    5339    QPixmap* surface = new QPixmap;
    54     QImage image(GST_BUFFER_DATA(buffer), size.width(), size.height(), imageFormat);
     40    GstVideoFormat format;
     41    IntSize size;
     42    int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
     43    webkitGetVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride);
     44
     45#ifdef GST_API_VERSION_1
     46    GstMapInfo info;
     47    gst_buffer_map(buffer, &info, GST_MAP_READ);
     48    uchar* bufferData = reinterpret_cast<uchar*>(info.data);
     49#else
     50    uchar* bufferData = reinterpret_cast<uchar*>(GST_BUFFER_DATA(buffer));
     51#endif
     52    QImage::Format imageFormat;
     53#if G_BYTE_ORDER == G_LITTLE_ENDIAN
     54    imageFormat = (format == GST_VIDEO_FORMAT_BGRA) ? QImage::Format_RGB32 : QImage::Format_RGB888;
     55#else
     56    imageFormat = (format == GST_VIDEO_FORMAT_ARGB) ? QImage::Format_ARGB32 : QImage::Format_RGB888;
     57#endif
     58
     59    QImage image(bufferData, size.width(), size.height(), imageFormat);
     60
    5561    surface->convertFromImage(image);
    5662    m_image = BitmapImage::create(surface);
     63
     64#ifdef GST_API_VERSION_1
     65    gst_buffer_unmap(buffer, &info);
     66#endif
    5767}
    5868
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r120654 r120790  
    255255    }
    256256
     257#ifndef GST_API_VERSION_1
    257258    if (m_videoSinkBin) {
    258259        gst_object_unref(m_videoSinkBin);
    259260        m_videoSinkBin = 0;
    260261    }
     262#endif
    261263
    262264    if (m_playBin) {
     
    498500        return IntSize();
    499501
    500     int pixelAspectRatioNumerator, pixelAspectRatioDenominator;
    501     int displayWidth, displayHeight, displayAspectRatioGCD;
    502     int originalWidth = 0, originalHeight = 0;
    503502
    504503    // TODO: handle possible clean aperture data. See
     
    509508    // Get the video PAR and original size, if this fails the
    510509    // video-sink has likely not yet negotiated its caps.
    511 #ifdef GST_API_VERSION_1
    512     GstVideoInfo info;
    513     if (!gst_video_info_from_caps(&info, caps))
     510    int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
     511    IntSize originalSize;
     512    GstVideoFormat format;
     513    if (!getVideoSizeAndFormatFromCaps(caps, originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride))
    514514        return IntSize();
    515515
    516     originalWidth = GST_VIDEO_INFO_WIDTH(&info);
    517     originalHeight = GST_VIDEO_INFO_HEIGHT(&info);
    518     pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
    519     pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
    520 #else
    521     // Get the video PAR and original size.
    522     if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
    523         || !gst_video_format_parse_caps(caps, 0, &originalWidth, &originalHeight)
    524         || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
    525                                                     &pixelAspectRatioDenominator))
    526         return IntSize();
    527 #endif
    528 
    529     LOG_VERBOSE(Media, "Original video size: %dx%d", originalWidth, originalHeight);
     516    LOG_VERBOSE(Media, "Original video size: %dx%d", originalSize.width(), originalSize.height());
    530517    LOG_VERBOSE(Media, "Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator);
    531518
    532519    // Calculate DAR based on PAR and video size.
    533     displayWidth = originalWidth * pixelAspectRatioNumerator;
    534     displayHeight = originalHeight * pixelAspectRatioDenominator;
     520    int displayWidth = originalSize.width() * pixelAspectRatioNumerator;
     521    int displayHeight = originalSize.height() * pixelAspectRatioDenominator;
    535522
    536523    // Divide display width and height by their GCD to avoid possible overflows.
    537     displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight);
     524    int displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight);
    538525    displayWidth /= displayAspectRatioGCD;
    539526    displayHeight /= displayAspectRatioGCD;
     
    541528    // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function.
    542529    guint64 width = 0, height = 0;
    543     if (!(originalHeight % displayHeight)) {
     530    if (!(originalSize.height() % displayHeight)) {
    544531        LOG_VERBOSE(Media, "Keeping video original height");
    545         width = gst_util_uint64_scale_int(originalHeight, displayWidth, displayHeight);
    546         height = static_cast<guint64>(originalHeight);
    547     } else if (!(originalWidth % displayWidth)) {
     532        width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight);
     533        height = static_cast<guint64>(originalSize.height());
     534    } else if (!(originalSize.width() % displayWidth)) {
    548535        LOG_VERBOSE(Media, "Keeping video original width");
    549         height = gst_util_uint64_scale_int(originalWidth, displayHeight, displayWidth);
    550         width = static_cast<guint64>(originalWidth);
     536        height = gst_util_uint64_scale_int(originalSize.width(), displayHeight, displayWidth);
     537        width = static_cast<guint64>(originalSize.width());
    551538    } else {
    552539        LOG_VERBOSE(Media, "Approximating while keeping original video height");
    553         width = gst_util_uint64_scale_int(originalHeight, displayWidth, displayHeight);
    554         height = static_cast<guint64>(originalHeight);
     540        width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight);
     541        height = static_cast<guint64>(originalSize.height());
    555542    }
    556543
     
    958945    while (!done) {
    959946#ifdef GST_API_VERSION_1
    960         GValue item = {0, };
     947        GValue item = G_VALUE_INIT;
    961948        switch (gst_iterator_next(iter, &item)) {
    962949        case GST_ITERATOR_OK: {
     
    14821469        return;
    14831470
    1484     RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer);
     1471    GstCaps* caps = webkitGstGetPadCaps(m_videoSinkPad.get());
     1472    if (!caps)
     1473        return;
     1474
     1475    RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps);
    14851476    if (!gstImage)
    14861477        return;
    14871478
    14881479    context->drawImage(reinterpret_cast<Image*>(gstImage->image().get()), ColorSpaceSRGB,
    1489                        rect, CompositeCopy, DoNotRespectImageOrientation, false);
     1480                       rect, gstImage->rect(), CompositeCopy, DoNotRespectImageOrientation, false);
    14901481}
    14911482
    14921483static HashSet<String> mimeTypeCache()
    14931484{
    1494 
    14951485    initializeGStreamerAndRegisterWebKitElements();
    14961486
     
    16741664    g_signal_connect(m_playBin, "audio-changed", G_CALLBACK(mediaPlayerPrivateAudioChangedCallback), this);
    16751665
     1666#ifndef GST_API_VERSION_1
    16761667    m_webkitVideoSink = webkitVideoSinkNew(m_gstGWorld.get());
     1668#else
     1669    m_webkitVideoSink = webkitVideoSinkNew();
     1670#endif
    16771671    m_videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink"));
    16781672
  • trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp

    r118789 r120790  
    3030#include "VideoSinkGStreamer.h"
    3131
     32#include "GStreamerVersioning.h"
     33#include "IntSize.h"
    3234#include <glib.h>
    3335#include <gst/gst.h>
     36#ifdef GST_API_VERSION_1
     37#include <gst/video/gstvideometa.h>
     38#include <gst/video/gstvideopool.h>
     39#endif
    3440#include <wtf/FastAllocBase.h>
    3541
    3642// CAIRO_FORMAT_RGB24 used to render the video buffers is little/big endian dependant.
    3743#if G_BYTE_ORDER == G_LITTLE_ENDIAN
     44#ifndef GST_API_VERSION_1
    3845#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA
    3946#else
     47#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ BGRx, BGRA }")
     48#endif
     49#else
     50#ifndef GST_API_VERSION_1
    4051#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_ARGB
     52#else
     53#define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ xRGB, ARGB }")
     54#endif
    4155#endif
    4256static GstStaticPadTemplate s_sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS(WEBKIT_VIDEO_SINK_PAD_CAPS));
     
    6377    GCond* dataCondition;
    6478
     79#ifdef GST_API_VERSION_1
     80    GstVideoInfo info;
     81#endif
     82
     83#ifndef GST_API_VERSION_1
    6584    WebCore::GStreamerGWorld* gstGWorld;
     85#endif
    6686
    6787    // If this is TRUE all processing should finish ASAP
     
    92112    sink->priv->bufferMutex = g_mutex_new();
    93113#endif
     114
     115#ifdef GST_API_VERSION_1
     116    gst_video_info_init(&sink->priv->info);
     117#endif
    94118}
    95119
     
    130154    }
    131155
     156#ifndef GST_API_VERSION_1
    132157    // Ignore buffers if the video is already in fullscreen using
    133158    // another sink.
     
    136161        return GST_FLOW_OK;
    137162    }
     163#endif
    138164
    139165    priv->buffer = gst_buffer_ref(buffer);
    140166
     167#ifndef GST_API_VERSION_1
    141168    // For the unlikely case where the buffer has no caps, the caps
    142169    // are implicitely the caps of the pad. This shouldn't happen.
     
    147174
    148175    GstCaps* caps = GST_BUFFER_CAPS(buffer);
     176#else
     177    GstCaps* caps = gst_video_info_to_caps(&priv->info);
     178#endif
     179
    149180    GstVideoFormat format;
    150     int width, height;
    151     if (UNLIKELY(!gst_video_format_parse_caps(caps, &format, &width, &height))) {
     181    WebCore::IntSize size;
     182    int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride;
     183    if (!getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) {
    152184        gst_buffer_unref(buffer);
     185#ifdef GST_API_VERSION_1
     186        gst_caps_unref(caps);
     187#endif
    153188        g_mutex_unlock(priv->bufferMutex);
    154189        return GST_FLOW_ERROR;
    155190    }
     191
     192#ifdef GST_API_VERSION_1
     193    gst_caps_unref(caps);
     194#endif
    156195
    157196    // Cairo's ARGB has pre-multiplied alpha while GStreamer's doesn't.
     
    163202        // could be passed multiple times to this method (in theory).
    164203
    165         GstBuffer* newBuffer = gst_buffer_try_new_and_alloc(GST_BUFFER_SIZE(buffer));
     204        GstBuffer* newBuffer = createGstBuffer(buffer);
    166205
    167206        // Check if allocation failed.
     
    171210        }
    172211
    173         gst_buffer_copy_metadata(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_ALL));
    174 
    175212        // We don't use Color::premultipliedARGBFromColor() here because
    176213        // one function call per video pixel is just too expensive:
    177214        // For 720p/PAL for example this means 1280*720*25=23040000
    178215        // function calls per second!
     216#ifndef GST_API_VERSION_1
    179217        const guint8* source = GST_BUFFER_DATA(buffer);
    180218        guint8* destination = GST_BUFFER_DATA(newBuffer);
    181 
    182         for (int x = 0; x < height; x++) {
    183             for (int y = 0; y < width; y++) {
     219#else
     220        GstMapInfo sourceInfo;
     221        GstMapInfo destinationInfo;
     222        gst_buffer_map(buffer, &sourceInfo, GST_MAP_READ);
     223        const guint8* source = const_cast<guint8*>(sourceInfo.data);
     224        gst_buffer_map(newBuffer, &destinationInfo, GST_MAP_WRITE);
     225        guint8* destination = static_cast<guint8*>(destinationInfo.data);
     226#endif
     227
     228        for (int x = 0; x < size.height(); x++) {
     229            for (int y = 0; y < size.width(); y++) {
    184230#if G_BYTE_ORDER == G_LITTLE_ENDIAN
    185231                unsigned short alpha = source[3];
     
    200246        }
    201247
     248#ifdef GST_API_VERSION_1
     249        gst_buffer_unmap(buffer, &sourceInfo);
     250        gst_buffer_unmap(newBuffer, &destinationInfo);
     251#endif
    202252        gst_buffer_unref(buffer);
    203253        buffer = priv->buffer = newBuffer;
     
    294344}
    295345
     346#ifdef GST_API_VERSION_1
     347static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery* query)
     348{
     349    GstCaps* caps;
     350    gst_query_parse_allocation(query, &caps, 0);
     351    if (!caps)
     352        return FALSE;
     353
     354    WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(baseSink);
     355    if (!gst_video_info_from_caps(&sink->priv->info, caps))
     356        return FALSE;
     357
     358    gst_query_add_allocation_meta(query, GST_VIDEO_META_API_TYPE);
     359    gst_query_add_allocation_meta(query, GST_VIDEO_CROP_META_API_TYPE);
     360    return TRUE;
     361}
     362#endif
     363
     364#ifndef GST_API_VERSION_1
    296365static void webkitVideoSinkMarshalVoidAndMiniObject(GClosure* closure, GValue* returnValue, guint parametersNumber, const GValue* parameterValues, gpointer invocationHint, gpointer marshalData)
    297366{
     
    314383    callback(data1, gst_value_get_mini_object(parameterValues + 1), data2);
    315384}
     385#endif
    316386
    317387static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
     
    322392
    323393    gst_element_class_add_pad_template(elementClass, gst_static_pad_template_get(&s_sinkTemplate));
     394#ifdef GST_API_VERSION_1
     395    gst_element_class_set_metadata(elementClass,
     396#else
    324397    gst_element_class_set_details_simple(elementClass,
     398#endif
    325399            "WebKit video sink",
    326400            "Sink/Video", "Sends video data from a GStreamer pipeline to a Cairo surface",
     
    337411    baseSinkClass->stop = webkitVideoSinkStop;
    338412    baseSinkClass->start = webkitVideoSinkStart;
     413#ifdef GST_API_VERSION_1
     414    baseSinkClass->propose_allocation = webkitVideoSinkProposeAllocation;
     415#endif
    339416
    340417    webkitVideoSinkSignals[REPAINT_REQUESTED] = g_signal_new("repaint-requested",
     
    344421            0, // Accumulator
    345422            0, // Accumulator data
     423#ifndef GST_API_VERSION_1
    346424            webkitVideoSinkMarshalVoidAndMiniObject,
     425#else
     426            g_cclosure_marshal_generic,
     427#endif
    347428            G_TYPE_NONE, // Return type
    348429            1, // Only one parameter
     
    351432
    352433
     434#ifndef GST_API_VERSION_1
    353435GstElement* webkitVideoSinkNew(WebCore::GStreamerGWorld* gstGWorld)
    354436{
     
    357439    return element;
    358440}
     441#else
     442GstElement* webkitVideoSinkNew()
     443{
     444    return GST_ELEMENT(g_object_new(WEBKIT_TYPE_VIDEO_SINK, 0));
     445}
     446#endif
    359447
    360448#endif // USE(GSTREAMER)
  • trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h

    r118789 r120790  
    2323#if ENABLE(VIDEO) && USE(GSTREAMER)
    2424
     25#ifndef GST_API_VERSION_1
    2526#include "GStreamerGWorld.h"
     27#endif
     28
    2629#include <glib-object.h>
    2730#include <gst/video/gstvideosink.h>
     
    5962GType webkit_video_sink_get_type() G_GNUC_CONST;
    6063
     64#ifndef GST_API_VERSION_1
    6165GstElement* webkitVideoSinkNew(WebCore::GStreamerGWorld*);
     66#else
     67GstElement* webkitVideoSinkNew();
     68#endif
    6269
    6370#endif // USE(GSTREAMER)
  • trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp

    r111354 r120790  
    854854
    855855    if (gst_tag_list_is_empty(tags))
     856#ifdef GST_API_VERSION_1
     857        gst_tag_list_unref(tags);
     858#else
    856859        gst_tag_list_free(tags);
     860#endif
    857861    else
    858862#ifdef GST_API_VERSION_1
    859         gst_pad_push_event(GST_PAD_CAST(m_src->priv->srcpad), gst_event_new_tag(tags));
     863        gst_pad_push_event(GST_PAD_CAST(m_src->priv->srcpad), gst_event_new_tag("WebKitWebSrc", tags));
    860864#else
    861865        gst_element_found_tags_for_pad(GST_ELEMENT(m_src), m_src->priv->srcpad, tags);
  • trunk/configure.ac

    r120228 r120790  
    349349GSTREAMER_0_10_REQUIRED_VERSION=0.10
    350350GSTREAMER_0_10_PLUGINS_BASE_REQUIRED_VERSION=0.10.30
    351 GSTREAMER_1_0_REQUIRED_VERSION=1.0
     351GSTREAMER_1_0_REQUIRED_VERSION=0.11.90
    352352GSTREAMER_1_0_PLUGINS_BASE_REQUIRED_VERSION=0.11.90
    353353
Note: See TracChangeset for help on using the changeset viewer.