Skip to content

Commit 66c7749

Browse files
committed
[GStreamer][Quirks] Address review feedback from downstream users
https://bugs.webkit.org/show_bug.cgi?id=271308 Reviewed by Xabier Rodriguez-Calvar. The USE_GSTREAMER_TEXT_SINK and USE_GSTREAMER_NATIVE_{AUDIO,VIDEO} ifdefs were replaced with runtime quirks. This patch also includes changes requested in WebPlatformForEmbedded/WPEWebKit#1297. * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: (WebCore::MediaPlayerPrivateGStreamer::setPlaybackFlags): (WebCore::MediaPlayerPrivateGStreamer::createVideoSink): * Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: (WebCore::MediaPlayerPrivateGStreamer::pipeline const): * Source/WebCore/platform/gstreamer/GStreamerHolePunchQuirkWesteros.cpp: (WebCore::GStreamerHolePunchQuirkWesteros::createHolePunchVideoSink): * Source/WebCore/platform/gstreamer/GStreamerQuirkAmLogic.cpp: (WebCore::GStreamerQuirkAmLogic::configureElement): * Source/WebCore/platform/gstreamer/GStreamerQuirkBroadcom.h: * Source/WebCore/platform/gstreamer/GStreamerQuirks.cpp: (WebCore::GStreamerQuirksManager::getAdditionalPlaybinFlags const): * Source/WebCore/platform/gstreamer/GStreamerQuirks.h: (WebCore::GStreamerQuirk::getAdditionalPlaybinFlags const): * Source/cmake/GStreamerDefinitions.cmake: Canonical link: https://commits.webkit.org/276450@main
1 parent 1ad9a7b commit 66c7749

8 files changed

Lines changed: 47 additions & 27 deletions

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

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

2967-
#if !USE(GSTREAMER_TEXT_SINK)
2968-
hasText = 0x0;
2969-
#endif
2970-
2971-
#if USE(GSTREAMER_NATIVE_VIDEO)
2972-
hasSoftwareColorBalance = 0x0;
2973-
#else
2974-
hasNativeVideo = 0x0;
2975-
#endif
2976-
2977-
#if !USE(GSTREAMER_NATIVE_AUDIO)
2978-
hasNativeAudio = 0x0;
2979-
#endif
2967+
unsigned additionalFlags = GStreamerQuirksManager::singleton().getAdditionalPlaybinFlags();
2968+
hasText &= additionalFlags;
2969+
hasSoftwareColorBalance &= additionalFlags;
2970+
hasNativeVideo &= additionalFlags;
2971+
hasNativeAudio &= additionalFlags;
29802972

29812973
GST_INFO_OBJECT(pipeline(), "text %s, audio %s (native %s), video %s (native %s, software color balance %s)", boolForPrinting(hasText),
29822974
boolForPrinting(hasAudio), boolForPrinting(hasNativeAudio), boolForPrinting(hasVideo), boolForPrinting(hasNativeVideo),
@@ -4234,10 +4226,9 @@ GstElement* MediaPlayerPrivateGStreamer::createVideoSink()
42344226

42354227
if (isHolePunchRenderingEnabled()) {
42364228
m_videoSink = createHolePunchVideoSink();
4237-
if (m_videoSink) {
4238-
pushNextHolePunchBuffer();
4239-
return m_videoSink.get();
4240-
}
4229+
// Do not check the m_videoSink value. The nullptr case will trigger auto-plugging in playbin.
4230+
pushNextHolePunchBuffer();
4231+
return m_videoSink.get();
42414232
}
42424233

42434234
#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
@@ -189,6 +189,8 @@ class MediaPlayerPrivateGStreamer
189189
bool performTaskAtTime(Function<void()>&&, const MediaTime&) override;
190190
void isLoopingChanged() final;
191191

192+
GstElement* pipeline() const { return m_pipeline.get(); }
193+
192194
#if USE(TEXTURE_MAPPER)
193195
PlatformLayer* platformLayer() const override;
194196
#if PLATFORM(WIN)
@@ -310,8 +312,6 @@ class MediaPlayerPrivateGStreamer
310312

311313
void setStreamVolumeElement(GstStreamVolume*);
312314

313-
GstElement* pipeline() const { return m_pipeline.get(); }
314-
315315
void repaint();
316316
void cancelRepaint(bool destroying = false);
317317

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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,18 @@ void GStreamerQuirksManager::setHolePunchEnabledForTesting(bool enabled)
230230
m_holePunchQuirk = nullptr;
231231
}
232232

233+
unsigned GStreamerQuirksManager::getAdditionalPlaybinFlags() const
234+
{
235+
for (const auto& quirk : m_quirks) {
236+
if (auto flags = quirk->getAdditionalPlaybinFlags()) {
237+
GST_DEBUG("Quirk %s requests these playbin flags: %u", quirk->identifier(), flags);
238+
return flags;
239+
}
240+
}
241+
GST_DEBUG("Quirks didn't request any specific playbin flags.");
242+
return getGstPlayFlag("text") | getGstPlayFlag("soft-colorbalance");
243+
}
244+
233245
#undef GST_CAT_DEFAULT
234246

235247
} // 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 getGstPlayFlag("text") | getGstPlayFlag("soft-colorbalance"); }
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

Source/cmake/GStreamerDefinitions.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,5 @@ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MEDIA_SOURCE PRIVATE ON)
66
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_GL "Whether to enable support for GStreamer GL" PRIVATE ON)
77
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_MPEGTS "Whether to enable support for MPEG-TS" PRIVATE OFF)
88
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_FULL "Whether to enable support for static GStreamer builds" PRIVATE OFF)
9-
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_NATIVE_VIDEO "Toggle native video support in GStreamer media player" PRIVATE OFF)
10-
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_NATIVE_AUDIO "Toggle native audio support in GStreamer media player" PRIVATE OFF)
11-
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_TEXT_SINK "Toggle text sink support in GStreamer media player" PRIVATE ON)
129
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_TRANSCODER "Whether to enable support for GStreamer MediaRecorder backend" PUBLIC ON)
1310
WEBKIT_OPTION_DEFINE(USE_GSTREAMER_WEBRTC "Whether to enable support for WebRTC" PUBLIC ON)

0 commit comments

Comments
 (0)