blob: 7251e90ee7b97df780496d8781d983ec53a398d0 [file] [log] [blame]
Benny Prijono2cd64f82009-02-17 19:57:48 +00001/* $Id$ */
2/*
3 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __AUDIODEV_IMP_H__
21#define __AUDIODEV_IMP_H__
22
23#include <pjmedia-audiodev/audiodev.h>
24
25/**
26 * @defgroup PJMED_AUD_DEV_IMP_API Audio Device Implementors API
27 * @ingroup PJMED_AUD_DEV
28 * @brief API for audio device implementors
29 * @{
30 */
31
32/**
33 * Sound device factory operations.
34 */
35typedef struct pjmedia_aud_dev_factory_op
36{
37 /**
38 * Initialize the audio device factory.
39 *
40 * @param f The audio device factory.
41 */
42 pj_status_t (*init)(pjmedia_aud_dev_factory *f);
43
44 /**
45 * Close this audio device factory and release all resources back to the
46 * operating system.
47 *
48 * @param f The audio device factory.
49 */
50 pj_status_t (*destroy)(pjmedia_aud_dev_factory *f);
51
52 /**
53 * Get the number of audio devices installed in the system.
54 *
55 * @param f The audio device factory.
56 */
57 unsigned (*get_dev_count)(pjmedia_aud_dev_factory *f);
58
59 /**
60 * Get the audio device information and capabilities.
61 *
62 * @param f The audio device factory.
Benny Prijono598b01d2009-02-18 13:55:03 +000063 * @param index Device index.
Benny Prijono2cd64f82009-02-17 19:57:48 +000064 * @param info The audio device information structure which will be
65 * initialized by this function once it returns
66 * successfully.
67 */
68 pj_status_t (*get_dev_info)(pjmedia_aud_dev_factory *f,
Benny Prijono598b01d2009-02-18 13:55:03 +000069 unsigned index,
Benny Prijono2cd64f82009-02-17 19:57:48 +000070 pjmedia_aud_dev_info *info);
71
72 /**
73 * Initialize the specified audio device parameter with the default
74 * values for the specified device.
75 *
76 * @param f The audio device factory.
Benny Prijono598b01d2009-02-18 13:55:03 +000077 * @param index Device index.
Benny Prijono2cd64f82009-02-17 19:57:48 +000078 * @param param The audio device parameter.
79 */
80 pj_status_t (*default_param)(pjmedia_aud_dev_factory *f,
Benny Prijono598b01d2009-02-18 13:55:03 +000081 unsigned index,
Benny Prijono2cd64f82009-02-17 19:57:48 +000082 pjmedia_aud_dev_param *param);
83
84 /**
85 * Open the audio device and create audio stream. See
86 * #pjmedia_aud_stream_create()
87 */
88 pj_status_t (*create_stream)(pjmedia_aud_dev_factory *f,
89 const pjmedia_aud_dev_param *param,
90 pjmedia_aud_rec_cb rec_cb,
91 pjmedia_aud_play_cb play_cb,
92 void *user_data,
93 pjmedia_aud_stream **p_aud_strm);
94
95} pjmedia_aud_dev_factory_op;
96
97
98/**
99 * This structure describes an audio device factory.
100 */
101struct pjmedia_aud_dev_factory
102{
103 /** Internal data to be initialized by the framework. */
104 struct {
105 unsigned id;
106 } internal;
107
108 /** Operations */
109 pjmedia_aud_dev_factory_op *op;
110};
111
112
113/**
114 * Sound stream operations.
115 */
116typedef struct pjmedia_aud_stream_op
117{
118 /**
119 * See #pjmedia_aud_stream_get_param()
120 */
121 pj_status_t (*get_param)(pjmedia_aud_stream *strm,
122 pjmedia_aud_dev_param *param);
123
124 /**
125 * See #pjmedia_aud_stream_get_cap()
126 */
127 pj_status_t (*get_cap)(pjmedia_aud_stream *strm,
128 pjmedia_aud_dev_cap cap,
129 void *value);
130
131 /**
132 * See #pjmedia_aud_stream_set_cap()
133 */
134 pj_status_t (*set_cap)(pjmedia_aud_stream *strm,
135 pjmedia_aud_dev_cap cap,
136 const void *value);
137
138 /**
139 * See #pjmedia_aud_stream_start()
140 */
141 pj_status_t (*start)(pjmedia_aud_stream *strm);
142
143 /**
144 * See #pjmedia_aud_stream_stop().
145 */
146 pj_status_t (*stop)(pjmedia_aud_stream *strm);
147
148 /**
149 * See #pjmedia_aud_stream_destroy().
150 */
151 pj_status_t (*destroy)(pjmedia_aud_stream *strm);
152
153} pjmedia_aud_stream_op;
154
155
156/**
157 * This structure describes the audio device stream.
158 */
159struct pjmedia_aud_stream
160{
161 /** Factory */
162 pjmedia_aud_dev_factory *factory;
163
164 /** Operations */
165 pjmedia_aud_stream_op *op;
166};
167
168
Benny Prijono598b01d2009-02-18 13:55:03 +0000169
170
Benny Prijono2cd64f82009-02-17 19:57:48 +0000171/**
172 * @}
173 */
174
175
176
177#endif __AUDIODEV_IMP_H__