blob: e0ef520577faa580545bd5a859d74263ebd6bd94 [file] [log] [blame]
Alexandre Lision67916dd2014-01-24 13:33:04 -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 __VIDEODEV_IMP_H__
20#define __VIDEODEV_IMP_H__
21
22#include <pjmedia-videodev/videodev.h>
23
24/**
25 * @defgroup s8_video_device_implementors_api Video Device Implementors API
26 * @ingroup video_device_api
27 * @brief API for video device implementors
28 * @{
29 */
30
31/**
32 * Video device factory operations.
33 */
34typedef struct pjmedia_vid_dev_factory_op
35{
36 /**
37 * Initialize the video device factory.
38 *
39 * @param f The video device factory.
40 */
41 pj_status_t (*init)(pjmedia_vid_dev_factory *f);
42
43 /**
44 * Close this video device factory and release all resources back to the
45 * operating system.
46 *
47 * @param f The video device factory.
48 */
49 pj_status_t (*destroy)(pjmedia_vid_dev_factory *f);
50
51 /**
52 * Get the number of video devices installed in the system.
53 *
54 * @param f The video device factory.
55 */
56 unsigned (*get_dev_count)(pjmedia_vid_dev_factory *f);
57
58 /**
59 * Get the video device information and capabilities.
60 *
61 * @param f The video device factory.
62 * @param index Device index.
63 * @param info The video device information structure which will be
64 * initialized by this function once it returns
65 * successfully.
66 */
67 pj_status_t (*get_dev_info)(pjmedia_vid_dev_factory *f,
68 unsigned index,
69 pjmedia_vid_dev_info *info);
70
71 /**
72 * Initialize the specified video device parameter with the default
73 * values for the specified device.
74 *
75 * @param f The video device factory.
76 * @param index Device index.
77 * @param param The video device parameter.
78 */
79 pj_status_t (*default_param)(pj_pool_t *pool,
80 pjmedia_vid_dev_factory *f,
81 unsigned index,
82 pjmedia_vid_dev_param *param);
83
84 /**
85 * Open the video device and create video stream. See
86 * #pjmedia_vid_dev_stream_create()
87 */
88 pj_status_t (*create_stream)(pjmedia_vid_dev_factory *f,
89 pjmedia_vid_dev_param *param,
90 const pjmedia_vid_dev_cb *cb,
91 void *user_data,
92 pjmedia_vid_dev_stream **p_vid_strm);
93
94 /**
95 * Refresh the list of video devices installed in the system.
96 *
97 * @param f The video device factory.
98 */
99 pj_status_t (*refresh)(pjmedia_vid_dev_factory *f);
100
101} pjmedia_vid_dev_factory_op;
102
103
104/**
105 * This structure describes a video device factory.
106 */
107struct pjmedia_vid_dev_factory
108{
109 /** Internal data to be initialized by video subsystem. */
110 struct {
111 /** Driver index */
112 unsigned drv_idx;
113 } sys;
114
115 /** Operations */
116 pjmedia_vid_dev_factory_op *op;
117};
118
119
120/**
121 * Video stream operations.
122 */
123typedef struct pjmedia_vid_dev_stream_op
124{
125 /**
126 * See #pjmedia_vid_dev_stream_get_param()
127 */
128 pj_status_t (*get_param)(pjmedia_vid_dev_stream *strm,
129 pjmedia_vid_dev_param *param);
130
131 /**
132 * See #pjmedia_vid_dev_stream_get_cap()
133 */
134 pj_status_t (*get_cap)(pjmedia_vid_dev_stream *strm,
135 pjmedia_vid_dev_cap cap,
136 void *value);
137
138 /**
139 * See #pjmedia_vid_dev_stream_set_cap()
140 */
141 pj_status_t (*set_cap)(pjmedia_vid_dev_stream *strm,
142 pjmedia_vid_dev_cap cap,
143 const void *value);
144
145 /**
146 * See #pjmedia_vid_dev_stream_start()
147 */
148 pj_status_t (*start)(pjmedia_vid_dev_stream *strm);
149
150 /**
151 * See #pjmedia_vid_dev_stream_get_frame()
152 */
153 pj_status_t (*get_frame)(pjmedia_vid_dev_stream *strm,
154 pjmedia_frame *frame);
155
156 /**
157 * See #pjmedia_vid_dev_stream_put_frame()
158 */
159 pj_status_t (*put_frame)(pjmedia_vid_dev_stream *strm,
160 const pjmedia_frame *frame);
161
162 /**
163 * See #pjmedia_vid_dev_stream_stop().
164 */
165 pj_status_t (*stop)(pjmedia_vid_dev_stream *strm);
166
167 /**
168 * See #pjmedia_vid_dev_stream_destroy().
169 */
170 pj_status_t (*destroy)(pjmedia_vid_dev_stream *strm);
171
172} pjmedia_vid_dev_stream_op;
173
174
175/**
176 * This structure describes the video device stream.
177 */
178struct pjmedia_vid_dev_stream
179{
180 /** Internal data to be initialized by video subsystem */
181 struct {
182 /** Driver index */
183 unsigned drv_idx;
184
185 /** Has it been started? */
186 pj_bool_t is_running;
187 } sys;
188
189 /** Operations */
190 pjmedia_vid_dev_stream_op *op;
191};
192
193
194/**
195 * Internal API: return the factory instance and device index that's local
196 * to the factory for a given device ID.
197 *
198 * @param id Device id.
199 * @param p_f Out: factory instance
200 * @param p_local_index Out: device index within the factory
201 *
202 * @return PJ_SUCCESS on success.
203 */
204PJ_DECL(pj_status_t)
205pjmedia_vid_dev_get_local_index(pjmedia_vid_dev_index id,
206 pjmedia_vid_dev_factory **p_f,
207 unsigned *p_local_index);
208
209/**
210 * Internal API: return the global device index given a factory instance and
211 * a local device index.
212 *
213 * @param f Factory.
214 * @param local_idx Local index.
215 * @param pid Returned global index.
216 *
217 * @return PJ_SUCCESS on success.
218 */
219PJ_DEF(pj_status_t)
220pjmedia_vid_dev_get_global_index(const pjmedia_vid_dev_factory *f,
221 unsigned local_idx,
222 pjmedia_vid_dev_index *pid);
223
224/**
225 * @}
226 */
227
228
229
230#endif /* __VIDEODEV_IMP_H__ */