Changeset 202897 in webkit


Ignore:
Timestamp:
Jul 6, 2016 11:58:19 PM (8 years ago)
Author:
Philippe Normand
Message:

[GStreamer][GL] switch to appsink
https://bugs.webkit.org/show_bug.cgi?id=159466

Reviewed by Carlos Garcia Campos.

Fakesink is mostly used for tests. Appsink provides the same
functionality and is actually meant to be used on application
side.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:

(WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
(WebCore::newSampleCallback):
(WebCore::newPrerollCallback):
(WebCore::MediaPlayerPrivateGStreamerBase::createVideoSinkGL):
(WebCore::MediaPlayerPrivateGStreamerBase::drawCallback): Deleted.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202895 r202897  
     12016-07-07  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer][GL] switch to appsink
     4        https://bugs.webkit.org/show_bug.cgi?id=159466
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Fakesink is mostly used for tests. Appsink provides the same
     9        functionality and is actually meant to be used on application
     10        side.
     11
     12        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
     13        (WebCore::MediaPlayerPrivateGStreamerBase::~MediaPlayerPrivateGStreamerBase):
     14        (WebCore::newSampleCallback):
     15        (WebCore::newPrerollCallback):
     16        (WebCore::MediaPlayerPrivateGStreamerBase::createVideoSinkGL):
     17        (WebCore::MediaPlayerPrivateGStreamerBase::drawCallback): Deleted.
     18        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
     19
    1202016-07-06  Chris Dumez  <cdumez@apple.com>
    221
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp

    r202611 r202897  
    3838#include "VideoSinkGStreamer.h"
    3939#include "WebKitWebSourceGStreamer.h"
    40 #include <gst/gst.h>
    4140#include <wtf/glib/GMutexLocker.h>
    4241#include <wtf/text/CString.h>
     
    4645
    4746#if USE(GSTREAMER_GL)
     47#include <gst/app/gstappsink.h>
    4848#define GST_USE_UNSTABLE_API
    4949#include <gst/gl/gl.h>
     
    169169    m_notifier.cancelPendingNotifications();
    170170
    171     if (m_videoSink)
     171    if (m_videoSink) {
    172172        g_signal_handlers_disconnect_matched(m_videoSink.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
     173#if USE(GSTREAMER_GL)
     174        if (GST_IS_BIN(m_videoSink.get())) {
     175            GRefPtr<GstElement> appsink = adoptGRef(gst_bin_get_by_name(GST_BIN_CAST(m_videoSink.get()), "webkit-gl-video-sink"));
     176            g_signal_handlers_disconnect_by_data(appsink.get(), this);
     177        }
     178#endif
     179    }
    173180
    174181    g_mutex_clear(&m_sampleMutex);
     
    580587
    581588#if USE(GSTREAMER_GL)
    582 gboolean MediaPlayerPrivateGStreamerBase::drawCallback(MediaPlayerPrivateGStreamerBase* player, GstBuffer* buffer, GstPad* pad, GstBaseSink* sink)
    583 {
    584     GST_PAD_STREAM_LOCK(pad);
    585     GRefPtr<GstCaps> caps = adoptGRef(gst_pad_get_current_caps(pad));
    586     GRefPtr<GstSample> sample = adoptGRef(gst_sample_new(buffer, caps.get(), &sink->segment, NULL));
    587     GST_PAD_STREAM_UNLOCK(pad);
     589GstFlowReturn MediaPlayerPrivateGStreamerBase::newSampleCallback(GstElement* sink, MediaPlayerPrivateGStreamerBase* player)
     590{
     591    GRefPtr<GstSample> sample = adoptGRef(gst_app_sink_pull_sample(GST_APP_SINK(sink)));
    588592    player->triggerRepaint(sample.get());
    589     return TRUE;
     593    return GST_FLOW_OK;
     594}
     595
     596GstFlowReturn MediaPlayerPrivateGStreamerBase::newPrerollCallback(GstElement* sink, MediaPlayerPrivateGStreamerBase* player)
     597{
     598    GRefPtr<GstSample> sample = adoptGRef(gst_app_sink_pull_preroll(GST_APP_SINK(sink)));
     599    player->triggerRepaint(sample.get());
     600    return GST_FLOW_OK;
    590601}
    591602#endif
     
    781792    }
    782793
    783     GstElement* fakesink = gst_element_factory_make("fakesink", nullptr);
    784 
    785     gst_bin_add_many(GST_BIN(videoSink), upload, colorconvert, fakesink, nullptr);
     794    GstElement* appsink = gst_element_factory_make("appsink", "webkit-gl-video-sink");
     795
     796    gst_bin_add_many(GST_BIN(videoSink), upload, colorconvert, appsink, nullptr);
    786797
    787798    GRefPtr<GstCaps> caps = adoptGRef(gst_caps_from_string("video/x-raw(" GST_CAPS_FEATURE_MEMORY_GL_MEMORY "), format = (string) { RGBA }"));
    788799
    789800    result &= gst_element_link_pads(upload, "src", colorconvert, "sink");
    790     result &= gst_element_link_pads_filtered(colorconvert, "src", fakesink, "sink", caps.get());
     801    result &= gst_element_link_pads_filtered(colorconvert, "src", appsink, "sink", caps.get());
    791802
    792803    GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(upload, "sink"));
    793804    gst_element_add_pad(videoSink, gst_ghost_pad_new("sink", pad.get()));
    794805
    795     g_object_set(fakesink, "enable-last-sample", FALSE, "signal-handoffs", TRUE, "silent", TRUE, "sync", TRUE, nullptr);
    796 
    797     if (result)
    798         g_signal_connect_swapped(fakesink, "handoff", G_CALLBACK(drawCallback), this);
    799     else {
     806    g_object_set(appsink, "enable-last-sample", FALSE, "emit-signals", TRUE, "max-buffers", 1, nullptr);
     807
     808    if (result) {
     809        g_signal_connect(appsink, "new-sample", G_CALLBACK(newSampleCallback), this);
     810        g_signal_connect(appsink, "new-preroll", G_CALLBACK(newPrerollCallback), this);
     811    } else {
    800812        WARN_MEDIA_MESSAGE("Failed to link GstGL elements");
    801813        gst_object_unref(videoSink);
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h

    r202854 r202897  
    3030#include "PlatformLayer.h"
    3131#include <glib.h>
     32#include <gst/gst.h>
    3233#include <wtf/Condition.h>
    3334#include <wtf/Forward.h>
     
    4243#endif
    4344
    44 typedef struct _GstBaseSink GstBaseSink;
    45 typedef struct _GstMessage GstMessage;
    4645typedef struct _GstStreamVolume GstStreamVolume;
    4746typedef struct _GstVideoInfo GstVideoInfo;
     
    138137
    139138#if USE(GSTREAMER_GL)
     139    static GstFlowReturn newSampleCallback(GstElement*, MediaPlayerPrivateGStreamerBase*);
     140    static GstFlowReturn newPrerollCallback(GstElement*, MediaPlayerPrivateGStreamerBase*);
    140141    GstElement* createVideoSinkGL();
    141142#endif
     
    153154
    154155    static void repaintCallback(MediaPlayerPrivateGStreamerBase*, GstSample*);
    155 #if USE(GSTREAMER_GL)
    156     static gboolean drawCallback(MediaPlayerPrivateGStreamerBase*, GstBuffer*, GstPad*, GstBaseSink*);
    157 #endif
    158156
    159157    void notifyPlayerOfVolumeChange();
Note: See TracChangeset for help on using the changeset viewer.