blob: 962435495e8691bf66cc10bc61e18b585c3ef947 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001/* $Id$ */
2/*
3 * Copyright (C) 2008-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_VIDPORT_H__
20#define __PJMEDIA_VIDPORT_H__
21
22/**
23 * @file pjmedia/videoport.h Video media port
24 * @brief Video media port
25 */
26
27#include <pjmedia-videodev/videodev.h>
28#include <pjmedia/port.h>
29
30/**
31 * @defgroup PJMEDIA_VIDEO_PORT Video media port
32 * @ingroup PJMEDIA_PORT_CLOCK
33 * @brief Video media port
34 * @{
35 */
36
37PJ_BEGIN_DECL
38
39/**
40 * This structure describes the parameters to create a video port
41 */
42typedef struct pjmedia_vid_port_param
43{
44 /**
45 * Video stream parameter.
46 */
47 pjmedia_vid_dev_param vidparam;
48
49 /**
50 * Specify whether the video port should use active or passive interface.
51 * If active interface is selected, the video port will perform as
52 * a media clock, automatically calls pjmedia_port_get_frame() and
53 * pjmedia_port_put_frame() of its slave port (depending on the direction
54 * that is specified when opening the video stream). If passive interface
55 * is selected, application can retrieve the media port of this video
56 * port by calling pjmedia_vid_port_get_passive_port(), and subsequently
57 * calls pjmedia_port_put_frame() or pjmedia_port_get_frame() to that
58 * media port.
59 *
60 * Default: PJ_TRUE
61 */
62 pj_bool_t active;
63
64} pjmedia_vid_port_param;
65
66/**
67 * Opaque data type for video port.
68 */
69typedef struct pjmedia_vid_port pjmedia_vid_port;
70
71/**
72 * Initialize the parameter with the default values. Note that this typically
73 * would only fill the structure to zeroes unless they have different default
74 * values.
75 *
76 * @param prm The parameter.
77 */
78PJ_DECL(void) pjmedia_vid_port_param_default(pjmedia_vid_port_param *prm);
79
80/**
81 * Create a video port with the specified parameter. When video port opens
82 * the video stream with different parameter than the requested values in
83 * the \a prm.vidparam argument, it will automatically do the necessary
84 * conversion.
85 *
86 * @param pool Pool to allocate memory from.
87 * @param prm The video port parameter.
88 * @param p_vp Pointer to receive the result.
89 *
90 * @return PJ_SUCCESS if video port has been created
91 * successfully, or the appropriate error code.
92 */
93PJ_DECL(pj_status_t) pjmedia_vid_port_create(pj_pool_t *pool,
94 const pjmedia_vid_port_param *prm,
95 pjmedia_vid_port **p_vp);
96
97/**
98 * Set the callbacks of the video port's underlying video stream.
99 *
100 * @param vid_port The video port.
101 * @param cb Pointer to structure containing video stream
102 * callbacks.
103 * @param user_data Arbitrary user data, which will be given back in the
104 * callbacks.
105 */
106PJ_DECL(void) pjmedia_vid_port_set_cb(pjmedia_vid_port *vid_port,
107 const pjmedia_vid_dev_cb *cb,
108 void *user_data);
109
110/**
111 * Return the underlying video stream of the video port.
112 *
113 * @param vid_port The video port.
114 *
115 * @return The video stream.
116 */
117PJ_DECL(pjmedia_vid_dev_stream*)
118pjmedia_vid_port_get_stream(pjmedia_vid_port *vid_port);
119
120/**
121 * Return the (passive) media port of the video port. This operation
122 * is only valid for video ports created with passive interface selected.
123 * Retrieving the media port for active video ports may raise an
124 * assertion.
125 *
126 * @param vid_port The video port.
127 *
128 * @return The media port instance, or NULL.
129 */
130PJ_DECL(pjmedia_port*)
131pjmedia_vid_port_get_passive_port(pjmedia_vid_port *vid_port);
132
133/**
134 * Get a clock source from the video port.
135 *
136 * @param vid_port The video port.
137 *
138 * @return The clock source.
139 */
140PJ_DECL(pjmedia_clock_src *)
141pjmedia_vid_port_get_clock_src( pjmedia_vid_port *vid_port );
142
143/**
144 * Set a clock source for the video port.
145 *
146 * @param vid_port The video port.
147 * @param clocksrc The clock source.
148 *
149 * @return PJ_SUCCESS on success or the appropriate error code.
150 */
151PJ_DECL(pj_status_t)
152pjmedia_vid_port_set_clock_src( pjmedia_vid_port *vid_port,
153 pjmedia_clock_src *clocksrc );
154
155/**
156 * Connect the video port to a downstream (slave) media port. This operation
157 * is only valid for video ports created with active interface selected.
158 * Connecting a passive video port may raise an assertion.
159 *
160 * @param vid_port The video port.
161 * @param port A downstream media port to be connected to
162 * this video port.
163 * @param destroy Specify if the downstream media port should also be
164 * destroyed by this video port when the video port
165 * is destroyed.
166 *
167 * @return PJ_SUCCESS on success or the appropriate error code.
168 */
169PJ_DECL(pj_status_t) pjmedia_vid_port_connect(pjmedia_vid_port *vid_port,
170 pjmedia_port *port,
171 pj_bool_t destroy);
172
173/**
174 * Disconnect the video port from its downstream (slave) media port, if any.
175 * This operation is only valid for video ports created with active interface
176 * selected, and assertion may be triggered if this is invoked on a passive
177 * video port.
178 *
179 * @param vid_port The video port.
180 *
181 * @return PJ_SUCCESS on success or the appropriate error code.
182 */
183PJ_DECL(pj_status_t) pjmedia_vid_port_disconnect(pjmedia_vid_port *vid_port);
184
185/**
186 * Retrieve the media port currently connected as downstream media port of the
187 * specified video port. This operation is only valid for video ports created
188 * with active interface selected, and assertion may be triggered if this is
189 * invoked on a passive video port.
190 *
191 * @param vid_port The video port.
192 *
193 * @return Media port currently connected to the video port,
194 * if any.
195 */
196PJ_DECL(pjmedia_port*)
197pjmedia_vid_port_get_connected_port(pjmedia_vid_port *vid_port);
198
199/**
200 * Start the video port.
201 *
202 * @param vid_port The video port.
203 *
204 * @return PJ_SUCCESS on success or the appropriate error code.
205 */
206PJ_DECL(pj_status_t) pjmedia_vid_port_start(pjmedia_vid_port *vid_port);
207
208/**
209 * Query whether the video port has been started.
210 *
211 * @param vid_port The video port.
212 *
213 * @return PJ_TRUE if the video port has been started.
214 */
215PJ_DECL(pj_bool_t) pjmedia_vid_port_is_running(pjmedia_vid_port *vid_port);
216
217/**
218 * Stop the video port.
219 *
220 * @param vid_port The video port.
221 *
222 * @return PJ_SUCCESS on success or the appropriate error code.
223 */
224PJ_DECL(pj_status_t) pjmedia_vid_port_stop(pjmedia_vid_port *vid_port);
225
226/**
227 * Destroy the video port, along with its video stream. If the video port is
228 * an active one, this may also destroy the downstream media port, if the
229 * destroy flag is set when the media port is connected.
230 *
231 * @param vid_port The video port.
232 */
233PJ_DECL(void) pjmedia_vid_port_destroy(pjmedia_vid_port *vid_port);
234
235
236PJ_END_DECL
237
238/**
239 * @}
240 */
241
242#endif /* __PJMEDIA_VIDPORT_H__ */
243