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
a8a71eb2
Commit
a8a71eb2
authored
Jul 19, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15092 from alalek:videoio_gstreamer_more_get_checks
parents
002904e4
61f589dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
6 deletions
+82
-6
cap_gstreamer.cpp
modules/videoio/src/cap_gstreamer.cpp
+24
-6
test_video_io.cpp
modules/videoio/test/test_video_io.cpp
+58
-0
No files found.
modules/videoio/src/cap_gstreamer.cpp
View file @
a8a71eb2
...
...
@@ -157,14 +157,14 @@ public:
inline
operator
T
*
()
CV_NOEXCEPT
{
return
ptr
;
}
inline
operator
/*const*/
T
*
()
const
CV_NOEXCEPT
{
return
(
T
*
)
ptr
;
}
// there is no const correctness in Gst C API
inline
T
*
get
()
CV_NOEXCEPT
{
return
ptr
;
}
inline
/*const*/
T
*
get
()
const
CV_NOEXCEPT
{
CV_Assert
(
ptr
);
return
(
T
*
)
ptr
;
}
// there is no const correctness in Gst C API
T
*
get
()
{
CV_Assert
(
ptr
);
return
ptr
;
}
/*const*/
T
*
get
()
const
{
CV_Assert
(
ptr
);
return
(
T
*
)
ptr
;
}
// there is no const correctness in Gst C API
inline
const
T
*
operator
->
()
const
{
CV_Assert
(
ptr
);
return
ptr
;
}
const
T
*
operator
->
()
const
{
CV_Assert
(
ptr
);
return
ptr
;
}
inline
operator
bool
()
const
CV_NOEXCEPT
{
return
ptr
!=
NULL
;
}
inline
bool
operator
!
()
const
CV_NOEXCEPT
{
return
ptr
==
NULL
;
}
inline
T
**
getRef
()
{
CV_Assert
(
ptr
==
NULL
);
return
&
ptr
;
}
T
**
getRef
()
{
CV_Assert
(
ptr
==
NULL
);
return
&
ptr
;
}
inline
GSafePtr
&
reset
(
T
*
p
)
CV_NOEXCEPT
// pass result of functions with "transfer floating" ownership
{
...
...
@@ -1313,7 +1313,21 @@ public:
num_frames
(
0
),
framerate
(
0
)
{
}
virtual
~
CvVideoWriter_GStreamer
()
CV_OVERRIDE
{
close
();
}
virtual
~
CvVideoWriter_GStreamer
()
CV_OVERRIDE
{
try
{
close
();
}
catch
(
const
std
::
exception
&
e
)
{
CV_WARN
(
"C++ exception in writer destructor: "
<<
e
.
what
());
}
catch
(...)
{
CV_WARN
(
"Unknown exception in writer destructor. Ignore"
);
}
}
int
getCaptureDomain
()
const
CV_OVERRIDE
{
return
cv
::
CAP_GSTREAMER
;
}
...
...
@@ -1345,7 +1359,11 @@ void CvVideoWriter_GStreamer::close_()
{
handleMessage
(
pipeline
);
if
(
gst_app_src_end_of_stream
(
GST_APP_SRC
(
source
.
get
()))
!=
GST_FLOW_OK
)
if
(
!
(
bool
)
source
)
{
CV_WARN
(
"No source in GStreamer pipeline. Ignore"
);
}
else
if
(
gst_app_src_end_of_stream
(
GST_APP_SRC
(
source
.
get
()))
!=
GST_FLOW_OK
)
{
CV_WARN
(
"Cannot send EOS to GStreamer pipeline"
);
}
...
...
modules/videoio/test/test_video_io.cpp
View file @
a8a71eb2
...
...
@@ -527,4 +527,62 @@ static vector<Ext_Fourcc_API> generate_Ext_Fourcc_API()
INSTANTIATE_TEST_CASE_P
(
videoio
,
Videoio_Writer
,
testing
::
ValuesIn
(
generate_Ext_Fourcc_API
()));
typedef
Videoio_Writer
Videoio_Writer_bad_fourcc
;
TEST_P
(
Videoio_Writer_bad_fourcc
,
nocrash
)
{
if
(
!
isBackendAvailable
(
apiPref
,
cv
::
videoio_registry
::
getStreamBackends
()))
throw
SkipTestException
(
cv
::
String
(
"Backend is not available/disabled: "
)
+
cv
::
videoio_registry
::
getBackendName
(
apiPref
));
VideoWriter
writer
;
EXPECT_NO_THROW
(
writer
.
open
(
video_file
,
apiPref
,
fourcc
,
fps
,
frame_size
,
true
));
ASSERT_FALSE
(
writer
.
isOpened
());
EXPECT_NO_THROW
(
writer
.
release
());
}
static
vector
<
Ext_Fourcc_API
>
generate_Ext_Fourcc_API_nocrash
()
{
static
const
Ext_Fourcc_API
params
[]
=
{
#ifdef HAVE_MSMF_DISABLED // MSMF opens writer stream
{
"wmv"
,
"aaaa"
,
CAP_MSMF
},
{
"mov"
,
"aaaa"
,
CAP_MSMF
},
#endif
#ifdef HAVE_QUICKTIME
{
"mov"
,
"aaaa"
,
CAP_QT
},
{
"avi"
,
"aaaa"
,
CAP_QT
},
{
"mkv"
,
"aaaa"
,
CAP_QT
},
#endif
#ifdef HAVE_AVFOUNDATION
{
"mov"
,
"aaaa"
,
CAP_AVFOUNDATION
},
{
"mp4"
,
"aaaa"
,
CAP_AVFOUNDATION
},
{
"m4v"
,
"aaaa"
,
CAP_AVFOUNDATION
},
#endif
#ifdef HAVE_FFMPEG
{
"avi"
,
"aaaa"
,
CAP_FFMPEG
},
{
"mkv"
,
"aaaa"
,
CAP_FFMPEG
},
#endif
#ifdef HAVE_GSTREAMER
{
"avi"
,
"aaaa"
,
CAP_GSTREAMER
},
{
"mkv"
,
"aaaa"
,
CAP_GSTREAMER
},
#endif
{
"avi"
,
"aaaa"
,
CAP_OPENCV_MJPEG
},
};
const
size_t
N
=
sizeof
(
params
)
/
sizeof
(
params
[
0
]);
vector
<
Ext_Fourcc_API
>
result
;
result
.
reserve
(
N
);
for
(
size_t
i
=
0
;
i
<
N
;
i
++
)
{
const
Ext_Fourcc_API
&
src
=
params
[
i
];
Ext_Fourcc_API
e
=
{
src
.
ext
,
src
.
fourcc
,
src
.
api
};
result
.
push_back
(
e
);
}
return
result
;
}
INSTANTIATE_TEST_CASE_P
(
videoio
,
Videoio_Writer_bad_fourcc
,
testing
::
ValuesIn
(
generate_Ext_Fourcc_API_nocrash
()));
}
// namespace
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