Skip to content

Commit 848f79e

Browse files
asurdej-comcasteocanha
authored andcommitted
[GStreamer] Don't advertise support for HDR on systems that don't explicitly declare that support
https://bugs.webkit.org/show_bug.cgi?id=299873 Reviewed by Philippe Normand. Some websites and JS players can try to play HDR video on systems that don't support it. Even when there isn't an effective HDR connected screen detection mechanism yet in place on GStreamer ports, it would be nice to at least report HDR as unsupported to those webpages asking for it. See: #1564 This patch now filters the MediaCapabilities query, so if the webpage is asking for an hdrMetadataType or a transferFunction and our internal screen data doesn't acknowledge the presence of an HDR screen, we reply that such MediaCapabilities combination is not supported. Also, if the requested codecs aren't supported (even by software), we now return that the MediaCapabilities combination is not supported. Original author: Andrzej Surdej <[email protected]> * Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp: (WebCore::GStreamerRegistryScanner::isConfigurationSupported const): Apply filters. Check if codecs are supported. Canonical link: https://commits.webkit.org/301049@main
1 parent 2ad411d commit 848f79e

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
#include "ContentType.h"
2626
#include "GStreamerCodecUtilities.h"
2727
#include "GStreamerCommon.h"
28+
#include "PlatformScreen.h"
2829
#include "RuntimeApplicationChecks.h"
30+
#include "ScreenProperties.h"
2931
#include <fnmatch.h>
3032
#include <gst/pbutils/codec-utils.h>
3133
#include <wtf/NeverDestroyed.h>
@@ -1005,7 +1007,6 @@ ASCIILiteral GStreamerRegistryScanner::configurationNameForLogging(Configuration
10051007

10061008
GStreamerRegistryScanner::RegistryLookupResult GStreamerRegistryScanner::isConfigurationSupported(Configuration configuration, const MediaConfiguration& mediaConfiguration) const
10071009
{
1008-
bool isSupported = false;
10091010
bool isUsingHardware = false;
10101011
#ifndef GST_DISABLE_GST_DEBUG
10111012
ASCIILiteral configLogString = configurationNameForLogging(configuration);
@@ -1020,11 +1021,30 @@ GStreamerRegistryScanner::RegistryLookupResult GStreamerRegistryScanner::isConfi
10201021
videoConfiguration.bitrate, videoConfiguration.framerate);
10211022
#endif
10221023

1024+
auto* scrData = screenData(primaryScreenDisplayID());
1025+
if (!scrData || !scrData->screenSupportsHighDynamicRange) {
1026+
// Check HDR metadata field
1027+
if (videoConfiguration.hdrMetadataType.has_value())
1028+
return { false, false, nullptr };
1029+
// Transfer function (EOTF)
1030+
if (videoConfiguration.transferFunction.has_value()) {
1031+
auto tf = videoConfiguration.transferFunction.value();
1032+
// compare to your enum values for PQ/HLG; adjust names if different
1033+
if (tf == TransferFunction::PQ || tf == TransferFunction::HLG)
1034+
return { false, false, nullptr };
1035+
}
1036+
}
1037+
10231038
auto contentType = ContentType(videoConfiguration.contentType);
1024-
isSupported = isContainerTypeSupported(configuration, contentType.containerType());
1039+
if (!isContainerTypeSupported(configuration, contentType.containerType()))
1040+
return { false, false, nullptr };
1041+
10251042
auto codecs = contentType.codecs();
1026-
if (!codecs.isEmpty())
1043+
if (!codecs.isEmpty()) {
1044+
if (!areAllCodecsSupported(configuration, codecs, false))
1045+
return { false, false, nullptr };
10271046
isUsingHardware = areAllCodecsSupported(configuration, codecs, true);
1047+
}
10281048
}
10291049

10301050
if (mediaConfiguration.audio) {
@@ -1035,10 +1055,11 @@ GStreamerRegistryScanner::RegistryLookupResult GStreamerRegistryScanner::isConfi
10351055
audioConfiguration.bitrate.value_or(0), audioConfiguration.samplerate.value_or(0));
10361056
#endif
10371057
auto contentType = ContentType(audioConfiguration.contentType);
1038-
isSupported = isContainerTypeSupported(configuration, contentType.containerType());
1058+
if (!isContainerTypeSupported(configuration, contentType.containerType()))
1059+
return { false, false, nullptr };
10391060
}
10401061

1041-
return { isSupported, isUsingHardware, nullptr };
1062+
return { true, isUsingHardware, nullptr };
10421063
}
10431064

10441065
#if USE(GSTREAMER_WEBRTC)

0 commit comments

Comments
 (0)