Skip to content

Commit d330a5d

Browse files
asurdej-comcasteocanha
authored andcommitted
[GStreamer] Support Dolby Vision codecs
Some applications (like AppleTV+) explicitly checks MSE for DV codecs support and select proper stream based on that. Browser needs to report that Dolby vision codecs are supported. List 'dvhe' and 'dvh1' codecs in GStreamer registry scanner but make sure they are exposed only if platform screen supports HDR. WPEPlatform provides screen properties throuhg ScreenManager. When disabled, use fake screen properties with HDR support based on page settings. For WPE port only.
1 parent f618603 commit d330a5d

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

Source/WebCore/platform/PlatformScreen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "config.h"
2727
#include "PlatformScreen.h"
2828

29-
#if PLATFORM(COCOA) || PLATFORM(GTK) || (PLATFORM(WPE) && ENABLE(WPE_PLATFORM))
29+
#if PLATFORM(COCOA) || PLATFORM(GTK) || PLATFORM(WPE)
3030

3131
#include "ScreenProperties.h"
3232
#include <wtf/NeverDestroyed.h>

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
#include "VideoEncoderPrivateGStreamer.h"
4343
#endif
4444

45+
#if PLATFORM(WPE)
46+
#include "PlatformScreen.h"
47+
#include "ScreenProperties.h"
48+
#endif // PLATFORM(WPE)
49+
4550
namespace {
4651
struct VideoDecodingLimits {
4752
unsigned mediaMaxWidth = 0;
@@ -510,6 +515,10 @@ void GStreamerRegistryScanner::initializeDecoders(const GStreamerRegistryScanner
510515
m_decoderCodecMap.add("x-h265"_s, h265DecoderAvailable);
511516
m_decoderCodecMap.add("hvc1*"_s, h265DecoderAvailable);
512517
m_decoderCodecMap.add("hev1*"_s, h265DecoderAvailable);
518+
#if PLATFORM(WPE)
519+
m_decoderCodecMap.add("dvhe*"_s, h265DecoderAvailable);
520+
m_decoderCodecMap.add("dvh1*"_s, h265DecoderAvailable);
521+
#endif // PLATFORM(WPE)
513522
}
514523

515524
if (shouldAddMP4Container) {
@@ -747,11 +756,22 @@ GStreamerRegistryScanner::CodecLookupResult GStreamerRegistryScanner::isCodecSup
747756
String subType = slashIndex != notFound ? codec.substring(slashIndex + 1) : codec;
748757
auto codecName = caseSensitive == CaseSensitiveCodecName::Yes ? subType : subType.convertToASCIILowercase();
749758

759+
#if PLATFORM(WPE)
760+
bool supportsDVHCodec = false;
761+
auto* scrData = screenData(primaryScreenDisplayID());
762+
if (scrData && scrData->screenSupportsHighDynamicRange)
763+
supportsDVHCodec = true;
764+
#endif // PLATFORM(WPE)
765+
750766
CodecLookupResult result;
751767
if (codecName.startsWith("avc1"_s))
752768
result = isAVC1CodecSupported(configuration, codecName, shouldCheckForHardwareUse);
753769
else if (codecName.startsWith("hev1"_s) || codecName.startsWith("hvc1"_s))
754770
result = isHEVCCodecSupported(configuration, codecName, shouldCheckForHardwareUse);
771+
#if PLATFORM(WPE)
772+
else if ((codecName.startsWith("dvhe"_s) || codecName.startsWith("dvh1"_s)) && !supportsDVHCodec)
773+
result = { false, nullptr };
774+
#endif // PLATFORM(WPE)
755775
else {
756776
auto& codecMap = configuration == Configuration::Decoding ? m_decoderCodecMap : m_encoderCodecMap;
757777
for (const auto& [codecId, lookupResult] : codecMap) {

Source/WebKit/WebProcess/WebPage/WebPage.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,11 @@
463463
#include <pal/cf/CoreTextSoftLink.h>
464464
#endif
465465

466+
#if PLATFORM(WPE) && !ENABLE(WPE_PLATFORM)
467+
#include <WebCore/PlatformScreen.h>
468+
#include <WebCore/ScreenProperties.h>
469+
#endif // PLATFORM(WPE) && !ENABLE(WPE_PLATFORM)
470+
466471
namespace WebKit {
467472
using namespace JSC;
468473
using namespace WebCore;
@@ -4813,6 +4818,20 @@ void WebPage::updatePreferences(const WebPreferencesStore& store)
48134818
#endif
48144819

48154820
m_page->settingsDidChange();
4821+
4822+
#if PLATFORM(WPE) && !ENABLE(WPE_PLATFORM)
4823+
// On WPE, we don't have a way to get screen properties from the system, so
4824+
// we fake them here based on the settings.
4825+
auto* currentScreenData = WebCore::screenData(primaryScreenDisplayID());
4826+
if (!currentScreenData || currentScreenData->screenSupportsHighDynamicRange != settings.screenSupportsHDR()) {
4827+
WebCore::ScreenData data;
4828+
data.screenSupportsHighDynamicRange = settings.screenSupportsHDR();
4829+
WebCore::ScreenProperties props;
4830+
props.primaryDisplayID = 1; // Fake display ID
4831+
props.screenDataMap.add(props.primaryDisplayID, WTFMove(data));
4832+
WebCore::setScreenProperties(props);
4833+
}
4834+
#endif // PLATFORM(WPE) && !ENABLE(WPE_PLATFORM
48164835
}
48174836

48184837
#if ENABLE(DATA_DETECTION)

0 commit comments

Comments
 (0)