mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #22919 from asmorkalov:as/gstreamer_read_timeout
Address https://github.com/opencv/opencv/issues/22868 Used the same defaults as it's done for FFmpeg ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake ``` force_builders=Custom build_image:Custom=gstreamer:16.04 buildworker:Custom=linux-1 ```
This commit is contained in:
committed by
GitHub
parent
0153e796cc
commit
3f22f4727c
@@ -151,4 +151,31 @@ TEST(videoio_gstreamer, gray16_writing)
|
||||
EXPECT_EQ(0, remove(temp_file.c_str()));
|
||||
}
|
||||
|
||||
TEST(videoio_gstreamer, timeout_property)
|
||||
{
|
||||
if (!videoio_registry::hasBackend(CAP_GSTREAMER))
|
||||
throw SkipTestException("GStreamer backend was not found");
|
||||
|
||||
VideoCapture cap;
|
||||
cap.open("videotestsrc ! appsink", CAP_GSTREAMER);
|
||||
ASSERT_TRUE(cap.isOpened());
|
||||
const double default_timeout = 30000; // 30 seconds
|
||||
const double open_timeout = 5678; // 3 seconds
|
||||
const double read_timeout = 1234; // 1 second
|
||||
EXPECT_NEAR(default_timeout, cap.get(CAP_PROP_OPEN_TIMEOUT_MSEC), 1e-3);
|
||||
const double current_read_timeout = cap.get(CAP_PROP_READ_TIMEOUT_MSEC);
|
||||
const bool read_timeout_supported = current_read_timeout > 0.0;
|
||||
if (read_timeout_supported)
|
||||
{
|
||||
EXPECT_NEAR(default_timeout, current_read_timeout, 1e-3);
|
||||
}
|
||||
cap.set(CAP_PROP_OPEN_TIMEOUT_MSEC, open_timeout);
|
||||
EXPECT_NEAR(open_timeout, cap.get(CAP_PROP_OPEN_TIMEOUT_MSEC), 1e-3);
|
||||
if (read_timeout_supported)
|
||||
{
|
||||
cap.set(CAP_PROP_READ_TIMEOUT_MSEC, read_timeout);
|
||||
EXPECT_NEAR(read_timeout, cap.get(CAP_PROP_READ_TIMEOUT_MSEC), 1e-3);
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user