Skip to content

Commit 553216b

Browse files
asurdej-comcastphiln
authored andcommitted
Fix thunderparser autoplugging for Westeros VP9 and AV1
Disconnect autoplug-continue signal that decodebin3 sets on a parsebin to make parsebin continue autoplugging proces even if caps already matches sink capabilities.
1 parent 83e5b96 commit 553216b

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,8 @@ void MediaPlayerPrivateGStreamer::configureElementPlatformQuirks(GstElement* ele
26562656
characteristics.add({ ElementRuntimeCharacteristics::HasAudio });
26572657
if (m_isLiveStream.value_or(false))
26582658
characteristics.add({ ElementRuntimeCharacteristics::IsLiveStream });
2659+
if (isMediaSource())
2660+
characteristics.add({ ElementRuntimeCharacteristics::IsMediaSource });
26592661

26602662
GStreamerQuirksManager::singleton().configureElement(element, WTFMove(characteristics));
26612663
}

Source/WebCore/platform/gstreamer/GStreamerQuirkRialto.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool GStreamerQuirkRialto::isPlatformSupported() const
7676
return gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(sinkFactory.get())) > GST_RANK_MARGINAL;
7777
}
7878

79-
void GStreamerQuirkRialto::configureElement(GstElement* element, const OptionSet<ElementRuntimeCharacteristics>&)
79+
void GStreamerQuirkRialto::configureElement(GstElement* element, const OptionSet<ElementRuntimeCharacteristics>& characteristics)
8080
{
8181
if (!g_strcmp0(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstURIDecodeBin3")) {
8282
GRefPtr<GstCaps> defaultCaps;
@@ -85,6 +85,13 @@ void GStreamerQuirkRialto::configureElement(GstElement* element, const OptionSet
8585
GST_INFO("Setting stop caps to %" GST_PTR_FORMAT, defaultCaps.get());
8686
g_object_set(element, "caps", defaultCaps.get(), nullptr);
8787
}
88+
if (!g_strcmp0(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstParseBin") &&
89+
characteristics.contains(ElementRuntimeCharacteristics::IsMediaSource)) {
90+
auto autoplugId = g_signal_lookup("autoplug-continue", G_OBJECT_TYPE (element));
91+
g_signal_handlers_disconnect_matched(
92+
element, static_cast<GSignalMatchType>(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
93+
autoplugId, 0, nullptr, nullptr, GST_OBJECT_PARENT(element));
94+
}
8895
}
8996

9097
GstElement* GStreamerQuirkRialto::createAudioSink()

Source/WebCore/platform/gstreamer/GStreamerQuirkWesteros.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,27 @@ bool GStreamerQuirkWesteros::isPlatformSupported() const
5959

6060
void GStreamerQuirkWesteros::configureElement(GstElement* element, const OptionSet<ElementRuntimeCharacteristics>& characteristics)
6161
{
62+
// Decodebin3 will try to autoplug available elements until it reaches a raw video format.
63+
// Set stop caps on decodebin3 to prevent it from decoding the stream.
64+
// Instead, it should expose a pad with encoded caps that platform sink can handle directly as a sink element.
65+
// That brings unwanted side effects for parsebin element.
66+
// Decodebin3 installs "autoplug-continue" signal handler on parsebin to stop its autoplugging process
67+
// when it reaches decodebin stop caps. We still may want to use some parsers elements,
68+
// like webkithunderparser, so we need to disconnect the "autoplug-continue" signal handler
69+
// and let parsebin to control the autoplugging process. (Default handler will stop on decoder element)
6270
if (equalIgnoringASCIICase(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstURIDecodeBin3")) {
6371
GRefPtr<GstCaps> defaultCaps;
6472
g_object_get(element, "caps", &defaultCaps.outPtr(), nullptr);
6573
defaultCaps = adoptGRef(gst_caps_merge(gst_caps_ref(m_sinkCaps.get()), defaultCaps.leakRef()));
6674
GST_INFO("Setting stop caps to %" GST_PTR_FORMAT, defaultCaps.get());
6775
g_object_set(element, "caps", defaultCaps.get(), nullptr);
68-
return;
76+
}
77+
if (equalIgnoringASCIICase(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstParseBin") &&
78+
characteristics.contains(ElementRuntimeCharacteristics::IsMediaSource)) {
79+
auto autoplugId = g_signal_lookup("autoplug-continue", G_OBJECT_TYPE (element));
80+
g_signal_handlers_disconnect_matched(
81+
element, static_cast<GSignalMatchType>(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
82+
autoplugId, 0, nullptr, nullptr, GST_OBJECT_PARENT(element));
6983
}
7084

7185
if (!characteristics.contains(ElementRuntimeCharacteristics::IsMediaStream))

Source/WebCore/platform/gstreamer/GStreamerQuirks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ enum class ElementRuntimeCharacteristics : uint8_t {
3939
HasVideo = 1 << 1,
4040
HasAudio = 1 << 2,
4141
IsLiveStream = 1 << 3,
42+
IsMediaSource = 1 << 4,
4243
};
4344

4445
class GStreamerQuirkBase {

0 commit comments

Comments
 (0)