Changeset 235110 in webkit
- Timestamp:
- Aug 21, 2018 2:07:33 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r235109 r235110 1 2018-08-21 Philippe Normand <philn@igalia.com> 2 3 [GStreamer][MSE] Generic main thread notification support 4 https://bugs.webkit.org/show_bug.cgi?id=188647 5 6 Reviewed by Xabier Rodriguez-Calvar. 7 8 Using GstBus for main thread notifications has the side effect of "leaking" the 9 application messages to the media player, leading to CPU cycles wasting. 10 11 No new tests, existing MSE tests cover this change. 12 13 * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp: 14 (webkit_media_src_init): 15 (webKitMediaSrcFinalize): 16 (webKitMediaSrcSetMediaPlayerPrivate): 17 * platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h: 18 1 19 2018-08-21 Philippe Normand <philn@igalia.com> 2 20 -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp
r235109 r235110 41 41 #include "WebKitMediaSourceGStreamerPrivate.h" 42 42 43 #include <gst/app/app.h>44 #include <gst/app/gstappsrc.h>45 #include <gst/gst.h>46 #include <gst/pbutils/missing-plugins.h>47 43 #include <gst/pbutils/pbutils.h> 48 44 #include <gst/video/video.h> 49 45 #include <wtf/Condition.h> 50 46 #include <wtf/MainThread.h> 47 #include <wtf/RefPtr.h> 51 48 #include <wtf/text/CString.h> 52 49 … … 86 83 87 84 static Stream* getStreamByAppsrc(WebKitMediaSrc*, GstElement*); 85 static void seekNeedsDataMainThread(WebKitMediaSrc*); 86 static void notifyReadyForMoreSamplesMainThread(WebKitMediaSrc*, Stream*); 88 87 89 88 static void enabledAppsrcNeedData(GstAppSrc* appsrc, guint, gpointer userData) … … 120 119 121 120 switch (appsrcSeekDataNextAction) { 122 case MediaSourceSeekToTime: { 123 GstStructure* structure = gst_structure_new_empty("seek-needs-data"); 124 GstMessage* message = gst_message_new_application(GST_OBJECT(appsrc), structure); 125 gst_bus_post(webKitMediaSrc->priv->bus.get(), message); 126 GST_TRACE("seek-needs-data message posted to the bus"); 127 break; 128 } 121 case MediaSourceSeekToTime: 122 webKitMediaSrc->priv->notifier->notify(WebKitMediaSrcMainThreadNotification::SeekNeedsData, [webKitMediaSrc] { 123 seekNeedsDataMainThread(webKitMediaSrc); 124 }); 125 break; 129 126 case Nothing: 130 127 break; … … 138 135 appsrcStream = getStreamByAppsrc(webKitMediaSrc, GST_ELEMENT(appsrc)); 139 136 140 if (appsrcStream && appsrcStream->type != WebCore::Invalid) { 141 GstStructure* structure = gst_structure_new("ready-for-more-samples", "appsrc-stream", G_TYPE_POINTER, appsrcStream, nullptr); 142 GstMessage* message = gst_message_new_application(GST_OBJECT(appsrc), structure); 143 gst_bus_post(webKitMediaSrc->priv->bus.get(), message); 144 GST_TRACE("ready-for-more-samples message posted to the bus"); 145 } 137 if (appsrcStream && appsrcStream->type != WebCore::Invalid) 138 webKitMediaSrc->priv->notifier->notify(WebKitMediaSrcMainThreadNotification::ReadyForMoreSamples, [webKitMediaSrc, appsrcStream] { 139 notifyReadyForMoreSamplesMainThread(webKitMediaSrc, appsrcStream); 140 }); 146 141 147 142 GST_OBJECT_UNLOCK(webKitMediaSrc); … … 265 260 source->priv->appsrcSeekDataNextAction = Nothing; 266 261 source->priv->flowCombiner = GUniquePtr<GstFlowCombiner>(gst_flow_combiner_new()); 262 source->priv->notifier = WebCore::MainThreadNotifier<WebKitMediaSrcMainThreadNotification>::create(); 267 263 268 264 // No need to reset Stream.appsrcNeedDataFlag because there are no Streams at this point yet. … … 283 279 284 280 priv->seekTime = MediaTime::invalidTime(); 281 282 source->priv->notifier->invalidate(); 285 283 286 284 if (priv->mediaPlayerPrivate) … … 695 693 } 696 694 697 static void applicationMessageCallback(GstBus*, GstMessage* message, WebKitMediaSrc* source)698 {699 ASSERT(WTF::isMainThread());700 ASSERT(GST_MESSAGE_TYPE(message) == GST_MESSAGE_APPLICATION);701 702 const GstStructure* structure = gst_message_get_structure(message);703 704 if (gst_structure_has_name(structure, "seek-needs-data")) {705 seekNeedsDataMainThread(source);706 return;707 }708 709 if (gst_structure_has_name(structure, "ready-for-more-samples")) {710 Stream* appsrcStream = nullptr;711 gst_structure_get(structure, "appsrc-stream", G_TYPE_POINTER, &appsrcStream, nullptr);712 ASSERT(appsrcStream);713 714 notifyReadyForMoreSamplesMainThread(source, appsrcStream);715 return;716 }717 718 ASSERT_NOT_REACHED();719 }720 721 695 void webKitMediaSrcSetMediaPlayerPrivate(WebKitMediaSrc* source, WebCore::MediaPlayerPrivateGStreamerMSE* mediaPlayerPrivate) 722 696 { 723 697 GST_OBJECT_LOCK(source); 724 if (source->priv->mediaPlayerPrivate && source->priv->mediaPlayerPrivate != mediaPlayerPrivate && source->priv->bus)725 g_signal_handlers_disconnect_by_func(source->priv->bus.get(), gpointer(applicationMessageCallback), source);726 698 727 699 // Set to nullptr on MediaPlayerPrivateGStreamer destruction, never a dangling pointer. 728 700 source->priv->mediaPlayerPrivate = mediaPlayerPrivate; 729 source->priv->bus = mediaPlayerPrivate ? adoptGRef(gst_pipeline_get_bus(GST_PIPELINE(mediaPlayerPrivate->pipeline()))) : nullptr;730 if (source->priv->bus) {731 // MediaPlayerPrivateGStreamer has called gst_bus_add_signal_watch() at this point, so we can subscribe.732 g_signal_connect(source->priv->bus.get(), "message::application", G_CALLBACK(applicationMessageCallback), source);733 }734 701 GST_OBJECT_UNLOCK(source); 735 702 } -
trunk/Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamerPrivate.h
r235109 r235110 25 25 #include "AudioTrackPrivateGStreamer.h" 26 26 #include "GUniquePtrGStreamer.h" 27 #include "MainThreadNotifier.h" 27 28 #include "SourceBufferPrivateGStreamer.h" 28 29 #include "VideoTrackPrivateGStreamer.h" … … 31 32 #include <gst/app/gstappsrc.h> 32 33 #include <gst/gst.h> 33 #include <wtf/Condition.h> 34 #include <wtf/RefPtr.h> 34 #include <wtf/Forward.h> 35 35 #include <wtf/glib/GRefPtr.h> 36 36 … … 96 96 }; 97 97 98 enum WebKitMediaSrcMainThreadNotification { 99 ReadyForMoreSamples = 1 << 0, 100 SeekNeedsData = 1 << 1 101 }; 102 98 103 struct _WebKitMediaSrcPrivate { 99 104 // Used to coordinate the release of Stream track info. … … 119 124 int appsrcNeedDataCount; 120 125 121 GRefPtr<GstBus> bus;122 126 WebCore::MediaPlayerPrivateGStreamerMSE* mediaPlayerPrivate; 123 127 128 RefPtr<WebCore::MainThreadNotifier<WebKitMediaSrcMainThreadNotification>> notifier; 124 129 GUniquePtr<GstFlowCombiner> flowCombiner; 125 130 };
Note: See TracChangeset
for help on using the changeset viewer.