<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="apa.html" title="Appendix A. Function Reference" /><link rel="prev" href="re24.html" title="ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER" /><link rel="next" href="re26.html" title="ioctl VIDIOC_ENUMAUDIO" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re24.html">Prev</a> </td><th width="60%" align="center">Appendix A. Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="re26.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD"><a id="vidioc-encoder-cmd"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD — Execute an encoder command</p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">int <b class="fsfunc">ioctl</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">request</var>, </td></tr><tr><td> </td><td>struct v4l2_encoder_cmd *<var class="pdparam">argp</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1" title="Arguments"><a id="id2690216"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>fd</code></em></span></dt><dd><p>File descriptor returned by <a class="link" href="re64.html" title="V4L2 open()"><code class="function">open()</code></a>.</p></dd><dt><span class="term"><em class="parameter"><code>request</code></em></span></dt><dd><p>VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD</p></dd><dt><span class="term"><em class="parameter"><code>argp</code></em></span></dt><dd><p></p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2690285"></a><h2>Description</h2><div class="note" title="Experimental" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Experimental</h3><p>This is an <a class="link" href="ch07s04.html" title="Experimental API Elements">experimental</a> interface and may change in the future.</p></div><p>These ioctls control an audio/video (usually MPEG-) encoder. <code class="constant">VIDIOC_ENCODER_CMD</code> sends a command to the encoder, <code class="constant">VIDIOC_TRY_ENCODER_CMD</code> can be used to try a command without actually executing it.</p><p>To send a command applications must initialize all fields of a struct <a class="link" href="re25.html#v4l2-encoder-cmd" title="Table A.10. struct v4l2_encoder_cmd">v4l2_encoder_cmd</a> and call <code class="constant">VIDIOC_ENCODER_CMD</code> or <code class="constant">VIDIOC_TRY_ENCODER_CMD</code> with a pointer to this structure.</p><p>The <em class="structfield"><code>cmd</code></em> field must contain the command code. The <em class="structfield"><code>flags</code></em> field is currently only used by the STOP command and contains one bit: If the <code class="constant">V4L2_ENC_CMD_STOP_AT_GOP_END</code> flag is set, encoding will continue until the end of the current <em class="wordasword">Group Of Pictures</em>, otherwise it will stop immediately.</p><p>A <code class="function">read</code>() call sends a START command to the encoder if it has not been started yet. After a STOP command, <code class="function">read</code>() calls will read the remaining data buffered by the driver. When the buffer is empty, <code class="function">read</code>() will return zero and the next <code class="function">read</code>() call will restart the encoder.</p><p>A <code class="function">close</code>() call sends an immediate STOP to the encoder, and all buffered data is discarded.</p><p>These ioctls are optional, not all drivers may support them. They were introduced in Linux 2.6.21.</p><div class="table"><a id="v4l2-encoder-cmd"></a><p class="title"><b>Table A.10. struct <span class="structname">v4l2_encoder_cmd</span></b></p><div class="table-contents"><table summary="struct v4l2_encoder_cmd" width="100%" border="0"><colgroup><col /><col /><col /></colgroup><tbody valign="top"><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>cmd</code></em></td><td valign="top">The encoder command, see <a class="xref" href="re25.html#encoder-cmds" title="Table A.11. Encoder Commands">Table A.11, “Encoder Commands”</a>.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>flags</code></em></td><td valign="top">Flags to go with the command, see <a class="xref" href="re25.html#encoder-flags" title="Table A.12. Encoder Command Flags">Table A.12, “Encoder Command Flags”</a>. If no flags are defined for this command, drivers and applications must set this field to zero.</td></tr><tr><td valign="top">__u32</td><td valign="top"><em class="structfield"><code>data</code></em>[8]</td><td valign="top">Reserved for future extensions. Drivers and applications must set the array to zero.</td></tr></tbody></table></div></div><br class="table-break" /><div class="table"><a id="encoder-cmds"></a><p class="title"><b>Table A.11. Encoder Commands</b></p><div class="table-contents"><table summary="Encoder Commands" width="100%" border="0"><colgroup><col /><col /><col /></colgroup><tbody valign="top"><tr><td valign="top"><code class="constant">V4L2_ENC_CMD_START</code></td><td valign="top">0</td><td valign="top">Start the encoder. When the encoder is already running or paused, this command does nothing. No flags are defined for this command.</td></tr><tr><td valign="top"><code class="constant">V4L2_ENC_CMD_STOP</code></td><td valign="top">1</td><td valign="top">Stop the encoder. When the <code class="constant">V4L2_ENC_CMD_STOP_AT_GOP_END</code> flag is set, encoding will continue until the end of the current <em class="wordasword">Group Of Pictures</em>, otherwise encoding will stop immediately. When the encoder is already stopped, this command does nothing.</td></tr><tr><td valign="top"><code class="constant">V4L2_ENC_CMD_PAUSE</code></td><td valign="top">2</td><td valign="top">Pause the encoder. When the encoder has not been started yet, the driver will return an <span class="errorcode">EPERM</span> error code. When the encoder is already paused, this command does nothing. No flags are defined for this command.</td></tr><tr><td valign="top"><code class="constant">V4L2_ENC_CMD_RESUME</code></td><td valign="top">3</td><td valign="top">Resume encoding after a PAUSE command. When the encoder has not been started yet, the driver will return an <span class="errorcode">EPERM</span> error code. When the encoder is already running, this command does nothing. No flags are defined for this command.</td></tr></tbody></table></div></div><br class="table-break" /><div class="table"><a id="encoder-flags"></a><p class="title"><b>Table A.12. Encoder Command Flags</b></p><div class="table-contents"><table summary="Encoder Command Flags" width="100%" border="0"><colgroup><col /><col /><col /></colgroup><tbody valign="top"><tr><td valign="top"><code class="constant">V4L2_ENC_CMD_STOP_AT_GOP_END</code></td><td valign="top">0x0001</td><td valign="top">Stop encoding at the end of the current <em class="wordasword">Group Of Pictures</em>, rather than immediately.</td></tr></tbody></table></div></div><br class="table-break" /></div><div class="refsect1" title="Return Value"><a id="id2690744"></a><h2>Return Value</h2><p>On success <span class="returnvalue">0</span> is returned, on error <span class="returnvalue">-1</span> and the <code class="varname">errno</code> variable is set appropriately:</p><div class="variablelist"><dl><dt><span class="term"><span class="errorcode">EINVAL</span></span></dt><dd><p>The driver does not support this ioctl, or the <em class="structfield"><code>cmd</code></em> field is invalid.</p></dd><dt><span class="term"><span class="errorcode">EPERM</span></span></dt><dd><p>The application sent a PAUSE or RESUME command when the encoder was not running.</p></dd></dl></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re24.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="apa.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="re26.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ioctl VIDIOC_ENUMAUDIO</td></tr></table></div></body></html>