Bug 188647 - [GStreamer][MSE] Generic main thread notification support
Summary: [GStreamer][MSE] Generic main thread notification support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Philippe Normand
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-16 06:26 PDT by Philippe Normand
Modified: 2018-08-21 02:09 PDT (History)
4 users (show)

See Also:


Attachments
Patch (8.00 KB, patch)
2018-08-16 06:29 PDT, Philippe Normand
calvaris: review+
calvaris: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Normand 2018-08-16 06:26:18 PDT
I did this only for the playback pipeline because reusing the player bus like this is not optimal. The same approach could be used in the append pipeline but it's less critical because a new bus is created there.
Comment 1 Philippe Normand 2018-08-16 06:29:11 PDT
Created attachment 347258 [details]
Patch
Comment 2 Xabier Rodríguez Calvar 2018-08-17 00:47:19 PDT
Comment on attachment 347258 [details]
Patch

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

> Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:126
>          case MediaSourceSeekToTime: {
> -            GstStructure* structure = gst_structure_new_empty("seek-needs-data");
> -            GstMessage* message = gst_message_new_application(GST_OBJECT(appsrc), structure);
> -            gst_bus_post(webKitMediaSrc->priv->bus.get(), message);
> -            GST_TRACE("seek-needs-data message posted to the bus");
> +            webKitMediaSrc->priv->notifier->notify(MSEMainThreadNotification::SeekNeedsData, [webKitMediaSrc] {
> +                seekNeedsDataMainThread(webKitMediaSrc);
> +            });
>              break;
>          }

You don't need to enclose the case in { } anymore since we don't have scoped variables. Please, remove them.

> Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp:143
>          if (appsrcStream && appsrcStream->type != WebCore::Invalid) {
> -            GstStructure* structure = gst_structure_new("ready-for-more-samples", "appsrc-stream", G_TYPE_POINTER, appsrcStream, nullptr);
> -            GstMessage* message = gst_message_new_application(GST_OBJECT(appsrc), structure);
> -            gst_bus_post(webKitMediaSrc->priv->bus.get(), message);
> -            GST_TRACE("ready-for-more-samples message posted to the bus");
> +
> +            webKitMediaSrc->priv->notifier->notify(MSEMainThreadNotification::ReadyForMoreSamples, [webKitMediaSrc, appsrcStream] {
> +                notifyReadyForMoreSamplesMainThread(webKitMediaSrc, appsrcStream);
> +            });
>          }

You don't need the if { } anymore because there is only one clause in it. Please remove them.

> Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h:100
> +enum MSEMainThreadNotification {

I guess you preprended MSE to this type because it can collide with other types defined inside other other files. In this case I would strongly encourage you to preprend the whole class and name it WebKitMediaSrcMainThreadNotification.

> Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h:102
> +    SeekNeedsData = 1 << 0,
> +    ReadyForMoreSamples = 1 << 1

Longshot nit: I think it would be nicer to, at least, begin with these alphabetically sorted. It is not a requirement, but nice to have :)
Comment 3 Alicia Boya García 2018-08-20 03:40:37 PDT
LGTM too.
Comment 4 Philippe Normand 2018-08-21 02:09:00 PDT
Committed r235110: <https://trac.webkit.org/changeset/235110>
Comment 5 Radar WebKit Bug Importer 2018-08-21 02:09:20 PDT
<rdar://problem/43551293>