vidioc-decoder-cmd.rst 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. .. -*- coding: utf-8; mode: rst -*-
  2. .. _VIDIOC_DECODER_CMD:
  3. ************************************************
  4. ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD
  5. ************************************************
  6. Name
  7. ====
  8. VIDIOC_DECODER_CMD - VIDIOC_TRY_DECODER_CMD - Execute an decoder command
  9. Synopsis
  10. ========
  11. .. c:function:: int ioctl( int fd, VIDIOC_DECODER_CMD, struct v4l2_decoder_cmd *argp )
  12. :name: VIDIOC_DECODER_CMD
  13. .. c:function:: int ioctl( int fd, VIDIOC_TRY_DECODER_CMD, struct v4l2_decoder_cmd *argp )
  14. :name: VIDIOC_TRY_DECODER_CMD
  15. Arguments
  16. =========
  17. ``fd``
  18. File descriptor returned by :ref:`open() <func-open>`.
  19. ``argp``
  20. pointer to struct :c:type:`v4l2_decoder_cmd`.
  21. Description
  22. ===========
  23. These ioctls control an audio/video (usually MPEG-) decoder.
  24. ``VIDIOC_DECODER_CMD`` sends a command to the decoder,
  25. ``VIDIOC_TRY_DECODER_CMD`` can be used to try a command without actually
  26. executing it. To send a command applications must initialize all fields
  27. of a struct :c:type:`v4l2_decoder_cmd` and call
  28. ``VIDIOC_DECODER_CMD`` or ``VIDIOC_TRY_DECODER_CMD`` with a pointer to
  29. this structure.
  30. The ``cmd`` field must contain the command code. Some commands use the
  31. ``flags`` field for additional information.
  32. A :ref:`write() <func-write>` or :ref:`VIDIOC_STREAMON`
  33. call sends an implicit START command to the decoder if it has not been
  34. started yet.
  35. A :ref:`close() <func-close>` or :ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`
  36. call of a streaming file descriptor sends an implicit immediate STOP
  37. command to the decoder, and all buffered data is discarded.
  38. These ioctls are optional, not all drivers may support them. They were
  39. introduced in Linux 3.3.
  40. .. tabularcolumns:: |p{1.1cm}|p{2.4cm}|p{1.2cm}|p{1.6cm}|p{10.6cm}|
  41. .. c:type:: v4l2_decoder_cmd
  42. .. cssclass:: longtable
  43. .. flat-table:: struct v4l2_decoder_cmd
  44. :header-rows: 0
  45. :stub-columns: 0
  46. :widths: 11 24 12 16 106
  47. * - __u32
  48. - ``cmd``
  49. -
  50. -
  51. - The decoder command, see :ref:`decoder-cmds`.
  52. * - __u32
  53. - ``flags``
  54. -
  55. -
  56. - Flags to go with the command. If no flags are defined for this
  57. command, drivers and applications must set this field to zero.
  58. * - union
  59. - (anonymous)
  60. -
  61. -
  62. -
  63. * -
  64. - struct
  65. - ``start``
  66. -
  67. - Structure containing additional data for the
  68. ``V4L2_DEC_CMD_START`` command.
  69. * -
  70. -
  71. - __s32
  72. - ``speed``
  73. - Playback speed and direction. The playback speed is defined as
  74. ``speed``/1000 of the normal speed. So 1000 is normal playback.
  75. Negative numbers denote reverse playback, so -1000 does reverse
  76. playback at normal speed. Speeds -1, 0 and 1 have special
  77. meanings: speed 0 is shorthand for 1000 (normal playback). A speed
  78. of 1 steps just one frame forward, a speed of -1 steps just one
  79. frame back.
  80. * -
  81. -
  82. - __u32
  83. - ``format``
  84. - Format restrictions. This field is set by the driver, not the
  85. application. Possible values are ``V4L2_DEC_START_FMT_NONE`` if
  86. there are no format restrictions or ``V4L2_DEC_START_FMT_GOP`` if
  87. the decoder operates on full GOPs (*Group Of Pictures*). This is
  88. usually the case for reverse playback: the decoder needs full
  89. GOPs, which it can then play in reverse order. So to implement
  90. reverse playback the application must feed the decoder the last
  91. GOP in the video file, then the GOP before that, etc. etc.
  92. * -
  93. - struct
  94. - ``stop``
  95. -
  96. - Structure containing additional data for the ``V4L2_DEC_CMD_STOP``
  97. command.
  98. * -
  99. -
  100. - __u64
  101. - ``pts``
  102. - Stop playback at this ``pts`` or immediately if the playback is
  103. already past that timestamp. Leave to 0 if you want to stop after
  104. the last frame was decoded.
  105. * -
  106. - struct
  107. - ``raw``
  108. -
  109. -
  110. * -
  111. -
  112. - __u32
  113. - ``data``\ [16]
  114. - Reserved for future extensions. Drivers and applications must set
  115. the array to zero.
  116. .. tabularcolumns:: |p{5.6cm}|p{0.6cm}|p{11.3cm}|
  117. .. _decoder-cmds:
  118. .. flat-table:: Decoder Commands
  119. :header-rows: 0
  120. :stub-columns: 0
  121. :widths: 56 6 113
  122. * - ``V4L2_DEC_CMD_START``
  123. - 0
  124. - Start the decoder. When the decoder is already running or paused,
  125. this command will just change the playback speed. That means that
  126. calling ``V4L2_DEC_CMD_START`` when the decoder was paused will
  127. *not* resume the decoder. You have to explicitly call
  128. ``V4L2_DEC_CMD_RESUME`` for that. This command has one flag:
  129. ``V4L2_DEC_CMD_START_MUTE_AUDIO``. If set, then audio will be
  130. muted when playing back at a non-standard speed.
  131. * - ``V4L2_DEC_CMD_STOP``
  132. - 1
  133. - Stop the decoder. When the decoder is already stopped, this
  134. command does nothing. This command has two flags: if
  135. ``V4L2_DEC_CMD_STOP_TO_BLACK`` is set, then the decoder will set
  136. the picture to black after it stopped decoding. Otherwise the last
  137. image will repeat. mem2mem decoders will stop producing new frames
  138. altogether. They will send a ``V4L2_EVENT_EOS`` event when the
  139. last frame has been decoded and all frames are ready to be
  140. dequeued and will set the ``V4L2_BUF_FLAG_LAST`` buffer flag on
  141. the last buffer of the capture queue to indicate there will be no
  142. new buffers produced to dequeue. This buffer may be empty,
  143. indicated by the driver setting the ``bytesused`` field to 0. Once
  144. the ``V4L2_BUF_FLAG_LAST`` flag was set, the
  145. :ref:`VIDIOC_DQBUF <VIDIOC_QBUF>` ioctl will not block anymore,
  146. but return an ``EPIPE`` error code. If
  147. ``V4L2_DEC_CMD_STOP_IMMEDIATELY`` is set, then the decoder stops
  148. immediately (ignoring the ``pts`` value), otherwise it will keep
  149. decoding until timestamp >= pts or until the last of the pending
  150. data from its internal buffers was decoded.
  151. * - ``V4L2_DEC_CMD_PAUSE``
  152. - 2
  153. - Pause the decoder. When the decoder has not been started yet, the
  154. driver will return an ``EPERM`` error code. When the decoder is
  155. already paused, this command does nothing. This command has one
  156. flag: if ``V4L2_DEC_CMD_PAUSE_TO_BLACK`` is set, then set the
  157. decoder output to black when paused.
  158. * - ``V4L2_DEC_CMD_RESUME``
  159. - 3
  160. - Resume decoding after a PAUSE command. When the decoder has not
  161. been started yet, the driver will return an ``EPERM`` error code. When
  162. the decoder is already running, this command does nothing. No
  163. flags are defined for this command.
  164. Return Value
  165. ============
  166. On success 0 is returned, on error -1 and the ``errno`` variable is set
  167. appropriately. The generic error codes are described at the
  168. :ref:`Generic Error Codes <gen-errors>` chapter.
  169. EINVAL
  170. The ``cmd`` field is invalid.
  171. EPERM
  172. The application sent a PAUSE or RESUME command when the decoder was
  173. not running.