Bug 159466 - [GStreamer][GL] switch to appsink
Summary: [GStreamer][GL] switch to appsink
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-06 06:05 PDT by Philippe Normand
Modified: 2016-07-06 23:59 PDT (History)
5 users (show)

See Also:


Attachments
patch (6.69 KB, patch)
2016-07-06 06:08 PDT, Philippe Normand
cgarcia: review-
Details | Formatted Diff | Diff
patch (7.17 KB, patch)
2016-07-06 06:53 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
patch (8.15 KB, patch)
2016-07-06 06:57 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
patch (7.24 KB, patch)
2016-07-06 06:59 PDT, Philippe Normand
cgarcia: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Normand 2016-07-06 06:05:51 PDT
Using fakesink for rendering is a bit weird because usually that element is used in tests. Appsink should be used instead. The following patch will be a refactoring.
Comment 1 Philippe Normand 2016-07-06 06:08:34 PDT
Created attachment 282884 [details]
patch
Comment 2 Carlos Garcia Campos 2016-07-06 06:19:46 PDT
Comment on attachment 282884 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=282884&action=review

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:592
> +static GstFlowReturn newSampleCallback(GstElement* sink, gpointer userData)
> +{
> +    MediaPlayerPrivateGStreamerBase* player = reinterpret_cast<MediaPlayerPrivateGStreamerBase*>(userData);

Since you are casting the callback in the g_signal_connect with G_CALLBACK, you can directly use MediaPlayerPrivateGStreamerBase* as parameter and avoid this cast.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:595
> +    GstSample* sample = gst_app_sink_pull_sample(GST_APP_SINK(sink));
> +
> +    player->triggerRepaint(sample);

You don't need the local variable, unless triggerRepaint doesn't adopt the sample, in which case, you need the local variable but you are leaking the sample here, since gst_app_sink_pull_sample is transfer full

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:604
> +    MediaPlayerPrivateGStreamerBase* player = reinterpret_cast<MediaPlayerPrivateGStreamerBase*>(userData);
> +    GstSample* sample = gst_app_sink_pull_preroll(GST_APP_SINK(sink));
> +
> +    player->triggerRepaint(sample);

Same comments here, the sample is leaked

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:133
> +    void triggerRepaint(GstSample*);
> +

This shouldn't be public, make the callbacks private static members if you need to access private API instead of exposing it.
Comment 3 Philippe Normand 2016-07-06 06:40:18 PDT
Comment on attachment 282884 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=282884&action=review

>> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:133
>> +
> 
> This shouldn't be public, make the callbacks private static members if you need to access private API instead of exposing it.

Why?
Comment 4 Philippe Normand 2016-07-06 06:53:06 PDT
Created attachment 282886 [details]
patch
Comment 5 Philippe Normand 2016-07-06 06:57:25 PDT
Created attachment 282887 [details]
patch
Comment 6 Philippe Normand 2016-07-06 06:59:58 PDT
Created attachment 282889 [details]
patch
Comment 7 Xabier Rodríguez Calvar 2016-07-06 07:44:36 PDT
Comment on attachment 282889 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=282889&action=review

I leave Carlos the r+ as he reviwed first.

> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:176
> +            g_signal_handlers_disconnect_matched(appsink.get(), G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);

Nit that I recommend to change before landing: g_signal_handlers_disconnect_by_data is less complex to use and more readable.
Comment 8 Carlos Garcia Campos 2016-07-06 08:05:31 PDT
(In reply to comment #3)
> Comment on attachment 282884 [details]
> patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=282884&action=review
> 
> >> Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:133
> >> +
> > 
> > This shouldn't be public, make the callbacks private static members if you need to access private API instead of exposing it.
> 
> Why?

Because it's only used internally, you made it public to call it from static functions, not to make it really public API.
Comment 9 Philippe Normand 2016-07-06 23:59:15 PDT
Committed r202897: <http://trac.webkit.org/changeset/202897>