1 <refentry id="vidioc-encoder-cmd">
3 <refentrytitle>ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</refentrytitle>
8 <refname>VIDIOC_ENCODER_CMD</refname>
9 <refname>VIDIOC_TRY_ENCODER_CMD</refname>
10 <refpurpose>Execute an encoder command</refpurpose>
16 <funcdef>int <function>ioctl</function></funcdef>
17 <paramdef>int <parameter>fd</parameter></paramdef>
18 <paramdef>int <parameter>request</parameter></paramdef>
19 <paramdef>struct v4l2_encoder_cmd *<parameter>argp</parameter></paramdef>
25 <title>Arguments</title>
29 <term><parameter>fd</parameter></term>
35 <term><parameter>request</parameter></term>
37 <para>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</para>
41 <term><parameter>argp</parameter></term>
50 <title>Description</title>
52 <para>These ioctls control an audio/video (usually MPEG-) encoder.
53 <constant>VIDIOC_ENCODER_CMD</constant> sends a command to the
54 encoder, <constant>VIDIOC_TRY_ENCODER_CMD</constant> can be used to
55 try a command without actually executing it.</para>
57 <para>To send a command applications must initialize all fields of a
58 &v4l2-encoder-cmd; and call
59 <constant>VIDIOC_ENCODER_CMD</constant> or
60 <constant>VIDIOC_TRY_ENCODER_CMD</constant> with a pointer to this
63 <para>The <structfield>cmd</structfield> field must contain the
64 command code. The <structfield>flags</structfield> field is currently
65 only used by the STOP command and contains one bit: If the
66 <constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant> flag is set,
67 encoding will continue until the end of the current <wordasword>Group
68 Of Pictures</wordasword>, otherwise it will stop immediately.</para>
70 <para>A <function>read</function>() or &VIDIOC-STREAMON; call sends an implicit
71 START command to the encoder if it has not been started yet. After a STOP command,
72 <function>read</function>() calls will read the remaining data
73 buffered by the driver. When the buffer is empty,
74 <function>read</function>() will return zero and the next
75 <function>read</function>() call will restart the encoder.</para>
77 <para>A <function>close</function>() or &VIDIOC-STREAMOFF; call of a streaming
78 file descriptor sends an implicit immediate STOP to the encoder, and all buffered
79 data is discarded.</para>
81 <para>These ioctls are optional, not all drivers may support
82 them. They were introduced in Linux 2.6.21.</para>
84 <table pgwide="1" frame="none" id="v4l2-encoder-cmd">
85 <title>struct <structname>v4l2_encoder_cmd</structname></title>
91 <entry><structfield>cmd</structfield></entry>
92 <entry>The encoder command, see <xref linkend="encoder-cmds" />.</entry>
96 <entry><structfield>flags</structfield></entry>
97 <entry>Flags to go with the command, see <xref
98 linkend="encoder-flags" />. If no flags are defined for
99 this command, drivers and applications must set this field to
104 <entry><structfield>data</structfield>[8]</entry>
105 <entry>Reserved for future extensions. Drivers and
106 applications must set the array to zero.</entry>
112 <table pgwide="1" frame="none" id="encoder-cmds">
113 <title>Encoder Commands</title>
118 <entry><constant>V4L2_ENC_CMD_START</constant></entry>
120 <entry>Start the encoder. When the encoder is already
121 running or paused, this command does nothing. No flags are defined for
122 this command.</entry>
125 <entry><constant>V4L2_ENC_CMD_STOP</constant></entry>
127 <entry>Stop the encoder. When the
128 <constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant> flag is set,
129 encoding will continue until the end of the current <wordasword>Group
130 Of Pictures</wordasword>, otherwise encoding will stop immediately.
131 When the encoder is already stopped, this command does
135 <entry><constant>V4L2_ENC_CMD_PAUSE</constant></entry>
137 <entry>Pause the encoder. When the encoder has not been
138 started yet, the driver will return an &EPERM;. When the encoder is
139 already paused, this command does nothing. No flags are defined for
140 this command.</entry>
143 <entry><constant>V4L2_ENC_CMD_RESUME</constant></entry>
145 <entry>Resume encoding after a PAUSE command. When the
146 encoder has not been started yet, the driver will return an &EPERM;.
147 When the encoder is already running, this command does nothing. No
148 flags are defined for this command.</entry>
154 <table pgwide="1" frame="none" id="encoder-flags">
155 <title>Encoder Command Flags</title>
160 <entry><constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant></entry>
161 <entry>0x0001</entry>
162 <entry>Stop encoding at the end of the current <wordasword>Group Of
163 Pictures</wordasword>, rather than immediately.</entry>
175 <term><errorcode>EINVAL</errorcode></term>
177 <para>The <structfield>cmd</structfield> field is invalid.</para>
181 <term><errorcode>EPERM</errorcode></term>
183 <para>The application sent a PAUSE or RESUME command when
184 the encoder was not running.</para>