/* $Id$ */ /* * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) * Copyright (C) 2003-2008 Benny Prijono * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __PJMEDIA_AUDIODEV_CONFIG_H__ #define __PJMEDIA_AUDIODEV_CONFIG_H__ /** * @file config.h * @brief Audio config. */ #include #include PJ_BEGIN_DECL /** * @defgroup audio_device_api Audio Device API * @brief PJMEDIA audio device abstraction API. */ /** * @defgroup s1_audio_device_config Compile time configurations * @ingroup audio_device_api * @brief Compile time configurations * @{ */ /** * This setting controls the buffer length of audio device name. * * Default: 128 for Windows platforms, 64 for others */ #ifndef PJMEDIA_AUD_DEV_INFO_NAME_LEN # if (defined(PJ_WIN32) && PJ_WIN32!=0) || \ (defined(PJ_WIN64) && PJ_WIN64!=0) # define PJMEDIA_AUD_DEV_INFO_NAME_LEN 128 # else # define PJMEDIA_AUD_DEV_INFO_NAME_LEN 64 # endif #endif /** * This setting controls whether PortAudio support should be included. * * By default it is disabled. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO # define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 0 #endif /** * This setting controls whether Android OpenSL audio support should be * included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_OPENSL # define PJMEDIA_AUDIO_DEV_HAS_OPENSL 0 #endif /** * This setting controls whether Android JNI audio support should be * included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_ANDROID_JNI # define PJMEDIA_AUDIO_DEV_HAS_ANDROID_JNI PJ_ANDROID #endif /** * This setting controls whether BlackBerry 10 (BB10) audio support * should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_BB10 # define PJMEDIA_AUDIO_DEV_HAS_BB10 0 #endif /** * This setting controls whether native ALSA support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_ALSA # define PJMEDIA_AUDIO_DEV_HAS_ALSA 0 #endif /** * This setting controls whether null audio support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_NULL_AUDIO # define PJMEDIA_AUDIO_DEV_HAS_NULL_AUDIO 0 #endif /** * This setting controls whether coreaudio support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_COREAUDIO # define PJMEDIA_AUDIO_DEV_HAS_COREAUDIO 0 #endif /** * This setting controls whether WMME support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_WMME # if (defined(PJ_WIN32_UWP) && PJ_WIN32_UWP!=0) || \ (defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8!=0) # define PJMEDIA_AUDIO_DEV_HAS_WMME 0 # else # define PJMEDIA_AUDIO_DEV_HAS_WMME 1 # endif #endif /** * This setting controls whether Windows Audio Session API (WASAPI) * support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_WASAPI # if (defined(PJ_WIN32_UWP) && PJ_WIN32_UWP!=0) || \ (defined(PJ_WIN32_WINPHONE8) && PJ_WIN32_WINPHONE8!=0) # define PJMEDIA_AUDIO_DEV_HAS_WASAPI 1 # else # define PJMEDIA_AUDIO_DEV_HAS_WASAPI 0 # endif #endif /** * This setting controls whether BDIMAD support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_BDIMAD # define PJMEDIA_AUDIO_DEV_HAS_BDIMAD 0 #endif /** * This setting controls whether Symbian APS support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_APS # define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS 0 #endif /** * This setting controls whether Symbian APS should perform codec * detection in its factory initalization. Note that codec detection * may take few seconds and detecting more codecs will take more time. * Possible values are: * - 0: no codec detection, all APS codec (AMR-NB, G.711, G.729, and * iLBC) will be assumed as supported. * - 1: minimal codec detection, i.e: only detect for AMR-NB and G.711, * (G.729 and iLBC are considered to be supported/unsupported when * G.711 is supported/unsupported). * - 2: full codec detection, i.e: detect AMR-NB, G.711, G.729, and iLBC. * * Default: 1 (minimal codec detection) */ #ifndef PJMEDIA_AUDIO_DEV_SYMB_APS_DETECTS_CODEC # define PJMEDIA_AUDIO_DEV_SYMB_APS_DETECTS_CODEC 1 #endif /** * This setting controls whether Symbian VAS support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS # define PJMEDIA_AUDIO_DEV_HAS_SYMB_VAS 0 #endif /** * This setting controls Symbian VAS version to be used. Currently, valid * values are only 1 (for VAS 1.0) and 2 (for VAS 2.0). * * Default: 1 (VAS version 1.0) */ #ifndef PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION # define PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION 1 #endif /** * This setting controls whether Symbian audio (using built-in multimedia * framework) support should be included. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA # define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA PJ_SYMBIAN #endif /** * This setting controls whether the Symbian audio with built-in multimedia * framework backend should be started synchronously. Note that synchronous * start will block the application/UI, e.g: about 40ms for each direction * on N95. While asynchronous start may cause invalid value (always zero) * returned in input/output volume query, if the query is performed when * the internal start procedure is not completely finished. * * Default: 1 (yes) */ #ifndef PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START # define PJMEDIA_AUDIO_DEV_MDA_USE_SYNC_START 1 #endif /** * This setting controls whether the Audio Device API should support * device implementation that is based on the old sound device API * (sound.h). * * Enable this API if: * - you have implemented your own sound device using the old sound * device API (sound.h), and * - you wish to be able to use your sound device implementation * using the new Audio Device API. * * Please see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more * info. */ #ifndef PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE # define PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE 0 #endif /** * @} */ PJ_END_DECL #endif /* __PJMEDIA_AUDIODEV_CONFIG_H__ */ /* --------------------- DOCUMENTATION FOLLOWS --------------------------- */ /** * @addtogroup audio_device_api Audio Device API * @{ PJMEDIA Audio Device API is a cross-platform audio API appropriate for use with VoIP applications and many other types of audio streaming applications. The API abstracts many different audio API's on various platforms, such as: - PortAudio back-end for Win32, Windows Mobile, Linux, Unix, dan MacOS X. - native WMME audio for Win32 and Windows Mobile devices - native Symbian audio streaming/multimedia framework (MMF) implementation - native Nokia Audio Proxy Server (APS) implementation - null-audio implementation - and more to be implemented in the future The Audio Device API/library is an evolution from PJMEDIA @ref PJMED_SND and contains many enhancements: - Forward compatibility: \n The new API has been designed to be extensible, it will support new API's as well as new features that may be introduced in the future without breaking compatibility with applications that use this API as well as compatibility with existing device implementations. - Device capabilities: \n At the heart of the API is device capabilities management, where all possible audio capabilities of audio devices should be able to be handled in a generic manner. With this framework, new capabilities that may be discovered in the future can be handled in manner without breaking existing applications. - Built-in features: \n The device capabilities framework enables applications to use and control audio features built-in in the device, such as: - echo cancellation, - built-in codecs, - audio routing (e.g. to earpiece or loudspeaker), - volume control, - etc. - Codec support: \n Some audio devices such as Nokia/Symbian Audio Proxy Server (APS) and Nokia VoIP Audio Services (VAS) support built-in hardware audio codecs (e.g. G.729, iLBC, and AMR), and application can use the sound device in encoded mode to make use of these hardware codecs. - Multiple backends: \n The new API supports multiple audio backends (called factories or drivers in the code) to be active simultaneously, and audio backends may be added or removed during run-time. @section using Overview on using the API @subsection getting_started Getting started -# Configure the application's project settings.\n Add the following include: \code #include \endcode\n And add pjmedia-audiodev library to your application link specifications.\n -# Compile time settings.\n Use the compile time settings to enable or disable specific audio drivers. For more information, please see \ref s1_audio_device_config. -# API initialization and cleaning up.\n Before anything else, application must initialize the API by calling: \code pjmedia_aud_subsys_init(pf);\endcode\n And add this in the application cleanup sequence \code pjmedia_aud_subsys_shutdown();\endcode @subsection devices Working with devices -# The following code prints the list of audio devices detected in the system. \code int dev_count; pjmedia_aud_dev_index dev_idx; pj_status_t status; dev_count = pjmedia_aud_dev_count(); printf("Got %d audio devices\n", dev_count); for (dev_idx=0; dev_idx