summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Blechmann <tim@klingt.org>2024-03-28 09:18:28 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-03-29 06:25:35 +0000
commit0e6cf74be5014b4ab0a32600f164df6d871b190e (patch)
tree7451d5988addadc8f155b8fbc77d60a2ebee283c
parenta8e366d222f46c014246c8b0292403f439ef18d3 (diff)
GStreamer: make all reference counting explicit
When constructing a wrapper object from a gstreamer pointer, we should always use the explicit reference counting argument. Pick-to: 6.5 Change-Id: I1a5d589ea48e242b4350ef237312b9e85828c870 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> (cherry picked from commit 157185521ddf4d1ebeefcdd3ebc82319dd88f786) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit ee4776f5c3ea153ec2ca489b2a45032ea5083896)
-rw-r--r--src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder.cpp3
-rw-r--r--src/plugins/multimedia/gstreamer/common/qgst.cpp4
-rw-r--r--src/plugins/multimedia/gstreamer/common/qgst_p.h14
-rw-r--r--src/plugins/multimedia/gstreamer/common/qgstreamermediaplayer.cpp4
-rw-r--r--src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp2
-rw-r--r--src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp6
-rw-r--r--src/plugins/multimedia/gstreamer/mediacapture/qgstreamercamera_p.h2
-rw-r--r--src/plugins/multimedia/gstreamer/mediacapture/qgstreamerimagecapture_p.h2
8 files changed, 22 insertions, 15 deletions
diff --git a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder.cpp b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder.cpp
index d286ceb3a..9c1983d7a 100644
--- a/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder.cpp
+++ b/src/plugins/multimedia/gstreamer/audio/qgstreameraudiodecoder.cpp
@@ -100,7 +100,8 @@ void QGstreamerAudioDecoder::configureAppSrcElement(GObject* object, GObject *or
g_object_get(orig, "source", &appsrc, NULL);
auto *qAppSrc = self->appsrc();
- qAppSrc->setExternalAppSrc(QGstElement(appsrc.get())); // CHECK: can we `release()`?
+ qAppSrc->setExternalAppSrc(
+ QGstElement(appsrc.get(), QGstElement::NeedsRef)); // CHECK: can we `release()`?
qAppSrc->setup(self->mDevice);
}
#endif
diff --git a/src/plugins/multimedia/gstreamer/common/qgst.cpp b/src/plugins/multimedia/gstreamer/common/qgst.cpp
index 0aafd6499..292ce5e25 100644
--- a/src/plugins/multimedia/gstreamer/common/qgst.cpp
+++ b/src/plugins/multimedia/gstreamer/common/qgst.cpp
@@ -698,7 +698,9 @@ bool QGstPad::sendEvent(GstEvent *event)
// QGstClock
-QGstClock::QGstClock(const QGstObject &o) : QGstClock(GST_CLOCK(o.object())) { }
+QGstClock::QGstClock(const QGstObject &o) : QGstClock(GST_CLOCK(o.object()), QGstElement::NeedsRef)
+{
+}
QGstClock::QGstClock(GstClock *clock, RefMode mode) : QGstObject(&clock->object, mode) { }
diff --git a/src/plugins/multimedia/gstreamer/common/qgst_p.h b/src/plugins/multimedia/gstreamer/common/qgst_p.h
index 5db195c17..efd19edaa 100644
--- a/src/plugins/multimedia/gstreamer/common/qgst_p.h
+++ b/src/plugins/multimedia/gstreamer/common/qgst_p.h
@@ -377,7 +377,7 @@ public:
QGstPad(QGstPad &&) noexcept = default;
explicit QGstPad(const QGstObject &o);
- explicit QGstPad(GstPad *pad, RefMode mode = NeedsRef);
+ explicit QGstPad(GstPad *pad, RefMode mode);
QGstPad &operator=(const QGstPad &) = default;
QGstPad &operator=(QGstPad &&) noexcept = default;
@@ -448,7 +448,7 @@ class QGstClock : public QGstObject
public:
QGstClock() = default;
explicit QGstClock(const QGstObject &o);
- explicit QGstClock(GstClock *clock, RefMode mode = NeedsRef);
+ explicit QGstClock(GstClock *clock, RefMode mode);
GstClock *clock() const;
GstClockTime time() const;
@@ -466,7 +466,7 @@ public:
QGstElement &operator=(const QGstElement &) = default;
QGstElement &operator=(QGstElement &&) noexcept = default;
- explicit QGstElement(GstElement *element, RefMode mode = NeedsRef);
+ explicit QGstElement(GstElement *element, RefMode mode);
static QGstElement createFromFactory(const char *factory, const char *name = nullptr);
static QGstElement createFromDevice(const QGstDeviceHandle &, const char *name = nullptr);
static QGstElement createFromDevice(GstDevice *, const char *name = nullptr);
@@ -493,7 +493,8 @@ public:
void onPadAdded(T *instance) {
struct Impl {
static void callback(GstElement *e, GstPad *pad, gpointer userData) {
- (static_cast<T *>(userData)->*Member)(QGstElement(e), QGstPad(pad, NeedsRef));
+ (static_cast<T *>(userData)->*Member)(QGstElement(e, NeedsRef),
+ QGstPad(pad, NeedsRef));
};
};
@@ -503,7 +504,8 @@ public:
void onPadRemoved(T *instance) {
struct Impl {
static void callback(GstElement *e, GstPad *pad, gpointer userData) {
- (static_cast<T *>(userData)->*Member)(QGstElement(e), QGstPad(pad, NeedsRef));
+ (static_cast<T *>(userData)->*Member)(QGstElement(e, NeedsRef),
+ QGstPad(pad, NeedsRef));
};
};
@@ -513,7 +515,7 @@ public:
void onNoMorePads(T *instance) {
struct Impl {
static void callback(GstElement *e, gpointer userData) {
- (static_cast<T *>(userData)->*Member)(QGstElement(e));
+ (static_cast<T *>(userData)->*Member)(QGstElement(e, NeedsRef));
};
};
diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamermediaplayer.cpp b/src/plugins/multimedia/gstreamer/common/qgstreamermediaplayer.cpp
index e08319e03..19fffc082 100644
--- a/src/plugins/multimedia/gstreamer/common/qgstreamermediaplayer.cpp
+++ b/src/plugins/multimedia/gstreamer/common/qgstreamermediaplayer.cpp
@@ -610,7 +610,7 @@ void QGstreamerMediaPlayer::uridecodebinElementAddedCallback(GstElement * /*urid
GstElement *child,
QGstreamerMediaPlayer *)
{
- QGstElement c(child);
+ QGstElement c(child, QGstElement::NeedsRef);
qCDebug(qLcMediaPlayer) << "New element added to uridecodebin:" << c.name();
static const GType decodeBinType = [] {
@@ -634,7 +634,7 @@ void QGstreamerMediaPlayer::sourceSetupCallback(GstElement *uridecodebin, GstEle
qCDebug(qLcMediaPlayer) << "Setting up source:" << g_type_name_from_instance((GTypeInstance*)source);
if (std::string_view("GstRTSPSrc") == g_type_name_from_instance((GTypeInstance *)source)) {
- QGstElement s(source);
+ QGstElement s(source, QGstElement::NeedsRef);
int latency{40};
bool ok{false};
int v = qEnvironmentVariableIntValue("QT_MEDIA_RTSP_LATENCY", &ok);
diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp b/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
index 96a9dfead..e5041bdab 100644
--- a/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
+++ b/src/plugins/multimedia/gstreamer/common/qgstreamervideooverlay.cpp
@@ -72,7 +72,7 @@ static QGstElement findBestVideoSink()
if (!gst_element_factory_has_interface(f, "GstVideoOverlay"))
continue;
- choice = QGstElement(gst_element_factory_create(f, nullptr));
+ choice = QGstElement(gst_element_factory_create(f, nullptr), QGstElement::NeedsRef);
if (choice.isNull())
continue;
diff --git a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp
index 6f5d71106..a4268db34 100644
--- a/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp
+++ b/src/plugins/multimedia/gstreamer/common/qgstreamervideosink.cpp
@@ -114,7 +114,8 @@ QGstreamerVideoSink::QGstreamerVideoSink(QVideoSink *parent)
}
sinkBin.addGhostPad(gstQueue, "sink");
- gstSubtitleSink = QGstElement(GST_ELEMENT(QGstSubtitleSink::createSink(this)));
+ gstSubtitleSink =
+ QGstElement(GST_ELEMENT(QGstSubtitleSink::createSink(this)), QGstElement::NeedsRef);
}
QGstreamerVideoSink::~QGstreamerVideoSink()
@@ -163,7 +164,8 @@ void QGstreamerVideoSink::createQtSink()
if (gstQtSink)
gstQtSink.setStateSync(GST_STATE_NULL);
- gstQtSink = QGstElement(reinterpret_cast<GstElement *>(QGstVideoRendererSink::createSink(this)));
+ gstQtSink = QGstElement(reinterpret_cast<GstElement *>(QGstVideoRendererSink::createSink(this)),
+ QGstElement::NeedsRef);
}
void QGstreamerVideoSink::updateSinkElement()
diff --git a/src/plugins/multimedia/gstreamer/mediacapture/qgstreamercamera_p.h b/src/plugins/multimedia/gstreamer/mediacapture/qgstreamercamera_p.h
index 59d69337f..a85180595 100644
--- a/src/plugins/multimedia/gstreamer/mediacapture/qgstreamercamera_p.h
+++ b/src/plugins/multimedia/gstreamer/mediacapture/qgstreamercamera_p.h
@@ -39,7 +39,7 @@ public:
bool setCameraFormat(const QCameraFormat &format) override;
void setPipeline(const QGstPipeline &);
- QGstElement gstElement() const { return QGstElement(gstCameraBin.element()); }
+ QGstElement gstElement() const { return gstCameraBin; }
#if QT_CONFIG(gstreamer_photography)
GstPhotography *photography() const;
#endif
diff --git a/src/plugins/multimedia/gstreamer/mediacapture/qgstreamerimagecapture_p.h b/src/plugins/multimedia/gstreamer/mediacapture/qgstreamerimagecapture_p.h
index 7db576023..3d8636cbe 100644
--- a/src/plugins/multimedia/gstreamer/mediacapture/qgstreamerimagecapture_p.h
+++ b/src/plugins/multimedia/gstreamer/mediacapture/qgstreamerimagecapture_p.h
@@ -46,7 +46,7 @@ public:
void setCaptureSession(QPlatformMediaCaptureSession *session);
- QGstElement gstElement() const { return QGstElement{ bin.element() }; }
+ QGstElement gstElement() const { return bin; }
public Q_SLOTS:
void cameraActiveChanged(bool active);