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