Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
30f7f971
Commit
30f7f971
authored
Jun 13, 2013
by
Dirk Van Haerenborgh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow for arbitraty number of sources and sinks
parent
6d66d110
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
45 deletions
+65
-45
cap_gstreamer.cpp
modules/highgui/src/cap_gstreamer.cpp
+65
-45
No files found.
modules/highgui/src/cap_gstreamer.cpp
View file @
30f7f971
...
...
@@ -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
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment