music / rpms / opencv

Forked from rpms/opencv 2 years ago
Clone
Blob Blame History Raw
From 6d66d11046bb526d508e9543ecc37cfee91f4435 Mon Sep 17 00:00:00 2001
From: Dirk Van Haerenborgh <dirk.vanhaerenborgh@hogent.be>
Date: Wed, 12 Jun 2013 16:58:16 +0200
Subject: [PATCH 0865/3152] gstreamer: cleaning up resources

---
 modules/highgui/src/cap_gstreamer.cpp | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp
index b8f4eb8..a347a74 100644
--- a/modules/highgui/src/cap_gstreamer.cpp
+++ b/modules/highgui/src/cap_gstreamer.cpp
@@ -1030,6 +1030,19 @@ void CvVideoWriter_GStreamer::close()
         handleMessage(pipeline);
 
         gst_object_unref (GST_OBJECT (pipeline));
+
+        if (source)
+          gst_object_unref (GST_OBJECT (source));
+
+        if (encodebin)
+          gst_object_unref (GST_OBJECT (encodebin));
+
+        if (file)
+          gst_object_unref (GST_OBJECT (file));
+
+        if (buffer)
+          gst_object_unref (GST_OBJECT (buffer));
+
     }
 }
 
@@ -1155,6 +1168,35 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
             source = gst_bin_get_by_name(GST_BIN(encodebin), "appsrc0");
         }
 
+//        GstIterator *it = gst_bin_iterate_sources (GST_BIN(encodebin));
+
+
+//        gboolean done = FALSE;
+//        GstElement *item = NULL;
+
+//        while (!done) {
+//          switch (gst_iterator_next (it, &item)) {
+//            case GST_ITERATOR_OK:
+//              source = item;
+//              gst_object_unref (item);
+//              done = TRUE;
+//              break;
+//            case GST_ITERATOR_RESYNC:
+//              gst_iterator_resync (it);
+//              break;
+//            case GST_ITERATOR_ERROR:
+//              done = TRUE;
+//              break;
+//            case GST_ITERATOR_DONE:
+//              done = TRUE;
+//              break;
+//          }
+//        }
+//        gst_iterator_free (it);
+
+
+
+
         if (!source){
             CV_ERROR(CV_StsError, "GStreamer: cannot find appsrc in manual pipeline\n");
             return false;
-- 
1.9.3