Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJMEDIA_VID_TEE_H__ |
| 20 | #define __PJMEDIA_VID_TEE_H__ |
| 21 | |
| 22 | /** |
| 23 | * @file vid_tee.h |
| 24 | * @brief Video tee (source duplicator). |
| 25 | */ |
| 26 | #include <pjmedia/port.h> |
| 27 | |
| 28 | /** |
| 29 | * @addtogroup PJMEDIA_VID_TEE Video source duplicator |
| 30 | * @ingroup PJMEDIA_PORT |
| 31 | * @brief Duplicate video data from a media port into multiple media port |
| 32 | * destinations |
| 33 | * @{ |
| 34 | * |
| 35 | * This section describes media port to duplicate video data in the stream. |
| 36 | * |
| 37 | * A video tee branches video stream flow from one source port to multiple |
| 38 | * destination ports by simply duplicating the video data supplied by the |
| 39 | * source port and delivering the copy to all registered destinations. |
| 40 | * |
| 41 | * The video tee is a unidirectional port, i.e: data flows from source port |
| 42 | * to destination ports only. Also, the video source port MUST actively call |
| 43 | * pjmedia_port_put_frame() to the video tee and the video destination ports |
| 44 | * MUST NEVER call pjmedia_port_get_frame() to the video tee. Please note that |
| 45 | * there is no specific order of which destination port will receive a frame |
| 46 | * from the video tee. |
| 47 | * |
| 48 | * The video tee is not thread-safe, so it is application responsibility |
| 49 | * to synchronize video tee operations, e.g: make sure the source port is |
| 50 | * paused during adding or removing a destination port. |
| 51 | */ |
| 52 | |
| 53 | PJ_BEGIN_DECL |
| 54 | |
| 55 | |
| 56 | /** |
| 57 | * Enumeration of video tee flags. |
| 58 | */ |
| 59 | typedef enum pjmedia_vid_tee_flag |
| 60 | { |
| 61 | /** |
| 62 | * Tell the video tee that the destination port will do in-place |
| 63 | * processing, so the delivered data may be modified by this port. |
| 64 | * If this flag is used, buffer will be copied before being given to |
| 65 | * the destination port. |
| 66 | */ |
| 67 | PJMEDIA_VID_TEE_DST_DO_IN_PLACE_PROC = 4, |
| 68 | |
| 69 | } pjmedia_vid_tee_flag; |
| 70 | |
| 71 | |
| 72 | /** |
| 73 | * Create a video tee port with the specified source media port. Application |
| 74 | * should destroy the tee with pjmedia_port_destroy() as usual. Note that |
| 75 | * destroying the tee does not destroy its destination ports. |
| 76 | * |
| 77 | * @param pool The pool. |
| 78 | * @param fmt The source media port's format. |
| 79 | * @param max_dst_cnt The maximum number of destination ports supported. |
| 80 | * @param p_vid_tee Pointer to receive the video tee port. |
| 81 | * |
| 82 | * @return PJ_SUCCESS on success, or the appropriate |
| 83 | * error code. |
| 84 | */ |
| 85 | PJ_DECL(pj_status_t) pjmedia_vid_tee_create(pj_pool_t *pool, |
| 86 | const pjmedia_format *fmt, |
| 87 | unsigned max_dst_cnt, |
| 88 | pjmedia_port **p_vid_tee); |
| 89 | |
| 90 | /** |
| 91 | * Add a destination media port to the video tee. For this function, the |
| 92 | * destination port's media format must match the source format. |
| 93 | * |
| 94 | * @param vid_tee The video tee. |
| 95 | * @param option Video tee option, see @pjmedia_vid_tee_flag. |
| 96 | * @param port The destination media port. |
| 97 | * |
| 98 | * @return PJ_SUCCESS on success, or the appropriate error |
| 99 | * code. |
| 100 | */ |
| 101 | PJ_DECL(pj_status_t) pjmedia_vid_tee_add_dst_port(pjmedia_port *vid_tee, |
| 102 | unsigned option, |
| 103 | pjmedia_port *port); |
| 104 | |
| 105 | |
| 106 | /** |
| 107 | * Add a destination media port to the video tee. This function will also |
| 108 | * create a converter if the destination port's media format does not match |
| 109 | * the source format. |
| 110 | * |
| 111 | * @param vid_tee The video tee. |
| 112 | * @param option Video tee option, see @pjmedia_vid_tee_flag. |
| 113 | * @param port The destination media port. |
| 114 | * |
| 115 | * @return PJ_SUCCESS on success, or the appropriate error |
| 116 | * code. |
| 117 | */ |
| 118 | PJ_DECL(pj_status_t) pjmedia_vid_tee_add_dst_port2(pjmedia_port *vid_tee, |
| 119 | unsigned option, |
| 120 | pjmedia_port *port); |
| 121 | |
| 122 | |
| 123 | /** |
| 124 | * Remove a destination media port from the video tee. |
| 125 | * |
| 126 | * @param vid_tee The video tee. |
| 127 | * @param port The destination media port to be removed. |
| 128 | * |
| 129 | * @return PJ_SUCCESS on success, or the appropriate error |
| 130 | * code. |
| 131 | */ |
| 132 | PJ_DECL(pj_status_t) pjmedia_vid_tee_remove_dst_port(pjmedia_port *vid_tee, |
| 133 | pjmedia_port *port); |
| 134 | |
| 135 | |
| 136 | PJ_END_DECL |
| 137 | |
| 138 | /** |
| 139 | * @} |
| 140 | */ |
| 141 | |
| 142 | #endif /* __PJMEDIA_VID_TEE_H__ */ |