blob: e12c0f21261f93993d2fb943b007a39ddf964e97 [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/**
Benny Prijono2058f472009-02-22 17:15:34 +000026 * @defgroup s8_audio_device_implementors_api Audio Device Implementors API
27 * @ingroup audio_device_api
Benny Prijono2cd64f82009-02-17 19:57:48 +000028 * @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 Prijono10454dc2009-02-21 14:21:59 +000082 pjmedia_aud_param *param);
Benny Prijono2cd64f82009-02-17 19:57:48 +000083
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,
Benny Prijono10454dc2009-02-21 14:21:59 +000089 const pjmedia_aud_param *param,
Benny Prijono2cd64f82009-02-17 19:57:48 +000090 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{
Benny Prijono96e74f32009-02-22 12:00:12 +0000103 /** Internal data to be initialized by audio subsystem. */
Benny Prijono2cd64f82009-02-17 19:57:48 +0000104 struct {
Benny Prijono96e74f32009-02-22 12:00:12 +0000105 /** Driver index */
106 unsigned drv_idx;
107 } sys;
Benny Prijono2cd64f82009-02-17 19:57:48 +0000108
109 /** Operations */
110 pjmedia_aud_dev_factory_op *op;
111};
112
113
114/**
115 * Sound stream operations.
116 */
117typedef struct pjmedia_aud_stream_op
118{
119 /**
120 * See #pjmedia_aud_stream_get_param()
121 */
122 pj_status_t (*get_param)(pjmedia_aud_stream *strm,
Benny Prijono10454dc2009-02-21 14:21:59 +0000123 pjmedia_aud_param *param);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000124
125 /**
126 * See #pjmedia_aud_stream_get_cap()
127 */
128 pj_status_t (*get_cap)(pjmedia_aud_stream *strm,
129 pjmedia_aud_dev_cap cap,
130 void *value);
131
132 /**
133 * See #pjmedia_aud_stream_set_cap()
134 */
135 pj_status_t (*set_cap)(pjmedia_aud_stream *strm,
136 pjmedia_aud_dev_cap cap,
137 const void *value);
138
139 /**
140 * See #pjmedia_aud_stream_start()
141 */
142 pj_status_t (*start)(pjmedia_aud_stream *strm);
143
144 /**
145 * See #pjmedia_aud_stream_stop().
146 */
147 pj_status_t (*stop)(pjmedia_aud_stream *strm);
148
149 /**
150 * See #pjmedia_aud_stream_destroy().
151 */
152 pj_status_t (*destroy)(pjmedia_aud_stream *strm);
153
154} pjmedia_aud_stream_op;
155
156
157/**
158 * This structure describes the audio device stream.
159 */
160struct pjmedia_aud_stream
161{
Benny Prijono96e74f32009-02-22 12:00:12 +0000162 /** Internal data to be initialized by audio subsystem */
163 struct {
164 /** Driver index */
165 unsigned drv_idx;
166 } sys;
Benny Prijono2cd64f82009-02-17 19:57:48 +0000167
168 /** Operations */
169 pjmedia_aud_stream_op *op;
170};
171
172
Benny Prijono598b01d2009-02-18 13:55:03 +0000173
174
Benny Prijono2cd64f82009-02-17 19:57:48 +0000175/**
176 * @}
177 */
178
179
180
Nanang Izzuddina940b362009-02-23 13:53:30 +0000181#endif /* __AUDIODEV_IMP_H__ */