# Explore video sample applications
You can use the video functionality at the native layer by using the [Qualcomm IM SDK](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/qimsdk_landing_page.html) framework or by using the V4L2 interfaces. Qualcomm provides GStreamer and V4L2-based sample applications to run the video sample use cases.
## GStreamer samples
The [Qualcomm IM SDK](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/qimsdk_landing_page.html) includes sample GStreamer applications for video playback.
Note
For information about sample GStreamer applications supported on different SoCs, see [Multimedia sample applications](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/example-applications.html#multimedia-sample-applications).
For information about the prerequisites for the GStreamer applications, see [Run sample applications for video and audio](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/audio-sample-applications.html).
The following table lists the methods and the corresponding sample video test cases:
| Method | Use case |
| --- | --- |
|
Using `gst-launch-1.0` | [Video playback](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/video-playback-use-cases.html) |
|
Using `gst-launch-1.0` | [Audio-video playback](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/audio-video-use-cases.html) |
|
Using `gst-launch-1.0` | [Video recording](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/camera-and-video-encode.html) |
| Using the GStreamer application | [Video playback](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/gst-video-playback-example.html) |
| | |
| | |
## V4L2 samples
The `iris_v4l2_test` sample video test application uses Linux V4L2 interfaces to simulate several basic encoder and decoder behaviors. For more information, see [sample V4L2 application](https://github.com/quic/v4l-video-test-app).
Qualcomm Linux supports the following video APIs:
- [GStreamer APIs](https://docs.qualcomm.com/doc/80-70030-20/topic/interfaces.html#section-r53-mv3-n1c-eputla-02-23-24-1111-38-601): The Qualcomm GStreamer plugins are open-source GStreamer framework compliant. For more information about the GStreamer based plugins, see [Qualcomm IM SDK](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/qimsdk_landing_page.html).
- [V4L2 APIs](https://docs.qualcomm.com/doc/80-70030-20/topic/interfaces.html#section-nss-w1z-k1c-eputla-02-14-24-2315-20-633): The Adreno VPU driver follows a standard V4L2-compliant call flow. The V4L2 APIs section provides information related to V4L2 APIs, commands, controls, and events.
## Configure GStreamer and V4L2 APIs
- Qualcomm offers GStreamer-based plugins that you can integrate into your media pipeline. For information about the GStreamer-based plugins, see [Configure Qualcomm GStreamer plugins](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/qim-sdk-plugins.html).
- The Adreno VPU driver uses the V4L2 interface to support video encoding and decoding for all clients that follow the V4L2 guidance.
### GStreamer APIs
For information about the GStreamer application development and pipeline creation, see [Building an Application](https://gstreamer.freedesktop.org/documentation/application-development/basics/index.html).
#### Configure GStreamer APIs
For information about configuring the GStreamer element property for different features and respective plugins, see [Configure Qualcomm GStreamer plugins](https://docs.qualcomm.com/bundle/publicresource/topics/80-70030-50/qim-sdk-plugins.html).
### V4L2 APIs
This section describes V4L2 device nodes, file operations, commands, controls, and events for the decoder and encoder.
#### VPU driver nodes
The device registers the VPU driver during the boot-up process and assigns the device node number.
- VPU driver node for decoder: `/dev/video32`
- VPU driver node for encoder: `/dev/video33`
#### V4L2 file operations
The Adreno VPU driver supports the following V4L2 file operations:
Table: VPU driver V4L2 file operations
| Operation | Description |
| --- | --- |
| `open` | Opens the video device file descriptor (FD) that's used to communicate with the VPU driver using the input/output control `ioctl` commands |
| `close` | Closes the video device upon the completion of a video use case, and releases all the VPU driver resources related to the video device |
| `poll` | Waits for the events from the VPU driver |
| `ioctl` | Sends commands or controls to the VPU device |
#### V4L2 common commands for decoder and encoder
The VPU driver supports the following `ioctl` commands for the video decoder and encoder use cases:
- `VIDIOC_ENUM_FMT`
- `VIDIOC_TRY_FMT`
- `VIDIOC_G_FMT`
- `VIDIOC_S_FMT`
- `VIDIOC_ENUM_FRAMESIZES`
- `VIDIOC_REQBUFS`
- `VIDIOC_QUERY_BUF`
- `VIDIOC_CREATE_BUF`
- `VIDIOC_PREPARE_BUF`
- `VIDIOC_QBUF`
- `VIDIOC_DQBUF`
- `VIDIOC_STREAMON`
- `VIDIOC_STREAMOFF`
- `VIDIOC_QUERYCAP`
- `VIDIOC_QUERYCTRL`
- `VIDIOC_QUERYMENU`
- `VIDIOC_SUBSCRIBE_EVENT`
- `VIDIOC_UNSUBSCRIBE_EVENT`
- `VIDIOC_G_SELECTION`
- `VIDIOC_G_CTRL`
- `VIDIOC_S_CTRL`
#### V4L2 video decoder
This section provides information on the Adreno VPU decoder device nodes, supported controls, commands, and events. For the procedure to open a VPU decoder node, see [VPU driver nodes](https://docs.qualcomm.com/doc/80-70030-20/topic/interfaces.html#p-lg1-3cs-s1c-eputla-03-13-24-1448-52-615).
**V4L2 ioctl commands for decoder**
For descriptions of the standard `ioctl` commands, see [Video for Linux API Function Reference](https://www.kernel.org/doc/html/v4.9/media/uapi/v4l/user-func.html).
Apart from the [common commands](https://docs.qualcomm.com/doc/80-70030-20/topic/interfaces.html#v4l2commoncommands), the VPU driver also supports the following `ioctl` commands for the video decoder use cases:
- `VIDIOC_TRY_DECODER_CMD`
- `VIDIOC_DECODER_CMD`
As specified in the [Memory-to-Memory Stateful Video Decoder Interface](https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-decoder.html), the decoder supports all the mandatory commands required for the video decoder use cases.
**V4L2 open-source controls for decoder**
For descriptions of the standard open-source controls, see [Codec Control Reference](https://www.kernel.org/doc/html/v5.5/media/uapi/v4l/ext-ctrls-codec.html).
The VPU driver supports the following open-source controls for the video decoder use cases:
Table: Open-source controls for decoder
| Control ID | Purpose | Dynamic/Static |
| --- | --- | --- |
| `V4L2_CID_MPEG_VIDEO_H264_PROFILE` | H.264 decoder profile | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_PROFILE` | HEVC decoder profile | Static |
| `V4L2_CID_MPEG_VIDEO_VP9_PROFILE` | VP9 decoder profile | Static |
| `V4L2_CID_MPEG_VIDEO_H264_LEVEL` | H.264 decoder level | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_LEVEL` | HEVC decoder level | Static |
| `V4L2_CID_MPEG_VIDEO_VP9_LEVEL` | VP9 decoder level | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_TIER` | HEVC decoder tier | Static |
The decoder supports the following V4L2 open-source events:
- `V4L2_EVENT_EOS`
- `V4L2_EVENT_SOURCE_CHANGE`
- `V4L2_EVENT_CTRL`
The decoder supports the following V4L2 commands:
- `V4L2_DEC_CMD_START`
- `V4L2_DEC_CMD_STOP`
#### V4L2 video encoder
This section provides the information on the Adreno VPU encoder device nodes, supported controls, commands, and events. For the procedure to open a VPU encoder node, see [VPU driver nodes](https://docs.qualcomm.com/doc/80-70030-20/topic/interfaces.html#p-lg1-3cs-s1c-eputla-03-13-24-1448-52-615).
**V4l2 ioctl commands for encoder**
For descriptions of the standard `ioctl` commands, see [Function Reference](https://www.kernel.org/doc/html/v4.9/media/uapi/v4l/user-func.html).
Apart from the [common commands](https://docs.qualcomm.com/doc/80-70030-20/topic/interfaces.html#v4l2commoncommands), the VPU driver also supports the following `ioctl` commands for the encode use cases:
- `VIDIOC_ENUM_FRAMEINTERVALS`
- `VIDIOC_S_SELECTION`
- `VIDIOC_S_PARM`
- `VIDIOC_G_PARM`
- `VIDIOC_TRY_ENCODER_CMD`
- `VIDIOC_ENCODER_CMD`
As specified in the [Memory-to-Memory Stateful Video Encoder Interface](https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/dev-encoder.html), the encoder supports all the mandatory commands required for the video encoder use cases.
**V4L2 open-source controls for encoder**
For descriptions of the standard open-source controls, see [Codec Control Reference](https://www.kernel.org/doc/html/v5.5/media/uapi/v4l/ext-ctrls-codec.html).
The VPU driver supports the following open-source controls for the video encoder use cases:
Table: Open-source controls for encoder
| Control ID | Purpose | Dynamic/Static |
| --- | --- | --- |
| `V4L2_CID_MPEG_VIDEO_H264_PROFILE` | H.264 encoder profile | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_PROFILE` | HEVC encoder profile | Static |
| `V4L2_CID_MPEG_VIDEO_H264_LEVEL` | H.264 encoder level | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_LEVEL` | HEVC encoder level | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_TIER` | H.264 encoder tier | Static |
| `V4L2_CID_HFLIP` | Horizontal flip | Both |
| `V4L2_CID_VFLIP` | Vertical flip | Both |
| `V4L2_CID_ROTATE` | Rotation | Static |
| `V4L2_CID_MPEG_VIDEO_HEADER_MODE` | Header mode | Static |
| `V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR` | SPS/PPS with Instantaneous Decoder Refresh (IDR) frame | Static |
| `V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME` | Request force sync frame | Both |
| `V4L2_CID_MPEG_VIDEO_BITRATE` | Average bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_BITRATE_PEAK` | Peak bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_BITRATE_MODE` | Rate control | Static |
| `V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE` | Frame skip mode | Static |
| `V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE` | RC enable/disable | Static |
| `V4L2_CID_MPEG_VIDEO_GOP_SIZE` | Group-of-pictures size | Both |
| `V4L2_CID_MPEG_VIDEO_B_FRAMES` | B-Frames | Static |
| `V4L2_CID_MPEG_VIDEO_LTR_COUNT` | LTR frame count | Static |
| `V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES` | Use LTR | Both |
| `V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX` | Mark LTR | Both |
| `V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID` | Set base layer ID for layer encode | Static |
| `V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE` | Intra-refresh | Static |
| `V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD` | Intra-refresh period | Both |
| `V4L2_CID_MPEG_VIDEO_H264_MIN_QP` | H.264 minimum Quantization Parameter (QP) | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP` | HEVC minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_MAX_QP` | H.264 maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP` | HEVC maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP` | H.264 I-Frame minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP` | HEVC I-Frame minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP` | H.264 P-Frame minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP` | HEVC P-Frame minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP` | H.264 B-Frame minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP` | HEVC B-Frame minimum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP` | H.264 I-Frame maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP` | HEVC I-Frame maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP` | H.264 P-Frame maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP` | HEVC P-Frame maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP` | H.264 B-Frame maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP` | HEVC B-Frame maximum QP | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP` | HEVC I-Frame QP | Both |
| `V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP` | H.264 I-Frame QP | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP` | HEVC P-Frame QP | Both |
| `V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP` | H.264 P-Frame QP | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP` | HEVC B-Frame QP | Both |
| `V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP` | H.264 B-Frame QP | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE` | HEVC Hier coding type | Static |
| `V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE` | H.264 Hier coding type | Static |
| `V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING` | H.264 Hier coding | Static |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER` | HEVC Hier layer count | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER` | H.264 Hier layer count | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR` | H.264 layer 0-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_BR` | HEVC layer 0-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR` | H.264 layer 1-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_BR` | HEVC layer 1-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR` | H.264 layer 2-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_BR` | HEVC layer 2-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR` | H.264 layer 3-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_BR` | HEVC layer 3-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR` | H.264 layer 4-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR` | HEVC layer 4-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR` | H.264 layer 5-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR` | HEVC layer 5-bit rate | Both |
| `V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE` | H.264 entropy mode | Static |
| `V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE` | Encode slice mode | Static |
| `V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES` | Maximum bytes in slice | Static |
| `V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB` | Maximum macroblocks in slice | Static |
Set all static configuration options after setting the formats on both the planes and before requesting buffers on either of the plane. Call the dynamic parameters after setting the formats on both planes.
For information about the V4L2 controls for encoder, see [Codec Control Reference](https://www.kernel.org/doc/html/v5.5/media/uapi/v4l/ext-ctrls-codec.html).
The supported open-source events for encoder are:
- `V4L2_EVENT_EOS`
- `V4L2_EVENT_CTRL`
The supported open-source commands for encoder are:
- `V4L2_ENC_CMD_START`
- `V4L2_ENC_CMD_STOP`
#### Configure V4L2 APIs
Use the V4L2 control IDs, accepted format, accepted ranges, and sample code information, to configure and manage different video features on your device.
**B-frame encode**
You can configure the VPU driver to set up B-frames in an encoder session using the `VIDIOC_S_CTRL` ioctl system call. Set the B-frame encode configuration before setting the `VIDIOC_STREAMON` on an output plane. The VPU driver supports B-frame encode only with Hierarchical coding. This feature doesn't support dynamic configuration.
Table: B-Frame encode: Control IDs for H.264 and HEVC
| Control ID for H.264 and HEVC codecs | Accepted format | Range |
| --- | --- | --- |
| `V4L2_CID_MPEG_VIDEO_B_FRAMES` | Integer |
{0, 1}
0: Disable B-frame
1: Enable single B-frame
1 to 51 for 8‑bit
1 to 63 (-12 to 51) for 10‑bit
1 to 51 for 8‑bit
1 to 63 (-12 to 51) for 10‑bit
1 to 51 for 8‑bit
1 to 63 (-12 to 51) for 10‑bit
1 to 51 for 8‑bit
1 to 63 (-12 to 51) for 10‑bit
1 to 51 for 8‑bit
1 to 63 (-12 to 51) for 10‑bit
1 to 51 for 8‑bit
1 to 63 (-12 to 51) for 10‑bit