vid_conf.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*
  2. * Copyright (C) 2019 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 __PJMEDIA_VID_CONF_H__
  19. #define __PJMEDIA_VID_CONF_H__
  20. /**
  21. * @file vid_conf.h
  22. * @brief Video conference bridge.
  23. */
  24. #include <pjmedia/port.h>
  25. /**
  26. * @addtogroup PJMEDIA_VID_CONF Video conference bridge
  27. * @ingroup PJMEDIA_PORT
  28. * @brief Video conference bridge implementation
  29. * destination
  30. * @{
  31. *
  32. * This describes the video conference bridge implementation in PJMEDIA. The
  33. * conference bridge provides powerful and efficient mechanism to route the
  34. * video flow and combine multiple video data from multiple video sources.
  35. */
  36. PJ_BEGIN_DECL
  37. /**
  38. * Opaque type for video conference bridge.
  39. */
  40. typedef struct pjmedia_vid_conf pjmedia_vid_conf;
  41. /**
  42. * Enumeration of video conference layout mode.
  43. */
  44. typedef enum pjmedia_vid_conf_layout
  45. {
  46. /**
  47. * In mixing video from multiple sources, each source will occupy about
  48. * the same size in the mixing result frame at all time.
  49. */
  50. PJMEDIA_VID_CONF_LAYOUT_DEFAULT,
  51. /**
  52. * Warning: this is not implemented yet.
  53. *
  54. * In mixing video from multiple sources, one specified participant
  55. * (or source port) will be the focus (i.e: occupy bigger portion
  56. * than the others).
  57. */
  58. PJMEDIA_VID_CONF_LAYOUT_SELECTIVE_FOCUS,
  59. /**
  60. * Warning: this is not implemented yet.
  61. *
  62. * In mixing video from multiple sources, one participant will be the
  63. * focus at a time (i.e: occupy bigger portion than the others), and
  64. * after some interval the focus will be shifted to another participant,
  65. * so each participant will have the same focus duration.
  66. */
  67. PJMEDIA_VID_CONF_LAYOUT_INTERVAL_FOCUS,
  68. /**
  69. * Warning: this is not implemented yet.
  70. *
  71. * In mixing video from multiple sources, each participant (or source
  72. * port) will have specific layout configuration.
  73. */
  74. PJMEDIA_VID_CONF_LAYOUT_CUSTOM,
  75. } pjmedia_vid_conf_layout;
  76. /**
  77. * Video conference bridge settings.
  78. */
  79. typedef struct pjmedia_vid_conf_setting
  80. {
  81. /**
  82. * Maximum number of slots or media ports can be registered to the bridge.
  83. *
  84. * Default: 32
  85. */
  86. unsigned max_slot_cnt;
  87. /**
  88. * Frame rate the bridge will operate at. For video playback smoothness,
  89. * ideally the bridge frame rate should be the common multiple of the
  90. * frame rates of the ports. Otherwise, ports whose unaligned frame rates
  91. * may experience jitter. For example, if the application will work with
  92. * frame rates of 10, 15, and 30 fps, setting this to 30 should be okay.
  93. * But if it also needs to handle 20 fps, better setting this to 60.
  94. *
  95. * Default: 60 (frames per second)
  96. */
  97. unsigned frame_rate;
  98. /**
  99. * Layout setting, see pjmedia_vid_conf_layout.
  100. *
  101. * Default: PJMEDIA_VID_CONF_LAYOUT_DEFAULT
  102. */
  103. unsigned layout;
  104. } pjmedia_vid_conf_setting;
  105. /**
  106. * Video conference bridge port info.
  107. */
  108. typedef struct pjmedia_vid_conf_port_info
  109. {
  110. unsigned slot; /**< Slot index. */
  111. pj_str_t name; /**< Port name. */
  112. pjmedia_format format; /**< Format. */
  113. unsigned listener_cnt; /**< Number of listeners. */
  114. unsigned *listener_slots; /**< Array of listeners. */
  115. unsigned transmitter_cnt; /**< Number of transmitter. */
  116. unsigned *transmitter_slots; /**< Array of transmitter. */
  117. } pjmedia_vid_conf_port_info;
  118. /**
  119. * Initialize video conference settings with default values.
  120. *
  121. * @param opt The settings to be initialized.
  122. */
  123. PJ_DECL(void) pjmedia_vid_conf_setting_default(pjmedia_vid_conf_setting *opt);
  124. /**
  125. * Create a video conference bridge.
  126. *
  127. * @param pool The memory pool.
  128. * @param opt The video conference settings.
  129. * @param p_vid_conf Pointer to receive the video conference bridge.
  130. *
  131. * @return PJ_SUCCESS on success, or the appropriate
  132. * error code.
  133. */
  134. PJ_DECL(pj_status_t) pjmedia_vid_conf_create(
  135. pj_pool_t *pool,
  136. const pjmedia_vid_conf_setting *opt,
  137. pjmedia_vid_conf **p_vid_conf);
  138. /**
  139. * Destroy video conference bridge.
  140. *
  141. * @param vid_conf The video conference bridge.
  142. *
  143. * @return PJ_SUCCESS on success.
  144. */
  145. PJ_DECL(pj_status_t) pjmedia_vid_conf_destroy(pjmedia_vid_conf *vid_conf);
  146. /**
  147. * Add a media port to the video conference bridge.
  148. *
  149. * @param vid_conf The video conference bridge.
  150. * @param pool The memory pool, the brige will create new pool
  151. * based on this pool factory for this media port.
  152. * @param port The media port to be added.
  153. * @param name Name to be assigned to the slot. If not set, it will
  154. * be set to the media port name.
  155. * @param opt The option, for future use, currently this must
  156. * be NULL.
  157. * @param p_slot Pointer to receive the slot index of the port in
  158. * the conference bridge.
  159. *
  160. * @return PJ_SUCCESS on success, or the appropriate error
  161. * code.
  162. */
  163. PJ_DECL(pj_status_t) pjmedia_vid_conf_add_port(pjmedia_vid_conf *vid_conf,
  164. pj_pool_t *pool,
  165. pjmedia_port *port,
  166. const pj_str_t *name,
  167. void *opt,
  168. unsigned *p_slot);
  169. /**
  170. * Remove a media port from the video conference bridge.
  171. *
  172. * @param vid_conf The video conference bridge.
  173. * @param slot The media port's slot index to be removed.
  174. *
  175. * @return PJ_SUCCESS on success, or the appropriate error
  176. * code.
  177. */
  178. PJ_DECL(pj_status_t) pjmedia_vid_conf_remove_port(pjmedia_vid_conf *vid_conf,
  179. unsigned slot);
  180. /**
  181. * Get number of ports currently registered in the video conference bridge.
  182. *
  183. * @param vid_conf The video conference bridge.
  184. *
  185. * @return Number of ports currently registered to the video
  186. * conference bridge.
  187. */
  188. PJ_DECL(unsigned) pjmedia_vid_conf_get_port_count(pjmedia_vid_conf *vid_conf);
  189. /**
  190. * Enumerate occupied slots in the video conference bridge.
  191. *
  192. * @param vid_conf The video conference bridge.
  193. * @param slots Array of slot to be filled in.
  194. * @param count On input, specifies the maximum number of slot
  195. * in the array. On return, it will be filled with
  196. * the actual number of slot.
  197. *
  198. * @return PJ_SUCCESS on success.
  199. */
  200. PJ_DECL(pj_status_t) pjmedia_vid_conf_enum_ports(pjmedia_vid_conf *vid_conf,
  201. unsigned slots[],
  202. unsigned *count);
  203. /**
  204. * Get port info.
  205. *
  206. * @param vid_conf The video conference bridge.
  207. * @param slot Slot index.
  208. * @param info Pointer to receive the info.
  209. *
  210. * @return PJ_SUCCESS on success.
  211. */
  212. PJ_DECL(pj_status_t) pjmedia_vid_conf_get_port_info(
  213. pjmedia_vid_conf *vid_conf,
  214. unsigned slot,
  215. pjmedia_vid_conf_port_info *info);
  216. /**
  217. * Enable unidirectional video flow from the specified source slot to
  218. * the specified sink slot.
  219. *
  220. * @param vid_conf The video conference bridge.
  221. * @param src_slot Source slot.
  222. * @param sink_slot Sink slot.
  223. * @param opt The option, for future use, currently this must
  224. * be NULL.
  225. *
  226. * @return PJ_SUCCES on success.
  227. */
  228. PJ_DECL(pj_status_t) pjmedia_vid_conf_connect_port(
  229. pjmedia_vid_conf *vid_conf,
  230. unsigned src_slot,
  231. unsigned sink_slot,
  232. void *opt);
  233. /**
  234. * Disconnect unidirectional video flow from the specified source to
  235. * the specified sink slot.
  236. *
  237. * @param vid_conf The video conference bridge.
  238. * @param src_slot Source slot.
  239. * @param sink_slot Sink slot.
  240. *
  241. * @return PJ_SUCCESS on success.
  242. */
  243. PJ_DECL(pj_status_t) pjmedia_vid_conf_disconnect_port(
  244. pjmedia_vid_conf *vid_conf,
  245. unsigned src_slot,
  246. unsigned sink_slot);
  247. /**
  248. * Update or refresh port states from video port info. Some port may
  249. * change its port info in the middle of a session, for example when
  250. * a video stream decoder learns that incoming video size or frame rate
  251. * has changed, video conference needs to be informed to update its
  252. * internal states.
  253. *
  254. * @param vid_conf The video conference bridge.
  255. * @param slot The media port's slot index to be updated.
  256. *
  257. * @return PJ_SUCCESS on success, or the appropriate error
  258. * code.
  259. */
  260. PJ_DECL(pj_status_t) pjmedia_vid_conf_update_port(pjmedia_vid_conf *vid_conf,
  261. unsigned slot);
  262. PJ_END_DECL
  263. /**
  264. * @}
  265. */
  266. #endif /* __PJMEDIA_VID_CONF_H__ */