- Timestamp:
- Mar 5, 2009 6:02:28 PM (16 years ago)
- Location:
- pjproject/branches/projects/aps-direct
- Files:
-
- 2 added
- 6 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/aps-direct/pjlib/include/pj/config_site_sample.h
r2381 r2489 1 2 3 //#define PJ_CONFIG_MINIMAL_SIZE 4 //#define PJ_CONFIG_MAXIMUM_SPEED 5 6 7 /* 8 * This file (config_site_sample.h) contains various configuration 9 * settings that I use for certain settings. 1 /* 2 * This file contains several sample settings especially for Windows 3 * Mobile and Symbian targets. You can include this file in your 4 * <pj/config_site.h> file. 5 * 6 * The Windows Mobile and Symbian settings will be activated 7 * automatically if you include this file. 8 * 9 * In addition, you may specify one of these macros (before including 10 * this file) to activate additional settings: 11 * 12 * #define PJ_CONFIG_NOKIA_APS_DIRECT 13 * Use this macro to activate the APS-Direct feature. Please see 14 * http://trac.pjsip.org/repos/wiki/Nokia_APS_VAS_Direct for more 15 * info. 16 * 17 * #define PJ_CONFIG_WIN32_WMME_DIRECT 18 * Configuration to activate "APS-Direct" media mode on Windows or 19 * Windows Mobile, useful for testing purposes only. 10 20 */ 11 21 … … 15 25 */ 16 26 #if defined(PJ_WIN32_WINCE) && PJ_WIN32_WINCE!=0 17 # define PJ_HAS_FLOATING_POINT 0 18 19 # define PJMEDIA_HAS_G711_PLC 0 20 //# define PJMEDIA_HAS_SMALL_FILTER 1 21 //# define PJMEDIA_HAS_LARGE_FILTER 0 22 # define PJMEDIA_HAS_L16_CODEC 0 23 /*# define PJMEDIA_HAS_GSM_CODEC 0*/ 24 /*# define PJMEDIA_HAS_ILBC_CODEC 0*/ 25 /*# define PJMEDIA_HAS_SPEEX_CODEC 0*/ 26 # define PJMEDIA_HAS_SPEEX_AEC 0 27 # undef PJMEDIA_RESAMPLE_IMP 28 # define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_LIBRESAMPLE 29 # define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE 30 31 /* Speex default quality settings */ 32 # define PJSUA_DEFAULT_CODEC_QUALITY 5 33 # define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 34 35 # define PJMEDIA_SDP_NEG_PREFER_REMOTE_CODEC_ORDER 0 36 #endif 27 28 /* 29 * PJLIB settings. 30 */ 31 32 /* Disable floating point support */ 33 #define PJ_HAS_FLOATING_POINT 0 34 35 /* 36 * PJMEDIA settings 37 */ 38 39 /* Select codecs to disable */ 40 #define PJMEDIA_HAS_L16_CODEC 0 41 #define PJMEDIA_HAS_ILBC_CODEC 0 42 43 /* We probably need more buffers on WM, so increase the limit */ 44 #define PJMEDIA_SOUND_BUFFER_COUNT 32 45 46 /* Fine tune Speex's default settings for best performance/quality */ 47 #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 48 49 /* For CPU reason, disable speex AEC and use the echo suppressor. */ 50 #define PJMEDIA_HAS_SPEEX_AEC 0 51 52 /* Shouldn't use resampling for performance reason too. */ 53 #define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE 54 55 /* Use the lighter WSOLA implementation */ 56 #define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE 57 58 /* 59 * PJSIP settings. 60 */ 61 62 /* Set maximum number of dialog/transaction/calls to minimum to reduce 63 * memory usage 64 */ 65 #define PJSIP_MAX_TSX_COUNT 31 66 #define PJSIP_MAX_DIALOG_COUNT 31 67 #define PJSUA_MAX_CALLS 4 68 69 /* 70 * PJSUA settings 71 */ 72 73 /* Default codec (Speex) quality */ 74 #define PJSUA_DEFAULT_CODEC_QUALITY 5 75 76 /* Set maximum number of objects to minimum to reduce memory usage */ 77 #define PJSUA_MAX_ACC 4 78 #define PJSUA_MAX_PLAYERS 4 79 #define PJSUA_MAX_RECORDERS 4 80 #define PJSUA_MAX_CONF_PORTS (PJSUA_MAX_CALLS+2*PJSUA_MAX_PLAYERS) 81 #define PJSUA_MAX_BUDDIES 32 82 83 #endif /* PJ_WIN32_WINCE */ 37 84 38 85 … … 42 89 #if defined(PJ_SYMBIAN) && PJ_SYMBIAN!=0 43 90 44 /* We don't want to use float, for now */ 45 # undef PJ_HAS_FLOATING_POINT 46 # define PJ_HAS_FLOATING_POINT 0 47 48 # define PJMEDIA_SOUND_IMPLEMENTATION PJMEDIA_SOUND_NULL_SOUND 91 /* 92 * PJLIB settings. 93 */ 94 95 /* Disable floating point support */ 96 #define PJ_HAS_FLOATING_POINT 0 49 97 50 98 /* Misc PJLIB setting */ 51 # define PJ_MAXPATH 80 52 53 /* SRTP has not been ported to Symbian yet */ 54 # define PJMEDIA_HAS_SRTP 1 55 56 /* Disable these */ 57 # define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE 58 # define PJMEDIA_HAS_SPEEX_AEC 0 59 # define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE 60 61 /* Disable all codecs but G.711 and GSM, for now */ 62 # define PJMEDIA_HAS_GSM_CODEC 1 63 # define PJMEDIA_HAS_L16_CODEC 0 64 # define PJMEDIA_HAS_ILBC_CODEC 0 65 # define PJMEDIA_HAS_SPEEX_CODEC 1 66 # define PJMEDIA_HAS_G722_CODEC 0 67 68 /* Need larger sound buffers */ 69 # define PJMEDIA_SOUND_BUFFER_COUNT 16 70 71 /* Disable safe module access */ 72 # define PJSIP_SAFE_MODULE 0 73 74 # define PJSIP_MAX_PKT_LEN 2000 99 #define PJ_MAXPATH 80 75 100 76 101 /* This is important for Symbian. Symbian lacks vsnprintf(), so … … 79 104 * to log the packet. 80 105 */ 81 # define PJ_LOG_MAX_SIZE (PJSIP_MAX_PKT_LEN+500) 82 83 /* Since we don't have threads, log buffer can use static buffer */ 84 # define PJ_LOG_USE_STACK_BUFFER 0 85 86 /* Disable check stack since it increases footprint */ 87 # undef PJ_OS_HAS_CHECK_STACK 88 # define PJ_OS_HAS_CHECK_STACK 0 106 #define PJ_LOG_MAX_SIZE (PJSIP_MAX_PKT_LEN+500) 107 108 /* Since we don't have threads, log buffer can use static buffer 109 * rather than stack 110 */ 111 #define PJ_LOG_USE_STACK_BUFFER 0 112 113 /* Disable check stack since it increases footprint */ 114 #define PJ_OS_HAS_CHECK_STACK 0 115 116 117 /* 118 * PJMEDIA settings 119 */ 120 121 /* Select codecs to disable */ 122 #define PJMEDIA_HAS_L16_CODEC 0 123 #define PJMEDIA_HAS_ILBC_CODEC 0 124 125 /* Fine tune Speex's default settings for best performance/quality */ 126 #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 127 128 /* For CPU reason, disable speex AEC and use the echo suppressor. */ 129 #define PJMEDIA_HAS_SPEEX_AEC 0 130 131 /* Shouldn't use resampling for performance reason too. */ 132 #define PJMEDIA_RESAMPLE_IMP PJMEDIA_RESAMPLE_NONE 133 134 /* Use the lighter WSOLA implementation */ 135 #define PJMEDIA_WSOLA_IMP PJMEDIA_WSOLA_IMP_WSOLA_LITE 136 137 /* We probably need more buffers especially if MDA audio backend 138 * is used, so increase the limit 139 */ 140 #define PJMEDIA_SOUND_BUFFER_COUNT 32 141 142 /* 143 * PJSIP settings. 144 */ 145 146 /* Disable safe module access, since we don't use multithreading */ 147 #define PJSIP_SAFE_MODULE 0 148 149 /* Increase allowable packet size, just in case */ 150 #define PJSIP_MAX_PKT_LEN 2000 89 151 90 152 /* Symbian has problem with too many large blocks */ 91 # define PJSIP_POOL_LEN_ENDPT 1000 92 # define PJSIP_POOL_INC_ENDPT 1000 93 # define PJSIP_POOL_RDATA_LEN 2000 94 # define PJSIP_POOL_RDATA_INC 2000 95 # define PJSIP_POOL_LEN_TDATA 2000 96 # define PJSIP_POOL_INC_TDATA 512 97 # define PJSIP_POOL_LEN_UA 2000 98 # define PJSIP_POOL_INC_UA 1000 99 # define PJSIP_POOL_TSX_LAYER_LEN 256 100 # define PJSIP_POOL_TSX_LAYER_INC 256 101 # define PJSIP_POOL_TSX_LEN 512 102 # define PJSIP_POOL_TSX_INC 128 153 #define PJSIP_POOL_LEN_ENDPT 1000 154 #define PJSIP_POOL_INC_ENDPT 1000 155 #define PJSIP_POOL_RDATA_LEN 2000 156 #define PJSIP_POOL_RDATA_INC 2000 157 #define PJSIP_POOL_LEN_TDATA 2000 158 #define PJSIP_POOL_INC_TDATA 512 159 #define PJSIP_POOL_LEN_UA 2000 160 #define PJSIP_POOL_INC_UA 1000 161 #define PJSIP_POOL_TSX_LAYER_LEN 256 162 #define PJSIP_POOL_TSX_LAYER_INC 256 163 #define PJSIP_POOL_TSX_LEN 512 164 #define PJSIP_POOL_TSX_INC 128 165 166 /* 167 * PJSUA settings. 168 */ 169 170 /* Default codec quality */ 171 #define PJSUA_DEFAULT_CODEC_QUALITY 5 103 172 104 173 /* Set maximum number of dialog/transaction/calls to minimum */ 105 #define PJSIP_MAX_TSX_COUNT 31106 # define PJSIP_MAX_DIALOG_COUNT31107 # define PJSUA_MAX_CALLS4174 #define PJSIP_MAX_TSX_COUNT 31 175 #define PJSIP_MAX_DIALOG_COUNT 31 176 #define PJSUA_MAX_CALLS 4 108 177 109 178 /* Other pjsua settings */ 110 # define PJSUA_MAX_ACC 4 111 # define PJSUA_MAX_PLAYERS 4 112 # define PJSUA_MAX_RECORDERS 4 113 # define PJSUA_MAX_CONF_PORTS (PJSUA_MAX_CALLS+2*PJSUA_MAX_PLAYERS) 114 # define PJSUA_MAX_BUDDIES 32 115 116 /* Speex default quality settings */ 117 # define PJSUA_DEFAULT_CODEC_QUALITY 5 118 # define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 179 #define PJSUA_MAX_ACC 4 180 #define PJSUA_MAX_PLAYERS 4 181 #define PJSUA_MAX_RECORDERS 4 182 #define PJSUA_MAX_CONF_PORTS (PJSUA_MAX_CALLS+2*PJSUA_MAX_PLAYERS) 183 #define PJSUA_MAX_BUDDIES 32 184 #endif 185 186 187 /* 188 * Additional configuration to activate APS-Direct feature for 189 * Nokia S60 target 190 * 191 * Please see http://trac.pjsip.org/repos/wiki/Nokia_APS_VAS_Direct 192 */ 193 #ifdef PJ_CONFIG_NOKIA_APS_DIRECT 194 195 /* MUST use switchboard rather than the conference bridge */ 196 #define PJMEDIA_CONF_USE_SWITCH_BOARD 1 197 198 /* Enable APS sound device backend and disable MDA */ 199 #define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA 0 200 #define PJMEDIA_AUDIO_DEV_HAS_SYMB_APS 1 201 202 /* Enable passthrough codec framework */ 203 #define PJMEDIA_HAS_PASSTHROUGH_CODECS 1 204 205 /* And selectively enable which codecs are supported by the handset */ 206 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1 207 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1 208 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 1 209 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 1 210 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 1 211 212 #endif 213 214 215 /* 216 * Configuration to activate "APS-Direct" media mode on Windows, 217 * useful for testing purposes only. 218 */ 219 #ifdef PJ_CONFIG_WIN32_WMME_DIRECT 220 221 /* MUST use switchboard rather than the conference bridge */ 222 #define PJMEDIA_CONF_USE_SWITCH_BOARD 1 223 224 /* Only WMME supports the "direct" feature */ 225 #define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 0 226 #define PJMEDIA_AUDIO_DEV_HAS_WMME 1 227 228 /* Enable passthrough codec framework */ 229 #define PJMEDIA_HAS_PASSTHROUGH_CODECS 1 230 231 /* Only PCMA and PCMU are supported by WMME-direct */ 232 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 1 233 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 1 234 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 0 235 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 0 236 #define PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 0 237 119 238 #endif 120 239 -
pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia.dsp
r2468 r2489 230 230 # Begin Source File 231 231 232 SOURCE=..\src\pjmedia\sound_legacy.c 233 # End Source File 234 # Begin Source File 235 232 236 SOURCE=..\src\pjmedia\sound_port.c 233 237 # End Source File -
pjproject/branches/projects/aps-direct/pjmedia/build/pjmedia_audiodev.dsp
r2488 r2489 102 102 # Begin Source File 103 103 104 SOURCE="..\src\pjmedia-audiodev\legacy_dev.c" 105 # End Source File 106 # Begin Source File 107 104 108 SOURCE="..\src\pjmedia-audiodev\pa_dev.c" 105 109 # End Source File -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/audiodev.h
r2488 r2489 27 27 #include <pjmedia-audiodev/config.h> 28 28 #include <pjmedia-audiodev/errno.h> 29 #include <pjmedia/ port.h>29 #include <pjmedia/types.h> 30 30 #include <pj/pool.h> 31 31 -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/config.h
r2475 r2489 25 25 * @brief Audio device API. 26 26 */ 27 #include <pjmedia/ port.h>27 #include <pjmedia/types.h> 28 28 #include <pj/pool.h> 29 29 … … 47 47 */ 48 48 #ifndef PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 49 # define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 049 # define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 1 50 50 #endif 51 51 … … 72 72 */ 73 73 #ifndef PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA 74 # define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA 0 75 #endif 74 # define PJMEDIA_AUDIO_DEV_HAS_SYMB_MDA PJ_SYMBIAN 75 #endif 76 77 78 /** 79 * This setting controls whether the Audio Device API should support 80 * device implementation that is based on the old sound device API 81 * (sound.h). 82 * 83 * Enable this API if: 84 * - you have implemented your own sound device using the old sound 85 * device API (sound.h), and 86 * - you wish to be able to use your sound device implementation 87 * using the new Audio Device API. 88 * 89 * Please see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more 90 * info. 91 */ 92 #ifndef PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE 93 # define PJMEDIA_AUDIO_DEV_HAS_LEGACY_DEVICE 0 94 #endif 95 76 96 77 97 /** -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia-audiodev/errno.h
r2488 r2489 98 98 * General/unknown error. 99 99 */ 100 #define PJMEDIA_ AUDIODEV_ERROR (PJMEDIA_AUDIODEV_ERRNO_START+1) /* 420001 */100 #define PJMEDIA_EAUD_ERR (PJMEDIA_AUDIODEV_ERRNO_START+1) /* 420001 */ 101 101 102 102 /** … … 161 161 162 162 /** 163 * @hideinitializer 164 * Bad latency setting 165 */ 166 #define PJMEDIA_EAUD_BADLATENCY (PJMEDIA_AUDIODEV_ERRNO_START+12) /* 4200012 */ 167 168 169 170 171 172 /** 163 173 * Get error message for the specified error code. Note that this 164 174 * function is only able to decode PJMEDIA Audiodev specific error code. -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/config.h
r2471 r2489 82 82 83 83 /** 84 * Setting PJMEDIA_AUDIO_API to this value will completely deprecate the use 85 * of old API, and inclusion of <pjmedia/sound.h> in the code will raise 86 * compilation error. 87 */ 88 #define PJMEDIA_AUDIO_API_NEW_ONLY 1 89 90 /** 91 * Setting PJMEDIA_AUDIO_API to this value enables application to use the old 92 * sound device API to access audio devices provided by the new audio device 93 * API. 94 */ 95 #define PJMEDIA_AUDIO_API_HAS_OLD_API 2 96 97 /** 98 * Setting PJMEDIA_AUDIO_API to this value enables old sound device 99 * implementation to be accessed via both old and new API's. 100 */ 101 #define PJMEDIA_AUDIO_API_HAS_OLD_DEVICE 3 102 103 /** 104 * Specify how the audio API should handle compatibility with old sound API. 105 * Valid values are: PJMEDIA_AUDIO_API_HAS_OLD_API (default, 106 * PJMEDIA_AUDIO_API_NEW_ONLY, or PJMEDIA_AUDIO_API_HAS_OLD_DEVICE. Please 107 * see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more info. 108 */ 109 #ifndef PJMEDIA_AUDIO_API 110 # define PJMEDIA_AUDIO_API PJMEDIA_AUDIO_API_NEW_ONLY 111 #endif 112 84 * This macro controls whether the legacy sound device API is to be 85 * implemented, for applications that still use the old sound device 86 * API (sound.h). If this macro is set to non-zero, the sound_legacy.c 87 * will be included in the compilation. The sound_legacy.c is an 88 * implementation of old sound device (sound.h) using the new Audio 89 * Device API. 90 * 91 * Please see http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more 92 * info. 93 */ 94 #ifndef PJMEDIA_HAS_LEGACY_SOUND_API 95 # define PJMEDIA_HAS_LEGACY_SOUND_API 1 96 #endif 113 97 114 98 /** -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/port.h
r2470 r2489 223 223 224 224 225 /**226 * Types of media frame.227 */228 typedef enum pjmedia_frame_type229 {230 PJMEDIA_FRAME_TYPE_NONE, /**< No frame. */231 PJMEDIA_FRAME_TYPE_AUDIO, /**< Normal audio frame. */232 PJMEDIA_FRAME_TYPE_EXTENDED /**< Extended audio frame. */233 234 } pjmedia_frame_type;235 236 237 /**238 * This structure describes a media frame.239 */240 typedef struct pjmedia_frame241 {242 pjmedia_frame_type type; /**< Frame type. */243 void *buf; /**< Pointer to buffer. */244 pj_size_t size; /**< Frame size in bytes. */245 pj_timestamp timestamp; /**< Frame timestamp. */246 pj_uint32_t bit_info; /**< Bit info of the frame, sample case:247 a frame may not exactly start and end248 at the octet boundary, so this field249 may be used for specifying start &250 end bit offset. */251 } pjmedia_frame;252 253 254 /**255 * The pjmedia_frame_ext is used to carry a more complex audio frames than256 * the typical PCM audio frames, and it is signaled by setting the "type"257 * field of a pjmedia_frame to PJMEDIA_FRAME_TYPE_EXTENDED. With this set,258 * application may typecast pjmedia_frame to pjmedia_frame_ext.259 *260 * This structure may contain more than one audio frames, which subsequently261 * will be called subframes in this structure. The subframes section262 * immediately follows the end of this structure, and each subframe is263 * represented by pjmedia_frame_ext_subframe structure. Every next264 * subframe immediately follows the previous subframe, and all subframes265 * are byte-aligned although its payload may not be byte-aligned.266 */267 268 #pragma pack(1)269 typedef struct pjmedia_frame_ext {270 pjmedia_frame base; /**< Base frame info */271 pj_uint16_t samples_cnt; /**< Number of samples in this frame */272 pj_uint16_t subframe_cnt; /**< Number of (sub)frames in this frame */273 274 /* Zero or more (sub)frames follows immediately after this,275 * each will be represented by pjmedia_frame_ext_subframe276 */277 } pjmedia_frame_ext;278 #pragma pack()279 280 /**281 * This structure represents the individual subframes in the282 * pjmedia_frame_ext structure.283 */284 #pragma pack(1)285 typedef struct pjmedia_frame_ext_subframe {286 pj_uint16_t bitlen; /**< Number of bits in the data */287 pj_uint8_t data[1]; /**< Start of encoded data */288 } pjmedia_frame_ext_subframe;289 290 #pragma pack()291 292 293 /**294 * Append one subframe to #pjmedia_frame_ext.295 *296 * @param frm The #pjmedia_frame_ext.297 * @param src Subframe data.298 * @param bitlen Lenght of subframe, in bits.299 * @param samples_cnt Number of audio samples in subframe.300 */301 PJ_INLINE(void) pjmedia_frame_ext_append_subframe(pjmedia_frame_ext *frm,302 const void *src,303 unsigned bitlen,304 unsigned samples_cnt)305 {306 pjmedia_frame_ext_subframe *fsub;307 pj_uint8_t *p;308 unsigned i;309 310 p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext);311 for (i = 0; i < frm->subframe_cnt; ++i) {312 fsub = (pjmedia_frame_ext_subframe*) p;313 p += sizeof(fsub->bitlen) + ((fsub->bitlen+7) >> 3);314 }315 316 fsub = (pjmedia_frame_ext_subframe*) p;317 fsub->bitlen = (pj_uint16_t)bitlen;318 if (bitlen)319 pj_memcpy(fsub->data, src, (bitlen+7) >> 3);320 321 frm->subframe_cnt++;322 frm->samples_cnt = (pj_uint16_t)(frm->samples_cnt + samples_cnt);323 }324 325 /**326 * Get a subframe from #pjmedia_frame_ext.327 *328 * @param frm The #pjmedia_frame_ext.329 * @param n Subframe index, zero based.330 *331 * @return The n-th subframe, or NULL if n is out-of-range.332 */333 PJ_INLINE(pjmedia_frame_ext_subframe*)334 pjmedia_frame_ext_get_subframe(const pjmedia_frame_ext *frm, unsigned n)335 {336 pjmedia_frame_ext_subframe *sf = NULL;337 338 if (n < frm->subframe_cnt) {339 pj_uint8_t *p;340 unsigned i;341 342 p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext);343 for (i = 0; i < n; ++i) {344 sf = (pjmedia_frame_ext_subframe*) p;345 p += sizeof(sf->bitlen) + ((sf->bitlen+7) >> 3);346 }347 348 sf = (pjmedia_frame_ext_subframe*) p;349 }350 351 return sf;352 }353 354 /**355 * Extract all frame payload to the specified buffer.356 *357 * @param frm The frame.358 * @param dst Destination buffer.359 * @param maxsize Maximum size to copy (i.e. the size of the360 * destination buffer).361 *362 * @return Total size of payload copied.363 */364 PJ_INLINE(unsigned)365 pjmedia_frame_ext_copy_payload(const pjmedia_frame_ext *frm,366 void *dst,367 unsigned maxlen)368 {369 unsigned i, copied=0;370 for (i=0; i<frm->subframe_cnt; ++i) {371 pjmedia_frame_ext_subframe *sf;372 unsigned sz;373 374 sf = pjmedia_frame_ext_get_subframe(frm, i);375 if (!sf)376 continue;377 378 sz = ((sf->bitlen + 7) >> 3);379 if (sz + copied > maxlen)380 break;381 382 pj_memcpy(((pj_uint8_t*)dst) + copied, sf->data, sz);383 copied += sz;384 }385 return copied;386 }387 388 389 /**390 * Pop out first n subframes from #pjmedia_frame_ext.391 *392 * @param frm The #pjmedia_frame_ext.393 * @param n Number of first subframes to be popped out.394 *395 * @return PJ_SUCCESS when successful.396 */397 PJ_INLINE(pj_status_t)398 pjmedia_frame_ext_pop_subframes(pjmedia_frame_ext *frm, unsigned n)399 {400 pjmedia_frame_ext_subframe *sf;401 pj_uint8_t *move_src;402 unsigned move_len;403 404 if (frm->subframe_cnt <= n) {405 frm->subframe_cnt = 0;406 frm->samples_cnt = 0;407 return PJ_SUCCESS;408 }409 410 move_src = (pj_uint8_t*)pjmedia_frame_ext_get_subframe(frm, n);411 sf = pjmedia_frame_ext_get_subframe(frm, frm->subframe_cnt-1);412 move_len = (pj_uint8_t*)sf - move_src + sizeof(sf->bitlen) +413 ((sf->bitlen+7) >> 3);414 pj_memmove((pj_uint8_t*)frm+sizeof(pjmedia_frame_ext),415 move_src, move_len);416 417 frm->samples_cnt = (pj_uint16_t)418 (frm->samples_cnt - n*frm->samples_cnt/frm->subframe_cnt);419 frm->subframe_cnt = (pj_uint16_t) (frm->subframe_cnt - n);420 421 return PJ_SUCCESS;422 }423 424 225 /** 425 226 * Port interface. -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/sound.h
r2468 r2489 22 22 23 23 24 /* This is legacy sound device code, which has been superseded by the25 * new pjmedia-audiodev framework. Please see the documentation on how26 * to use this legacy API.27 */28 #if PJMEDIA_AUDIO_API==PJMEDIA_AUDIO_API_NEW_ONLY29 # error "The sound device API is deprecated. Please see doc for details."30 #endif31 32 33 24 /** 34 25 * @file sound.h 35 * @brief Sound player and recorder device framework. 36 */ 26 * @brief Legacy sound device API 27 */ 28 #include <pjmedia-audiodev/audiodev.h> 37 29 #include <pjmedia/types.h> 38 #include <pj/pool.h> 30 39 31 40 32 PJ_BEGIN_DECL … … 45 37 * @brief PJMEDIA abstraction for sound device hardware 46 38 * @{ 39 * 40 * <strong>Warning: this sound device API has been deprecated 41 * and replaced by PJMEDIA Audio Device API. Please see 42 * http://trac.pjsip.org/repos/wiki/Audio_Dev_API for more 43 * information.</strong> 47 44 * 48 45 * This section describes lower level abstraction for sound device … … 71 68 */ 72 69 73 /** Opaque d ata type for audiostream. */70 /** Opaque declaration for pjmedia_snd_stream. */ 74 71 typedef struct pjmedia_snd_stream pjmedia_snd_stream; 75 72 … … 101 98 unsigned play_latency; /**< Playback latency, in samples. */ 102 99 } pjmedia_snd_stream_info; 103 104 /**105 * Audio routing destination.106 */107 typedef enum pjmedia_snd_route108 {109 /** Route to default destination */110 PJMEDIA_SND_ROUTE_DEFAULT,111 112 /** Route to loudspeaker */113 PJMEDIA_SND_ROUTE_LOUDSPEAKER,114 115 /** Route to earpiece */116 PJMEDIA_SND_ROUTE_EARPIECE,117 118 } pjmedia_snd_route;119 120 121 /**122 * Stream setting for opening sound device with non-PCM data.123 */124 typedef struct pjmedia_snd_setting125 {126 pjmedia_format format; /**< Format. */127 pj_bool_t plc; /**< PLC enabled/disabled. */128 pjmedia_snd_route route; /**< Audio routing. */129 } pjmedia_snd_setting;130 131 100 132 101 /** … … 310 279 311 280 /** 312 * Create sound stream for capturing audio and/or audio playback, from the313 * same device. This also allows opening sound stream with extended settings,314 * e.g: stream format, see #pjmedia_snd_setting.315 *316 * @param dir Sound stream direction.317 * @param rec_id Device index for recorder/capture stream, or318 * -1 to use the first capable device.319 * @param play_id Device index for playback stream, or -1 to use320 * the first capable device.321 * @param clock_rate Sound device's clock rate to set.322 * @param channel_count Set number of channels, 1 for mono, or 2 for323 * stereo. The channel count determines the format324 * of the frame.325 * @param samples_per_frame Number of samples per frame.326 * @param bits_per_sample Set the number of bits per sample. The normal327 * value for this parameter is 16 bits per sample.328 * @param rec_cb Callback to handle captured audio samples.329 * @param play_cb Callback to be called when the sound player needs330 * more audio samples to play.331 * @param user_data User data to be associated with the stream.332 * @param setting Sound device extended setting.333 * @param p_snd_strm Pointer to receive the stream instance.334 *335 * @return PJ_SUCCESS on success.336 */337 PJ_DECL(pj_status_t) pjmedia_snd_open2( pjmedia_dir dir,338 int rec_id,339 int play_id,340 unsigned clock_rate,341 unsigned channel_count,342 unsigned samples_per_frame,343 unsigned bits_per_sample,344 pjmedia_snd_rec_cb rec_cb,345 pjmedia_snd_play_cb play_cb,346 void *user_data,347 const pjmedia_snd_setting *setting,348 pjmedia_snd_stream **p_snd_strm);349 350 351 /**352 281 * Get information about live stream. 353 282 * -
pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/types.h
r2471 r2489 325 325 } 326 326 327 /** 328 * Types of media frame. 329 */ 330 typedef enum pjmedia_frame_type 331 { 332 PJMEDIA_FRAME_TYPE_NONE, /**< No frame. */ 333 PJMEDIA_FRAME_TYPE_AUDIO, /**< Normal audio frame. */ 334 PJMEDIA_FRAME_TYPE_EXTENDED /**< Extended audio frame. */ 335 336 } pjmedia_frame_type; 337 338 339 /** 340 * This structure describes a media frame. 341 */ 342 typedef struct pjmedia_frame 343 { 344 pjmedia_frame_type type; /**< Frame type. */ 345 void *buf; /**< Pointer to buffer. */ 346 pj_size_t size; /**< Frame size in bytes. */ 347 pj_timestamp timestamp; /**< Frame timestamp. */ 348 pj_uint32_t bit_info; /**< Bit info of the frame, sample case: 349 a frame may not exactly start and end 350 at the octet boundary, so this field 351 may be used for specifying start & 352 end bit offset. */ 353 } pjmedia_frame; 354 355 356 /** 357 * The pjmedia_frame_ext is used to carry a more complex audio frames than 358 * the typical PCM audio frames, and it is signaled by setting the "type" 359 * field of a pjmedia_frame to PJMEDIA_FRAME_TYPE_EXTENDED. With this set, 360 * application may typecast pjmedia_frame to pjmedia_frame_ext. 361 * 362 * This structure may contain more than one audio frames, which subsequently 363 * will be called subframes in this structure. The subframes section 364 * immediately follows the end of this structure, and each subframe is 365 * represented by pjmedia_frame_ext_subframe structure. Every next 366 * subframe immediately follows the previous subframe, and all subframes 367 * are byte-aligned although its payload may not be byte-aligned. 368 */ 369 370 #pragma pack(1) 371 typedef struct pjmedia_frame_ext { 372 pjmedia_frame base; /**< Base frame info */ 373 pj_uint16_t samples_cnt; /**< Number of samples in this frame */ 374 pj_uint16_t subframe_cnt; /**< Number of (sub)frames in this frame */ 375 376 /* Zero or more (sub)frames follows immediately after this, 377 * each will be represented by pjmedia_frame_ext_subframe 378 */ 379 } pjmedia_frame_ext; 380 #pragma pack() 381 382 /** 383 * This structure represents the individual subframes in the 384 * pjmedia_frame_ext structure. 385 */ 386 #pragma pack(1) 387 typedef struct pjmedia_frame_ext_subframe { 388 pj_uint16_t bitlen; /**< Number of bits in the data */ 389 pj_uint8_t data[1]; /**< Start of encoded data */ 390 } pjmedia_frame_ext_subframe; 391 392 #pragma pack() 393 394 395 /** 396 * Append one subframe to #pjmedia_frame_ext. 397 * 398 * @param frm The #pjmedia_frame_ext. 399 * @param src Subframe data. 400 * @param bitlen Lenght of subframe, in bits. 401 * @param samples_cnt Number of audio samples in subframe. 402 */ 403 PJ_INLINE(void) pjmedia_frame_ext_append_subframe(pjmedia_frame_ext *frm, 404 const void *src, 405 unsigned bitlen, 406 unsigned samples_cnt) 407 { 408 pjmedia_frame_ext_subframe *fsub; 409 pj_uint8_t *p; 410 unsigned i; 411 412 p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext); 413 for (i = 0; i < frm->subframe_cnt; ++i) { 414 fsub = (pjmedia_frame_ext_subframe*) p; 415 p += sizeof(fsub->bitlen) + ((fsub->bitlen+7) >> 3); 416 } 417 418 fsub = (pjmedia_frame_ext_subframe*) p; 419 fsub->bitlen = (pj_uint16_t)bitlen; 420 if (bitlen) 421 pj_memcpy(fsub->data, src, (bitlen+7) >> 3); 422 423 frm->subframe_cnt++; 424 frm->samples_cnt = (pj_uint16_t)(frm->samples_cnt + samples_cnt); 425 } 426 427 /** 428 * Get a subframe from #pjmedia_frame_ext. 429 * 430 * @param frm The #pjmedia_frame_ext. 431 * @param n Subframe index, zero based. 432 * 433 * @return The n-th subframe, or NULL if n is out-of-range. 434 */ 435 PJ_INLINE(pjmedia_frame_ext_subframe*) 436 pjmedia_frame_ext_get_subframe(const pjmedia_frame_ext *frm, unsigned n) 437 { 438 pjmedia_frame_ext_subframe *sf = NULL; 439 440 if (n < frm->subframe_cnt) { 441 pj_uint8_t *p; 442 unsigned i; 443 444 p = (pj_uint8_t*)frm + sizeof(pjmedia_frame_ext); 445 for (i = 0; i < n; ++i) { 446 sf = (pjmedia_frame_ext_subframe*) p; 447 p += sizeof(sf->bitlen) + ((sf->bitlen+7) >> 3); 448 } 449 450 sf = (pjmedia_frame_ext_subframe*) p; 451 } 452 453 return sf; 454 } 455 456 /** 457 * Extract all frame payload to the specified buffer. 458 * 459 * @param frm The frame. 460 * @param dst Destination buffer. 461 * @param maxsize Maximum size to copy (i.e. the size of the 462 * destination buffer). 463 * 464 * @return Total size of payload copied. 465 */ 466 PJ_INLINE(unsigned) 467 pjmedia_frame_ext_copy_payload(const pjmedia_frame_ext *frm, 468 void *dst, 469 unsigned maxlen) 470 { 471 unsigned i, copied=0; 472 for (i=0; i<frm->subframe_cnt; ++i) { 473 pjmedia_frame_ext_subframe *sf; 474 unsigned sz; 475 476 sf = pjmedia_frame_ext_get_subframe(frm, i); 477 if (!sf) 478 continue; 479 480 sz = ((sf->bitlen + 7) >> 3); 481 if (sz + copied > maxlen) 482 break; 483 484 pj_memcpy(((pj_uint8_t*)dst) + copied, sf->data, sz); 485 copied += sz; 486 } 487 return copied; 488 } 489 490 491 /** 492 * Pop out first n subframes from #pjmedia_frame_ext. 493 * 494 * @param frm The #pjmedia_frame_ext. 495 * @param n Number of first subframes to be popped out. 496 * 497 * @return PJ_SUCCESS when successful. 498 */ 499 PJ_INLINE(pj_status_t) 500 pjmedia_frame_ext_pop_subframes(pjmedia_frame_ext *frm, unsigned n) 501 { 502 pjmedia_frame_ext_subframe *sf; 503 pj_uint8_t *move_src; 504 unsigned move_len; 505 506 if (frm->subframe_cnt <= n) { 507 frm->subframe_cnt = 0; 508 frm->samples_cnt = 0; 509 return PJ_SUCCESS; 510 } 511 512 move_src = (pj_uint8_t*)pjmedia_frame_ext_get_subframe(frm, n); 513 sf = pjmedia_frame_ext_get_subframe(frm, frm->subframe_cnt-1); 514 move_len = (pj_uint8_t*)sf - move_src + sizeof(sf->bitlen) + 515 ((sf->bitlen+7) >> 3); 516 pj_memmove((pj_uint8_t*)frm+sizeof(pjmedia_frame_ext), 517 move_src, move_len); 518 519 frm->samples_cnt = (pj_uint16_t) 520 (frm->samples_cnt - n*frm->samples_cnt/frm->subframe_cnt); 521 frm->subframe_cnt = (pj_uint16_t) (frm->subframe_cnt - n); 522 523 return PJ_SUCCESS; 524 } 525 526 327 527 /** 328 528 * @} -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/audiodev.c
r2488 r2489 19 19 */ 20 20 #include <pjmedia-audiodev/audiodev_imp.h> 21 #include <pj/assert.h> 21 22 #include <pj/errno.h> 22 23 #include <pj/log.h> -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/errno.c
r2488 r2489 47 47 } err_str[] = 48 48 { 49 PJ_BUILD_ERR( PJMEDIA_ AUDIODEV_ERROR,"Unspecified audio device error" ),49 PJ_BUILD_ERR( PJMEDIA_EAUD_ERR, "Unspecified audio device error" ), 50 50 PJ_BUILD_ERR( PJMEDIA_EAUD_SYSERR, "Unknown error from audio driver" ), 51 51 PJ_BUILD_ERR( PJMEDIA_EAUD_INIT, "Audio subsystem not initialized" ), … … 57 57 PJ_BUILD_ERR( PJMEDIA_EAUD_INVOP, "Invalid or unsupported audio device operation" ), 58 58 PJ_BUILD_ERR( PJMEDIA_EAUD_BADFORMAT, "Bad or invalid audio device format" ), 59 PJ_BUILD_ERR( PJMEDIA_EAUD_SAMPFORMAT, "Invalid audio device sample format") 59 PJ_BUILD_ERR( PJMEDIA_EAUD_SAMPFORMAT, "Invalid audio device sample format"), 60 PJ_BUILD_ERR( PJMEDIA_EAUD_BADLATENCY, "Bad audio latency setting") 60 61 61 62 }; -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/symb_mda_dev.cpp
r2479 r2489 20 20 #include <pjmedia-audiodev/audiodev_imp.h> 21 21 #include <pjmedia/alaw_ulaw.h> 22 #include <pjmedia/errno.h>23 22 #include <pj/assert.h> 24 23 #include <pj/log.h> -
pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-audiodev/wmme_dev.c
r2488 r2489 1150 1150 return PJ_SUCCESS; 1151 1151 } else { 1152 return PJ _ENOTSUP;1152 return PJMEDIA_EAUD_INVCAP; 1153 1153 } 1154 1154 } … … 1176 1176 return (mr==MMSYSERR_NOERROR)? PJ_SUCCESS : 1177 1177 PJMEDIA_AUDIODEV_ERRNO_FROM_WMME_OUT(mr); 1178 } else { 1179 return PJ_ENOTSUP; 1180 } 1181 1182 return PJ_ENOTSUP; 1178 } 1179 1180 return PJMEDIA_EAUD_INVCAP; 1183 1181 } 1184 1182
Note: See TracChangeset
for help on using the changeset viewer.