Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 1 | .. -*- coding: utf-8; mode: rst -*- |
| 2 | |
Mauro Carvalho Chehab | af4a4d0 | 2016-07-01 13:42:29 -0300 | [diff] [blame] | 3 | .. _VIDIOC_DECODER_CMD: |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 4 | |
| 5 | ************************************************ |
| 6 | ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD |
| 7 | ************************************************ |
| 8 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 9 | Name |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 10 | ==== |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 11 | |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 12 | VIDIOC_DECODER_CMD - VIDIOC_TRY_DECODER_CMD - Execute an decoder command |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 13 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 14 | |
| 15 | Synopsis |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 16 | ======== |
| 17 | |
Mauro Carvalho Chehab | 1b81f01 | 2016-08-19 12:00:43 -0300 | [diff] [blame^] | 18 | .. c:function:: int ioctl( int fd, int request, struct v4l2_decoder_cmd *argp ) |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 19 | |
Mauro Carvalho Chehab | 586027c | 2016-07-05 07:58:48 -0300 | [diff] [blame] | 20 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 21 | Arguments |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 22 | ========= |
| 23 | |
| 24 | ``fd`` |
| 25 | File descriptor returned by :ref:`open() <func-open>`. |
| 26 | |
| 27 | ``request`` |
| 28 | VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD |
| 29 | |
| 30 | ``argp`` |
| 31 | |
| 32 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 33 | Description |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 34 | =========== |
| 35 | |
| 36 | These ioctls control an audio/video (usually MPEG-) decoder. |
| 37 | ``VIDIOC_DECODER_CMD`` sends a command to the decoder, |
| 38 | ``VIDIOC_TRY_DECODER_CMD`` can be used to try a command without actually |
| 39 | executing it. To send a command applications must initialize all fields |
| 40 | of a struct :ref:`v4l2_decoder_cmd <v4l2-decoder-cmd>` and call |
| 41 | ``VIDIOC_DECODER_CMD`` or ``VIDIOC_TRY_DECODER_CMD`` with a pointer to |
| 42 | this structure. |
| 43 | |
| 44 | The ``cmd`` field must contain the command code. Some commands use the |
| 45 | ``flags`` field for additional information. |
| 46 | |
Mauro Carvalho Chehab | 760c701 | 2016-07-04 12:56:17 -0300 | [diff] [blame] | 47 | A :ref:`write() <func-write>` or :ref:`VIDIOC_STREAMON` |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 48 | call sends an implicit START command to the decoder if it has not been |
| 49 | started yet. |
| 50 | |
Mauro Carvalho Chehab | 760c701 | 2016-07-04 12:56:17 -0300 | [diff] [blame] | 51 | A :ref:`close() <func-close>` or :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>` |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 52 | call of a streaming file descriptor sends an implicit immediate STOP |
| 53 | command to the decoder, and all buffered data is discarded. |
| 54 | |
| 55 | These ioctls are optional, not all drivers may support them. They were |
| 56 | introduced in Linux 3.3. |
| 57 | |
| 58 | |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 59 | .. tabularcolumns:: |p{1.1cm}|p{2.4cm}|p{1.2cm}|p{1.6cm}|p{10.6cm}| |
| 60 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 61 | .. _v4l2-decoder-cmd: |
| 62 | |
Mauro Carvalho Chehab | 201784b | 2016-08-18 13:31:34 -0300 | [diff] [blame] | 63 | .. cssclass:: longtable |
| 64 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 65 | .. flat-table:: struct v4l2_decoder_cmd |
| 66 | :header-rows: 0 |
| 67 | :stub-columns: 0 |
Mauro Carvalho Chehab | 201784b | 2016-08-18 13:31:34 -0300 | [diff] [blame] | 68 | :widths: 11 24 12 16 106 |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 69 | |
| 70 | |
| 71 | - .. row 1 |
| 72 | |
| 73 | - __u32 |
| 74 | |
| 75 | - ``cmd`` |
| 76 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 77 | - |
| 78 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 79 | - The decoder command, see :ref:`decoder-cmds`. |
| 80 | |
| 81 | - .. row 2 |
| 82 | |
| 83 | - __u32 |
| 84 | |
| 85 | - ``flags`` |
| 86 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 87 | - |
| 88 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 89 | - Flags to go with the command. If no flags are defined for this |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 90 | command, drivers and applications must set this field to zero. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 91 | |
| 92 | - .. row 3 |
| 93 | |
| 94 | - union |
| 95 | |
| 96 | - (anonymous) |
| 97 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 98 | - |
| 99 | - |
| 100 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 101 | |
| 102 | - .. row 4 |
| 103 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 104 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 105 | - struct |
| 106 | |
| 107 | - ``start`` |
| 108 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 109 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 110 | - Structure containing additional data for the |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 111 | ``V4L2_DEC_CMD_START`` command. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 112 | |
| 113 | - .. row 5 |
| 114 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 115 | - |
| 116 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 117 | - __s32 |
| 118 | |
| 119 | - ``speed`` |
| 120 | |
| 121 | - Playback speed and direction. The playback speed is defined as |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 122 | ``speed``/1000 of the normal speed. So 1000 is normal playback. |
| 123 | Negative numbers denote reverse playback, so -1000 does reverse |
| 124 | playback at normal speed. Speeds -1, 0 and 1 have special |
| 125 | meanings: speed 0 is shorthand for 1000 (normal playback). A speed |
| 126 | of 1 steps just one frame forward, a speed of -1 steps just one |
| 127 | frame back. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 128 | |
| 129 | - .. row 6 |
| 130 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 131 | - |
| 132 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 133 | - __u32 |
| 134 | |
| 135 | - ``format`` |
| 136 | |
| 137 | - Format restrictions. This field is set by the driver, not the |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 138 | application. Possible values are ``V4L2_DEC_START_FMT_NONE`` if |
| 139 | there are no format restrictions or ``V4L2_DEC_START_FMT_GOP`` if |
| 140 | the decoder operates on full GOPs (*Group Of Pictures*). This is |
| 141 | usually the case for reverse playback: the decoder needs full |
| 142 | GOPs, which it can then play in reverse order. So to implement |
| 143 | reverse playback the application must feed the decoder the last |
| 144 | GOP in the video file, then the GOP before that, etc. etc. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 145 | |
| 146 | - .. row 7 |
| 147 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 148 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 149 | - struct |
| 150 | |
| 151 | - ``stop`` |
| 152 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 153 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 154 | - Structure containing additional data for the ``V4L2_DEC_CMD_STOP`` |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 155 | command. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 156 | |
| 157 | - .. row 8 |
| 158 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 159 | - |
| 160 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 161 | - __u64 |
| 162 | |
| 163 | - ``pts`` |
| 164 | |
| 165 | - Stop playback at this ``pts`` or immediately if the playback is |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 166 | already past that timestamp. Leave to 0 if you want to stop after |
| 167 | the last frame was decoded. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 168 | |
| 169 | - .. row 9 |
| 170 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 171 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 172 | - struct |
| 173 | |
| 174 | - ``raw`` |
| 175 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 176 | - |
| 177 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 178 | |
| 179 | - .. row 10 |
| 180 | |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 181 | - |
| 182 | - |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 183 | - __u32 |
| 184 | |
Mauro Carvalho Chehab | 8968da9 | 2016-07-13 08:43:30 -0300 | [diff] [blame] | 185 | - ``data``\ [16] |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 186 | |
| 187 | - Reserved for future extensions. Drivers and applications must set |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 188 | the array to zero. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 189 | |
| 190 | |
| 191 | |
Mauro Carvalho Chehab | 201784b | 2016-08-18 13:31:34 -0300 | [diff] [blame] | 192 | .. tabularcolumns:: |p{5.6cm}|p{0.6cm}|p{11.3cm}| |
Mauro Carvalho Chehab | 5bd4bb7 | 2016-08-17 08:14:19 -0300 | [diff] [blame] | 193 | |
Mauro Carvalho Chehab | fa92b04d | 2016-08-19 11:14:23 -0300 | [diff] [blame] | 194 | .. _decoder-cmds: |
| 195 | |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 196 | .. flat-table:: Decoder Commands |
| 197 | :header-rows: 0 |
| 198 | :stub-columns: 0 |
Mauro Carvalho Chehab | 201784b | 2016-08-18 13:31:34 -0300 | [diff] [blame] | 199 | :widths: 56 6 113 |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 200 | |
| 201 | |
| 202 | - .. row 1 |
| 203 | |
| 204 | - ``V4L2_DEC_CMD_START`` |
| 205 | |
| 206 | - 0 |
| 207 | |
| 208 | - Start the decoder. When the decoder is already running or paused, |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 209 | this command will just change the playback speed. That means that |
| 210 | calling ``V4L2_DEC_CMD_START`` when the decoder was paused will |
| 211 | *not* resume the decoder. You have to explicitly call |
| 212 | ``V4L2_DEC_CMD_RESUME`` for that. This command has one flag: |
| 213 | ``V4L2_DEC_CMD_START_MUTE_AUDIO``. If set, then audio will be |
| 214 | muted when playing back at a non-standard speed. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 215 | |
| 216 | - .. row 2 |
| 217 | |
| 218 | - ``V4L2_DEC_CMD_STOP`` |
| 219 | |
| 220 | - 1 |
| 221 | |
| 222 | - Stop the decoder. When the decoder is already stopped, this |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 223 | command does nothing. This command has two flags: if |
| 224 | ``V4L2_DEC_CMD_STOP_TO_BLACK`` is set, then the decoder will set |
| 225 | the picture to black after it stopped decoding. Otherwise the last |
| 226 | image will repeat. mem2mem decoders will stop producing new frames |
| 227 | altogether. They will send a ``V4L2_EVENT_EOS`` event when the |
| 228 | last frame has been decoded and all frames are ready to be |
| 229 | dequeued and will set the ``V4L2_BUF_FLAG_LAST`` buffer flag on |
| 230 | the last buffer of the capture queue to indicate there will be no |
| 231 | new buffers produced to dequeue. This buffer may be empty, |
| 232 | indicated by the driver setting the ``bytesused`` field to 0. Once |
| 233 | the ``V4L2_BUF_FLAG_LAST`` flag was set, the |
| 234 | :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will not block anymore, |
| 235 | but return an ``EPIPE`` error code. If |
| 236 | ``V4L2_DEC_CMD_STOP_IMMEDIATELY`` is set, then the decoder stops |
| 237 | immediately (ignoring the ``pts`` value), otherwise it will keep |
| 238 | decoding until timestamp >= pts or until the last of the pending |
| 239 | data from its internal buffers was decoded. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 240 | |
| 241 | - .. row 3 |
| 242 | |
| 243 | - ``V4L2_DEC_CMD_PAUSE`` |
| 244 | |
| 245 | - 2 |
| 246 | |
| 247 | - Pause the decoder. When the decoder has not been started yet, the |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 248 | driver will return an ``EPERM`` error code. When the decoder is |
| 249 | already paused, this command does nothing. This command has one |
| 250 | flag: if ``V4L2_DEC_CMD_PAUSE_TO_BLACK`` is set, then set the |
| 251 | decoder output to black when paused. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 252 | |
| 253 | - .. row 4 |
| 254 | |
| 255 | - ``V4L2_DEC_CMD_RESUME`` |
| 256 | |
| 257 | - 3 |
| 258 | |
| 259 | - Resume decoding after a PAUSE command. When the decoder has not |
Mauro Carvalho Chehab | 0579e6e | 2016-07-04 16:25:48 -0300 | [diff] [blame] | 260 | been started yet, the driver will return an ``EPERM`` error code. When |
| 261 | the decoder is already running, this command does nothing. No |
| 262 | flags are defined for this command. |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 263 | |
| 264 | |
Mauro Carvalho Chehab | 15e7d61 | 2016-07-05 15:14:35 -0300 | [diff] [blame] | 265 | Return Value |
Markus Heiser | 5377d91 | 2016-06-30 15:18:56 +0200 | [diff] [blame] | 266 | ============ |
| 267 | |
| 268 | On success 0 is returned, on error -1 and the ``errno`` variable is set |
| 269 | appropriately. The generic error codes are described at the |
| 270 | :ref:`Generic Error Codes <gen-errors>` chapter. |
| 271 | |
| 272 | EINVAL |
| 273 | The ``cmd`` field is invalid. |
| 274 | |
| 275 | EPERM |
| 276 | The application sent a PAUSE or RESUME command when the decoder was |
| 277 | not running. |