1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
* Copyright (C) 2024 Igalia S.L
* Copyright (C) 2024 Metrological Group B.V.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* aint with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "GStreamerQuirkWesteros.h"
#if USE(GSTREAMER)
#include "GStreamerCommon.h"
#include <wtf/OptionSet.h>
namespace WebCore {
GST_DEBUG_CATEGORY_STATIC(webkit_westeros_quirks_debug);
#define GST_CAT_DEFAULT webkit_westeros_quirks_debug
GStreamerQuirkWesteros::GStreamerQuirkWesteros()
{
GST_DEBUG_CATEGORY_INIT(webkit_westeros_quirks_debug, "webkitquirkswesteros", 0, "WebKit Westeros Quirks");
auto westerosFactory = adoptGRef(gst_element_factory_find("westerossink"));
if (UNLIKELY(!westerosFactory))
return;
gst_object_unref(gst_plugin_feature_load(GST_PLUGIN_FEATURE(westerosFactory.get())));
for (auto* t = gst_element_factory_get_static_pad_templates(westerosFactory.get()); t; t = g_list_next(t)) {
auto* padtemplate = static_cast<GstStaticPadTemplate*>(t->data);
if (padtemplate->direction != GST_PAD_SINK)
continue;
if (m_sinkCaps)
m_sinkCaps = adoptGRef(gst_caps_merge(m_sinkCaps.leakRef(), gst_static_caps_get(&padtemplate->static_caps)));
else
m_sinkCaps = adoptGRef(gst_static_caps_get(&padtemplate->static_caps));
}
}
void GStreamerQuirkWesteros::configureElement(GstElement* element, const OptionSet<ElementRuntimeCharacteristics>& characteristics)
{
auto view = StringView::fromLatin1(GST_ELEMENT_NAME(element));
if (view.startsWith("uridecodebin3"_s)) {
GRefPtr<GstCaps> defaultCaps;
g_object_get(element, "caps", &defaultCaps.outPtr(), nullptr);
defaultCaps = adoptGRef(gst_caps_merge(gst_caps_ref(m_sinkCaps.get()), defaultCaps.leakRef()));
GST_INFO("Setting stop caps to %" GST_PTR_FORMAT, defaultCaps.get());
g_object_set(element, "caps", defaultCaps.get(), nullptr);
return;
}
if (!characteristics.contains(ElementRuntimeCharacteristics::IsMediaStream))
return;
if (!g_strcmp0(G_OBJECT_TYPE_NAME(G_OBJECT(element)), "GstWesterosSink") && gstObjectHasProperty(element, "immediate-output")) {
GST_INFO("Enable 'immediate-output' in WesterosSink");
g_object_set(element, "immediate-output", TRUE, nullptr);
}
}
std::optional<bool> GStreamerQuirkWesteros::isHardwareAccelerated(GstElementFactory* factory)
{
auto view = StringView::fromLatin1(GST_OBJECT_NAME(factory));
if (view.startsWith("westeros"_s))
return true;
return std::nullopt;
}
#undef GST_CAT_DEFAULT
} // namespace WebCore
#endif // USE(GSTREAMER)
|