Video Inputs and Outputs

Video for Linux Two API Specification: Revision 0.24
Prev | Chapter 1. Common API Elements | Next

# 1.4. Video Inputs and Outputs

Video inputs and outputs are physical connectors of a device. These can be for example RF connectors (antenna/cable), CVBS a.k.a. Composite Video, S-Video or RGB connectors. Only video and VBI capture devices have inputs, output devices have outputs, at least one each. Radio devices have no video inputs or outputs.

To learn about the number and attributes of the available inputs and outputs applications can enumerate them with the `VIDIOC_ENUMINPUT` and `VIDIOC_ENUMOUTPUT` ioctl, respectively. The struct v4l2_input returned by the `VIDIOC_ENUMINPUT` ioctl also contains signal status information applicable when the current video input is queried.

The `VIDIOC_G_INPUT` and `VIDIOC_G_OUTPUT` ioctl return the index of the current video input or output. To select a different input or output applications call the `VIDIOC_S_INPUT` and `VIDIOC_S_OUTPUT` ioctl. Drivers must implement all the input ioctls when the device has one or more inputs, all the output ioctls when the device has one or more outputs.

Example 1-1. Information about the current video input

    struct v4l2_input input;
    int index;

    if (-1 == ioctl (fd, VIDIOC_G_INPUT, &index)) {
            perror ("VIDIOC_G_INPUT");
            exit (EXIT_FAILURE);
    }

    memset (&input, 0, sizeof (input));
    input.index = index;

    if (-1 == ioctl (fd, VIDIOC_ENUMINPUT, &input)) {
            perror ("VIDIOC_ENUMINPUT");
            exit (EXIT_FAILURE);
    }

    printf ("Current input: %s\n", input.name);

Example 1-2. Switching to the first video input

    int index;

    index = 0;

    if (-1 == ioctl (fd, VIDIOC_S_INPUT, &index)) {
            perror ("VIDIOC_S_INPUT");
            exit (EXIT_FAILURE);
    }

Prev | Home | Next
Application Priority | Up | Audio Inputs and Outputs