vidioc-encoder-cmd.xml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <refentry id="vidioc-encoder-cmd">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_ENCODER_CMD</refname>
  8. <refname>VIDIOC_TRY_ENCODER_CMD</refname>
  9. <refpurpose>Execute an encoder command</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>int <function>ioctl</function></funcdef>
  15. <paramdef>int <parameter>fd</parameter></paramdef>
  16. <paramdef>int <parameter>request</parameter></paramdef>
  17. <paramdef>struct v4l2_encoder_cmd *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. </refsynopsisdiv>
  21. <refsect1>
  22. <title>Arguments</title>
  23. <variablelist>
  24. <varlistentry>
  25. <term><parameter>fd</parameter></term>
  26. <listitem>
  27. <para>&fd;</para>
  28. </listitem>
  29. </varlistentry>
  30. <varlistentry>
  31. <term><parameter>request</parameter></term>
  32. <listitem>
  33. <para>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</para>
  34. </listitem>
  35. </varlistentry>
  36. <varlistentry>
  37. <term><parameter>argp</parameter></term>
  38. <listitem>
  39. <para></para>
  40. </listitem>
  41. </varlistentry>
  42. </variablelist>
  43. </refsect1>
  44. <refsect1>
  45. <title>Description</title>
  46. <para>These ioctls control an audio/video (usually MPEG-) encoder.
  47. <constant>VIDIOC_ENCODER_CMD</constant> sends a command to the
  48. encoder, <constant>VIDIOC_TRY_ENCODER_CMD</constant> can be used to
  49. try a command without actually executing it.</para>
  50. <para>To send a command applications must initialize all fields of a
  51. &v4l2-encoder-cmd; and call
  52. <constant>VIDIOC_ENCODER_CMD</constant> or
  53. <constant>VIDIOC_TRY_ENCODER_CMD</constant> with a pointer to this
  54. structure.</para>
  55. <para>The <structfield>cmd</structfield> field must contain the
  56. command code. The <structfield>flags</structfield> field is currently
  57. only used by the STOP command and contains one bit: If the
  58. <constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant> flag is set,
  59. encoding will continue until the end of the current <wordasword>Group
  60. Of Pictures</wordasword>, otherwise it will stop immediately.</para>
  61. <para>A <function>read</function>() or &VIDIOC-STREAMON; call sends an implicit
  62. START command to the encoder if it has not been started yet. After a STOP command,
  63. <function>read</function>() calls will read the remaining data
  64. buffered by the driver. When the buffer is empty,
  65. <function>read</function>() will return zero and the next
  66. <function>read</function>() call will restart the encoder.</para>
  67. <para>A <function>close</function>() or &VIDIOC-STREAMOFF; call of a streaming
  68. file descriptor sends an implicit immediate STOP to the encoder, and all buffered
  69. data is discarded.</para>
  70. <para>These ioctls are optional, not all drivers may support
  71. them. They were introduced in Linux 2.6.21.</para>
  72. <table pgwide="1" frame="none" id="v4l2-encoder-cmd">
  73. <title>struct <structname>v4l2_encoder_cmd</structname></title>
  74. <tgroup cols="3">
  75. &cs-str;
  76. <tbody valign="top">
  77. <row>
  78. <entry>__u32</entry>
  79. <entry><structfield>cmd</structfield></entry>
  80. <entry>The encoder command, see <xref linkend="encoder-cmds" />.</entry>
  81. </row>
  82. <row>
  83. <entry>__u32</entry>
  84. <entry><structfield>flags</structfield></entry>
  85. <entry>Flags to go with the command, see <xref
  86. linkend="encoder-flags" />. If no flags are defined for
  87. this command, drivers and applications must set this field to
  88. zero.</entry>
  89. </row>
  90. <row>
  91. <entry>__u32</entry>
  92. <entry><structfield>data</structfield>[8]</entry>
  93. <entry>Reserved for future extensions. Drivers and
  94. applications must set the array to zero.</entry>
  95. </row>
  96. </tbody>
  97. </tgroup>
  98. </table>
  99. <table pgwide="1" frame="none" id="encoder-cmds">
  100. <title>Encoder Commands</title>
  101. <tgroup cols="3">
  102. &cs-def;
  103. <tbody valign="top">
  104. <row>
  105. <entry><constant>V4L2_ENC_CMD_START</constant></entry>
  106. <entry>0</entry>
  107. <entry>Start the encoder. When the encoder is already
  108. running or paused, this command does nothing. No flags are defined for
  109. this command.</entry>
  110. </row>
  111. <row>
  112. <entry><constant>V4L2_ENC_CMD_STOP</constant></entry>
  113. <entry>1</entry>
  114. <entry>Stop the encoder. When the
  115. <constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant> flag is set,
  116. encoding will continue until the end of the current <wordasword>Group
  117. Of Pictures</wordasword>, otherwise encoding will stop immediately.
  118. When the encoder is already stopped, this command does
  119. nothing. mem2mem encoders will send a <constant>V4L2_EVENT_EOS</constant> event
  120. when the last frame has been encoded and all frames are ready to be dequeued and
  121. will set the <constant>V4L2_BUF_FLAG_LAST</constant> buffer flag on the last
  122. buffer of the capture queue to indicate there will be no new buffers produced to
  123. dequeue. This buffer may be empty, indicated by the driver setting the
  124. <structfield>bytesused</structfield> field to 0. Once the
  125. <constant>V4L2_BUF_FLAG_LAST</constant> flag was set, the
  126. <link linkend="vidioc-qbuf">VIDIOC_DQBUF</link> ioctl will not block anymore,
  127. but return an &EPIPE;.</entry>
  128. </row>
  129. <row>
  130. <entry><constant>V4L2_ENC_CMD_PAUSE</constant></entry>
  131. <entry>2</entry>
  132. <entry>Pause the encoder. When the encoder has not been
  133. started yet, the driver will return an &EPERM;. When the encoder is
  134. already paused, this command does nothing. No flags are defined for
  135. this command.</entry>
  136. </row>
  137. <row>
  138. <entry><constant>V4L2_ENC_CMD_RESUME</constant></entry>
  139. <entry>3</entry>
  140. <entry>Resume encoding after a PAUSE command. When the
  141. encoder has not been started yet, the driver will return an &EPERM;.
  142. When the encoder is already running, this command does nothing. No
  143. flags are defined for this command.</entry>
  144. </row>
  145. </tbody>
  146. </tgroup>
  147. </table>
  148. <table pgwide="1" frame="none" id="encoder-flags">
  149. <title>Encoder Command Flags</title>
  150. <tgroup cols="3">
  151. &cs-def;
  152. <tbody valign="top">
  153. <row>
  154. <entry><constant>V4L2_ENC_CMD_STOP_AT_GOP_END</constant></entry>
  155. <entry>0x0001</entry>
  156. <entry>Stop encoding at the end of the current <wordasword>Group Of
  157. Pictures</wordasword>, rather than immediately.</entry>
  158. </row>
  159. </tbody>
  160. </tgroup>
  161. </table>
  162. </refsect1>
  163. <refsect1>
  164. &return-value;
  165. <variablelist>
  166. <varlistentry>
  167. <term><errorcode>EINVAL</errorcode></term>
  168. <listitem>
  169. <para>The <structfield>cmd</structfield> field is invalid.</para>
  170. </listitem>
  171. </varlistentry>
  172. <varlistentry>
  173. <term><errorcode>EPERM</errorcode></term>
  174. <listitem>
  175. <para>The application sent a PAUSE or RESUME command when
  176. the encoder was not running.</para>
  177. </listitem>
  178. </varlistentry>
  179. </variablelist>
  180. </refsect1>
  181. </refentry>