videodev_imp.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program 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
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __VIDEODEV_IMP_H__
  19. #define __VIDEODEV_IMP_H__
  20. #include <pjmedia-videodev/videodev.h>
  21. /**
  22. * @defgroup s8_video_device_implementors_api Video Device Implementors API
  23. * @ingroup video_device_api
  24. * @brief API for video device implementors
  25. * @{
  26. */
  27. /**
  28. * Video device factory operations.
  29. */
  30. typedef struct pjmedia_vid_dev_factory_op
  31. {
  32. /**
  33. * Initialize the video device factory.
  34. *
  35. * @param f The video device factory.
  36. */
  37. pj_status_t (*init)(pjmedia_vid_dev_factory *f);
  38. /**
  39. * Close this video device factory and release all resources back to the
  40. * operating system.
  41. *
  42. * @param f The video device factory.
  43. */
  44. pj_status_t (*destroy)(pjmedia_vid_dev_factory *f);
  45. /**
  46. * Get the number of video devices installed in the system.
  47. *
  48. * @param f The video device factory.
  49. */
  50. unsigned (*get_dev_count)(pjmedia_vid_dev_factory *f);
  51. /**
  52. * Get the video device information and capabilities.
  53. *
  54. * @param f The video device factory.
  55. * @param index Device index.
  56. * @param info The video device information structure which will be
  57. * initialized by this function once it returns
  58. * successfully.
  59. */
  60. pj_status_t (*get_dev_info)(pjmedia_vid_dev_factory *f,
  61. unsigned index,
  62. pjmedia_vid_dev_info *info);
  63. /**
  64. * Initialize the specified video device parameter with the default
  65. * values for the specified device.
  66. *
  67. * @param f The video device factory.
  68. * @param index Device index.
  69. * @param param The video device parameter.
  70. */
  71. pj_status_t (*default_param)(pj_pool_t *pool,
  72. pjmedia_vid_dev_factory *f,
  73. unsigned index,
  74. pjmedia_vid_dev_param *param);
  75. /**
  76. * Open the video device and create video stream. See
  77. * #pjmedia_vid_dev_stream_create()
  78. */
  79. pj_status_t (*create_stream)(pjmedia_vid_dev_factory *f,
  80. pjmedia_vid_dev_param *param,
  81. const pjmedia_vid_dev_cb *cb,
  82. void *user_data,
  83. pjmedia_vid_dev_stream **p_vid_strm);
  84. /**
  85. * Refresh the list of video devices installed in the system.
  86. *
  87. * @param f The video device factory.
  88. */
  89. pj_status_t (*refresh)(pjmedia_vid_dev_factory *f);
  90. } pjmedia_vid_dev_factory_op;
  91. /**
  92. * This structure describes a video device factory.
  93. */
  94. struct pjmedia_vid_dev_factory
  95. {
  96. /** Internal data to be initialized by video subsystem. */
  97. struct {
  98. /** Driver index */
  99. unsigned drv_idx;
  100. } sys;
  101. /** Operations */
  102. pjmedia_vid_dev_factory_op *op;
  103. };
  104. /**
  105. * Video stream operations.
  106. */
  107. typedef struct pjmedia_vid_dev_stream_op
  108. {
  109. /**
  110. * See #pjmedia_vid_dev_stream_get_param()
  111. */
  112. pj_status_t (*get_param)(pjmedia_vid_dev_stream *strm,
  113. pjmedia_vid_dev_param *param);
  114. /**
  115. * See #pjmedia_vid_dev_stream_get_cap()
  116. */
  117. pj_status_t (*get_cap)(pjmedia_vid_dev_stream *strm,
  118. pjmedia_vid_dev_cap cap,
  119. void *value);
  120. /**
  121. * See #pjmedia_vid_dev_stream_set_cap()
  122. */
  123. pj_status_t (*set_cap)(pjmedia_vid_dev_stream *strm,
  124. pjmedia_vid_dev_cap cap,
  125. const void *value);
  126. /**
  127. * See #pjmedia_vid_dev_stream_start()
  128. */
  129. pj_status_t (*start)(pjmedia_vid_dev_stream *strm);
  130. /**
  131. * See #pjmedia_vid_dev_stream_get_frame()
  132. */
  133. pj_status_t (*get_frame)(pjmedia_vid_dev_stream *strm,
  134. pjmedia_frame *frame);
  135. /**
  136. * See #pjmedia_vid_dev_stream_put_frame()
  137. */
  138. pj_status_t (*put_frame)(pjmedia_vid_dev_stream *strm,
  139. const pjmedia_frame *frame);
  140. /**
  141. * See #pjmedia_vid_dev_stream_stop().
  142. */
  143. pj_status_t (*stop)(pjmedia_vid_dev_stream *strm);
  144. /**
  145. * See #pjmedia_vid_dev_stream_destroy().
  146. */
  147. pj_status_t (*destroy)(pjmedia_vid_dev_stream *strm);
  148. } pjmedia_vid_dev_stream_op;
  149. /**
  150. * This structure describes the video device stream.
  151. */
  152. struct pjmedia_vid_dev_stream
  153. {
  154. /** Internal data to be initialized by video subsystem */
  155. struct {
  156. /** Driver index */
  157. unsigned drv_idx;
  158. /** Has it been started? */
  159. pj_bool_t is_running;
  160. } sys;
  161. /** Operations */
  162. pjmedia_vid_dev_stream_op *op;
  163. };
  164. /**
  165. * Internal API: return the factory instance and device index that's local
  166. * to the factory for a given device ID.
  167. *
  168. * @param id Device id.
  169. * @param p_f Out: factory instance
  170. * @param p_local_index Out: device index within the factory
  171. *
  172. * @return PJ_SUCCESS on success.
  173. */
  174. PJ_DECL(pj_status_t)
  175. pjmedia_vid_dev_get_local_index(pjmedia_vid_dev_index id,
  176. pjmedia_vid_dev_factory **p_f,
  177. unsigned *p_local_index);
  178. /**
  179. * Internal API: return the global device index given a factory instance and
  180. * a local device index.
  181. *
  182. * @param f Factory.
  183. * @param local_idx Local index.
  184. * @param pid Returned global index.
  185. *
  186. * @return PJ_SUCCESS on success.
  187. */
  188. PJ_DEF(pj_status_t)
  189. pjmedia_vid_dev_get_global_index(const pjmedia_vid_dev_factory *f,
  190. unsigned local_idx,
  191. pjmedia_vid_dev_index *pid);
  192. /**
  193. * @}
  194. */
  195. #endif /* __VIDEODEV_IMP_H__ */