Skip to content

Commit 4bd45a8

Browse files
philncalvaris
authored andcommitted
[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 #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 93d9ab4 commit 4bd45a8

File tree

8 files changed

+47
-27
lines changed

8 files changed

+47
-27
lines changed

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

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

2931-
#if !USE(GSTREAMER_TEXT_SINK)
2932-
hasText = 0x0;
2933-
#endif
2934-
2935-
#if USE(GSTREAMER_NATIVE_VIDEO)
2936-
hasSoftwareColorBalance = 0x0;
2937-
#else
2938-
hasNativeVideo = 0x0;
2939-
#endif
2940-
2941-
#if !USE(GSTREAMER_NATIVE_AUDIO)
2942-
hasNativeAudio = 0x0;
2943-
#endif
2931+
unsigned additionalFlags = GStreamerQuirksManager::singleton().getAdditionalPlaybinFlags();
2932+
hasText &= additionalFlags;
2933+
hasSoftwareColorBalance &= additionalFlags;
2934+
hasNativeVideo &= additionalFlags;
2935+
hasNativeAudio &= additionalFlags;
29442936

29452937
GST_INFO_OBJECT(pipeline(), "text %s, audio %s (native %s), video %s (native %s, software color balance %s)", boolForPrinting(hasText),
29462938
boolForPrinting(hasAudio), boolForPrinting(hasNativeAudio), boolForPrinting(hasVideo), boolForPrinting(hasNativeVideo),
@@ -4178,10 +4170,9 @@ GstElement* MediaPlayerPrivateGStreamer::createVideoSink()
41784170

41794171
if (isHolePunchRenderingEnabled()) {
41804172
m_videoSink = createHolePunchVideoSink();
4181-
if (m_videoSink) {
4182-
pushNextHolePunchBuffer();
4183-
return m_videoSink.get();
4184-
}
4173+
// Do not check the m_videoSink value. The nullptr case will trigger auto-plugging in playbin.
4174+
pushNextHolePunchBuffer();
4175+
return m_videoSink.get();
41854176
}
41864177

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

191+
GstElement* pipeline() const { return m_pipeline.get(); }
192+
191193
#if USE(TEXTURE_MAPPER_GL)
192194
PlatformLayer* platformLayer() const override;
193195
#if PLATFORM(WIN)
@@ -334,8 +336,6 @@ class MediaPlayerPrivateGStreamer
334336

335337
void setStreamVolumeElement(GstStreamVolume*);
336338

337-
GstElement* pipeline() const { return m_pipeline.get(); }
338-
339339
void repaint();
340340
void cancelRepaint(bool destroying = false);
341341

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)