audiodev.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  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 __PJMEDIA_AUDIO_DEV_H__
  20. #define __PJMEDIA_AUDIO_DEV_H__
  21. /**
  22. * @file audiodev.h
  23. * @brief Audio device API.
  24. */
  25. #include <pjmedia-audiodev/config.h>
  26. #include <pjmedia-audiodev/errno.h>
  27. #include <pjmedia/format.h>
  28. #include <pjmedia/frame.h>
  29. #include <pjmedia/types.h>
  30. #include <pj/pool.h>
  31. PJ_BEGIN_DECL
  32. /**
  33. * @defgroup PJMEDIA_AUDIODEV_API Audio Device API Reference
  34. * @ingroup audio_device_api
  35. * @brief Documentation and API Reference
  36. * @{
  37. *
  38. * @section ec_sec Hardware/Built-in Echo Cancellation
  39. *
  40. * On some platforms, audio device comes with built-in echo cancellation
  41. * feature. This is usually done based on specific hardware configuration,
  42. * such as the use of multiple microphones and/or a known fixed distance
  43. * between the capture and playback device, in order to precalculate the
  44. * echo time distance. Because of this, when using the hardware EC,
  45. * users may not get the freedom to select their own audio devices.
  46. * This is applicable for Mac (users must use default audio devices) and
  47. * iOS (users must use the same built-in audio device).
  48. *
  49. * In PJMEDIA, applications wishing to use sofware echo instead can pass
  50. * PJMEDIA_ECHO_USE_SW_ECHO when calling pjmedia_snd_port_create2().
  51. */
  52. /**
  53. * Type for device index.
  54. */
  55. typedef pj_int32_t pjmedia_aud_dev_index;
  56. /**
  57. * Device index constants.
  58. */
  59. /**
  60. * Constant to denote default capture device
  61. */
  62. #define PJMEDIA_AUD_DEFAULT_CAPTURE_DEV -1
  63. /**
  64. * Constant to denote default playback device
  65. */
  66. #define PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV -2
  67. /**
  68. * Constant to denote invalid device index.
  69. */
  70. #define PJMEDIA_AUD_INVALID_DEV -3
  71. #define PJMEDIA_AUD_MAX_DRIVERS 16
  72. #define PJMEDIA_AUD_MAX_DEVS 64
  73. /** Forward declaration for pjmedia_aud_stream */
  74. typedef struct pjmedia_aud_stream pjmedia_aud_stream;
  75. /** Forward declaration for audio device factory */
  76. typedef struct pjmedia_aud_dev_factory pjmedia_aud_dev_factory;
  77. /* typedef for factory creation function */
  78. typedef pjmedia_aud_dev_factory*
  79. (*pjmedia_aud_dev_factory_create_func_ptr)(pj_pool_factory*);
  80. /* Audio driver structure */
  81. typedef struct pjmedia_aud_driver
  82. {
  83. pjmedia_aud_dev_factory_create_func_ptr create; /* Creation function */
  84. pjmedia_aud_dev_factory *f; /* Factory instance */
  85. char name[32]; /* Driver name */
  86. unsigned dev_cnt; /* Number of devices */
  87. unsigned start_idx; /* Start index in global list */
  88. int rec_dev_idx; /* Default capture device. */
  89. int play_dev_idx;/* Default playback device */
  90. int dev_idx; /* Default device. */
  91. } pjmedia_aud_driver;
  92. /* Audio subsystem structure */
  93. typedef struct pjmedia_aud_subsys
  94. {
  95. unsigned init_count; /* How many times init() is called */
  96. pj_pool_factory *pf; /* The pool factory. */
  97. unsigned drv_cnt; /* Number of drivers. */
  98. pjmedia_aud_driver drv[PJMEDIA_AUD_MAX_DRIVERS];/* Array of drivers. */
  99. unsigned dev_cnt; /* Total number of devices. */
  100. pj_uint32_t dev_list[PJMEDIA_AUD_MAX_DEVS];/* Array of dev IDs. */
  101. } pjmedia_aud_subsys;
  102. /**
  103. * This enumeration identifies various audio device capabilities. These audio
  104. * capabilities indicates what features are supported by the underlying
  105. * audio device implementation.
  106. *
  107. * Applications get these capabilities in the #pjmedia_aud_dev_info structure.
  108. *
  109. * Application can also set the specific features/capabilities when opening
  110. * the audio stream by setting the \a flags member of #pjmedia_aud_param
  111. * structure.
  112. *
  113. * Once audio stream is running, application can also retrieve or set some
  114. * specific audio capability, by using #pjmedia_aud_stream_get_cap() and
  115. * #pjmedia_aud_stream_set_cap() and specifying the desired capability. The
  116. * value of the capability is specified as pointer, and application needs to
  117. * supply the pointer with the correct value, according to the documentation
  118. * of each of the capability.
  119. */
  120. typedef enum pjmedia_aud_dev_cap
  121. {
  122. /**
  123. * Support for audio formats other than PCM. The value of this capability
  124. * is represented by #pjmedia_format structure.
  125. */
  126. PJMEDIA_AUD_DEV_CAP_EXT_FORMAT = 1,
  127. /**
  128. * Support for audio input latency control or query. The value of this
  129. * capability is an unsigned integer containing milliseconds value of
  130. * the latency.
  131. */
  132. PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY = 2,
  133. /**
  134. * Support for audio output latency control or query. The value of this
  135. * capability is an unsigned integer containing milliseconds value of
  136. * the latency.
  137. */
  138. PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY = 4,
  139. /**
  140. * Support for setting/retrieving the audio input device volume level.
  141. * The value of this capability is an unsigned integer representing
  142. * the input audio volume setting in percent.
  143. */
  144. PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING = 8,
  145. /**
  146. * Support for setting/retrieving the audio output device volume level.
  147. * The value of this capability is an unsigned integer representing
  148. * the output audio volume setting in percent.
  149. */
  150. PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING = 16,
  151. /**
  152. * Support for monitoring the current audio input signal volume.
  153. * The value of this capability is an unsigned integer representing
  154. * the audio volume in percent.
  155. */
  156. PJMEDIA_AUD_DEV_CAP_INPUT_SIGNAL_METER = 32,
  157. /**
  158. * Support for monitoring the current audio output signal volume.
  159. * The value of this capability is an unsigned integer representing
  160. * the audio volume in percent.
  161. */
  162. PJMEDIA_AUD_DEV_CAP_OUTPUT_SIGNAL_METER = 64,
  163. /**
  164. * Support for audio input routing/source. The value of this capability
  165. * is an integer containing #pjmedia_aud_dev_route enumeration.
  166. */
  167. PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE = 128,
  168. PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE = 128,
  169. /**
  170. * Support for audio output routing (e.g. loudspeaker vs earpiece). The
  171. * value of this capability is an integer containing #pjmedia_aud_dev_route
  172. * enumeration.
  173. */
  174. PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE = 256,
  175. /**
  176. * The audio device has echo cancellation feature. The value of this
  177. * capability is a pj_bool_t containing boolean PJ_TRUE or PJ_FALSE.
  178. */
  179. PJMEDIA_AUD_DEV_CAP_EC = 512,
  180. /**
  181. * The audio device supports setting echo cancellation fail length. The
  182. * value of this capability is an unsigned integer representing the
  183. * echo tail in milliseconds.
  184. */
  185. PJMEDIA_AUD_DEV_CAP_EC_TAIL = 1024,
  186. /**
  187. * The audio device has voice activity detection feature. The value
  188. * of this capability is a pj_bool_t containing boolean PJ_TRUE or
  189. * PJ_FALSE.
  190. */
  191. PJMEDIA_AUD_DEV_CAP_VAD = 2048,
  192. /**
  193. * The audio device has comfort noise generation feature. The value
  194. * of this capability is a pj_bool_t containing boolean PJ_TRUE or
  195. * PJ_FALSE.
  196. */
  197. PJMEDIA_AUD_DEV_CAP_CNG = 4096,
  198. /**
  199. * The audio device has packet loss concealment feature. The value
  200. * of this capability is a pj_bool_t containing boolean PJ_TRUE or
  201. * PJ_FALSE.
  202. */
  203. PJMEDIA_AUD_DEV_CAP_PLC = 8192,
  204. /**
  205. * End of capability
  206. */
  207. PJMEDIA_AUD_DEV_CAP_MAX = 16384
  208. } pjmedia_aud_dev_cap;
  209. /**
  210. * This enumeration describes audio routing/source setting.
  211. */
  212. typedef enum pjmedia_aud_dev_route
  213. {
  214. /**
  215. * Default route/source, it is the default audio route/source of
  216. * the audio framework backend, as in opening audio device without
  217. * specifying any route/source setting or with specifying neutral
  218. * route/source setting.
  219. */
  220. PJMEDIA_AUD_DEV_ROUTE_DEFAULT = 0,
  221. /** Route to loudspeaker */
  222. PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER = 1,
  223. /** Route to earpiece */
  224. PJMEDIA_AUD_DEV_ROUTE_EARPIECE = 2,
  225. /** Route to paired Bluetooth device */
  226. PJMEDIA_AUD_DEV_ROUTE_BLUETOOTH = 4,
  227. /**
  228. * Custom audio route/source, specific to each audio device
  229. * backend.
  230. *
  231. * For Android JNI audio device, the default is
  232. * VOICE_COMMUNICATION (7). To change it to another value, set
  233. * the input source capability of pjmedia_aud_param accordingly.
  234. * For example:
  235. * // 6 is VOICE_RECOGNITION
  236. * unsigned aud_source = PJMEDIA_AUD_DEV_ROUTE_CUSTOM | 6;
  237. * pjmedia_aud_param_set_cap(&param, PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE,
  238. * &aud_source);
  239. */
  240. PJMEDIA_AUD_DEV_ROUTE_CUSTOM = 128
  241. } pjmedia_aud_dev_route;
  242. /**
  243. * Device information structure returned by #pjmedia_aud_dev_get_info().
  244. */
  245. typedef struct pjmedia_aud_dev_info
  246. {
  247. /**
  248. * The device ID
  249. */
  250. pjmedia_aud_dev_index id;
  251. /**
  252. * The device name
  253. */
  254. char name[PJMEDIA_AUD_DEV_INFO_NAME_LEN];
  255. /**
  256. * Maximum number of input channels supported by this device. If the
  257. * value is zero, the device does not support input operation (i.e.
  258. * it is a playback only device).
  259. */
  260. unsigned input_count;
  261. /**
  262. * Maximum number of output channels supported by this device. If the
  263. * value is zero, the device does not support output operation (i.e.
  264. * it is an input only device).
  265. */
  266. unsigned output_count;
  267. /**
  268. * Default sampling rate.
  269. */
  270. unsigned default_samples_per_sec;
  271. /**
  272. * The underlying driver name
  273. */
  274. char driver[32];
  275. /**
  276. * Device capabilities, as bitmask combination of #pjmedia_aud_dev_cap.
  277. */
  278. unsigned caps;
  279. /**
  280. * Supported audio device routes/sources, as bitmask combination of
  281. * #pjmedia_aud_dev_route. The value may be zero if the device
  282. * does not support changing audio routes/sources.
  283. */
  284. unsigned routes;
  285. /**
  286. * Number of audio formats supported by this device. The value may be
  287. * zero if the device does not support non-PCM format.
  288. */
  289. unsigned ext_fmt_cnt;
  290. /**
  291. * Array of supported extended audio formats
  292. */
  293. pjmedia_format ext_fmt[8];
  294. } pjmedia_aud_dev_info;
  295. /**
  296. * This callback is called by player stream when it needs additional data
  297. * to be played by the device. Application must fill in the whole of output
  298. * buffer with audio samples.
  299. *
  300. * The frame argument contains the following values:
  301. * - timestamp Playback timestamp, in samples.
  302. * - buf Buffer to be filled out by application.
  303. * - size The size requested in bytes, which will be equal to
  304. * the size of one whole packet.
  305. *
  306. * @param user_data User data associated with the stream.
  307. * @param frame Audio frame, which buffer is to be filled in by
  308. * the application.
  309. *
  310. * @return Returning non-PJ_SUCCESS will cause the audio stream
  311. * to stop
  312. */
  313. typedef pj_status_t (*pjmedia_aud_play_cb)(void *user_data,
  314. pjmedia_frame *frame);
  315. /**
  316. * This callback is called by recorder stream when it has captured the whole
  317. * packet worth of audio samples.
  318. *
  319. * @param user_data User data associated with the stream.
  320. * @param frame Captured frame.
  321. *
  322. * @return Returning non-PJ_SUCCESS will cause the audio stream
  323. * to stop
  324. */
  325. typedef pj_status_t (*pjmedia_aud_rec_cb)(void *user_data,
  326. pjmedia_frame *frame);
  327. /**
  328. * This structure specifies the parameters to open the audio stream.
  329. */
  330. typedef struct pjmedia_aud_param
  331. {
  332. /**
  333. * The audio direction. This setting is mandatory.
  334. */
  335. pjmedia_dir dir;
  336. /**
  337. * The audio recorder device ID. This setting is mandatory if the audio
  338. * direction includes input/capture direction.
  339. */
  340. pjmedia_aud_dev_index rec_id;
  341. /**
  342. * The audio playback device ID. This setting is mandatory if the audio
  343. * direction includes output/playback direction.
  344. */
  345. pjmedia_aud_dev_index play_id;
  346. /**
  347. * Clock rate/sampling rate. This setting is mandatory.
  348. */
  349. unsigned clock_rate;
  350. /**
  351. * Number of channels. This setting is mandatory.
  352. */
  353. unsigned channel_count;
  354. /**
  355. * Number of samples per frame. This setting is mandatory.
  356. */
  357. unsigned samples_per_frame;
  358. /**
  359. * Number of bits per sample. This setting is mandatory.
  360. */
  361. unsigned bits_per_sample;
  362. /**
  363. * This flags specifies which of the optional settings are valid in this
  364. * structure. The flags is bitmask combination of pjmedia_aud_dev_cap.
  365. */
  366. unsigned flags;
  367. /**
  368. * Set the audio format. This setting is optional, and will only be used
  369. * if PJMEDIA_AUD_DEV_CAP_EXT_FORMAT is set in the flags.
  370. */
  371. pjmedia_format ext_fmt;
  372. /**
  373. * Input latency, in milliseconds. This setting is optional, and will
  374. * only be used if PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY is set in the flags.
  375. */
  376. unsigned input_latency_ms;
  377. /**
  378. * Input latency, in milliseconds. This setting is optional, and will
  379. * only be used if PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY is set in the flags.
  380. */
  381. unsigned output_latency_ms;
  382. /**
  383. * Input volume setting, in percent. This setting is optional, and will
  384. * only be used if PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING is set in
  385. * the flags.
  386. */
  387. unsigned input_vol;
  388. /**
  389. * Output volume setting, in percent. This setting is optional, and will
  390. * only be used if PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING is set in
  391. * the flags.
  392. */
  393. unsigned output_vol;
  394. /**
  395. * Set the audio input route/source. This setting is optional, and
  396. * will only be used if PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE/
  397. * PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE is set in the flags.
  398. */
  399. pjmedia_aud_dev_route input_route;
  400. /**
  401. * Set the audio output route. This setting is optional, and will only be
  402. * used if PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE is set in the flags.
  403. */
  404. pjmedia_aud_dev_route output_route;
  405. /**
  406. * Enable/disable echo canceller, if the device supports it. This setting
  407. * is optional, and will only be used if PJMEDIA_AUD_DEV_CAP_EC is set in
  408. * the flags.
  409. */
  410. pj_bool_t ec_enabled;
  411. /**
  412. * Set echo canceller tail length in milliseconds, if the device supports
  413. * it. This setting is optional, and will only be used if
  414. * PJMEDIA_AUD_DEV_CAP_EC_TAIL is set in the flags.
  415. */
  416. unsigned ec_tail_ms;
  417. /**
  418. * Enable/disable PLC. This setting is optional, and will only be used
  419. * if PJMEDIA_AUD_DEV_CAP_PLC is set in the flags.
  420. */
  421. pj_bool_t plc_enabled;
  422. /**
  423. * Enable/disable CNG. This setting is optional, and will only be used
  424. * if PJMEDIA_AUD_DEV_CAP_CNG is set in the flags.
  425. */
  426. pj_bool_t cng_enabled;
  427. /**
  428. * Enable/disable VAD. This setting is optional, and will only be used
  429. * if PJMEDIA_AUD_DEV_CAP_VAD is set in the flags.
  430. */
  431. pj_bool_t vad_enabled;
  432. } pjmedia_aud_param;
  433. /**
  434. * Get the audio subsystem.
  435. *
  436. * @return The audio subsystem.
  437. */
  438. PJ_DECL(pjmedia_aud_subsys*) pjmedia_get_aud_subsys(void);
  439. /**
  440. * Initialize the audio driver.
  441. *
  442. * @param drv_idx The index of the audio driver.
  443. * @param refresh Specify non-zero to refresh the audio driver.
  444. *
  445. * @return PJ_SUCCESS on successful operation or the appropriate
  446. * error code.
  447. */
  448. PJ_DECL(pj_status_t) pjmedia_aud_driver_init(unsigned drv_idx,
  449. pj_bool_t refresh);
  450. /**
  451. * Deinitialize the audio driver.
  452. *
  453. * @param drv_idx The index of the audio driver.
  454. */
  455. PJ_DECL(void) pjmedia_aud_driver_deinit(unsigned drv_idx);
  456. /**
  457. * Get string info for the specified capability.
  458. *
  459. * @param cap The capability ID.
  460. * @param p_desc Optional pointer which will be filled with longer
  461. * description about the capability.
  462. *
  463. * @return Capability name.
  464. */
  465. PJ_DECL(const char*) pjmedia_aud_dev_cap_name(pjmedia_aud_dev_cap cap,
  466. const char **p_desc);
  467. /**
  468. * Set a capability field value in #pjmedia_aud_param structure. This will
  469. * also set the flags field for the specified capability in the structure.
  470. *
  471. * @param param The structure.
  472. * @param cap The audio capability which value is to be set.
  473. * @param pval 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. */
  479. PJ_DECL(pj_status_t) pjmedia_aud_param_set_cap(pjmedia_aud_param *param,
  480. pjmedia_aud_dev_cap cap,
  481. const void *pval);
  482. /**
  483. * Get a capability field value from #pjmedia_aud_param structure. This
  484. * function will return PJMEDIA_EAUD_INVCAP error if the flag for that
  485. * capability is not set in the flags field in the structure.
  486. *
  487. * @param param The structure.
  488. * @param cap The audio capability which value is to be retrieved.
  489. * @param pval Pointer to value. Please see the type of value to
  490. * be supplied in the pjmedia_aud_dev_cap documentation.
  491. *
  492. * @return PJ_SUCCESS on successful operation or the appropriate
  493. * error code.
  494. */
  495. PJ_DECL(pj_status_t) pjmedia_aud_param_get_cap(const pjmedia_aud_param *param,
  496. pjmedia_aud_dev_cap cap,
  497. void *pval);
  498. /**
  499. * Refresh the list of sound devices installed in the system. This function
  500. * will only refresh the list of audio device so all active audio streams will
  501. * be unaffected. After refreshing the device list, application MUST make sure
  502. * to update all index references to audio devices (i.e. all variables of type
  503. * pjmedia_aud_dev_index) before calling any function that accepts audio device
  504. * index as its parameter.
  505. *
  506. * @return PJ_SUCCESS on successful operation or the appropriate
  507. * error code.
  508. */
  509. PJ_DECL(pj_status_t) pjmedia_aud_dev_refresh(void);
  510. /**
  511. * Get the number of sound devices installed in the system.
  512. *
  513. * @return The number of sound devices installed in the system.
  514. */
  515. PJ_DECL(unsigned) pjmedia_aud_dev_count(void);
  516. /**
  517. * Get device information.
  518. *
  519. * @param id The audio device ID.
  520. * @param info The device information which will be filled in by this
  521. * function once it returns successfully.
  522. *
  523. * @return PJ_SUCCESS on successful operation or the appropriate
  524. * error code.
  525. */
  526. PJ_DECL(pj_status_t) pjmedia_aud_dev_get_info(pjmedia_aud_dev_index id,
  527. pjmedia_aud_dev_info *info);
  528. /**
  529. * Lookup device index based on the driver and device name.
  530. *
  531. * @param drv_name The driver name.
  532. * @param dev_name The device name.
  533. * @param id Pointer to store the returned device ID.
  534. *
  535. * @return PJ_SUCCESS if the device can be found.
  536. */
  537. PJ_DECL(pj_status_t) pjmedia_aud_dev_lookup(const char *drv_name,
  538. const char *dev_name,
  539. pjmedia_aud_dev_index *id);
  540. /**
  541. * Initialize the audio device parameters with default values for the
  542. * specified device.
  543. *
  544. * @param id The audio device ID.
  545. * @param param The audio device parameters which will be initialized
  546. * by this function once it returns successfully.
  547. *
  548. * @return PJ_SUCCESS on successful operation or the appropriate
  549. * error code.
  550. */
  551. PJ_DECL(pj_status_t) pjmedia_aud_dev_default_param(pjmedia_aud_dev_index id,
  552. pjmedia_aud_param *param);
  553. /**
  554. * Open audio stream object using the specified parameters.
  555. *
  556. * @param param Sound device parameters to be used for the stream.
  557. * @param rec_cb Callback to be called on every input frame captured.
  558. * @param play_cb Callback to be called everytime the sound device needs
  559. * audio frames to be played back.
  560. * @param user_data Arbitrary user data, which will be given back in the
  561. * callbacks.
  562. * @param p_strm Pointer to receive the audio stream.
  563. *
  564. * @return PJ_SUCCESS on successful operation or the appropriate
  565. * error code.
  566. */
  567. PJ_DECL(pj_status_t) pjmedia_aud_stream_create(const pjmedia_aud_param *param,
  568. pjmedia_aud_rec_cb rec_cb,
  569. pjmedia_aud_play_cb play_cb,
  570. void *user_data,
  571. pjmedia_aud_stream **p_strm);
  572. /**
  573. * Get the running parameters for the specified audio stream.
  574. *
  575. * @param strm The audio stream.
  576. * @param param Audio stream parameters to be filled in by this
  577. * function once it returns successfully.
  578. *
  579. * @return PJ_SUCCESS on successful operation or the appropriate
  580. * error code.
  581. */
  582. PJ_DECL(pj_status_t) pjmedia_aud_stream_get_param(pjmedia_aud_stream *strm,
  583. pjmedia_aud_param *param);
  584. /**
  585. * Get the value of a specific capability of the audio stream.
  586. *
  587. * @param strm The audio stream.
  588. * @param cap The audio capability which value is to be retrieved.
  589. * @param value Pointer to value to be filled in by this function
  590. * once it returns successfully. Please see the type
  591. * of value to be supplied in the pjmedia_aud_dev_cap
  592. * documentation.
  593. *
  594. * @return PJ_SUCCESS on successful operation or the appropriate
  595. * error code.
  596. */
  597. PJ_DECL(pj_status_t) pjmedia_aud_stream_get_cap(pjmedia_aud_stream *strm,
  598. pjmedia_aud_dev_cap cap,
  599. void *value);
  600. /**
  601. * Set the value of a specific capability of the audio stream.
  602. *
  603. * @param strm The audio stream.
  604. * @param cap The audio capability which value is to be set.
  605. * @param value Pointer to value. Please see the type of value to
  606. * be supplied in the pjmedia_aud_dev_cap documentation.
  607. *
  608. * @return PJ_SUCCESS on successful operation or the appropriate
  609. * error code.
  610. */
  611. PJ_DECL(pj_status_t) pjmedia_aud_stream_set_cap(pjmedia_aud_stream *strm,
  612. pjmedia_aud_dev_cap cap,
  613. const void *value);
  614. /**
  615. * Start the stream.
  616. *
  617. * @param strm The audio stream.
  618. *
  619. * @return PJ_SUCCESS on successful operation or the appropriate
  620. * error code.
  621. */
  622. PJ_DECL(pj_status_t) pjmedia_aud_stream_start(pjmedia_aud_stream *strm);
  623. /**
  624. * Stop the stream.
  625. *
  626. * @param strm The audio stream.
  627. *
  628. * @return PJ_SUCCESS on successful operation or the appropriate
  629. * error code.
  630. */
  631. PJ_DECL(pj_status_t) pjmedia_aud_stream_stop(pjmedia_aud_stream *strm);
  632. /**
  633. * Destroy the stream.
  634. *
  635. * @param strm The audio stream.
  636. *
  637. * @return PJ_SUCCESS on successful operation or the appropriate
  638. * error code.
  639. */
  640. PJ_DECL(pj_status_t) pjmedia_aud_stream_destroy(pjmedia_aud_stream *strm);
  641. /**
  642. * @}
  643. */
  644. PJ_END_DECL
  645. #endif /* __PJMEDIA_AUDIO_DEV_H__ */