Skip to content

Commit 6d66d11

Browse files
author
Dirk Van Haerenborgh
committed
gstreamer: cleaning up resources
1 parent 1acbc7b commit 6d66d11

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

modules/highgui/src/cap_gstreamer.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,19 @@ void CvVideoWriter_GStreamer::close()
10301030
handleMessage(pipeline);
10311031

10321032
gst_object_unref (GST_OBJECT (pipeline));
1033+
1034+
if (source)
1035+
gst_object_unref (GST_OBJECT (source));
1036+
1037+
if (encodebin)
1038+
gst_object_unref (GST_OBJECT (encodebin));
1039+
1040+
if (file)
1041+
gst_object_unref (GST_OBJECT (file));
1042+
1043+
if (buffer)
1044+
gst_object_unref (GST_OBJECT (buffer));
1045+
10331046
}
10341047
}
10351048

@@ -1155,6 +1168,35 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
11551168
source = gst_bin_get_by_name(GST_BIN(encodebin), "appsrc0");
11561169
}
11571170

1171+
// GstIterator *it = gst_bin_iterate_sources (GST_BIN(encodebin));
1172+
1173+
1174+
// gboolean done = FALSE;
1175+
// GstElement *item = NULL;
1176+
1177+
// while (!done) {
1178+
// switch (gst_iterator_next (it, &item)) {
1179+
// case GST_ITERATOR_OK:
1180+
// source = item;
1181+
// gst_object_unref (item);
1182+
// done = TRUE;
1183+
// break;
1184+
// case GST_ITERATOR_RESYNC:
1185+
// gst_iterator_resync (it);
1186+
// break;
1187+
// case GST_ITERATOR_ERROR:
1188+
// done = TRUE;
1189+
// break;
1190+
// case GST_ITERATOR_DONE:
1191+
// done = TRUE;
1192+
// break;
1193+
// }
1194+
// }
1195+
// gst_iterator_free (it);
1196+
1197+
1198+
1199+
11581200
if (!source){
11591201
CV_ERROR(CV_StsError, "GStreamer: cannot find appsrc in manual pipeline\n");
11601202
return false;

0 commit comments

Comments
 (0)