blob: 5a523ca8bffe88f08fee015d0469ffadd05eb473 [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 */
Benny Prijono10454dc2009-02-21 14:21:59 +000020#ifndef __PJMEDIA_AUDIODEV_AUDIODEV_H__
21#define __PJMEDIA_AUDIODEV_AUDIODEV_H__
Benny Prijono2cd64f82009-02-17 19:57:48 +000022
23/**
24 * @file audiodev.h
25 * @brief Audio device API.
26 */
Benny Prijono2058f472009-02-22 17:15:34 +000027#include <pjmedia-audiodev/config.h>
Benny Prijono8eeab0b2009-03-04 19:00:28 +000028#include <pjmedia-audiodev/errno.h>
Benny Prijono64f91382009-03-05 18:02:28 +000029#include <pjmedia/types.h>
Benny Prijono2cd64f82009-02-17 19:57:48 +000030#include <pj/pool.h>
31
32
33PJ_BEGIN_DECL
34
35/**
Benny Prijono2058f472009-02-22 17:15:34 +000036 * @defgroup s2_audio_device_reference Audio Device API Reference
37 * @ingroup audio_device_api
38 * @brief API Reference
Benny Prijono2cd64f82009-02-17 19:57:48 +000039 * @{
40 */
41
Sauw Ming8fd16932010-05-05 04:23:27 +000042/**
Benny Prijono10454dc2009-02-21 14:21:59 +000043 * Type for device index.
44 */
45typedef pj_int32_t pjmedia_aud_dev_index;
Benny Prijono2cd64f82009-02-17 19:57:48 +000046
Benny Prijono96e74f32009-02-22 12:00:12 +000047/**
48 * Device index constants.
Benny Prijono10454dc2009-02-21 14:21:59 +000049 */
Benny Prijono96e74f32009-02-22 12:00:12 +000050enum
51{
52 /**
53 * Constant to denote default capture device
54 */
55 PJMEDIA_AUD_DEFAULT_CAPTURE_DEV = -1,
56
57 /**
58 * Constant to denote default playback device
59 */
60 PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV = -2,
61
62 /**
63 * Constant to denote invalid device index.
64 */
65 PJMEDIA_AUD_INVALID_DEV = -3
66};
67
Benny Prijono10454dc2009-02-21 14:21:59 +000068
Benny Prijono2cd64f82009-02-17 19:57:48 +000069/**
70 * This enumeration identifies various audio device capabilities. These audio
71 * capabilities indicates what features are supported by the underlying
72 * audio device implementation.
73 *
74 * Applications get these capabilities in the #pjmedia_aud_dev_info structure.
75 *
76 * Application can also set the specific features/capabilities when opening
Benny Prijono10454dc2009-02-21 14:21:59 +000077 * the audio stream by setting the \a flags member of #pjmedia_aud_param
Benny Prijono2cd64f82009-02-17 19:57:48 +000078 * structure.
79 *
80 * Once audio stream is running, application can also retrieve or set some
81 * specific audio capability, by using #pjmedia_aud_stream_get_cap() and
82 * #pjmedia_aud_stream_set_cap() and specifying the desired capability. The
83 * value of the capability is specified as pointer, and application needs to
84 * supply the pointer with the correct value, according to the documentation
85 * of each of the capability.
86 */
87typedef enum pjmedia_aud_dev_cap
88{
89 /**
90 * Support for audio formats other than PCM. The value of this capability
91 * is represented by #pjmedia_format structure.
92 */
93 PJMEDIA_AUD_DEV_CAP_EXT_FORMAT = 1,
94
95 /**
96 * Support for audio input latency control or query. The value of this
97 * capability is an unsigned integer containing milliseconds value of
98 * the latency.
99 */
100 PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY = 2,
101
102 /**
103 * Support for audio output latency control or query. The value of this
104 * capability is an unsigned integer containing milliseconds value of
105 * the latency.
106 */
107 PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY = 4,
108
109 /**
Benny Prijono598b01d2009-02-18 13:55:03 +0000110 * Support for setting/retrieving the audio input device volume level.
111 * The value of this capability is an unsigned integer representing
112 * the input audio volume setting in percent.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000113 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000114 PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING = 8,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000115
116 /**
Benny Prijono598b01d2009-02-18 13:55:03 +0000117 * Support for setting/retrieving the audio output device volume level.
118 * The value of this capability is an unsigned integer representing
119 * the output audio volume setting in percent.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000120 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000121 PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING = 16,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000122
123 /**
Benny Prijono598b01d2009-02-18 13:55:03 +0000124 * Support for monitoring the current audio input signal volume.
125 * The value of this capability is an unsigned integer representing
126 * the audio volume in percent.
127 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000128 PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER = 32,
Benny Prijono598b01d2009-02-18 13:55:03 +0000129
130 /**
131 * Support for monitoring the current audio output signal volume.
132 * The value of this capability is an unsigned integer representing
133 * the audio volume in percent.
134 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000135 PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER = 64,
Benny Prijono598b01d2009-02-18 13:55:03 +0000136
137 /**
138 * Support for audio input routing. The value of this capability is an
139 * integer containing #pjmedia_aud_dev_route enumeration.
140 */
141 PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE = 128,
142
143 /**
144 * Support for audio output routing (e.g. loudspeaker vs earpiece). The
145 * value of this capability is an integer containing #pjmedia_aud_dev_route
Benny Prijono2cd64f82009-02-17 19:57:48 +0000146 * enumeration.
147 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000148 PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE = 256,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000149
150 /**
151 * The audio device has echo cancellation feature. The value of this
Benny Prijono10454dc2009-02-21 14:21:59 +0000152 * capability is a pj_bool_t containing boolean PJ_TRUE or PJ_FALSE.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000153 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000154 PJMEDIA_AUD_DEV_CAP_EC = 512,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000155
156 /**
157 * The audio device supports setting echo cancellation fail length. The
158 * value of this capability is an unsigned integer representing the
159 * echo tail in milliseconds.
160 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000161 PJMEDIA_AUD_DEV_CAP_EC_TAIL = 1024,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000162
163 /**
164 * The audio device has voice activity detection feature. The value
Benny Prijono10454dc2009-02-21 14:21:59 +0000165 * of this capability is a pj_bool_t containing boolean PJ_TRUE or
Benny Prijono2cd64f82009-02-17 19:57:48 +0000166 * PJ_FALSE.
167 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000168 PJMEDIA_AUD_DEV_CAP_VAD = 2048,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000169
170 /**
171 * The audio device has comfort noise generation feature. The value
Benny Prijono10454dc2009-02-21 14:21:59 +0000172 * of this capability is a pj_bool_t containing boolean PJ_TRUE or
Benny Prijono2cd64f82009-02-17 19:57:48 +0000173 * PJ_FALSE.
174 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000175 PJMEDIA_AUD_DEV_CAP_CNG = 4096,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000176
177 /**
178 * The audio device has packet loss concealment feature. The value
Benny Prijono10454dc2009-02-21 14:21:59 +0000179 * of this capability is a pj_bool_t containing boolean PJ_TRUE or
Benny Prijono2cd64f82009-02-17 19:57:48 +0000180 * PJ_FALSE.
181 */
Benny Prijono7a380002009-03-09 12:55:29 +0000182 PJMEDIA_AUD_DEV_CAP_PLC = 8192,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000183
Benny Prijono7a380002009-03-09 12:55:29 +0000184 /**
185 * End of capability
186 */
187 PJMEDIA_AUD_DEV_CAP_MAX = 16384
188
Benny Prijono2cd64f82009-02-17 19:57:48 +0000189} pjmedia_aud_dev_cap;
190
191
192/**
193 * This enumeration describes audio routing setting.
194 */
195typedef enum pjmedia_aud_dev_route
196{
197 /** Default route. */
198 PJMEDIA_AUD_DEV_ROUTE_DEFAULT = 0,
199
200 /** Route to loudspeaker */
201 PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER = 1,
202
203 /** Route to earpiece */
204 PJMEDIA_AUD_DEV_ROUTE_EARPIECE = 2
205
206} pjmedia_aud_dev_route;
207
208
209/**
Benny Prijono2058f472009-02-22 17:15:34 +0000210 * Device information structure returned by #pjmedia_aud_dev_get_info().
Benny Prijono2cd64f82009-02-17 19:57:48 +0000211 */
212typedef struct pjmedia_aud_dev_info
213{
214 /**
215 * The device name
216 */
217 char name[64];
218
219 /**
220 * Maximum number of input channels supported by this device. If the
221 * value is zero, the device does not support input operation (i.e.
222 * it is a playback only device).
223 */
224 unsigned input_count;
225
226 /**
227 * Maximum number of output channels supported by this device. If the
228 * value is zero, the device does not support output operation (i.e.
229 * it is an input only device).
230 */
231 unsigned output_count;
232
233 /**
234 * Default sampling rate.
235 */
236 unsigned default_samples_per_sec;
237
238 /**
239 * The underlying driver name
240 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000241 char driver[32];
Benny Prijono2cd64f82009-02-17 19:57:48 +0000242
243 /**
244 * Device capabilities, as bitmask combination of #pjmedia_aud_dev_cap.
245 */
246 unsigned caps;
247
248 /**
249 * Supported audio device routes, as bitmask combination of
250 * #pjmedia_aud_dev_route. The value may be zero if the device
251 * does not support audio routing.
252 */
253 unsigned routes;
254
255 /**
256 * Number of audio formats supported by this device. The value may be
257 * zero if the device does not support non-PCM format.
258 */
259 unsigned ext_fmt_cnt;
260
261 /**
262 * Array of supported extended audio formats
263 */
264 pjmedia_format ext_fmt[8];
265
266
267} pjmedia_aud_dev_info;
268
269
270/**
271 * This callback is called by player stream when it needs additional data
272 * to be played by the device. Application must fill in the whole of output
273 * buffer with audio samples.
274 *
Benny Prijono598b01d2009-02-18 13:55:03 +0000275 * The frame argument contains the following values:
276 * - timestamp Playback timestamp, in samples.
277 * - buf Buffer to be filled out by application.
278 * - size The size requested in bytes, which will be equal to
279 * the size of one whole packet.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000280 *
Benny Prijono598b01d2009-02-18 13:55:03 +0000281 * @param user_data User data associated with the stream.
282 * @param frame Audio frame, which buffer is to be filled in by
283 * the application.
284 *
285 * @return Returning non-PJ_SUCCESS will cause the audio stream
286 * to stop
Benny Prijono2cd64f82009-02-17 19:57:48 +0000287 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000288typedef pj_status_t (*pjmedia_aud_play_cb)(void *user_data,
289 pjmedia_frame *frame);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000290
291/**
292 * This callback is called by recorder stream when it has captured the whole
293 * packet worth of audio samples.
294 *
Benny Prijono598b01d2009-02-18 13:55:03 +0000295 * @param user_data User data associated with the stream.
296 * @param frame Captured frame.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000297 *
Benny Prijono598b01d2009-02-18 13:55:03 +0000298 * @return Returning non-PJ_SUCCESS will cause the audio stream
299 * to stop
Benny Prijono2cd64f82009-02-17 19:57:48 +0000300 */
Benny Prijono598b01d2009-02-18 13:55:03 +0000301typedef pj_status_t (*pjmedia_aud_rec_cb)(void *user_data,
302 pjmedia_frame *frame);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000303
304/**
Benny Prijono10454dc2009-02-21 14:21:59 +0000305 * This structure specifies the parameters to open the audio stream.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000306 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000307typedef struct pjmedia_aud_param
Benny Prijono2cd64f82009-02-17 19:57:48 +0000308{
309 /**
310 * The audio direction. This setting is mandatory.
311 */
312 pjmedia_dir dir;
313
314 /**
315 * The audio recorder device ID. This setting is mandatory if the audio
316 * direction includes input/capture direction.
317 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000318 pjmedia_aud_dev_index rec_id;
Benny Prijono2cd64f82009-02-17 19:57:48 +0000319
320 /**
321 * The audio playback device ID. This setting is mandatory if the audio
322 * direction includes output/playback direction.
323 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000324 pjmedia_aud_dev_index play_id;
Benny Prijono2cd64f82009-02-17 19:57:48 +0000325
326 /**
327 * Clock rate/sampling rate. This setting is mandatory.
328 */
329 unsigned clock_rate;
330
331 /**
332 * Number of channels. This setting is mandatory.
333 */
334 unsigned channel_count;
335
336 /**
337 * Number of samples per frame. This setting is mandatory.
338 */
339 unsigned samples_per_frame;
340
341 /**
342 * Number of bits per sample. This setting is mandatory.
343 */
344 unsigned bits_per_sample;
345
346 /**
347 * This flags specifies which of the optional settings are valid in this
348 * structure. The flags is bitmask combination of pjmedia_aud_dev_cap.
349 */
350 unsigned flags;
351
352 /**
353 * Set the audio format. This setting is optional, and will only be used
354 * if PJMEDIA_AUD_DEV_CAP_EXT_FORMAT is set in the flags.
355 */
356 pjmedia_format ext_fmt;
357
358 /**
359 * Input latency, in milliseconds. This setting is optional, and will
360 * only be used if PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY is set in the flags.
361 */
362 unsigned input_latency_ms;
363
364 /**
365 * Input latency, in milliseconds. This setting is optional, and will
366 * only be used if PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY is set in the flags.
367 */
368 unsigned output_latency_ms;
369
Benny Prijono7a380002009-03-09 12:55:29 +0000370 /**
371 * Input volume setting, in percent. This setting is optional, and will
372 * only be used if PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING is set in
373 * the flags.
374 */
375 unsigned input_vol;
376
377 /**
378 * Output volume setting, in percent. This setting is optional, and will
379 * only be used if PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING is set in
380 * the flags.
381 */
382 unsigned output_vol;
383
384 /**
385 * Set the audio input route. This setting is optional, and will only be
386 * used if PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE is set in the flags.
387 */
388 pjmedia_aud_dev_route input_route;
389
Benny Prijono2cd64f82009-02-17 19:57:48 +0000390 /**
Benny Prijono598b01d2009-02-18 13:55:03 +0000391 * Set the audio output route. This setting is optional, and will only be
392 * used if PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE is set in the flags.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000393 */
Benny Prijono7a380002009-03-09 12:55:29 +0000394 pjmedia_aud_dev_route output_route;
Benny Prijono2cd64f82009-02-17 19:57:48 +0000395
396 /**
397 * Enable/disable echo canceller, if the device supports it. This setting
398 * is optional, and will only be used if PJMEDIA_AUD_DEV_CAP_EC is set in
399 * the flags.
400 */
401 pj_bool_t ec_enabled;
402
403 /**
404 * Set echo canceller tail length in milliseconds, if the device supports
405 * it. This setting is optional, and will only be used if
406 * PJMEDIA_AUD_DEV_CAP_EC_TAIL is set in the flags.
407 */
408 unsigned ec_tail_ms;
409
410 /**
411 * Enable/disable PLC. This setting is optional, and will only be used
412 * if PJMEDIA_AUD_DEV_CAP_PLC is set in the flags.
413 */
414 pj_bool_t plc_enabled;
415
416 /**
417 * Enable/disable CNG. This setting is optional, and will only be used
418 * if PJMEDIA_AUD_DEV_CAP_CNG is set in the flags.
419 */
420 pj_bool_t cng_enabled;
421
Benny Prijono10454dc2009-02-21 14:21:59 +0000422} pjmedia_aud_param;
Benny Prijono2cd64f82009-02-17 19:57:48 +0000423
424
425/** Forward declaration for pjmedia_aud_stream */
426typedef struct pjmedia_aud_stream pjmedia_aud_stream;
427
428/** Forward declaration for audio device factory */
429typedef struct pjmedia_aud_dev_factory pjmedia_aud_dev_factory;
430
Sauw Ming8fd16932010-05-05 04:23:27 +0000431/* typedef for factory creation function */
432typedef pjmedia_aud_dev_factory*
433(*pjmedia_aud_dev_factory_create_func_ptr)(pj_pool_factory*);
434
435
Benny Prijono7a380002009-03-09 12:55:29 +0000436/**
437 * Get string info for the specified capability.
438 *
439 * @param cap The capability ID.
440 * @param p_desc Optional pointer which will be filled with longer
441 * description about the capability.
442 *
443 * @return Capability name.
444 */
445PJ_DECL(const char*) pjmedia_aud_dev_cap_name(pjmedia_aud_dev_cap cap,
446 const char **p_desc);
447
448
449/**
450 * Set a capability field value in #pjmedia_aud_param structure. This will
451 * also set the flags field for the specified capability in the structure.
452 *
453 * @param param The structure.
454 * @param cap The audio capability which value is to be set.
455 * @param value Pointer to value. Please see the type of value to
456 * be supplied in the pjmedia_aud_dev_cap documentation.
457 *
458 * @return PJ_SUCCESS on successful operation or the appropriate
459 * error code.
460 */
461PJ_DECL(pj_status_t) pjmedia_aud_param_set_cap(pjmedia_aud_param *param,
462 pjmedia_aud_dev_cap cap,
463 const void *pval);
464
465
466/**
467 * Get a capability field value from #pjmedia_aud_param structure. This
468 * function will return PJMEDIA_EAUD_INVCAP error if the flag for that
469 * capability is not set in the flags field in the structure.
470 *
471 * @param param The structure.
472 * @param cap The audio capability which value is to be retrieved.
473 * @param value Pointer to value. Please see the type of value to
474 * be supplied in the pjmedia_aud_dev_cap documentation.
475 *
476 * @return PJ_SUCCESS on successful operation or the appropriate
477 * error code.
478 */
479PJ_DECL(pj_status_t) pjmedia_aud_param_get_cap(const pjmedia_aud_param *param,
480 pjmedia_aud_dev_cap cap,
481 void *pval);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000482
483/**
484 * Initialize the audio subsystem. This will register all supported audio
485 * device factories to the audio subsystem. This function may be called
486 * more than once, but each call to this function must have the
487 * corresponding #pjmedia_aud_subsys_shutdown() call.
488 *
489 * @param pf The pool factory.
490 *
491 * @return PJ_SUCCESS on successful operation or the appropriate
492 * error code.
493 */
494PJ_DECL(pj_status_t) pjmedia_aud_subsys_init(pj_pool_factory *pf);
495
496
497/**
Benny Prijonoe3ebd552009-02-18 20:14:15 +0000498 * Get the pool factory registered to the audio subsystem.
499 *
500 * @return The pool factory.
501 */
502PJ_DECL(pj_pool_factory*) pjmedia_aud_subsys_get_pool_factory(void);
503
504
505/**
Benny Prijono2cd64f82009-02-17 19:57:48 +0000506 * Shutdown the audio subsystem. This will destroy all audio device factories
507 * registered in the audio subsystem. Note that currently opened audio streams
508 * may or may not be closed, depending on the implementation of the audio
509 * device factories.
510 *
511 * @return PJ_SUCCESS on successful operation or the appropriate
512 * error code.
513 */
514PJ_DECL(pj_status_t) pjmedia_aud_subsys_shutdown(void);
515
516
517/**
Sauw Ming8fd16932010-05-05 04:23:27 +0000518 * Register a supported audio device factory to the audio subsystem. This
519 * function can only be called after calling #pjmedia_aud_subsys_init().
520 *
521 * @param adf The audio device factory.
522 *
523 * @return PJ_SUCCESS on successful operation or the appropriate
524 * error code.
525 */
526PJ_DECL(pj_status_t)
527pjmedia_aud_register_factory(pjmedia_aud_dev_factory_create_func_ptr adf);
528
529
530/**
531 * Unregister an audio device factory from the audio subsystem. This
532 * function can only be called after calling #pjmedia_aud_subsys_init().
533 * Devices from this factory will be unlisted. If a device from this factory
534 * is currently in use, then the behavior is undefined.
535 *
536 * @param adf The audio device factory.
537 *
538 * @return PJ_SUCCESS on successful operation or the appropriate
539 * error code.
540 */
541PJ_DECL(pj_status_t)
542pjmedia_aud_unregister_factory(pjmedia_aud_dev_factory_create_func_ptr adf);
543
544
545/**
Benny Prijono2cd64f82009-02-17 19:57:48 +0000546 * Get the number of sound devices installed in the system.
547 *
548 * @return The number of sound devices installed in the system.
549 */
550PJ_DECL(unsigned) pjmedia_aud_dev_count(void);
551
552
553/**
Benny Prijono2cd64f82009-02-17 19:57:48 +0000554 * Get device information.
555 *
556 * @param id The audio device ID.
557 * @param info The device information which will be filled in by this
558 * function once it returns successfully.
559 *
560 * @return PJ_SUCCESS on successful operation or the appropriate
561 * error code.
562 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000563PJ_DECL(pj_status_t) pjmedia_aud_dev_get_info(pjmedia_aud_dev_index id,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000564 pjmedia_aud_dev_info *info);
565
566
567/**
Benny Prijono10454dc2009-02-21 14:21:59 +0000568 * Lookup device index based on the driver and device name.
569 *
570 * @param drv_name The driver name.
571 * @param dev_name The device name.
Benny Prijono2058f472009-02-22 17:15:34 +0000572 * @param id Pointer to store the returned device ID.
Benny Prijono10454dc2009-02-21 14:21:59 +0000573 *
574 * @return PJ_SUCCESS if the device can be found.
575 */
576PJ_DECL(pj_status_t) pjmedia_aud_dev_lookup(const char *drv_name,
577 const char *dev_name,
578 pjmedia_aud_dev_index *id);
579
580
581/**
Benny Prijono2cd64f82009-02-17 19:57:48 +0000582 * Initialize the audio device parameters with default values for the
583 * specified device.
584 *
585 * @param id The audio device ID.
586 * @param param The audio device parameters which will be initialized
587 * by this function once it returns successfully.
588 *
589 * @return PJ_SUCCESS on successful operation or the appropriate
590 * error code.
591 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000592PJ_DECL(pj_status_t) pjmedia_aud_dev_default_param(pjmedia_aud_dev_index id,
593 pjmedia_aud_param *param);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000594
595
596/**
597 * Open audio stream object using the specified parameters.
598 *
599 * @param param Sound device parameters to be used for the stream.
600 * @param rec_cb Callback to be called on every input frame captured.
601 * @param play_cb Callback to be called everytime the sound device needs
602 * audio frames to be played back.
603 * @param user_data Arbitrary user data, which will be given back in the
604 * callbacks.
Benny Prijono2058f472009-02-22 17:15:34 +0000605 * @param p_strm Pointer to receive the audio stream.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000606 *
607 * @return PJ_SUCCESS on successful operation or the appropriate
608 * error code.
609 */
Benny Prijono10454dc2009-02-21 14:21:59 +0000610PJ_DECL(pj_status_t) pjmedia_aud_stream_create(const pjmedia_aud_param *param,
Benny Prijono2cd64f82009-02-17 19:57:48 +0000611 pjmedia_aud_rec_cb rec_cb,
612 pjmedia_aud_play_cb play_cb,
613 void *user_data,
Benny Prijono10454dc2009-02-21 14:21:59 +0000614 pjmedia_aud_stream **p_strm);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000615
616/**
617 * Get the running parameters for the specified audio stream.
618 *
619 * @param strm The audio stream.
620 * @param param Audio stream parameters to be filled in by this
621 * function once it returns successfully.
622 *
623 * @return PJ_SUCCESS on successful operation or the appropriate
624 * error code.
625 */
626PJ_DECL(pj_status_t) pjmedia_aud_stream_get_param(pjmedia_aud_stream *strm,
Benny Prijono10454dc2009-02-21 14:21:59 +0000627 pjmedia_aud_param *param);
Benny Prijono2cd64f82009-02-17 19:57:48 +0000628
629/**
630 * Get the value of a specific capability of the audio stream.
631 *
632 * @param strm The audio stream.
633 * @param cap The audio capability which value is to be retrieved.
634 * @param value Pointer to value to be filled in by this function
Benny Prijono7a380002009-03-09 12:55:29 +0000635 * once it returns successfully. Please see the type
636 * of value to be supplied in the pjmedia_aud_dev_cap
637 * documentation.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000638 *
639 * @return PJ_SUCCESS on successful operation or the appropriate
640 * error code.
641 */
642PJ_DECL(pj_status_t) pjmedia_aud_stream_get_cap(pjmedia_aud_stream *strm,
643 pjmedia_aud_dev_cap cap,
644 void *value);
645
646/**
647 * Set the value of a specific capability of the audio stream.
648 *
649 * @param strm The audio stream.
650 * @param cap The audio capability which value is to be set.
Benny Prijono7a380002009-03-09 12:55:29 +0000651 * @param value Pointer to value. Please see the type of value to
652 * be supplied in the pjmedia_aud_dev_cap documentation.
Benny Prijono2cd64f82009-02-17 19:57:48 +0000653 *
654 * @return PJ_SUCCESS on successful operation or the appropriate
655 * error code.
656 */
657PJ_DECL(pj_status_t) pjmedia_aud_stream_set_cap(pjmedia_aud_stream *strm,
658 pjmedia_aud_dev_cap cap,
659 const void *value);
660
661/**
662 * Start the stream.
663 *
664 * @param strm The audio stream.
665 *
666 * @return PJ_SUCCESS on successful operation or the appropriate
667 * error code.
668 */
669PJ_DECL(pj_status_t) pjmedia_aud_stream_start(pjmedia_aud_stream *strm);
670
671/**
672 * Stop the stream.
673 *
674 * @param strm The audio stream.
675 *
676 * @return PJ_SUCCESS on successful operation or the appropriate
677 * error code.
678 */
679PJ_DECL(pj_status_t) pjmedia_aud_stream_stop(pjmedia_aud_stream *strm);
680
681/**
682 * Destroy the stream.
683 *
684 * @param strm The audio stream.
685 *
686 * @return PJ_SUCCESS on successful operation or the appropriate
687 * error code.
688 */
689PJ_DECL(pj_status_t) pjmedia_aud_stream_destroy(pjmedia_aud_stream *strm);
690
691
Benny Prijono2cd64f82009-02-17 19:57:48 +0000692/**
Benny Prijono2058f472009-02-22 17:15:34 +0000693 * @}
Benny Prijono2cd64f82009-02-17 19:57:48 +0000694 */
695
696PJ_END_DECL
697
698
Benny Prijono10454dc2009-02-21 14:21:59 +0000699#endif /* __PJMEDIA_AUDIODEV_AUDIODEV_H__ */
Benny Prijono2cd64f82009-02-17 19:57:48 +0000700