From 15251056ba7b345f2d7de973637da3ec5816662b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Thu, 25 Sep 2014 14:51:34 +0400 Subject: [PATCH] Fixed compatibility with GStreamer 1.x --- modules/videoio/src/cap_gstreamer.cpp | 19 ++++++++++++++----- modules/videoio/test/test_basic_props.cpp | 6 +++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/modules/videoio/src/cap_gstreamer.cpp b/modules/videoio/src/cap_gstreamer.cpp index da3beaca93..cae719996e 100644 --- a/modules/videoio/src/cap_gstreamer.cpp +++ b/modules/videoio/src/cap_gstreamer.cpp @@ -788,26 +788,32 @@ bool CvCapture_GStreamer::open( int type, const char* filename ) duration = -1; } - GstPad* pad = gst_element_get_pad(color, "src"); + GstPad* pad = gst_element_get_static_pad(color, "src"); +#if GST_VERSION_MAJOR == 0 GstCaps* buffer_caps = gst_pad_get_caps(pad); +#else + GstCaps* buffer_caps = gst_pad_get_current_caps(pad); +#endif const GstStructure *structure = gst_caps_get_structure (buffer_caps, 0); if (!gst_structure_get_int (structure, "width", &width)) + { CV_WARN("Cannot query video width\n"); + } if (!gst_structure_get_int (structure, "height", &height)) + { CV_WARN("Cannot query video heigth\n"); - - if (!gst_structure_get_int (structure, "height", &height)) - CV_WARN("Cannot query video heigth\n"); + } gint num = 0, denom=1; if(!gst_structure_get_fraction(structure, "framerate", &num, &denom)) + { CV_WARN("Cannot query video fps\n"); + } fps = (double)num/(double)denom; - // GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); } else @@ -1217,8 +1223,11 @@ bool CvVideoWriter_GStreamer::open( const char * filename, int fourcc, gboolean done = FALSE; GstElement *element = NULL; gchar* name = NULL; + +#if GST_VERSION_MAJOR == 0 GstElement* splitter = NULL; GstElement* combiner = NULL; +#endif // we first try to construct a pipeline from the given string. // if that fails, we assume it is an ordinary filename diff --git a/modules/videoio/test/test_basic_props.cpp b/modules/videoio/test/test_basic_props.cpp index 76d4d8fd18..516b7b0fce 100644 --- a/modules/videoio/test/test_basic_props.cpp +++ b/modules/videoio/test/test_basic_props.cpp @@ -51,7 +51,11 @@ using namespace cv; using namespace std; using namespace cvtest; -const string ext[] = {"avi"}; //, "mov", "mp4"}; +#ifdef HAVE_GSTREAMER +const string ext[] = {"avi"}; +#else +const string ext[] = {"avi", "mov", "mp4"}; +#endif TEST(Videoio_Video, prop_resolution) { -- GitLab