backport support for GStreamer 1 (#1123078)

epel9
Rex Dieter 11 years ago
parent 3b2f2d33a9
commit 053e3d73ad

@ -0,0 +1,39 @@
From 921675c4e233d8f9e78786550d549e9e05ffeb2a Mon Sep 17 00:00:00 2001
From: Dirk Van Haerenborgh <vhdirk@gmail.com>
Date: Thu, 21 Mar 2013 16:11:53 +0100
Subject: [PATCH 0552/3152] eliminated warnings
---
modules/highgui/src/cap_gstreamer.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp
index b1a2ca0..9ef0a3f 100644
--- a/modules/highgui/src/cap_gstreamer.cpp
+++ b/modules/highgui/src/cap_gstreamer.cpp
@@ -83,7 +83,8 @@ static cv::Mutex gst_initializer_mutex;
/*!
* \brief The gst_initializer class
* Initializes gstreamer once in the whole process
- */class gst_initializer
+ */
+class gst_initializer
{
public:
static void init()
@@ -1007,9 +1008,9 @@ void CvVideoWriter_GStreamer::init()
*/
void CvVideoWriter_GStreamer::close()
{
- if (pipeline) {
- GstFlowReturn ret;
- ret = gst_app_src_end_of_stream(GST_APP_SRC(source));
+ if (pipeline)
+ {
+ gst_app_src_end_of_stream(GST_APP_SRC(source));
//wait for EOS to trickle down the pipeline. This will let all elements finish properly
GstBus* bus = gst_element_get_bus(pipeline);
--
1.9.3

@ -0,0 +1,100 @@
From 6377922716f37b00e4f8f5eab87a8fbcb16422e5 Mon Sep 17 00:00:00 2001
From: Andrey Kamaev <andrey.kamaev@itseez.com>
Date: Tue, 26 Mar 2013 12:27:39 +0400
Subject: [PATCH 0587/3152] Fix build with gstreamer 0.10.28
---
modules/highgui/src/cap_gstreamer.cpp | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp
index 9ef0a3f..b8c7f4f 100644
--- a/modules/highgui/src/cap_gstreamer.cpp
+++ b/modules/highgui/src/cap_gstreamer.cpp
@@ -56,9 +56,15 @@
#include <gst/app/gstappsink.h>
#include <gst/app/gstappsrc.h>
#include <gst/riff/riff-media.h>
-#include <gst/pbutils/encoding-profile.h>
#include <gst/pbutils/missing-plugins.h>
+
+#define VERSION_NUM(major, minor, micro) (major * 1000000 + minor * 1000 + micro)
+#define FULL_GST_VERSION VERSION_NUM(GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO)
+
+#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
+#include <gst/pbutils/encoding-profile.h>
//#include <gst/base/gsttypefindhelper.h>
+#endif
#ifdef NDEBUG
@@ -1114,9 +1120,12 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
GstCaps* caps = NULL;
GstCaps* videocaps = NULL;
+
+#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
GstCaps* containercaps = NULL;
GstEncodingContainerProfile* containerprofile = NULL;
GstEncodingVideoProfile* videoprofile = NULL;
+#endif
#if GST_VERSION_MAJOR == 0
GstIterator *it = NULL;
@@ -1178,16 +1187,21 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
if (!mime) {
CV_ERROR( CV_StsUnsupportedFormat, "Gstreamer Opencv backend does not support this file type.");
}
+
+#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
containercaps = gst_caps_from_string(mime);
//create encodebin profile
containerprofile = gst_encoding_container_profile_new("container", "container", containercaps, NULL);
videoprofile = gst_encoding_video_profile_new(videocaps, NULL, NULL, 1);
gst_encoding_container_profile_add_profile(containerprofile, (GstEncodingProfile *) videoprofile);
+#endif
//create pipeline elements
encodebin = gst_element_factory_make("encodebin", NULL);
+#if FULL_GST_VERSION >= VERSION_NUM(0,10,32)
g_object_set(G_OBJECT(encodebin), "profile", containerprofile, NULL);
+#endif
source = gst_element_factory_make("appsrc", NULL);
file = gst_element_factory_make("filesink", NULL);
g_object_set(G_OBJECT(file), "location", filename, NULL);
@@ -1218,6 +1232,7 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
}
else
{
+#if FULL_GST_VERSION >= VERSION_NUM(0,10,29)
input_pix_fmt = GST_VIDEO_FORMAT_GRAY8;
bufsize = frameSize.width * frameSize.height;
@@ -1236,6 +1251,9 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
NULL);
caps = gst_caps_fixate(caps);
#endif
+#else
+ CV_Assert(!"Gstreamer 0.10.29 or newer is required for grayscale input");
+#endif
}
gst_app_src_set_caps(GST_APP_SRC(source), caps);
@@ -1296,11 +1314,13 @@ bool CvVideoWriter_GStreamer::writeFrame( const IplImage * image )
CV_ERROR(CV_StsUnsupportedFormat, "cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 3.");
}
}
+#if FULL_GST_VERSION >= VERSION_NUM(0,10,29)
else if (input_pix_fmt == GST_VIDEO_FORMAT_GRAY8) {
if (image->nChannels != 1 || image->depth != IPL_DEPTH_8U) {
CV_ERROR(CV_StsUnsupportedFormat, "cvWriteFrame() needs images with depth = IPL_DEPTH_8U and nChannels = 1.");
}
}
+#endif
else {
assert(false);
}
--
1.9.3

@ -0,0 +1,72 @@
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

@ -0,0 +1,165 @@
From 30f7f9717f1f0a8c11ba88d4f04b0c7cf26bba70 Mon Sep 17 00:00:00 2001
From: Dirk Van Haerenborgh <dirk.vanhaerenborgh@hogent.be>
Date: Thu, 13 Jun 2013 11:16:33 +0200
Subject: [PATCH 0871/3152] allow for arbitraty number of sources and sinks
---
modules/highgui/src/cap_gstreamer.cpp | 110 ++++++++++++++++++++--------------
1 file changed, 65 insertions(+), 45 deletions(-)
diff --git a/modules/highgui/src/cap_gstreamer.cpp b/modules/highgui/src/cap_gstreamer.cpp
index a347a74..4d4dc71 100644
--- a/modules/highgui/src/cap_gstreamer.cpp
+++ b/modules/highgui/src/cap_gstreamer.cpp
@@ -651,17 +651,47 @@ bool CvCapture_GStreamer::open( int type, const char* filename )
if(manualpipeline)
{
+ GstIterator *it = NULL;
#if GST_VERSION_MAJOR == 0
- GstIterator *it = gst_bin_iterate_sinks(GST_BIN(uridecodebin));
+ it = gst_bin_iterate_sinks(GST_BIN(uridecodebin));
if(gst_iterator_next(it, (gpointer *)&sink) != GST_ITERATOR_OK) {
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
return false;
}
#else
- sink = gst_bin_get_by_name(GST_BIN(uridecodebin), "opencvsink");
- if (!sink){
- sink = gst_bin_get_by_name(GST_BIN(uridecodebin), "appsink0");
+ it = gst_bin_iterate_sinks (GST_BIN(uridecodebin));
+
+ gboolean done = FALSE;
+ GstElement *element = NULL;
+ gchar* name = NULL;
+ GValue value = G_VALUE_INIT;
+
+ while (!done) {
+ switch (gst_iterator_next (it, &value)) {
+ case GST_ITERATOR_OK:
+ element = GST_ELEMENT (g_value_get_object (&value));
+ name = gst_element_get_name(element);
+ if (name){
+ if(strstr(name, "opencvsink") != NULL || strstr(name, "appsink") != NULL) {
+ sink = GST_ELEMENT ( gst_object_ref (element) );
+ done = TRUE;
+ }
+ g_free(name);
+ }
+ g_value_unset (&value);
+
+ break;
+ case GST_ITERATOR_RESYNC:
+ gst_iterator_resync (it);
+ break;
+ case GST_ITERATOR_ERROR:
+ case GST_ITERATOR_DONE:
+ done = TRUE;
+ break;
+ }
}
+ gst_iterator_free (it);
+
if (!sink){
CV_ERROR(CV_StsError, "GStreamer: cannot find appsink in manual pipeline\n");
@@ -1034,15 +1064,8 @@ void CvVideoWriter_GStreamer::close()
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));
-
}
}
@@ -1140,9 +1163,7 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
GstEncodingVideoProfile* videoprofile = NULL;
#endif
-#if GST_VERSION_MAJOR == 0
GstIterator *it = NULL;
-#endif
// we first try to construct a pipeline from the given string.
// if that fails, we assume it is an ordinary filename
@@ -1163,39 +1184,38 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc,
return false;
}
#else
- source = gst_bin_get_by_name(GST_BIN(encodebin), "opencvsrc");
- if (!source){
- source = gst_bin_get_by_name(GST_BIN(encodebin), "appsrc0");
+ it = gst_bin_iterate_sources (GST_BIN(encodebin));
+
+ gboolean done = FALSE;
+ GstElement *element = NULL;
+ gchar* name = NULL;
+ GValue value = G_VALUE_INIT;
+
+ while (!done) {
+ switch (gst_iterator_next (it, &value)) {
+ case GST_ITERATOR_OK:
+ element = GST_ELEMENT (g_value_get_object (&value));
+ name = gst_element_get_name(element);
+ if (name){
+ if(strstr(name, "opencvsrc") != NULL || strstr(name, "appsrc") != NULL) {
+ source = GST_ELEMENT ( gst_object_ref (element) );
+ done = TRUE;
+ }
+ g_free(name);
+ }
+ g_value_unset (&value);
+
+ break;
+ case GST_ITERATOR_RESYNC:
+ gst_iterator_resync (it);
+ break;
+ case GST_ITERATOR_ERROR:
+ case GST_ITERATOR_DONE:
+ done = TRUE;
+ break;
+ }
}
-
-// 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);
-
-
-
+ gst_iterator_free (it);
if (!source){
CV_ERROR(CV_StsError, "GStreamer: cannot find appsrc in manual pipeline\n");
--
1.9.3

@ -2,7 +2,7 @@
Name: opencv
Version: 2.4.9
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Collection of algorithms for computer vision
Group: Development/Libraries
# This is normal three clause BSD.
@ -24,6 +24,17 @@ Patch3: opencv-2.4.9-ts_static.patch
# https://bugzilla.redhat.com/1031312
Patch4: opencv-2.4.7-cmake_paths.patch
# relevant gst1-related patches from upstream master branch
%if 0%{?fedora} > 20
%global gst1 1
%endif
# 0550 needed slight rebasing -- rex
Patch10: 0550-bomb-commit-of-gstreamer-videocapture-and-videowrite.patch
Patch11: 0552-eliminated-warnings.patch
Patch12: 0587-Fix-build-with-gstreamer-0.10.28.patch
Patch13: 0865-gstreamer-cleaning-up-resources.patch
Patch14: 0871-allow-for-arbitraty-number-of-sources-and-sinks.patch
BuildRequires: libtool
BuildRequires: cmake >= 2.6.3
BuildRequires: chrpath
@ -63,7 +74,11 @@ BuildRequires: python2-devel
BuildRequires: numpy, swig >= 1.3.24
BuildRequires: python-sphinx
%{?_with_ffmpeg:BuildRequires: ffmpeg-devel >= 0.4.9}
%if 0%{?gst1}
%{!?_without_gstreamer:BuildRequires: gstreamer1-devel gstreamer1-plugins-base-devel}
%else
%{!?_without_gstreamer:BuildRequires: gstreamer-devel gstreamer-plugins-base-devel}
%endif
%{?_with_xine:BuildRequires: xine-lib-devel}
BuildRequires: opencl-headers
@ -120,6 +135,14 @@ This package contains Python bindings for the OpenCV library.
%patch3 -p1 -b .ts_static
%patch4 -p1 -b .cmake_paths
%if 0%{?gst1}
%patch10 -p1 -b .10
%patch11 -p1 -b .11
%patch12 -p1 -b .12
%patch13 -p1 -b .13
%patch14 -p1 -b .14
%endif
# fix dos end of lines
sed -i 's|\r||g' samples/c/adaptiveskindetector.cpp
@ -250,6 +273,9 @@ popd
%{python2_sitearch}/cv2.so
%changelog
* Fri Jul 25 2014 Rex Dieter <rdieter@fedoraproject.org> 2.4.9-2
- backport support for GStreamer 1 (#1123078)
* Thu Jul 03 2014 Nicolas Chauvet <kwizart@gmail.com> - 2.4.9-1
- Update to 2.4.9

Loading…
Cancel
Save