Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 14cb80d8a004ff61c5550db2b35f7c0d66771313 https://github.com/WebKit/WebKit/commit/14cb80d8a004ff61c5550db2b35f7c0d66771313 Author: Enrique Ocaña González <eoca...@igalia.com> Date: 2025-04-04 (Fri, 04 Apr 2025)
Changed paths: M Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp M Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp M Source/WebCore/platform/gstreamer/GStreamerQuirkAmLogic.h M Source/WebCore/platform/gstreamer/GStreamerQuirkBroadcom.h M Source/WebCore/platform/gstreamer/GStreamerQuirkRealtek.h M Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.h M Source/WebCore/platform/gstreamer/GStreamerQuirkWesteros.h M Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp M Source/WebCore/platform/gstreamer/GStreamerQuirks.h Log Message: ----------- [GStreamer][Quirks] Add quirk supporting instant rate change with custom event https://bugs.webkit.org/show_bug.cgi?id=290933 Reviewed by Xabier Rodriguez-Calvar. Some downstream platforms don't use GstClock for audio/video synchronization, don't support existing GST_SEEK_FLAG_INSTANT_RATE_CHANGE, or it doesn't work well in all use cases. This patch uses a "custom-instant-rate-change" custom OOB downstream event sent by MediaPlayerPrivateGStreamer to the pipeline. That event is then processed by WebKitMediaSrcGStreamer, who forwards it to all its src pads and checks that it has been processed in all the streams. If that happens, the rate field is updated in the GstSegment and regular media processing continues. As this is platform-specific behaviour, both MediaPlayerPrivateGStreamer and WebKitMediaSrc delegate part of the implementation to the GStreamer Quirks system. The custom event added in this patch needs to be forwarded to all the pads, instead of just to the first one processing it. This needs a behaviour change in webKitMediaSrcSendEvent(), but only for specific cases (the regular case is to forward it to the first pad attending it), and that's why the analyzeWebKitMediaSrcCustomEvent() method is needed in the Quirks. As a style choice, the quirk functions that need to return one or more meaningful values do that directly (as a direct return type), optionally, or by means of an std::pair. In all those cases, the "meaning" of each value is named in a /* comment */ after the type. If this scheme evolves in the future and the methods need to return more fields, and std::pair or even a specific struct with the field names should be used. Ideally, we might have used structs in this patch, but creating a struct to hold a single value doesn't seem sensible at this point. This patch is co-authored by Eugene Mutavchi <ievgen_mutav...@comcast.com> See: https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/1475 * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::updatePlaybackRate): Apply (by delegating to the Quirks) custom instant rate change in those platforms that need, instead of doing a seek to change it. Update the last playback rate if the change succeeded. (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): Don't use the scaletempo element on platforms that rely on instant rate change. * Source/WebCore/platform/graphics/gstreamer/mse/WebKitMediaSourceGStreamer.cpp: (webKitMediaSrcStreamFlush): Update the GstSegment rate to the one currently configured in WebKitMediaSrcGStreamer (which might have been set when processing the "custom-instant-rate-change" event) (webKitMediaSrcSendEvent): Added code to process OOB custom events (in general), by delegating in the Quirks. The Quirks can now decide if the event has to be propagated to all the pads or only to the first one processing it (default behaviour). In the specific case of the "custom-instant-rate-change" event, the Quirks will decide to propagate to all the pads, and the result of the propagation will be communicated to the Quirks, which will then decide to update the rate stored by WebKitMediaSourceGStreamer if the propagation was successful.in that case * Source/WebCore/platform/gstreamer/GStreamerQuirkAmLogic.h: Override default behaviour and enable custom instant rate change on this platform. * Source/WebCore/platform/gstreamer/GStreamerQuirkBroadcom.h: Ditto. * Source/WebCore/platform/gstreamer/GStreamerQuirkRealtek.h: Ditto. * Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.h: Ditto. * Source/WebCore/platform/gstreamer/GStreamerQuirkWesteros.h: Ditto. * Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp: (WebCore::GStreamerQuirksManager::needsCustomInstantRateChange const): True if any registered quirk needs instant rate change. Evaluated in short-circuit (if one quirk is true, evaluation stops). (WebCore::GStreamerQuirksManager::applyCustomInstantRateChange const): Returns a pair with a first field indicating that the request to apply the instant rate has been processed (acknowledged by the first quirk that needs instant rate change), and a second field indicating if the instant rate change succeeded (was actually performed). Look at the GStreamerQuirk implementation for an explanation of what this method does. (WebCore::GStreamerQuirksManager::analyzeWebKitMediaSrcCustomEvent const): Returns true if the first quirk that needs instant rate change indicates that the OOB event needs to be forwarded by all the src pads. (WebCore::GStreamerQuirksManager::processWebKitMediaSrcCustomEvent const): Returns an optional new rate if the the first quirk that needs instant rate change has been able to retrieve a rate from the event (the event is of the "custom-instant-rate-change" kind and has a rate). (WebCore::GStreamerQuirk::applyCustomInstantRateChange const): Default implementation (to be inherited/reused by the subclasses) to perform instant rate change on already playing pipelines. A "custom-instant-rate-change" event is sent to the pipeline, and the pipeline mute status is updated accordingly. This implementation is guarded, so it won't run in case of the method being called by mistake on platforms not supporting custom instant rate changes. (WebCore::GStreamerQuirk::analyzeWebKitMediaSrcCustomEvent const): Default guarded implementation to determine if the custom event must be forwarded to all the streams/pads (required for "custom-instant-rate-change" on platforms supporting it) or only to the first one successfully processing it (default behaviour for the rest of the events). (WebCore::GStreamerQuirk::processWebKitMediaSrcCustomEvent const): Default guarded implementation to extract the rate from the "custom-instant-rate-change" event, so that WebKitMediaSrcGStreamer can update its stored rate with that parsed value. This is a method with a parameter passed by reference (to store the result there), instead of returned as a method result, because that's the common way to do it in GStreamer parse functions (this operation is similar to a parsing). This design can better accept future evolution, where other fields may need to be provided by the analysis performed in this method. * Source/WebCore/platform/gstreamer/GStreamerQuirks.h: (WebCore::GStreamerQuirk::needsCustomInstantRateChange const): False by default, meaning that custom instant rate change isn't required on the platforms that don't override this method. Canonical link: https://commits.webkit.org/293255@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes