Skip to content

Commit

Permalink
[Gstreamer][Westeros] Bring back westeros autoplug code for playbin3
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=263714

Reviewed by Philippe Normand.

To autoplug westeros sink in playbin3 we need to specify the stop caps to ensure encoded data goes directly into the
sink.

This is a revert of # https://commits.webkit.org/266178@main.

* Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::syncOnClock):
(WebCore::MediaPlayerPrivateGStreamer::configureElementPlatformQuirks):

Canonical link: https://commits.webkit.org/269808@main
  • Loading branch information
calvaris committed Oct 26, 2023
1 parent 5a41af7 commit 2ffd552
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,6 @@ void MediaPlayerPrivateGStreamer::syncOnClock(bool sync)
#if !USE(WESTEROS_SINK)
setSyncOnClock(videoSink(), sync);
setSyncOnClock(audioSink(), sync);
#else
UNUSED_PARAM(sync);
#endif
}

Expand Down Expand Up @@ -2306,12 +2304,40 @@ void MediaPlayerPrivateGStreamer::configureElementPlatformQuirks(GstElement* ele
#endif
#endif

#if USE(WESTEROS_SINK)
static GstCaps* westerosSinkCaps = nullptr;
static GType westerosSinkType = G_TYPE_INVALID;
static std::once_flag onceFlag;
std::call_once(onceFlag, [] {
GRefPtr<GstElementFactory> westerosfactory = adoptGRef(gst_element_factory_find("westerossink"));
if (westerosfactory) {
gst_object_unref(gst_plugin_feature_load(GST_PLUGIN_FEATURE(westerosfactory.get())));
westerosSinkType = gst_element_factory_get_element_type(westerosfactory.get());
for (auto* t = gst_element_factory_get_static_pad_templates(westerosfactory.get()); t; t = g_list_next(t)) {
GstStaticPadTemplate* padtemplate = static_cast<GstStaticPadTemplate*>(t->data);
if (padtemplate->direction != GST_PAD_SINK)
continue;
if (westerosSinkCaps)
westerosSinkCaps = gst_caps_merge(westerosSinkCaps, gst_static_caps_get(&padtemplate->static_caps));
else
westerosSinkCaps = gst_static_caps_get(&padtemplate->static_caps);
}
}
});
#if ENABLE(MEDIA_STREAM)
if (m_streamPrivate && !g_strcmp0(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstWesterosSink") && gstObjectHasProperty(element, "immediate-output")) {
GST_DEBUG_OBJECT(pipeline(), "Enable 'immediate-output' in WesterosSink");
g_object_set(element, "immediate-output", TRUE, nullptr);
}
#endif
if (!m_isLegacyPlaybin && westerosSinkCaps && g_str_has_prefix(GST_ELEMENT_NAME(element), "uridecodebin3")) {
GRefPtr<GstCaps> defaultCaps;
g_object_get(element, "caps", &defaultCaps.outPtr(), NULL);
defaultCaps = adoptGRef(gst_caps_merge(gst_caps_ref(westerosSinkCaps), defaultCaps.leakRef()));
g_object_set(element, "caps", defaultCaps.get(), NULL);
GST_INFO_OBJECT(pipeline(), "setting stop caps tp %" GST_PTR_FORMAT, defaultCaps.get());
}
#endif

#if ENABLE(MEDIA_STREAM) && PLATFORM(REALTEK)
if (m_streamPrivate) {
Expand Down

0 comments on commit 2ffd552

Please sign in to comment.