1 .. -*- coding: utf-8; mode: rst -*-
3 .. _VIDIOC_DECODER_CMD:
5 ************************************************
6 ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD
7 ************************************************
9 *man VIDIOC_DECODER_CMD(2)*
11 VIDIOC_TRY_DECODER_CMD
12 Execute an decoder command
18 .. c:function:: int ioctl( int fd, int request, struct v4l2_decoder_cmd *argp )
24 File descriptor returned by :ref:`open() <func-open>`.
27 VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD
35 These ioctls control an audio/video (usually MPEG-) decoder.
36 ``VIDIOC_DECODER_CMD`` sends a command to the decoder,
37 ``VIDIOC_TRY_DECODER_CMD`` can be used to try a command without actually
38 executing it. To send a command applications must initialize all fields
39 of a struct :ref:`v4l2_decoder_cmd <v4l2-decoder-cmd>` and call
40 ``VIDIOC_DECODER_CMD`` or ``VIDIOC_TRY_DECODER_CMD`` with a pointer to
43 The ``cmd`` field must contain the command code. Some commands use the
44 ``flags`` field for additional information.
46 A :c:func:`write()`() or :ref:`VIDIOC_STREAMON`
47 call sends an implicit START command to the decoder if it has not been
50 A :c:func:`close()`() or :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`
51 call of a streaming file descriptor sends an implicit immediate STOP
52 command to the decoder, and all buffered data is discarded.
54 These ioctls are optional, not all drivers may support them. They were
55 introduced in Linux 3.3.
60 .. flat-table:: struct v4l2_decoder_cmd
74 - The decoder command, see :ref:`decoder-cmds`.
84 - Flags to go with the command. If no flags are defined for this
85 command, drivers and applications must set this field to zero.
105 - Structure containing additional data for the
106 ``V4L2_DEC_CMD_START`` command.
116 - Playback speed and direction. The playback speed is defined as
117 ``speed``/1000 of the normal speed. So 1000 is normal playback.
118 Negative numbers denote reverse playback, so -1000 does reverse
119 playback at normal speed. Speeds -1, 0 and 1 have special
120 meanings: speed 0 is shorthand for 1000 (normal playback). A speed
121 of 1 steps just one frame forward, a speed of -1 steps just one
132 - Format restrictions. This field is set by the driver, not the
133 application. Possible values are ``V4L2_DEC_START_FMT_NONE`` if
134 there are no format restrictions or ``V4L2_DEC_START_FMT_GOP`` if
135 the decoder operates on full GOPs (*Group Of Pictures*). This is
136 usually the case for reverse playback: the decoder needs full
137 GOPs, which it can then play in reverse order. So to implement
138 reverse playback the application must feed the decoder the last
139 GOP in the video file, then the GOP before that, etc. etc.
149 - Structure containing additional data for the ``V4L2_DEC_CMD_STOP``
160 - Stop playback at this ``pts`` or immediately if the playback is
161 already past that timestamp. Leave to 0 if you want to stop after
162 the last frame was decoded.
182 - Reserved for future extensions. Drivers and applications must set
189 .. flat-table:: Decoder Commands
197 - ``V4L2_DEC_CMD_START``
201 - Start the decoder. When the decoder is already running or paused,
202 this command will just change the playback speed. That means that
203 calling ``V4L2_DEC_CMD_START`` when the decoder was paused will
204 *not* resume the decoder. You have to explicitly call
205 ``V4L2_DEC_CMD_RESUME`` for that. This command has one flag:
206 ``V4L2_DEC_CMD_START_MUTE_AUDIO``. If set, then audio will be
207 muted when playing back at a non-standard speed.
211 - ``V4L2_DEC_CMD_STOP``
215 - Stop the decoder. When the decoder is already stopped, this
216 command does nothing. This command has two flags: if
217 ``V4L2_DEC_CMD_STOP_TO_BLACK`` is set, then the decoder will set
218 the picture to black after it stopped decoding. Otherwise the last
219 image will repeat. mem2mem decoders will stop producing new frames
220 altogether. They will send a ``V4L2_EVENT_EOS`` event when the
221 last frame has been decoded and all frames are ready to be
222 dequeued and will set the ``V4L2_BUF_FLAG_LAST`` buffer flag on
223 the last buffer of the capture queue to indicate there will be no
224 new buffers produced to dequeue. This buffer may be empty,
225 indicated by the driver setting the ``bytesused`` field to 0. Once
226 the ``V4L2_BUF_FLAG_LAST`` flag was set, the
227 :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will not block anymore,
228 but return an EPIPE error code. If
229 ``V4L2_DEC_CMD_STOP_IMMEDIATELY`` is set, then the decoder stops
230 immediately (ignoring the ``pts`` value), otherwise it will keep
231 decoding until timestamp >= pts or until the last of the pending
232 data from its internal buffers was decoded.
236 - ``V4L2_DEC_CMD_PAUSE``
240 - Pause the decoder. When the decoder has not been started yet, the
241 driver will return an EPERM error code. When the decoder is
242 already paused, this command does nothing. This command has one
243 flag: if ``V4L2_DEC_CMD_PAUSE_TO_BLACK`` is set, then set the
244 decoder output to black when paused.
248 - ``V4L2_DEC_CMD_RESUME``
252 - Resume decoding after a PAUSE command. When the decoder has not
253 been started yet, the driver will return an EPERM error code. When
254 the decoder is already running, this command does nothing. No
255 flags are defined for this command.
262 On success 0 is returned, on error -1 and the ``errno`` variable is set
263 appropriately. The generic error codes are described at the
264 :ref:`Generic Error Codes <gen-errors>` chapter.
267 The ``cmd`` field is invalid.
270 The application sent a PAUSE or RESUME command when the decoder was
274 .. ------------------------------------------------------------------------------
275 .. This file was automatically converted from DocBook-XML with the dbxml
276 .. library (https://github.com/return42/sphkerneldoc). The origin XML comes
277 .. from the linux kernel, refer to:
279 .. * https://github.com/torvalds/linux/tree/master/Documentation/DocBook
280 .. ------------------------------------------------------------------------------