Skip to content

Commit a5fd98e

Browse files
committed
Quirks: Address review feedback
Backport of https://commits.webkit.org/276450@main keeping old ifdefs compatibility, so the GStreamerQuirksManager::getAdditionalPlaybinFlags() implementation diverges from upstream version.
1 parent 75cfc9e commit a5fd98e

File tree

7 files changed

+59
-24
lines changed

7 files changed

+59
-24
lines changed

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2894,19 +2894,11 @@ void MediaPlayerPrivateGStreamer::setPlaybackFlags(bool isMediaStream)
28942894
if (isMediaStream)
28952895
flags = flags & ~getGstPlayFlag("buffering");
28962896

2897-
#if !USE(GSTREAMER_TEXT_SINK)
2898-
hasText = 0x0;
2899-
#endif
2900-
2901-
#if USE(GSTREAMER_NATIVE_VIDEO)
2902-
hasSoftwareColorBalance = 0x0;
2903-
#else
2904-
hasNativeVideo = 0x0;
2905-
#endif
2906-
2907-
#if !USE(GSTREAMER_NATIVE_AUDIO)
2908-
hasNativeAudio = 0x0;
2909-
#endif
2897+
unsigned additionalFlags = GStreamerQuirksManager::singleton().getAdditionalPlaybinFlags();
2898+
hasText &= additionalFlags;
2899+
hasSoftwareColorBalance &= additionalFlags;
2900+
hasNativeVideo &= additionalFlags;
2901+
hasNativeAudio &= additionalFlags;
29102902

