diff options
author | Piotr Srebrny <piotr.srebrny@qt.io> | 2022-09-07 15:08:58 +0200 |
---|---|---|
committer | Piotr Srebrny <piotr.srebrny@qt.io> | 2022-10-10 09:53:52 +0200 |
commit | bf4e6b506583170f1f86eb408ab01b5846b7a96d (patch) | |
tree | 3fa98757619bcb2186664311d08486d62d06fa5e /src/plugins/multimedia/gstreamer/common/qgst_p.h | |
parent | 6fae541a2015c329942f6c2a96fc3b1de3f14a7a (diff) |
Validate that gstreamer elements necessary for operation are available
This patch validates that all elements that are necessary to run
the requested functionality are available. Instead of running
constructors directly, the patch uses a static create() function for
each class. This function first tries to instantiate all necessary
GStreamer plugins and then pass them to the class constructor.
If some element is missing the function returns an error message
describing the element.
Pick-to: 6.4
Fixes: QTBUG-106257
Change-Id: I2b9db3f509e9ad5b760fcc251e634a01c687b790
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Diffstat (limited to 'src/plugins/multimedia/gstreamer/common/qgst_p.h')
-rw-r--r-- | src/plugins/multimedia/gstreamer/common/qgst_p.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/plugins/multimedia/gstreamer/common/qgst_p.h b/src/plugins/multimedia/gstreamer/common/qgst_p.h index 40897ad9d..ec2f9cb58 100644 --- a/src/plugins/multimedia/gstreamer/common/qgst_p.h +++ b/src/plugins/multimedia/gstreamer/common/qgst_p.h @@ -290,6 +290,8 @@ public: gst_object_unref(m_object); } + explicit operator bool() const { return bool(m_object); } + friend bool operator==(const QGstObject &a, const QGstObject &b) { return a.m_object == b.m_object; } friend bool operator!=(const QGstObject &a, const QGstObject &b) @@ -430,6 +432,10 @@ public: QGstElement(const char *factory, const char *name = nullptr) : QGstElement(gst_element_factory_make(factory, name), NeedsRef) { +#ifndef QT_NO_DEBUG + if (!m_object) + qWarning() << "Failed to make element" << name << "from factory" << factory; +#endif } bool linkFiltered(const QGstElement &next, const QGstMutableCaps &caps) @@ -595,6 +601,11 @@ inline QGstCaps QGValue::toCaps() const return QGstCaps(gst_value_get_caps(value)); } +inline QString errorMessageCannotFindElement(std::string_view element) +{ + return QStringLiteral("Could not find the %1 GStreamer element").arg(element.data()); +} + QT_END_NAMESPACE #endif |