1
/* $Id: vid_port.h 4168 2012-06-18 05:59:08Z ming $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
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.
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.
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
19
#ifndef __PJMEDIA_VIDPORT_H__
20
#define __PJMEDIA_VIDPORT_H__
23
* @file pjmedia/videoport.h Video media port
24
* @brief Video media port
27
#include <pjmedia-videodev/videodev.h>
28
#include <pjmedia/port.h>
31
* @defgroup PJMEDIA_VIDEO_PORT Video media port
32
* @ingroup PJMEDIA_PORT_CLOCK
33
* @brief Video media port
40
* This structure describes the parameters to create a video port
42
typedef struct pjmedia_vid_port_param
45
* Video stream parameter.
47
pjmedia_vid_dev_param vidparam;
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
64
} pjmedia_vid_port_param;
67
* Opaque data type for video port.
69
typedef struct pjmedia_vid_port pjmedia_vid_port;
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
76
* @param prm The parameter.
78
PJ_DECL(void) pjmedia_vid_port_param_default(pjmedia_vid_port_param *prm);
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
86
* @param pool Pool to allocate memory from.
87
* @param prm The video port parameter.
88
* @param p_vp Pointer to receive the result.
90
* @return PJ_SUCCESS if video port has been created
91
* successfully, or the appropriate error code.
93
PJ_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);
98
* Set the callbacks of the video port's underlying video stream.
100
* @param vid_port The video port.
101
* @param cb Pointer to structure containing video stream
103
* @param user_data Arbitrary user data, which will be given back in the
106
PJ_DECL(void) pjmedia_vid_port_set_cb(pjmedia_vid_port *vid_port,
107
const pjmedia_vid_dev_cb *cb,
111
* Return the underlying video stream of the video port.
113
* @param vid_port The video port.
115
* @return The video stream.
117
PJ_DECL(pjmedia_vid_dev_stream*)
118
pjmedia_vid_port_get_stream(pjmedia_vid_port *vid_port);
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
126
* @param vid_port The video port.
128
* @return The media port instance, or NULL.
130
PJ_DECL(pjmedia_port*)
131
pjmedia_vid_port_get_passive_port(pjmedia_vid_port *vid_port);
134
* Get a clock source from the video port.
136
* @param vid_port The video port.
138
* @return The clock source.
140
PJ_DECL(pjmedia_clock_src *)
141
pjmedia_vid_port_get_clock_src( pjmedia_vid_port *vid_port );
144
* Set a clock source for the video port.
146
* @param vid_port The video port.
147
* @param clocksrc The clock source.
149
* @return PJ_SUCCESS on success or the appropriate error code.
152
pjmedia_vid_port_set_clock_src( pjmedia_vid_port *vid_port,
153
pjmedia_clock_src *clocksrc );
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.
160
* @param vid_port The video port.
161
* @param port A downstream media port to be connected to
163
* @param destroy Specify if the downstream media port should also be
164
* destroyed by this video port when the video port
167
* @return PJ_SUCCESS on success or the appropriate error code.
169
PJ_DECL(pj_status_t) pjmedia_vid_port_connect(pjmedia_vid_port *vid_port,
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
179
* @param vid_port The video port.
181
* @return PJ_SUCCESS on success or the appropriate error code.
183
PJ_DECL(pj_status_t) pjmedia_vid_port_disconnect(pjmedia_vid_port *vid_port);
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.
191
* @param vid_port The video port.
193
* @return Media port currently connected to the video port,
196
PJ_DECL(pjmedia_port*)
197
pjmedia_vid_port_get_connected_port(pjmedia_vid_port *vid_port);
200
* Start the video port.
202
* @param vid_port The video port.
204
* @return PJ_SUCCESS on success or the appropriate error code.
206
PJ_DECL(pj_status_t) pjmedia_vid_port_start(pjmedia_vid_port *vid_port);
209
* Query whether the video port has been started.
211
* @param vid_port The video port.
213
* @return PJ_TRUE if the video port has been started.
215
PJ_DECL(pj_bool_t) pjmedia_vid_port_is_running(pjmedia_vid_port *vid_port);
218
* Stop the video port.
220
* @param vid_port The video port.
222
* @return PJ_SUCCESS on success or the appropriate error code.
224
PJ_DECL(pj_status_t) pjmedia_vid_port_stop(pjmedia_vid_port *vid_port);
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.
231
* @param vid_port The video port.
233
PJ_DECL(void) pjmedia_vid_port_destroy(pjmedia_vid_port *vid_port);
242
#endif /* __PJMEDIA_VIDPORT_H__ */