vid_tee.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (C) 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 __PJMEDIA_VID_TEE_H__
  19. #define __PJMEDIA_VID_TEE_H__
  20. /**
  21. * @file vid_tee.h
  22. * @brief Video tee (source duplicator).
  23. */
  24. #include <pjmedia/port.h>
  25. /**
  26. * @addtogroup PJMEDIA_VID_TEE Video source duplicator
  27. * @ingroup PJMEDIA_PORT
  28. * @brief Duplicate video data from a media port into multiple media port
  29. * destinations
  30. * @{
  31. *
  32. * This section describes media port to duplicate video data in the stream.
  33. *
  34. * A video tee branches video stream flow from one source port to multiple
  35. * destination ports by simply duplicating the video data supplied by the
  36. * source port and delivering the copy to all registered destinations.
  37. *
  38. * The video tee is a unidirectional port, i.e: data flows from source port
  39. * to destination ports only. Also, the video source port MUST actively call
  40. * pjmedia_port_put_frame() to the video tee and the video destination ports
  41. * MUST NEVER call pjmedia_port_get_frame() to the video tee. Please note that
  42. * there is no specific order of which destination port will receive a frame
  43. * from the video tee.
  44. *
  45. * The video tee is not thread-safe, so it is application responsibility
  46. * to synchronize video tee operations, e.g: make sure the source port is
  47. * paused during adding or removing a destination port.
  48. */
  49. PJ_BEGIN_DECL
  50. /**
  51. * Enumeration of video tee flags.
  52. */
  53. typedef enum pjmedia_vid_tee_flag
  54. {
  55. /**
  56. * Tell the video tee that the destination port will do in-place
  57. * processing, so the delivered data may be modified by this port.
  58. * If this flag is used, buffer will be copied before being given to
  59. * the destination port.
  60. */
  61. PJMEDIA_VID_TEE_DST_DO_IN_PLACE_PROC = 4,
  62. } pjmedia_vid_tee_flag;
  63. /**
  64. * Create a video tee port with the specified source media port. Application
  65. * should destroy the tee with pjmedia_port_destroy() as usual. Note that
  66. * destroying the tee does not destroy its destination ports.
  67. *
  68. * @param pool The pool.
  69. * @param fmt The source media port's format.
  70. * @param max_dst_cnt The maximum number of destination ports supported.
  71. * @param p_vid_tee Pointer to receive the video tee port.
  72. *
  73. * @return PJ_SUCCESS on success, or the appropriate
  74. * error code.
  75. */
  76. PJ_DECL(pj_status_t) pjmedia_vid_tee_create(pj_pool_t *pool,
  77. const pjmedia_format *fmt,
  78. unsigned max_dst_cnt,
  79. pjmedia_port **p_vid_tee);
  80. /**
  81. * Add a destination media port to the video tee. For this function, the
  82. * destination port's media format must match the source format.
  83. *
  84. * @param vid_tee The video tee.
  85. * @param option Video tee option, see pjmedia_vid_tee_flag.
  86. * @param port The destination media port.
  87. *
  88. * @return PJ_SUCCESS on success, or the appropriate error
  89. * code.
  90. */
  91. PJ_DECL(pj_status_t) pjmedia_vid_tee_add_dst_port(pjmedia_port *vid_tee,
  92. unsigned option,
  93. pjmedia_port *port);
  94. /**
  95. * Add a destination media port to the video tee. This function will also
  96. * create a converter if the destination port's media format does not match
  97. * the source format.
  98. *
  99. * @param vid_tee The video tee.
  100. * @param option Video tee option, see pjmedia_vid_tee_flag.
  101. * @param port The destination media port.
  102. *
  103. * @return PJ_SUCCESS on success, or the appropriate error
  104. * code.
  105. */
  106. PJ_DECL(pj_status_t) pjmedia_vid_tee_add_dst_port2(pjmedia_port *vid_tee,
  107. unsigned option,
  108. pjmedia_port *port);
  109. /**
  110. * Remove a destination media port from the video tee.
  111. *
  112. * @param vid_tee The video tee.
  113. * @param port The destination media port to be removed.
  114. *
  115. * @return PJ_SUCCESS on success, or the appropriate error
  116. * code.
  117. */
  118. PJ_DECL(pj_status_t) pjmedia_vid_tee_remove_dst_port(pjmedia_port *vid_tee,
  119. pjmedia_port *port);
  120. PJ_END_DECL
  121. /**
  122. * @}
  123. */
  124. #endif /* __PJMEDIA_VID_TEE_H__ */