File webkit2gtk3-old-gstreamer.patch of Package webkit2gtk3.29343
diff -urp webkitgtk-2.40.2.orig/Source/cmake/GStreamerChecks.cmake webkitgtk-2.40.2/Source/cmake/GStreamerChecks.cmake
--- webkitgtk-2.40.2.orig/Source/cmake/GStreamerChecks.cmake 2023-02-20 03:22:22.481757600 -0600
+++ webkitgtk-2.40.2/Source/cmake/GStreamerChecks.cmake 2023-05-31 16:37:39.593519068 -0500
@@ -36,7 +36,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
list(APPEND GSTREAMER_COMPONENTS webrtc)
endif ()
- find_package(GStreamer 1.16.2 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
+ find_package(GStreamer 1.10.0 REQUIRED COMPONENTS ${GSTREAMER_COMPONENTS})
if (ENABLE_WEB_AUDIO)
if (NOT PC_GSTREAMER_AUDIO_FOUND OR NOT PC_GSTREAMER_FFT_FOUND)
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp 2023-02-20 03:22:14.673726800 -0600
+++ webkitgtk-2.40.2/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp 2023-05-31 16:37:39.593519068 -0500
@@ -68,7 +68,9 @@ void MediaStreamAudioSource::consumeAudi
GST_BUFFER_FLAG_SET(buffer.get(), GST_BUFFER_FLAG_LIVE);
copyBusData(bus, buffer.get(), muted());
+#if GST_CHECK_VERSION(1, 16, 0)
gst_buffer_add_audio_meta(buffer.get(), &info, numberOfFrames, nullptr);
+#endif
auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr));
GStreamerAudioData audioBuffer(WTFMove(sample), info);
GStreamerAudioStreamDescription description(&info);
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp 2023-02-20 03:22:18.077740200 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp 2023-05-31 16:37:39.593519068 -0500
@@ -77,6 +77,7 @@ struct _WebKitWebAudioSrcPrivate {
GRefPtr<GstBufferPool> pool;
+ bool enableGapBufferSupport;
bool hasRenderedAudibleFrame { false };
Lock dispatchToRenderThreadLock;
@@ -91,6 +92,11 @@ struct _WebKitWebAudioSrcPrivate {
sourcePad = webkitGstGhostPadFromStaticTemplate(&srcTemplate, "src", nullptr);
g_rec_mutex_init(&mutex);
+
+ // GAP buffer support is enabled only for GStreamer 1.12.5 because of a
+ // memory leak that was fixed in that version.
+ // https://bugzilla.gnome.org/show_bug.cgi?id=793067
+ enableGapBufferSupport = webkitGstCheckVersion(1, 12, 5);
}
~_WebKitWebAudioSrcPrivate()
@@ -318,7 +324,9 @@ static GRefPtr<GstBuffer> webKitWebAudio
// Attach audio meta on buffer.
GstAudioInfo info;
gst_audio_info_from_caps(&info, priv->caps.get());
+#if GST_CHECK_VERSION(1, 16, 0)
gst_buffer_add_audio_meta(buffer.get(), &info, priv->framesToPull, nullptr);
+#endif
GstMappedBuffer mappedBuffer(buffer.get(), GST_MAP_READWRITE);
ASSERT(mappedBuffer);
@@ -365,7 +373,7 @@ static void webKitWebAudioSrcRenderAndPu
GST_BUFFER_TIMESTAMP(buffer.get()) = outputTimestamp.position.nanoseconds();
GST_BUFFER_DURATION(buffer.get()) = duration;
- if (priv->bus->isSilent())
+ if (priv->enableGapBufferSupport && priv->bus->isSilent())
GST_BUFFER_FLAG_SET(buffer.get(), GST_BUFFER_FLAG_GAP);
// Leak the buffer ref, because gst_app_src_push_buffer steals it.
@@ -420,7 +428,9 @@ static GstStateChangeReturn webKitWebAud
auto* src = WEBKIT_WEB_AUDIO_SRC(element);
auto* priv = src->priv;
+#if GST_CHECK_VERSION(1, 14, 0)
GST_DEBUG_OBJECT(element, "%s", gst_state_change_get_name(transition));
+#endif
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h 2023-02-20 03:22:18.925743600 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h 2023-05-31 16:37:39.597519089 -0500
@@ -61,8 +61,10 @@ public:
const String& systemId() const { return m_systemId; }
String payloadContainerType() const
{
+#if GST_CHECK_VERSION(1, 16, 0)
if (m_systemId == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID ""_s)
return "webm"_s;
+#endif
return "cenc"_s;
}
@@ -111,8 +113,10 @@ public:
static constexpr auto s_WidevineKeySystem = "com.widevine.alpha"_s;
static constexpr auto s_PlayReadyUUID = WEBCORE_GSTREAMER_EME_UTILITIES_PLAYREADY_UUID ""_s;
static constexpr std::array<ASCIILiteral, 2> s_PlayReadyKeySystems = { "com.microsoft.playready"_s, "com.youtube.playready"_s };
+#if GST_CHECK_VERSION(1, 16, 0)
static constexpr auto s_unspecifiedUUID = GST_PROTECTION_UNSPECIFIED_SYSTEM_ID ""_s;
static constexpr auto s_unspecifiedKeySystem = GST_PROTECTION_UNSPECIFIED_SYSTEM_ID ""_s;
+#endif
static bool isClearKeyKeySystem(const String& keySystem)
{
@@ -144,6 +148,7 @@ public:
return equalIgnoringASCIICase(uuid, s_PlayReadyUUID);
}
+#if GST_CHECK_VERSION(1, 16, 0)
static bool isUnspecifiedKeySystem(const String& keySystem)
{
return equalIgnoringASCIICase(keySystem, s_unspecifiedKeySystem);
@@ -153,6 +158,7 @@ public:
{
return equalIgnoringASCIICase(uuid, s_unspecifiedUUID);
}
+#endif
static const char* keySystemToUuid(const String& keySystem)
{
@@ -165,8 +171,10 @@ public:
if (isPlayReadyKeySystem(keySystem))
return s_PlayReadyUUID;
+#if GST_CHECK_VERSION(1, 16, 0)
if (isUnspecifiedKeySystem(keySystem))
return s_unspecifiedUUID;
+#endif
ASSERT_NOT_REACHED();
return { };
@@ -183,8 +191,10 @@ public:
if (isPlayReadyUUID(uuid))
return s_PlayReadyKeySystems[0];
+#if GST_CHECK_VERSION(1, 16, 0)
if (isUnspecifiedUUID(uuid))
return s_unspecifiedKeySystem;
+#endif
ASSERT_NOT_REACHED();
return ""_s;
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp 2023-02-20 03:22:18.925743600 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp 2023-05-31 16:37:39.597519089 -0500
@@ -170,8 +170,11 @@ static GstCaps* transformCaps(GstBaseTra
// GST_PROTECTION_UNSPECIFIED_SYSTEM_ID was added in the GStreamer
// developement git master which will ship as version 1.16.0.
- gst_structure_set_name(outgoingStructure.get(), !g_strcmp0(klass->protectionSystemId(self),
- GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-webm-enc" : "application/x-cenc");
+ gst_structure_set_name(outgoingStructure.get(),
+#if GST_CHECK_VERSION(1, 16, 0)
+ !g_strcmp0(klass->protectionSystemId(self), GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-webm-enc" :
+#endif
+ "application/x-cenc");
}
}
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp 2023-02-20 03:22:18.893743500 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/GLVideoSinkGStreamer.cpp 2023-05-31 16:37:39.597519089 -0500
@@ -88,7 +88,25 @@ static void webKitGLVideoSinkConstructed
ASSERT(colorconvert);
gst_bin_add_many(GST_BIN_CAST(sink), upload, colorconvert, sink->priv->appSink.get(), nullptr);
- GRefPtr<GstCaps> caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) " GST_GL_CAPS_FORMAT));
+ // Workaround until we can depend on GStreamer 1.16.2.
+ // https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/commit/8d32de090554cf29fe359f83aa46000ba658a693
+ // Forcing a color conversion to RGBA here allows glupload to internally use
+ // an uploader that adds a VideoMeta, through the TextureUploadMeta caps
+ // feature, without needing the patch above. However this specific caps
+ // feature is going to be removed from GStreamer so it is considered a
+ // short-term workaround. This code path most likely will have a negative
+ // performance impact on embedded platforms as well. Downstream embedders
+ // are highly encouraged to cherry-pick the patch linked above in their BSP
+ // and set the WEBKIT_GST_NO_RGBA_CONVERSION environment variable until
+ // GStreamer 1.16.2 is released.
+ // See also https://bugs.webkit.org/show_bug.cgi?id=201422
+ GRefPtr<GstCaps> caps;
+ if (webkitGstCheckVersion(1, 16, 2) || getenv("WEBKIT_GST_NO_RGBA_CONVERSION"))
+ caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) " GST_GL_CAPS_FORMAT));
+ else {
+ GST_INFO_OBJECT(sink, "Forcing RGBA as GStreamer is not new enough.");
+ caps = adoptGRef(gst_caps_from_string("video/x-raw, format = (string) RGBA"));
+ }
gst_caps_set_features(caps.get(), 0, gst_caps_features_new(GST_CAPS_FEATURE_MEMORY_GL_MEMORY, nullptr));
g_object_set(sink->priv->appSink.get(), "caps", caps.get(), nullptr);
@@ -141,7 +159,11 @@ std::optional<GRefPtr<GstContext>> reque
if (!g_strcmp0(contextType, "gst.gl.app_context")) {
GRefPtr<GstContext> appContext = adoptGRef(gst_context_new("gst.gl.app_context", TRUE));
GstStructure* structure = gst_context_writable_structure(appContext.get());
+#if GST_CHECK_VERSION(1, 12, 0)
gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, gstGLContext, nullptr);
+#else
+ gst_structure_set(structure, "context", GST_GL_TYPE_CONTEXT, gstGLContext, nullptr);
+#endif
return appContext;
}
@@ -162,11 +184,15 @@ static bool setGLContext(GstElement* ele
static GstStateChangeReturn webKitGLVideoSinkChangeState(GstElement* element, GstStateChange transition)
{
+#if GST_CHECK_VERSION(1, 14, 0)
GST_DEBUG_OBJECT(element, "%s", gst_state_change_get_name(transition));
+#endif
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
+#if GST_CHECK_VERSION(1, 14, 0)
case GST_STATE_CHANGE_READY_TO_READY:
+#endif
case GST_STATE_CHANGE_READY_TO_PAUSED: {
if (!setGLContext(element, GST_GL_DISPLAY_CONTEXT_TYPE))
return GST_STATE_CHANGE_FAILURE;
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp 2023-02-20 03:22:18.893743500 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/GStreamerAudioMixer.cpp 2023-05-31 16:37:39.597519089 -0500
@@ -57,8 +57,9 @@ GStreamerAudioMixer::GStreamerAudioMixer
void GStreamerAudioMixer::ensureState(GstStateChange stateChange)
{
+#if GST_CHECK_VERSION(1, 14, 0)
GST_DEBUG_OBJECT(m_pipeline.get(), "Handling %s transition (%u mixer pads)", gst_state_change_get_name(stateChange), m_mixer->numsinkpads);
-
+#endif
switch (stateChange) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
gst_element_set_state(m_pipeline.get(), GST_STATE_PAUSED);
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp 2023-05-29 02:59:44.856173500 -0500
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp 2023-05-31 16:37:39.601519111 -0500
@@ -43,6 +43,7 @@
#include <wtf/Scope.h>
#include <wtf/glib/GUniquePtr.h>
#include <wtf/glib/RunLoopSourcePriority.h>
+#include <wtf/PrintStream.h>
#if USE(GSTREAMER_MPEGTS)
#define GST_USE_UNSTABLE_API
@@ -872,12 +873,14 @@ PlatformVideoColorSpace videoColorSpaceF
case GST_VIDEO_COLOR_PRIMARIES_SMPTE170M:
colorSpace.primaries = PlatformVideoColorPrimaries::Smpte170m;
break;
+#if GST_CHECK_VERSION(1, 16, 0)
case GST_VIDEO_COLOR_PRIMARIES_SMPTERP431:
colorSpace.primaries = PlatformVideoColorPrimaries::SmpteRp431;
break;
case GST_VIDEO_COLOR_PRIMARIES_SMPTEEG432:
colorSpace.primaries = PlatformVideoColorPrimaries::SmpteEg432;
break;
+#endif
case GST_VIDEO_COLOR_PRIMARIES_FILM:
colorSpace.primaries = PlatformVideoColorPrimaries::Film;
break;
@@ -887,9 +890,11 @@ PlatformVideoColorSpace videoColorSpaceF
case GST_VIDEO_COLOR_PRIMARIES_SMPTE240M:
colorSpace.primaries = PlatformVideoColorPrimaries::Smpte240m;
break;
+#if GST_CHECK_VERSION(1, 16, 0)
case GST_VIDEO_COLOR_PRIMARIES_EBU3213:
colorSpace.primaries = PlatformVideoColorPrimaries::JedecP22Phosphors;
break;
+#endif
case GST_VIDEO_COLOR_PRIMARIES_UNKNOWN:
colorSpace.primaries = PlatformVideoColorPrimaries::Unspecified;
break;
@@ -1004,12 +1009,14 @@ void fillVideoInfoColorimetryFromColorSp
case PlatformVideoColorPrimaries::Smpte170m:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE170M;
break;
+#if GST_CHECK_VERSION(1, 16, 0)
case PlatformVideoColorPrimaries::SmpteRp431:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTERP431;
break;
case PlatformVideoColorPrimaries::SmpteEg432:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTEEG432;
break;
+#endif
case PlatformVideoColorPrimaries::Film:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_FILM;
break;
@@ -1019,9 +1026,11 @@ void fillVideoInfoColorimetryFromColorSp
case PlatformVideoColorPrimaries::Smpte240m:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_SMPTE240M;
break;
+#if GST_CHECK_VERSION(1, 16, 0)
case PlatformVideoColorPrimaries::JedecP22Phosphors:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_EBU3213;
break;
+#endif
case PlatformVideoColorPrimaries::Unspecified:
GST_VIDEO_INFO_COLORIMETRY(info).primaries = GST_VIDEO_COLOR_PRIMARIES_UNKNOWN;
break;
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp 2023-05-29 02:59:44.856173500 -0500
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp 2023-05-31 16:37:39.601519111 -0500
@@ -272,9 +272,11 @@ void ImageDecoderGStreamer::storeDecoded
void ImageDecoderGStreamer::pushEncodedData(const FragmentedSharedBuffer& sharedBuffer)
{
+ gsize size;
auto data = sharedBuffer.makeContiguous();
auto bytes = data->createGBytes();
- auto buffer = adoptGRef(gst_buffer_new_wrapped_bytes(bytes.get()));
+ guint8 *bytes_data = (guint8 *) g_bytes_get_data (bytes.get(), &size);
+ auto buffer = adoptGRef(gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY, bytes_data, size, 0, size, g_bytes_ref (bytes.get()), (GDestroyNotify) g_bytes_unref));
m_eos = false;
m_error = false;
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2023-05-29 02:59:44.856173500 -0500
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2023-05-31 16:38:23.933753124 -0500
@@ -51,7 +51,6 @@
#include "InbandTextTrackPrivateGStreamer.h"
#include "TextCombinerGStreamer.h"
#include "TextSinkGStreamer.h"
-#include "VideoFrameMetadataGStreamer.h"
#include "VideoTrackPrivateGStreamer.h"
#if ENABLE(MEDIA_STREAM)
@@ -148,6 +147,14 @@ using namespace std;
static const FloatSize s_holePunchDefaultFrameSize(1280, 720);
#endif
+static void convertToInternalProtocol(URL& url)
+{
+ if (webkitGstCheckVersion(1, 12, 0))
+ return;
+ if (url.protocolIsInHTTPFamily() || url.protocolIsBlob())
+ url.setProtocol(makeString("webkit+", url.protocol()));
+}
+
static void initializeDebugCategory()
{
static std::once_flag onceFlag;
@@ -346,6 +353,7 @@ void MediaPlayerPrivateGStreamer::load(c
m_readyState = MediaPlayer::ReadyState::HaveNothing;
m_player->readyStateChanged();
m_areVolumeAndMuteInitialized = false;
+ m_hasTaintedOrigin = std::nullopt;
if (!m_isDelayingLoad)
commitLoad();
@@ -478,7 +486,9 @@ bool MediaPlayerPrivateGStreamer::doSeek
auto seekStart = toGstClockTime(startTime);
auto seekStop = toGstClockTime(endTime);
+#if GST_CHECK_VERSION(1, 18, 0)
GST_DEBUG_OBJECT(pipeline(), "[Seek] Performing actual seek to %" GST_TIMEP_FORMAT " (endTime: %" GST_TIMEP_FORMAT ") at rate %f", &seekStart, &seekStop, rate);
+#endif
return gst_element_seek(m_pipeline.get(), rate, GST_FORMAT_TIME, m_seekFlags, GST_SEEK_TYPE_SET, seekStart, GST_SEEK_TYPE_SET, seekStop);
}
@@ -834,6 +844,12 @@ unsigned long long MediaPlayerPrivateGSt
std::optional<bool> MediaPlayerPrivateGStreamer::isCrossOrigin(const SecurityOrigin& origin) const
{
+ // GStreamer < 1.12 has an incomplete uridownloader implementation so we
+ // can't use WebKitWebSrc for adaptive fragments downloading if this
+ // version is detected.
+ if (m_hasTaintedOrigin)
+ return true;
+
if (WEBKIT_IS_WEB_SRC(m_source.get()))
return webKitSrcIsCrossOrigin(WEBKIT_WEB_SRC(m_source.get()), origin);
return false;
@@ -933,6 +949,7 @@ void MediaPlayerPrivateGStreamer::setPla
cleanURLString = cleanURLString.left(url.pathEnd());
m_url = URL { cleanURLString };
+ convertToInternalProtocol(m_url);
GST_INFO_OBJECT(pipeline(), "Load %s", m_url.string().utf8().data());
g_object_set(m_pipeline.get(), "uri", m_url.string().utf8().data(), nullptr);
}
@@ -1891,6 +1908,7 @@ void MediaPlayerPrivateGStreamer::handle
GST_DEBUG_OBJECT(pipeline(), "Processing HTTP headers: %" GST_PTR_FORMAT, structure);
if (const char* uri = gst_structure_get_string(structure, "uri")) {
URL url { String::fromLatin1(uri) };
+ convertToInternalProtocol(m_url);
if (url != m_url) {
GST_DEBUG_OBJECT(pipeline(), "Ignoring HTTP response headers for non-main URI.");
@@ -1929,6 +1947,11 @@ void MediaPlayerPrivateGStreamer::handle
if (gst_structure_get(structure, "read-position", G_TYPE_UINT64, &m_networkReadPosition, "size", G_TYPE_UINT64, &m_httpResponseTotalSize, nullptr))
GST_LOG_OBJECT(pipeline(), "Updated network read position %" G_GUINT64_FORMAT ", size: %" G_GUINT64_FORMAT, m_networkReadPosition, m_httpResponseTotalSize);
} else if (gst_structure_has_name(structure, "GstCacheDownloadComplete")) {
+ } else if (gst_structure_has_name(structure, "adaptive-streaming-statistics")) {
+ if (WEBKIT_IS_WEB_SRC(m_source.get()) && !webkitGstCheckVersion(1, 12, 0)) {
+ if (const char* uri = gst_structure_get_string(structure, "uri"))
+ m_hasTaintedOrigin = webKitSrcIsCrossOrigin(WEBKIT_WEB_SRC_CAST(m_source.get()), SecurityOrigin::create(URL(URL(), String::fromLatin1(uri))));
+ }
GST_INFO_OBJECT(pipeline(), "Stream is fully downloaded, stopping monitoring downloading progress.");
m_fillTimer.stop();
m_bufferingPercentage = 100;
@@ -2138,6 +2161,7 @@ void MediaPlayerPrivateGStreamer::proces
processTableOfContentsEntry(static_cast<GstTocEntry*>(i->data));
}
+#if 0
void MediaPlayerPrivateGStreamer::configureElement(GstElement* element)
{
#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK)
@@ -2182,6 +2206,7 @@ void MediaPlayerPrivateGStreamer::config
if (!g_strcmp0(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstQueue2"))
g_object_set(G_OBJECT(element), "high-watermark", 0.10, nullptr);
}
+#endif
#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK)
void MediaPlayerPrivateGStreamer::configureElementPlatformQuirks(GstElement* element)
@@ -2853,8 +2878,34 @@ void MediaPlayerPrivateGStreamer::create
g_object_set(m_pipeline.get(), "mute", static_cast<gboolean>(m_player->muted()), nullptr);
- g_signal_connect(GST_BIN_CAST(m_pipeline.get()), "element-setup", G_CALLBACK(+[](GstBin*, GstElement* element, MediaPlayerPrivateGStreamer* player) {
- player->configureElement(element);
+ g_signal_connect(GST_BIN_CAST(m_pipeline.get()), "deep-element-added", G_CALLBACK(+[](GstBin*, GstBin* subBin, GstElement* element, MediaPlayerPrivateGStreamer* player) {
+ GUniquePtr<char> binName(gst_element_get_name(GST_ELEMENT_CAST(subBin)));
+ GUniquePtr<char> elementName(gst_element_get_name(element));
+
+ if (g_str_has_prefix(elementName.get(), "downloadbuffer")) {
+ player->configureDownloadBuffer(element);
+ return;
+ }
+
+ if (g_str_has_prefix(elementName.get(), "uridecodebin")) {
+ // This will set the multiqueue size to the default value.
+ g_object_set(element, "buffer-size", 2 * MB, nullptr);
+ return;
+ }
+
+ if (!g_str_has_prefix(binName.get(), "decodebin"))
+ return;
+
+ if (g_str_has_prefix(elementName.get(), "v4l2"))
+ player->m_videoDecoderPlatform = GstVideoDecoderPlatform::Video4Linux;
+ else if (g_str_has_prefix(elementName.get(), "imxvpudec"))
+ player->m_videoDecoderPlatform = GstVideoDecoderPlatform::ImxVPU;
+ else if (g_str_has_prefix(elementName.get(), "omx"))
+ player->m_videoDecoderPlatform = GstVideoDecoderPlatform::OpenMAX;
+
+#if USE(TEXTURE_MAPPER_GL)
+ player->updateTextureMapperFlags();
+#endif
}), this);
g_signal_connect_swapped(m_pipeline.get(), "source-setup", G_CALLBACK(sourceSetupCallback), this);
@@ -2913,6 +2964,7 @@ void MediaPlayerPrivateGStreamer::config
g_object_set(depayloader, "wait-for-keyframe", TRUE, nullptr);
}
+#if 0
void MediaPlayerPrivateGStreamer::configureVideoDecoder(GstElement* decoder)
{
GUniquePtr<char> name(gst_element_get_name(decoder));
@@ -2974,6 +3026,7 @@ void MediaPlayerPrivateGStreamer::config
return GST_PAD_PROBE_OK;
}, this, nullptr);
}
+#endif
bool MediaPlayerPrivateGStreamer::didPassCORSAccessCheck() const
{
@@ -3092,8 +3145,6 @@ void MediaPlayerPrivateGStreamer::pushTe
if (!GST_IS_SAMPLE(m_sample.get()))
return;
- ++m_sampleCount;
-
auto internalCompositingOperation = [this](TextureMapperPlatformLayerProxyGL& proxy, std::unique_ptr<GstVideoFrameHolder>&& frameHolder) {
std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer;
if (frameHolder->hasMappedTextures()) {
@@ -3230,8 +3281,6 @@ void MediaPlayerPrivateGStreamer::pushDM
}
}
- ++m_sampleCount;
-
auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy();
ASSERT(is<TextureMapperPlatformLayerProxyDMABuf>(proxy));
@@ -3676,7 +3725,7 @@ void MediaPlayerPrivateGStreamer::flushC
{
Locker sampleLocker { m_sampleMutex };
- if (m_sample && gst_sample_get_buffer(m_sample.get())) {
+ if (m_sample) {
// Allocate a new copy of the sample which has to be released. The copy is necessary so that
// the video dimensions can still be fetched and also for canvas rendering. The release is
// necessary because the sample might have been allocated by a hardware decoder and memory
@@ -4313,6 +4362,7 @@ WTFLogChannel& MediaPlayerPrivateGStream
}
#endif
+#if 0
std::optional<VideoFrameMetadata> MediaPlayerPrivateGStreamer::videoFrameMetadata()
{
if (m_sampleCount == m_lastVideoFrameMetadataSampleCount)
@@ -4337,6 +4387,7 @@ std::optional<VideoFrameMetadata> MediaP
return metadata;
}
+#endif
static bool areAllSinksPlayingForBin(GstBin* bin)
{
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2023-05-29 02:59:44.860173700 -0500
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2023-05-31 16:37:39.605519131 -0500
@@ -54,6 +54,16 @@ typedef struct _GstMpegtsSection GstMpeg
#if USE(LIBEPOXY)
// Include the <epoxy/gl.h> header before <gst/gl/gl.h>.
#include <epoxy/gl.h>
+
+// Workaround build issue with RPi userland GLESv2 headers and libepoxy <https://webkit.org/b/185639>
+#if !GST_CHECK_VERSION(1, 14, 0)
+#include <gst/gl/gstglconfig.h>
+#if defined(GST_GL_HAVE_WINDOW_DISPMANX) && GST_GL_HAVE_WINDOW_DISPMANX
+#define __gl2_h_
+#undef GST_GL_HAVE_GLSYNC
+#define GST_GL_HAVE_GLSYNC 1
+#endif
+#endif // !GST_CHECK_VERSION(1, 14, 0)
#endif // USE(LIBEPOXY)
#define GST_USE_UNSTABLE_API
@@ -492,7 +502,6 @@ private:
static void downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer*);
void configureDepayloader(GstElement*);
- void configureVideoDecoder(GstElement*);
void configureElement(GstElement*);
#if PLATFORM(BROADCOM) || USE(WESTEROS_SINK)
void configureElementPlatformQuirks(GstElement*);
@@ -587,6 +596,8 @@ private:
uint64_t m_networkReadPosition { 0 };
mutable uint64_t m_readPositionAtLastDidLoadingProgress { 0 };
+ std::optional<bool> m_hasTaintedOrigin { std::nullopt };
+
GRefPtr<GstElement> m_fpsSink { nullptr };
uint64_t m_totalVideoFrames { 0 };
uint64_t m_droppedVideoFrames { 0 };
@@ -595,9 +606,6 @@ private:
DataMutex<TaskAtMediaTimeScheduler> m_TaskAtMediaTimeSchedulerDataMutex;
private:
- std::optional<VideoFrameMetadata> videoFrameMetadata() final;
- uint64_t m_sampleCount { 0 };
- uint64_t m_lastVideoFrameMetadataSampleCount { 0 };
#if USE(WPE_VIDEO_PLANE_DISPLAY_DMABUF)
GUniquePtr<struct wpe_video_plane_display_dmabuf_source> m_wpeVideoPlaneDisplayDmaBuf;
#endif
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp 2023-02-20 03:22:18.917743700 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/PlatformDisplayGStreamer.cpp 2023-05-31 16:37:39.605519131 -0500
@@ -93,11 +93,19 @@ bool PlatformDisplay::tryEnsureGstGLCont
return false;
GstGLPlatform glPlatform = sharedContext->isEGLContext() ? GST_GL_PLATFORM_EGL : GST_GL_PLATFORM_GLX;
- m_gstGLDisplay = adoptGRef(createGstGLDisplay(*this, glPlatform));
+ bool shouldAdoptRef = webkitGstCheckVersion(1, 14, 0);
+
+ if (shouldAdoptRef)
+ m_gstGLDisplay = adoptGRef(createGstGLDisplay(*this, glPlatform));
+ else
+ m_gstGLDisplay = createGstGLDisplay(*this, glPlatform);
if (!m_gstGLDisplay)
return false;
- m_gstGLContext = adoptGRef(gst_gl_context_new_wrapped(m_gstGLDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI));
+ if (shouldAdoptRef)
+ m_gstGLContext = adoptGRef(gst_gl_context_new_wrapped(m_gstGLDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI));
+ else
+ m_gstGLContext = gst_gl_context_new_wrapped(m_gstGLDisplay.get(), reinterpret_cast<guintptr>(contextHandle), glPlatform, glAPI);
// Activate and fill the GStreamer wrapped context with the Webkit's shared one.
auto* previousActiveContext = GLContext::current();
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp 2023-05-29 02:59:44.860173700 -0500
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/VideoFrameGStreamer.cpp 2023-05-31 16:37:39.605519131 -0500
@@ -39,6 +39,7 @@
#if USE(GSTREAMER_GL)
#include <gst/gl/gstglcolorconvert.h>
+#include <gst/gl/gl.h>
#include <gst/gl/gstglmemory.h>
#endif
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp 2023-02-20 03:22:18.925743600 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp 2023-05-31 16:37:39.609519153 -0500
@@ -256,7 +256,9 @@ static GstStateChangeReturn webKitAudioS
auto* sink = WEBKIT_AUDIO_SINK(element);
auto* priv = sink->priv;
+#if GST_CHECK_VERSION(1, 14, 0)
GST_DEBUG_OBJECT(sink, "Handling %s transition", gst_state_change_get_name(stateChange));
+#endif
auto& mixer = GStreamerAudioMixer::singleton();
if (priv->interAudioSink && stateChange == GST_STATE_CHANGE_NULL_TO_READY)
diff -urp webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
--- webkitgtk-2.40.2.orig/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp 2023-02-20 03:22:18.925743600 -0600
+++ webkitgtk-2.40.2/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp 2023-05-31 16:37:39.609519153 -0500
@@ -468,8 +468,12 @@ static GstFlowReturn webKitWebSrcCreate(
// 1) webKitWebSrcSetMediaPlayer() is called by MediaPlayerPrivateGStreamer by means of hooking playbin's
// "source-setup" event. This doesn't work for additional WebKitWebSrc elements created by adaptivedemux.
//
- // 2) A GstContext query made here.
- if (!members->player) {
+ // 2) A GstContext query made here. Because of a bug, this only works in GStreamer >= 1.12.
+ //
+ // As a compatibility workaround, the http: URI protocol is only registered for gst>=1.12; otherwise using
+ // webkit+http:, which is used by MediaPlayerPrivateGStreamer but not by adaptivedemux's additional source
+ // elements, therefore using souphttpsrc instead and not routing traffic through the NetworkProcess.
+ if (webkitGstCheckVersion(1, 12, 0) && !members->player) {
members.runUnlocked([src, baseSrc]() {
GRefPtr<GstQuery> query = adoptGRef(gst_query_new_context(WEBKIT_WEB_SRC_PLAYER_CONTEXT_TYPE_NAME));
if (gst_pad_peer_query(GST_BASE_SRC_PAD(baseSrc), query.get())) {
@@ -871,16 +875,27 @@ static GstURIType webKitWebSrcUriGetType
const gchar* const* webKitWebSrcGetProtocols(GType)
{
static const char* protocols[4];
- protocols[0] = "http";
- protocols[1] = "https";
- protocols[2] = "blob";
+ if (webkitGstCheckVersion(1, 12, 0)) {
+ protocols[0] = "http";
+ protocols[1] = "https";
+ protocols[2] = "blob";
+ } else {
+ protocols[0] = "webkit+http";
+ protocols[1] = "webkit+https";
+ protocols[2] = "webkit+blob";
+ }
protocols[3] = nullptr;
return protocols;
}
static URL convertPlaybinURI(const char* uriString)
{
- return URL { String::fromLatin1(uriString) };
+ URL url { String::fromLatin1(uriString) };
+ if (!webkitGstCheckVersion(1, 12, 0)) {
+ ASSERT(url.protocol().substring(0, 7) == "webkit+");
+ url.setProtocol(url.protocol().substring(7).toString());
+ }
+ return url;
}
static gchar* webKitWebSrcGetUri(GstURIHandler* handler)