29112903
GST_INFO_OBJECT(pipeline(), "text %s, audio %s (native %s), video %s (native %s, software color balance %s)", boolForPrinting(hasText),
29122904
boolForPrinting(hasAudio), boolForPrinting(hasNativeAudio), boolForPrinting(hasVideo), boolForPrinting(hasNativeVideo),
@@ -4145,10 +4137,9 @@ GstElement* MediaPlayerPrivateGStreamer::createVideoSink()
41454137

41464138
if (isHolePunchRenderingEnabled()) {
41474139
m_videoSink = createHolePunchVideoSink();
4148-
if (m_videoSink) {
4149-
pushNextHolePunchBuffer();
4150-
return m_videoSink.get();
4151-
}
4140+
// Do not check the m_videoSink value. The nullptr case will trigger auto-plugging in playbin.
4141+
pushNextHolePunchBuffer();
4142+
return m_videoSink.get();
41524143
}
41534144

41544145
#if USE(TEXTURE_MAPPER_DMABUF)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface
197197
void acceleratedRenderingStateChanged() final;
198198
bool performTaskAtMediaTime(Function<void()>&&, const MediaTime&) override;
199199

200+
GstElement* pipeline() const { return m_pipeline.get(); }
201+
200202
#if USE(TEXTURE_MAPPER_GL)
201203
PlatformLayer* platformLayer() const override;
202204
#if PLATFORM(WIN_CAIRO)
@@ -342,8 +344,6 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface
342344

343345
void setStreamVolumeElement(GstStreamVolume*);
344346

345-
GstElement* pipeline() const { return m_pipeline.get(); }
346-
347347
void repaint();
348348
void cancelRepaint(bool destroying = false);
349349

Source/WebCore/platform/gstreamer/GStreamerHolePunchQuirkWesteros.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "config.h"
2222
#include "GStreamerHolePunchQuirkWesteros.h"
23+
#include "MediaPlayerPrivateGStreamer.h"
2324

2425
#if USE(GSTREAMER)
2526

@@ -37,8 +38,15 @@ GstElement* GStreamerHolePunchQuirkWesteros::createHolePunchVideoSink(bool isLeg
3738
// Westeros using holepunch.
3839
GstElement* videoSink = makeGStreamerElement("westerossink", "WesterosVideoSink");
3940
g_object_set(videoSink, "zorder", 0.0f, nullptr);
40-
if (isPIPRequested)
41+
if (isPIPRequested) {
4142
g_object_set(videoSink, "res-usage", 0u, nullptr);
43+
// Set context for pipelines that use ERM in decoder elements.
44+
auto context = adoptGRef(gst_context_new("erm", FALSE));
45+
auto contextStructure = gst_context_writable_structure(context.get());
46+
gst_structure_set(contextStructure, "res-usage", G_TYPE_UINT, 0x0u, nullptr);
47+
auto playerPrivate = reinterpret_cast<const MediaPlayerPrivateGStreamer*>(player->playerPrivate());
48+
gst_element_set_context(playerPrivate->pipeline(), context.get());
49+
}
4250
return videoSink;
4351
}
4452

Source/WebCore/platform/gstreamer/GStreamerQuirkAmLogic.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,17 @@ GstElement* GStreamerQuirkAmLogic::createWebAudioSink()
5050

5151
bool GStreamerQuirkAmLogic::configureElement(GstElement* element, const OptionSet<ElementRuntimeCharacteristics>& characteristics)
5252
{
53-
GST_INFO("Set property disable-xrun to TRUE");
54-
g_object_set(element, "disable-xrun", TRUE, nullptr);
55-
if (characteristics.contains(ElementRuntimeCharacteristics::HasVideo))
53+
if (gstObjectHasProperty(element, "disable-xrun")) {
54+
GST_INFO("Set property disable-xrun to TRUE");
55+
g_object_set(element, "disable-xrun", TRUE, nullptr);
56+
} else
57+
return false;
58+
59+
if (characteristics.contains(ElementRuntimeCharacteristics::HasVideo) && gstObjectHasProperty(element, "wait-video")) {
60+
GST_INFO("Set property wait-video to TRUE");
5661
g_object_set(element, "wait-video", TRUE, nullptr);
62+
} else
63+
return false;
5764

5865
return true;
5966
}

Source/WebCore/platform/gstreamer/GStreamerQuirkBroadcom.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#if USE(GSTREAMER)
2424

25+
#include "GStreamerCommon.h"
2526
#include "GStreamerQuirks.h"
2627

2728
namespace WebCore {
@@ -35,6 +36,7 @@ class GStreamerQuirkBroadcom final : public GStreamerQuirk {
3536
std::optional<bool> isHardwareAccelerated(GstElementFactory*) final;
3637
std::optional<GstElementFactoryListType> audioVideoDecoderFactoryListType() const final { return GST_ELEMENT_FACTORY_TYPE_PARSER; }
3738
Vector<String> disallowedWebAudioDecoders() const final { return m_disallowedWebAudioDecoders; }
39+
unsigned getAdditionalPlaybinFlags() const final { return getGstPlayFlag("text") | getGstPlayFlag("native-audio"); }
3840

3941
private:
4042
Vector<String> m_disallowedWebAudioDecoders;

Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,30 @@ void GStreamerQuirksManager::setHolePunchEnabledForTesting(bool enabled)
259259
m_holePunchQuirk = nullptr;
260260
}
261261

262+
unsigned GStreamerQuirksManager::getAdditionalPlaybinFlags() const
263+
{
264+
unsigned flags = 0;
265+
#if USE(GSTREAMER_NATIVE_VIDEO)
266+
flags |= getGstPlayFlag("native-video");
267+
#else
268+
flags |= getGstPlayFlag("soft-colorbalance");
269+
#endif
270+
#if USE(GSTREAMER_NATIVE_AUDIO)
271+
flags |= getGstPlayFlag("native-audio");
272+
#endif
273+
#if USE(GSTREAMER_TEXT_SINK)
274+
flags |= getGstPlayFlag("text");
275+
#endif
276+
for (const auto& quirk : m_quirks) {
277+
if (auto additionalFlags = quirk->getAdditionalPlaybinFlags()) {
278+
GST_DEBUG("Quirk %s requests these playbin flags: %u", quirk->identifier(), additionalFlags);
279+
flags |= additionalFlags;
280+
}
281+
}
282+
283+
return flags;
284+
}
285+
262286
#undef GST_CAT_DEFAULT
263287

264288
} // namespace WebCore

Source/WebCore/platform/gstreamer/GStreamerQuirks.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#if USE(GSTREAMER)
2424

25-
#include "GRefPtrGStreamer.h"
25+
#include "GStreamerCommon.h"
2626
#include "MediaPlayer.h"
2727
#include <wtf/Forward.h>
2828
#include <wtf/RefCounted.h>
@@ -59,6 +59,7 @@ class GStreamerQuirk : public GStreamerQuirkBase {
5959
virtual std::optional<bool> isHardwareAccelerated(GstElementFactory*) { return std::nullopt; }
6060
virtual std::optional<GstElementFactoryListType> audioVideoDecoderFactoryListType() const { return std::nullopt; }
6161
virtual Vector<String> disallowedWebAudioDecoders() const { return { }; }
62+
virtual unsigned getAdditionalPlaybinFlags() const { return 0; }
6263
};
6364

6465
class GStreamerHolePunchQuirk : public GStreamerQuirkBase {
@@ -99,6 +100,8 @@ class GStreamerQuirksManager : public RefCounted<GStreamerQuirksManager> {
99100

100101
void setHolePunchEnabledForTesting(bool);
101102

103+
unsigned getAdditionalPlaybinFlags() const;
104+
102105
private:
103106
GStreamerQuirksManager(bool, bool);
104107

0 commit comments

Comments
 (0)