[Bug 796908] New: v4l2: can't use different v4l2 input than the first one that was used
GStreamer (GNOME Bugzilla)
bugzilla at gnome.org
Wed Aug 1 13:55:05 UTC 2018
https://bugzilla.gnome.org/show_bug.cgi?id=796908
Bug ID: 796908
Summary: v4l2: can't use different v4l2 input than the first
one that was used
Classification: Platform
Product: GStreamer
Version: 1.14.x
OS: Linux
Status: NEW
Severity: minor
Priority: Normal
Component: gst-plugins-good
Assignee: gstreamer-bugs at lists.freedesktop.org
Reporter: inigohuguet at hotmail.com
QA Contact: gstreamer-bugs at lists.freedesktop.org
GNOME version: ---
Created attachment 373240
--> https://bugzilla.gnome.org/attachment.cgi?id=373240&action=edit
Proposed solution
V4L2 devices may have different inputs, which can be selected with ioctl
VIDIOC_S_INPUT.
I'm using v4l2src and I need to change the input which is being used. GStreamer
doesn't allow to do it (it used to allow it with GST_TUNER, but not now).
What I've tried is to put the pipeline to null state, make an ioctl S_INPUT to
select a different input, and put the pipeline to playing again. However,
GStreamer selects again the original input that is started using the first
time, undoing the input change I made.
This is what I want to do:
int input;
// pipeline to null
gst_element_set_state(pipeline, GST_STATE_NULL);
// open video file descriptor
int fd = open("/dev/video1", O_RDWR);
// check current input
ioctl(fd, VIDIOC_G_INPUT, &input);
std::cout << "Current input: " << input << std::endl;
// set new input
input = NEW_INPUT;
ioctl(fd, VIDIOC_S_INPUT, &input);
// check that change is applied
ioctl(fd, VIDIOC_G_INPUT, &input);
std::cout << "Current input (pre-play): " << input << std::endl;
// close file descriptor
close(fd);
// pipeline to playing and again to null
gst_element_set_state (pipeline, GST_STATE_PLAYING);
gst_element_set_state(pipeline, GST_STATE_NULL);
// check if input is still the new one
fd = open("/dev/video1", O_RDWR);
ioctl(fd, VIDIOC_G_INPUT, &input);
std::cout << "Current input (post-play): " << input << std::endl;
close(fd);
Now I get this output:
Current input: 0
Current input (pre-play): 1
Current input (post-play): 0
I attach a patch with my proposed solution. When v4l2src changes to NULL state,
it forget the previous input, making that next time it changes to PLAYING
state, it checks again for the current selected input.
I think this is the better behavior, considering that GStreamer doesn't allow
to select an input and the first time it selects the currently selected one, I
would expect the next times to do the same. Also, if not done like this, it is
not possible for the user to select a different input reusing the same
pipeline.
Different inputs of the same device might have different formats, framesizes,
etc, so for example I have had to change my selected caps for v4l2src, but
that's something that the user have to take care of it.
Also, it would be a good enhancement to allow selecting the input as a property
of v4l2src (gst-launch-1.0 v4l2src device=/dev/video1 input=1 ! autovideosink).
I haven't used v4l2sink, but I guess that the same could apply to its outputs.
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the gstreamer-bugs
mailing list