avdevice.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVDEVICE_AVDEVICE_H
  19. #define AVDEVICE_AVDEVICE_H
  20. #include "version.h"
  21. /**
  22. * @file
  23. * @ingroup lavd
  24. * Main libavdevice API header
  25. */
  26. /**
  27. * @defgroup lavd Special devices muxing/demuxing library
  28. * @{
  29. * Libavdevice is a complementary library to @ref libavf "libavformat". It
  30. * provides various "special" platform-specific muxers and demuxers, e.g. for
  31. * grabbing devices, audio capture and playback etc. As a consequence, the
  32. * (de)muxers in libavdevice are of the AVFMT_NOFILE type (they use their own
  33. * I/O functions). The filename passed to avformat_open_input() often does not
  34. * refer to an actually existing file, but has some special device-specific
  35. * meaning - e.g. for x11grab it is the display name.
  36. *
  37. * To use libavdevice, simply call avdevice_register_all() to register all
  38. * compiled muxers and demuxers. They all use standard libavformat API.
  39. * @}
  40. */
  41. #include "libavformat/avformat.h"
  42. /**
  43. * Return the LIBAVDEVICE_VERSION_INT constant.
  44. */
  45. unsigned avdevice_version(void);
  46. /**
  47. * Return the libavdevice build-time configuration.
  48. */
  49. const char *avdevice_configuration(void);
  50. /**
  51. * Return the libavdevice license.
  52. */
  53. const char *avdevice_license(void);
  54. /**
  55. * Initialize libavdevice and register all the input and output devices.
  56. * @warning This function is not thread safe.
  57. */
  58. void avdevice_register_all(void);
  59. typedef struct AVDeviceRect {
  60. int x; /**< x coordinate of top left corner */
  61. int y; /**< y coordinate of top left corner */
  62. int width; /**< width */
  63. int height; /**< height */
  64. } AVDeviceRect;
  65. /**
  66. * Message types used by avdevice_app_to_dev_control_message().
  67. */
  68. enum AVAppToDevMessageType {
  69. /**
  70. * Dummy message.
  71. */
  72. AV_APP_TO_DEV_NONE = MKBETAG('N','O','N','E'),
  73. /**
  74. * Window size change message.
  75. *
  76. * Message is sent to the device every time the application changes the size
  77. * of the window device renders to.
  78. * Message should also be sent right after window is created.
  79. *
  80. * data: AVDeviceRect: new window size.
  81. */
  82. AV_APP_TO_DEV_WINDOW_SIZE = MKBETAG('G','E','O','M'),
  83. /**
  84. * Repaint request message.
  85. *
  86. * Message is sent to the device when window have to be rapainted.
  87. *
  88. * data: AVDeviceRect: area required to be repainted.
  89. * NULL: whole area is required to be repainted.
  90. */
  91. AV_APP_TO_DEV_WINDOW_REPAINT = MKBETAG('R','E','P','A')
  92. };
  93. /**
  94. * Message types used by avdevice_dev_to_app_control_message().
  95. */
  96. enum AVDevToAppMessageType {
  97. /**
  98. * Dummy message.
  99. */
  100. AV_DEV_TO_APP_NONE = MKBETAG('N','O','N','E'),
  101. /**
  102. * Create window buffer message.
  103. *
  104. * Device requests to create a window buffer. Exact meaning is device-
  105. * and application-dependent. Message is sent before rendering first
  106. * frame and all one-shot initializations should be done here.
  107. *
  108. * data: NULL.
  109. */
  110. AV_DEV_TO_APP_CREATE_WINDOW_BUFFER = MKBETAG('B','C','R','E'),
  111. /**
  112. * Prepare window buffer message.
  113. *
  114. * Device requests to prepare a window buffer for rendering.
  115. * Exact meaning is device- and application-dependent.
  116. * Message is sent before rendering of each frame.
  117. *
  118. * data: NULL.
  119. */
  120. AV_DEV_TO_APP_PREPARE_WINDOW_BUFFER = MKBETAG('B','P','R','E'),
  121. /**
  122. * Display window buffer message.
  123. *
  124. * Device requests to display a window buffer.
  125. * Message is sent when new frame is ready to be displyed.
  126. * Usually buffers need to be swapped in handler of this message.
  127. *
  128. * data: NULL.
  129. */
  130. AV_DEV_TO_APP_DISPLAY_WINDOW_BUFFER = MKBETAG('B','D','I','S'),
  131. /**
  132. * Destroy window buffer message.
  133. *
  134. * Device requests to destroy a window buffer.
  135. * Message is sent when device is about to be destroyed and window
  136. * buffer is not required anymore.
  137. *
  138. * data: NULL.
  139. */
  140. AV_DEV_TO_APP_DESTROY_WINDOW_BUFFER = MKBETAG('B','D','E','S')
  141. };
  142. /**
  143. * Send control message from application to device.
  144. *
  145. * @param s device context.
  146. * @param type message type.
  147. * @param data message data. Exact type depends on message type.
  148. * @param data_size size of message data.
  149. * @return >= 0 on success, negative on error.
  150. * AVERROR(ENOSYS) when device doesn't implement handler of the message.
  151. */
  152. int avdevice_app_to_dev_control_message(struct AVFormatContext *s,
  153. enum AVAppToDevMessageType type,
  154. void *data, size_t data_size);
  155. /**
  156. * Send control message from device to application.
  157. *
  158. * @param s device context.
  159. * @param type message type.
  160. * @param data message data. Can be NULL.
  161. * @param data_size size of message data.
  162. * @return >= 0 on success, negative on error.
  163. * AVERROR(ENOSYS) when application doesn't implement handler of the message.
  164. */
  165. int avdevice_dev_to_app_control_message(struct AVFormatContext *s,
  166. enum AVDevToAppMessageType type,
  167. void *data, size_t data_size);
  168. #endif /* AVDEVICE_AVDEVICE_H */