def foreach_device_output(fd, func): original_index = v4l2.c_int() ioctl(fd, v4l2.VIDIOC_G_OUTPUT, original_index) for output in get_device_outputs(fd): if output_.index != original_index.value: try: ioctl(fd, v4l2.VIDIOC_S_OUTPUT, v4l2.c_int(output.index)) except IOError, e: if e.errno == errno.EBUSY: continue else: raise func(fd, output)
def foreach_device_input(fd, func): original_index = v4l2.c_int() fcntl.ioctl(fd, v4l2.VIDIOC_G_INPUT, original_index) for input_ in get_device_inputs(fd): if input_.index != original_index.value: try: fcntl.ioctl(fd, v4l2.VIDIOC_S_INPUT, v4l2.c_int(input_.index)) except IOError, e: if e.errno == errno.EBUSY: continue else: raise func(fd, input_)
def test_VIDIOC_G_OUTPUT(fd): cap = v4l2.v4l2_capability() ioctl(fd, v4l2.VIDIOC_QUERYCAP, cap) if not cap.capabilities & v4l2.V4L2_CAP_VIDEO_OUTPUT: # test does not apply for this device return index = v4l2.c_int() ioctl(fd, v4l2.VIDIOC_G_OUTPUT, index)
def test_VIDIOC_S_INPUT(fd): cap = v4l2.v4l2_capability() ioctl(fd, v4l2.VIDIOC_QUERYCAP, cap) if not cap.capabilities & v4l2.V4L2_CAP_VIDEO_CAPTURE: # test does not apply for this device return index = v4l2.c_int(0) try: ioctl(fd, v4l2.VIDIOC_S_INPUT, index) except IOError, e: assert e.errno == errno.EBUSY return
def test_VIDIOC_S_OUTPUT(fd): cap = v4l2.v4l2_capability() ioctl(fd, v4l2.VIDIOC_QUERYCAP, cap) if not cap.capabilities & v4l2.V4L2_CAP_VIDEO_OUTPUT: # test does not apply for this device return index = v4l2.c_int(0) ioctl(fd, v4l2.VIDIOC_S_OUTPUT, index) index.value = 1 << 31 try: ioctl(fd, v4l2.VIDIOC_S_OUTPUT, index) except IOError as e: assert e.errno == errno.EINVAL
def test_VIDIOC_S_OUTPUT(fd): cap = v4l2.v4l2_capability() ioctl(fd, v4l2.VIDIOC_QUERYCAP, cap) if not cap.capabilities & v4l2.V4L2_CAP_VIDEO_OUTPUT: # test does not apply for this device return index = v4l2.c_int(0) ioctl(fd, v4l2.VIDIOC_S_OUTPUT, index) index.value = 1 << 31 try: ioctl(fd, v4l2.VIDIOC_S_OUTPUT, index) except IOError, e: assert e.errno == errno.EINVAL