Changeset 3175


Ignore:
Timestamp:
May 17, 2010 1:07:39 PM (14 years ago)
Author:
ming
Message:

Merge #1050, #1052, #1053, #1054 into the main trunk.

Location:
pjproject/trunk
Files:
12 edited
37 copied

Legend:

Unmodified
Added
Removed
  • pjproject/trunk

  • pjproject/trunk/aconfigure

    r3158 r3175  
    22842284ac_config_headers="$ac_config_headers pjlib/include/pj/compat/os_auto.h pjlib/include/pj/compat/m_auto.h pjmedia/include/pjmedia/config_auto.h pjmedia/include/pjmedia-codec/config_auto.h pjsip/include/pjsip/sip_autoconf.h" 
    22852285 
    2286 ac_config_files="$ac_config_files build.mak build/os-auto.mak pjlib/build/os-auto.mak pjlib-util/build/os-auto.mak pjmedia/build/os-auto.mak pjsip/build/os-auto.mak third_party/build/os-auto.mak third_party/build/portaudio/os-auto.mak" 
     2286ac_config_files="$ac_config_files build.mak build/os-auto.mak build/cc-auto.mak pjlib/build/os-auto.mak pjlib-util/build/os-auto.mak pjmedia/build/os-auto.mak pjsip/build/os-auto.mak third_party/build/os-auto.mak third_party/build/portaudio/os-auto.mak" 
    22872287 
    22882288 
     
    33273327 
    33283328 
     3329if test "$AR" = ""; then AR="$(CROSS_COMPILE)ar rv"; fi 
     3330 
     3331if test "$LD" = ""; then LD="$CC"; fi 
     3332 
     3333if test "$LDOUT" = ""; then LDOUT="-o"; fi 
     3334 
     3335if test "$RANLIB" = ""; then RANLIB="$(CROSSCOMPILE)ranlib"; fi 
     3336 
     3337if test "$OBJEXT" = ""; then OBJEXT='o'; fi 
     3338 
     3339if test "$LIBEXT" = ""; then LIBEXT='a'; fi 
     3340 
     3341if test "$LIBEXT2" = ""; then LIBEXT2=""; fi 
     3342 
     3343if test "$CC_OUT" = ""; then CC_OUT="-o"; fi 
     3344 
     3345if test "$CC_INC" = ""; then CC_INC="-I"; fi 
     3346 
     3347if test "$CC_DEF" = ""; then CC_DEF="-D"; fi 
     3348 
     3349if test "$CC_OPTIMIZE" = ""; then CC_OPTIMIZE="-O2"; fi 
     3350 
     3351if test "$CC_CFLAGS" = ""; then CC_CFLAGS="-Wall"; fi 
     3352 
     3353 
     3354 
     3355 
    33293356 
    33303357 
     
    53855412else 
    53865413 case $target in 
     5414  arm-apple-darwin*) 
     5415        LIBS="$LIBS -framework CoreAudio -framework CoreFoundation -framework AudioToolbox" 
     5416        { echo "$as_me:$LINENO: result: Checking sound device backend... AudioUnit" >&5 
     5417echo "${ECHO_T}Checking sound device backend... AudioUnit" >&6; } 
     5418        ;; 
    53875419  *darwin*) 
    53885420        LIBS="$LIBS -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox" 
     
    68516883    "build.mak") CONFIG_FILES="$CONFIG_FILES build.mak" ;; 
    68526884    "build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES build/os-auto.mak" ;; 
     6885    "build/cc-auto.mak") CONFIG_FILES="$CONFIG_FILES build/cc-auto.mak" ;; 
    68536886    "pjlib/build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES pjlib/build/os-auto.mak" ;; 
    68546887    "pjlib-util/build/os-auto.mak") CONFIG_FILES="$CONFIG_FILES pjlib-util/build/os-auto.mak" ;; 
  • pjproject/trunk/aconfigure.ac

    r3158 r3175  
    1414AC_CONFIG_FILES([build.mak  
    1515                 build/os-auto.mak  
     16                 build/cc-auto.mak 
    1617                 pjlib/build/os-auto.mak  
    1718                 pjlib-util/build/os-auto.mak  
     
    3435CXXFLAGS="$CFLAGS $CXXFLAGS" 
    3536 
     37dnl # 
     38dnl # Configure tools 
     39dnl # 
    3640AC_PROG_CC 
    3741AC_PROG_CXX 
    3842AC_LANG_C 
     43 
     44if test "$AR" = ""; then AR="$(CROSS_COMPILE)ar rv"; fi 
     45AC_SUBST(AR) 
     46if test "$LD" = ""; then LD="$CC"; fi 
     47AC_SUBST(LD) 
     48if test "$LDOUT" = ""; then LDOUT="-o"; fi 
     49AC_SUBST(LDOUT) 
     50if test "$RANLIB" = ""; then RANLIB="$(CROSSCOMPILE)ranlib"; fi 
     51AC_SUBST(RANLIB) 
     52if test "$OBJEXT" = ""; then OBJEXT='o'; fi 
     53AC_SUBST(OBJEXT) 
     54if test "$LIBEXT" = ""; then LIBEXT='a'; fi 
     55AC_SUBST(LIBEXT) 
     56if test "$LIBEXT2" = ""; then LIBEXT2=""; fi 
     57AC_SUBST(LIBEXT2) 
     58if test "$CC_OUT" = ""; then CC_OUT="-o"; fi 
     59AC_SUBST(CC_OUT) 
     60if test "$CC_INC" = ""; then CC_INC="-I"; fi 
     61AC_SUBST(CC_INC) 
     62if test "$CC_DEF" = ""; then CC_DEF="-D"; fi 
     63AC_SUBST(CC_DEF) 
     64if test "$CC_OPTIMIZE" = ""; then CC_OPTIMIZE="-O2"; fi 
     65AC_SUBST(CC_OPTIMIZE) 
     66if test "$CC_CFLAGS" = ""; then CC_CFLAGS="-Wall"; fi 
     67AC_SUBST(CC_CFLAGS) 
     68 
     69 
    3970 
    4071AC_SUBST(ac_pjdir) 
     
    488519else 
    489520 case $target in 
     521  arm-apple-darwin*) 
     522        LIBS="$LIBS -framework CoreAudio -framework CoreFoundation -framework AudioToolbox" 
     523        AC_MSG_RESULT([Checking sound device backend... AudioUnit]) 
     524        ;; 
    490525  *darwin*) 
    491526        LIBS="$LIBS -framework CoreAudio -framework CoreServices -framework AudioUnit -framework AudioToolbox" 
  • pjproject/trunk/build

    • Property svn:ignore
      •  

        old new  
        22*.opt 
        33os-auto.mak 
         4cc-auto.mak 
  • pjproject/trunk/build.mak.in

    r3063 r3175  
    6161# CFLAGS, LDFLAGS, and LIBS to be used by applications 
    6262export PJDIR := @ac_pjdir@ 
    63 export APP_CC := $(CROSS_COMPILE)$(CC_NAME) 
     63export APP_CC := @CC@ 
     64export APP_CXX := @CXX@ 
    6465export APP_CFLAGS := -DPJ_AUTOCONF=1\ 
    6566        @CFLAGS@\ 
     
    106107export PJ_DIR := $(PJDIR) 
    107108export PJ_CC := $(APP_CC) 
     109export PJ_CXX := $(APP_CXX) 
    108110export PJ_CFLAGS := $(APP_CFLAGS) 
    109111export PJ_CXXFLAGS := $(APP_CXXFLAGS) 
  • pjproject/trunk/build/common.mak

    r1180 r3175  
    1616# 
    1717-include cc-$(CC_NAME).mak 
     18 
     19# 
     20# Include auto configured compiler specification. 
     21# This will override the compiler settings above. 
     22# Currently this is made OPTIONAL, to prevent people 
     23# from getting errors because they don't re-run ./configure 
     24# after downloading new PJSIP. 
     25# 
     26-include $(PJDIR)/build/cc-auto.mak 
    1827 
    1928# 
  • pjproject/trunk/build/rules.mak

    r2183 r3175  
    6666        @echo $(APP)_LDFLAGS=$($(APP)_LDFLAGS) 
    6767        @echo DEPFLAGS=$(DEPFLAGS) 
     68        @echo CC=$(CC) 
     69        @echo AR=$(AR) 
     70        @echo RANLIB=$(RANLIB) 
    6871 
    6972print_bin: print_common 
  • pjproject/trunk/configure-iphone

    r3168 r3175  
    11#!/bin/bash 
    22 
     3F="configure-iphone" 
     4 
    35if test "$*" = "--help" -o "$*" = "-h"; then 
    4   echo "configure-iphone [SDK=name_path] [OPTIONS]" 
     6  echo "$F [OPTIONS]" 
    57  echo "" 
    6   echo "SDK=name_path   Choose which SDK to use. Value can be SDK name (e.g." 
    7   echo "                iPhoneOS2.2.1.sdk) or the full path of the SDK" 
    8   echo "OPTIONS         Other options that will be passed directly to " 
    9   echo "                ./aconfigure script. Run ./aconfigure --help for" 
    10   echo "                more info." 
     8  echo "where:" 
     9  echo "  OPTIONS    Other options that will be passed directly to" 
     10  echo "             ./aconfigure script. Run ./aconfigure --help" 
     11  echo "             for more info." 
     12  echo "" 
     13  echo "Environment variables:" 
     14  echo "  IPHONESDK  Optionally specify which SDK to use. Value is the full " 
     15  echo "             path of the SDK. By default, the latest SDK installed" 
     16  echo "             will be used." 
     17  echo "  CC         Optionally specify the path of the ARM cross compiler" 
     18  echo "             to use. By default, the compiler is deduced from the" 
     19  echo "             SDK." 
    1120  echo "" 
    1221  exit 0 
    1322fi 
    1423 
    15 F="configure-iphone" 
    16  
    1724# Set the main iPhone developer directory, if not set 
    1825if test "x${DEVPATH}" = "x"; then 
    1926  DEVPATH=/Developer/Platforms/iPhoneOS.platform/Developer 
     27  echo "$F: DEVPATH is not specified, using ${DEVPATH}" 
    2028fi 
    2129 
     
    2735 
    2836# Choose SDK version to use 
    29 if test "x$SDK" = "x"; then 
    30   # If SDK is not set, use the latest one 
     37if test "$IPHONESDK" = ""; then 
     38  # If IPHONESDK is not set, use the latest one 
    3139  for f in `ls $DEVPATH/SDKs/`; do echo $f | sed 's/\(.sdk\)//'; done | sort | tail -1 > tmpsdkname 
    32   SDK=`cat tmpsdkname`.sdk 
     40  IPHONESDK=`cat tmpsdkname`.sdk 
    3341  rm -f tmpsdkname 
    34   echo "$F info: using ${SDK}" 
    35   SDKPATH=${DEVPATH}/SDKs/${SDK} 
    36 elif test -d ${SDK}; then 
    37   # .. else if SDK is set and it points to a valid path, just use it 
    38   SDKPATH=${SDK} 
     42  SDKPATH=${DEVPATH}/SDKs/${IPHONESDK} 
     43  echo "$F: IPHONESDK is not specified, choosing ${IPHONESDK}" 
     44elif test -d ${IPHONESDK}; then 
     45  # .. else if IPHONESDK is set and it points to a valid path, just use it 
     46  SDKPATH=${IPHONESDK} 
    3947else 
    4048  # .. else assume the SDK name is used. 
    41   SDKPATH=${DEVPATH}/SDKs/${SDK} 
     49  SDKPATH=${DEVPATH}/SDKs/${IPHONESDK} 
    4250fi 
    4351 
     
    4856fi 
    4957 
    50 # Settings to feed to configure script 
    51 export CFLAGS="-O2 -arch armv6 -isysroot ${SDKPATH}" 
    52 export LDFLAGS="-O2 -arch armv6 -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation" 
     58# Default CFLAGS if it's not specified 
     59if test "$CFLAGS" = ""; then 
     60  CFLAGS="-O2 -Wno-unused-label" 
     61fi 
     62 
     63# Default LDFLAGS if it's not specified 
     64if test "$LDFLAGS" = ""; then 
     65  LDFLAGS="-O2" 
     66fi 
     67 
     68# Determine which gcc for this SDK. Binaries should have the 
     69# full path as it's not normally in user's PATH 
     70 
     71if test "${CC}" = ""; then 
     72  for archpath in `ls -d ${SDKPATH}/usr/lib/gcc/arm-apple-darwin*`; do 
     73    archname=`basename ${archpath}` 
     74    for gccver in `ls ${archpath}`; do 
     75       gccpath="${DEVPATH}/usr/bin/${archname}-gcc-${gccver}" 
     76       if test -e ${gccpath}; then 
     77          export CC="${gccpath}" 
     78          break 
     79       fi 
     80    done 
     81    if test ! "${CC}" = ""; then 
     82       echo "$F: CC is not specified, choosing ${CC}" 
     83       break 
     84    fi 
     85  done 
     86fi 
     87 
     88if test "${CC}" = ""; then 
     89    echo "$F error: unable to find gcc for ${IPHONESDK}. If you think you have the right gcc, set the full path in CC environment variable." 
     90    exit 1 
     91fi 
     92 
     93# Set CXX if not set 
     94if test "${CXX}" = ""; then 
     95  export CXX=`echo ${CC} | sed 's/gcc/g++/'` 
     96  echo "$F: CXX is not specified, using ${CXX}" 
     97fi 
     98 
     99# Other settings to feed to configure script.  
     100#ARCH="-arch armv6" 
     101export CFLAGS="${CFLAGS} ${ARCH} -isysroot ${SDKPATH}" 
     102export LDFLAGS="${LDFLAGS} ${ARCH} -isysroot ${SDKPATH} -framework AudioToolbox -framework Foundation" 
    53103export AR="${DEVPATH}/usr/bin/libtool -static -o" 
    54104export RANLIB="echo ranlib" 
    55105# Use gcc -E as preprocessor instead of cpp, since cpp will find the 
    56 # header files in standard /usr/include 
    57 export CPP="${DEVPATH}/usr/bin/arm-apple-darwin9-gcc -E -isysroot ${SDKPATH}" 
     106# header files in standard /usr/include instead of in isysroot 
     107export CPP="${CC} -E -isysroot ${SDKPATH}" 
    58108 
    59 # And finally invoke configure script itself 
     109# Print settings 
     110if test "1" = "1"; then 
     111  echo "$F: calling ./aconfigure with env vars:" 
     112  echo " CC = ${CC}" 
     113  echo " CXX = ${CXX}" 
     114  echo " SDKPATH = ${SDKPATH}" 
     115  echo " CFLAGS = ${CFLAGS}" 
     116  echo " LDFLAGS = ${LDFLAGS}" 
     117  echo " AR = ${AR}" 
     118  echo " RANLIB = ${RANLIB}" 
     119fi 
     120 
     121# And finally invoke the configure script itself 
    60122./aconfigure --host=arm-apple-darwin9 --disable-floating-point $* 
    61123 
     124if test "$?" = "0"; then 
     125  echo "Done configuring for `basename $SDKPATH`" 
     126  echo "" 
     127fi 
     128 
  • pjproject/trunk/pjlib/include/pj/config_site_sample.h

    r2833 r3175  
    295295#endif 
    296296 
     297/* 
     298 * iPhone sample settings. 
     299 */ 
     300#if PJ_CONFIG_IPHONE 
     301    /* 
     302     * PJLIB settings. 
     303     */ 
     304 
     305    /* Disable floating point support */ 
     306    #define PJ_HAS_FLOATING_POINT               0 
     307 
     308    /* Misc PJLIB setting */ 
     309    #define PJ_MAXPATH                          80 
     310 
     311    /* 
     312     * PJMEDIA settings 
     313     */ 
     314 
     315    /* We have our own native CoreAudio backend */ 
     316    #define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO     0 
     317    #define PJMEDIA_AUDIO_DEV_HAS_WMME          0 
     318    #define PJMEDIA_AUDIO_DEV_HAS_COREAUDIO     1 
     319 
     320    /* The CoreAudio backend has built-in echo canceller! */ 
     321    #define PJMEDIA_HAS_SPEEX_AEC    0 
     322 
     323    /* Disable some codecs */ 
     324    #define PJMEDIA_HAS_L16_CODEC               0 
     325    #define PJMEDIA_HAS_ILBC_CODEC              0 
     326    #define PJMEDIA_HAS_G722_CODEC              0 
     327 
     328    /* Fine tune Speex's default settings for best performance/quality */ 
     329    #define PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY 5 
     330 
     331    /* 
     332     * PJSIP settings. 
     333     */ 
     334 
     335    /* Increase allowable packet size, just in case */ 
     336    #define PJSIP_MAX_PKT_LEN                   2000 
     337 
     338    /* 
     339     * PJSUA settings. 
     340     */ 
     341 
     342    /* Default codec quality, previously was set to 5, however it is now 
     343     * set to 4 to make sure pjsua instantiates resampler with small filter. 
     344     */ 
     345    #define PJSUA_DEFAULT_CODEC_QUALITY         4 
     346 
     347    /* Set maximum number of dialog/transaction/calls to minimum */ 
     348    #define PJSIP_MAX_TSX_COUNT                 31 
     349    #define PJSIP_MAX_DIALOG_COUNT              31 
     350    #define PJSUA_MAX_CALLS                     4 
     351 
     352    /* Other pjsua settings */ 
     353    #define PJSUA_MAX_ACC                       4 
     354    #define PJSUA_MAX_PLAYERS                   4 
     355    #define PJSUA_MAX_RECORDERS                 4 
     356    #define PJSUA_MAX_CONF_PORTS                (PJSUA_MAX_CALLS+2*PJSUA_MAX_PLAYERS) 
     357    #define PJSUA_MAX_BUDDIES                   32 
     358 
     359#endif 
    297360 
    298361/* 
  • pjproject/trunk/pjmedia/src/pjmedia-codec/ilbc.c

    r2834 r3175  
    3131#include <pj/string.h> 
    3232#include <pj/os.h> 
    33 #include "../../third_party/ilbc/iLBC_encode.h" 
    34 #include "../../third_party/ilbc/iLBC_decode.h" 
    35  
     33 
     34#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     35    #include <AudioToolbox/AudioToolbox.h> 
     36    #define iLBC_Enc_Inst_t AudioConverterRef 
     37    #define iLBC_Dec_Inst_t AudioConverterRef 
     38    #define BLOCKL_MAX          1 
     39#else 
     40    #include "../../third_party/ilbc/iLBC_encode.h" 
     41    #include "../../third_party/ilbc/iLBC_decode.h" 
     42#endif 
    3643 
    3744/* 
     
    132139    pj_timestamp         last_tx; 
    133140 
     141 
    134142    pj_bool_t            enc_ready; 
    135143    iLBC_Enc_Inst_t      enc; 
     
    143151    unsigned             dec_samples_per_frame; 
    144152    float                dec_block[BLOCKL_MAX]; 
     153 
     154#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     155    unsigned             enc_total_packets; 
     156    char                 *enc_buffer; 
     157    unsigned             enc_buffer_offset; 
     158 
     159    unsigned             dec_total_packets; 
     160    char                 *dec_buffer; 
     161    unsigned             dec_buffer_offset; 
     162#endif 
    145163}; 
    146164 
     
    353371 
    354372    ilbc_codec = (struct ilbc_codec*) codec; 
     373 
     374#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     375    if (ilbc_codec->enc) { 
     376        AudioConverterDispose(ilbc_codec->enc); 
     377        ilbc_codec->enc = NULL; 
     378    } 
     379    if (ilbc_codec->dec) { 
     380        AudioConverterDispose(ilbc_codec->dec); 
     381        ilbc_codec->dec = NULL; 
     382    } 
     383#endif 
     384 
    355385    pj_pool_release(ilbc_codec->pool); 
    356386 
     
    380410    pj_uint16_t dec_fmtp_mode = DEFAULT_MODE,  
    381411                enc_fmtp_mode = DEFAULT_MODE; 
     412 
     413#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     414    AudioStreamBasicDescription srcFormat, dstFormat; 
     415    UInt32 size; 
     416 
     417    srcFormat.mSampleRate       = attr->info.clock_rate; 
     418    srcFormat.mFormatID         = kAudioFormatLinearPCM; 
     419    srcFormat.mFormatFlags      = kLinearPCMFormatFlagIsSignedInteger 
     420                                  | kLinearPCMFormatFlagIsPacked; 
     421    srcFormat.mBitsPerChannel   = attr->info.pcm_bits_per_sample; 
     422    srcFormat.mChannelsPerFrame = attr->info.channel_cnt; 
     423    srcFormat.mBytesPerFrame    = srcFormat.mChannelsPerFrame 
     424                                  * srcFormat.mBitsPerChannel >> 3; 
     425    srcFormat.mFramesPerPacket  = 1; 
     426    srcFormat.mBytesPerPacket   = srcFormat.mBytesPerFrame * 
     427                                  srcFormat.mFramesPerPacket; 
     428 
     429    memset(&dstFormat, 0, sizeof(dstFormat)); 
     430    dstFormat.mSampleRate       = attr->info.clock_rate; 
     431    dstFormat.mFormatID         = kAudioFormatiLBC; 
     432    dstFormat.mChannelsPerFrame = attr->info.channel_cnt; 
     433#endif 
    382434 
    383435    pj_assert(ilbc_codec != NULL); 
     
    428480 
    429481    /* Create encoder */ 
     482#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     483    dstFormat.mFramesPerPacket  = CLOCK_RATE * enc_fmtp_mode / 1000; 
     484    dstFormat.mBytesPerPacket   = (enc_fmtp_mode == 20? 38 : 50); 
     485 
     486    /* Use AudioFormat API to fill out the rest of the description */ 
     487    size = sizeof(dstFormat); 
     488    AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 
     489                           0, NULL, &size, &dstFormat); 
     490 
     491    if (AudioConverterNew(&srcFormat, &dstFormat, &ilbc_codec->enc) != noErr) 
     492        return PJMEDIA_CODEC_EFAILED; 
     493    ilbc_codec->enc_frame_size = (enc_fmtp_mode == 20? 38 : 50); 
     494#else 
    430495    ilbc_codec->enc_frame_size = initEncode(&ilbc_codec->enc, enc_fmtp_mode); 
     496#endif 
    431497    ilbc_codec->enc_samples_per_frame = CLOCK_RATE * enc_fmtp_mode / 1000; 
    432498    ilbc_codec->enc_ready = PJ_TRUE; 
    433499 
    434500    /* Create decoder */ 
     501#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     502    if (AudioConverterNew(&dstFormat, &srcFormat, &ilbc_codec->dec) != noErr) 
     503        return PJMEDIA_CODEC_EFAILED; 
     504    ilbc_codec->dec_samples_per_frame = CLOCK_RATE * dec_fmtp_mode / 1000; 
     505#else 
    435506    ilbc_codec->dec_samples_per_frame = initDecode(&ilbc_codec->dec, 
    436507                                                   dec_fmtp_mode, 
    437508                                                   attr->setting.penh); 
     509#endif 
    438510    ilbc_codec->dec_frame_size = (dec_fmtp_mode == 20? 38 : 50); 
    439511    ilbc_codec->dec_ready = PJ_TRUE; 
     
    511583        frames[count].size = ilbc_codec->dec_frame_size; 
    512584        frames[count].timestamp.u64 = ts->u64 + count *  
    513                                           ilbc_codec->dec_samples_per_frame; 
     585                                      ilbc_codec->dec_samples_per_frame; 
    514586 
    515587        pkt = ((char*)pkt) + ilbc_codec->dec_frame_size; 
     
    522594    return PJ_SUCCESS; 
    523595} 
     596 
     597#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     598static OSStatus encodeDataProc ( 
     599    AudioConverterRef             inAudioConverter, 
     600    UInt32                        *ioNumberDataPackets, 
     601    AudioBufferList               *ioData, 
     602    AudioStreamPacketDescription  **outDataPacketDescription, 
     603    void                          *inUserData 
     604) 
     605{ 
     606    struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)inUserData; 
     607 
     608    /* Initialize in case of failure */ 
     609    ioData->mBuffers[0].mData = NULL; 
     610    ioData->mBuffers[0].mDataByteSize = 0; 
     611 
     612    if (ilbc_codec->enc_total_packets < *ioNumberDataPackets) { 
     613        *ioNumberDataPackets = ilbc_codec->enc_total_packets; 
     614    } 
     615 
     616    if (*ioNumberDataPackets) { 
     617        ioData->mBuffers[0].mData = ilbc_codec->enc_buffer + 
     618                                    ilbc_codec->enc_buffer_offset; 
     619        ioData->mBuffers[0].mDataByteSize = *ioNumberDataPackets * 
     620                                            ilbc_codec->enc_samples_per_frame 
     621                                            << 1; 
     622        ilbc_codec->enc_buffer_offset += ioData->mBuffers[0].mDataByteSize; 
     623    } 
     624 
     625    ilbc_codec->enc_total_packets -= *ioNumberDataPackets; 
     626    return noErr; 
     627} 
     628 
     629static OSStatus decodeDataProc ( 
     630    AudioConverterRef             inAudioConverter, 
     631    UInt32                        *ioNumberDataPackets, 
     632    AudioBufferList               *ioData, 
     633    AudioStreamPacketDescription  **outDataPacketDescription, 
     634    void                          *inUserData 
     635) 
     636{ 
     637    struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)inUserData; 
     638 
     639    /* Initialize in case of failure */ 
     640    ioData->mBuffers[0].mData = NULL; 
     641    ioData->mBuffers[0].mDataByteSize = 0; 
     642 
     643    if (ilbc_codec->dec_total_packets < *ioNumberDataPackets) { 
     644        *ioNumberDataPackets = ilbc_codec->dec_total_packets; 
     645    } 
     646 
     647    if (*ioNumberDataPackets) { 
     648        ioData->mBuffers[0].mData = ilbc_codec->dec_buffer + 
     649                                    ilbc_codec->dec_buffer_offset; 
     650        ioData->mBuffers[0].mDataByteSize = *ioNumberDataPackets * 
     651                                            ilbc_codec->dec_frame_size; 
     652        ilbc_codec->dec_buffer_offset += ioData->mBuffers[0].mDataByteSize; 
     653    } 
     654 
     655    ilbc_codec->dec_total_packets -= *ioNumberDataPackets; 
     656    return noErr; 
     657} 
     658#endif 
    524659 
    525660/* 
     
    534669    pj_int16_t *pcm_in; 
    535670    unsigned nsamples; 
     671#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     672    UInt32 npackets; 
     673    OSStatus err; 
     674    AudioBufferList theABL; 
     675#endif 
    536676 
    537677    pj_assert(ilbc_codec && input && output); 
     
    574714    /* Encode */ 
    575715    output->size = 0; 
     716#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     717    npackets = nsamples / ilbc_codec->enc_samples_per_frame; 
     718 
     719    theABL.mNumberBuffers = 1; 
     720    theABL.mBuffers[0].mNumberChannels = 1; 
     721    theABL.mBuffers[0].mDataByteSize = output_buf_len; 
     722    theABL.mBuffers[0].mData = output->buf; 
     723 
     724    ilbc_codec->enc_total_packets = npackets; 
     725    ilbc_codec->enc_buffer = (char *)input->buf; 
     726    ilbc_codec->enc_buffer_offset = 0; 
     727 
     728    err = AudioConverterFillComplexBuffer(ilbc_codec->enc, encodeDataProc, 
     729                                          ilbc_codec, &npackets, 
     730                                          &theABL, NULL); 
     731    if (err == noErr) { 
     732        output->size = npackets * ilbc_codec->enc_frame_size; 
     733    } 
     734#else 
    576735    while (nsamples >= ilbc_codec->enc_samples_per_frame) { 
    577736        unsigned i; 
     
    589748        nsamples -= ilbc_codec->enc_samples_per_frame; 
    590749    } 
     750#endif 
    591751 
    592752    output->type = PJMEDIA_FRAME_TYPE_AUDIO; 
     
    605765{ 
    606766    struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 
     767#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     768    UInt32 npackets; 
     769    OSStatus err; 
     770    AudioBufferList theABL; 
     771#else 
    607772    unsigned i; 
     773#endif 
    608774 
    609775    pj_assert(ilbc_codec != NULL); 
     
    617783 
    618784    /* Decode to temporary buffer */ 
     785#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     786    npackets = input->size / ilbc_codec->dec_frame_size * 
     787               ilbc_codec->dec_samples_per_frame; 
     788 
     789    theABL.mNumberBuffers = 1; 
     790    theABL.mBuffers[0].mNumberChannels = 1; 
     791    theABL.mBuffers[0].mDataByteSize = output_buf_len; 
     792    theABL.mBuffers[0].mData = output->buf; 
     793 
     794    ilbc_codec->dec_total_packets = npackets; 
     795    ilbc_codec->dec_buffer = (char *)input->buf; 
     796    ilbc_codec->dec_buffer_offset = 0; 
     797 
     798    err = AudioConverterFillComplexBuffer(ilbc_codec->dec, decodeDataProc, 
     799                                          ilbc_codec, &npackets, 
     800                                          &theABL, NULL); 
     801    if (err == noErr) { 
     802        output->size = npackets * (ilbc_codec->dec_samples_per_frame << 1); 
     803    } 
     804#else 
    619805    iLBC_decode(ilbc_codec->dec_block, (unsigned char*) input->buf, 
    620806                &ilbc_codec->dec, 1); 
     
    625811    } 
    626812    output->size = (ilbc_codec->dec_samples_per_frame << 1); 
     813#endif 
     814 
    627815    output->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    628816    output->timestamp = input->timestamp; 
     
    640828{ 
    641829    struct ilbc_codec *ilbc_codec = (struct ilbc_codec*)codec; 
     830#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     831    UInt32 npackets; 
     832    OSStatus err; 
     833    AudioBufferList theABL; 
     834#else 
    642835    unsigned i; 
     836#endif 
    643837 
    644838    pj_assert(ilbc_codec != NULL); 
     
    649843 
    650844    /* Decode to temporary buffer */ 
     845#ifdef PJMEDIA_ILBC_CODEC_USE_COREAUDIO 
     846    npackets = 1; 
     847 
     848    theABL.mNumberBuffers = 1; 
     849    theABL.mBuffers[0].mNumberChannels = 1; 
     850    theABL.mBuffers[0].mDataByteSize = output_buf_len; 
     851    theABL.mBuffers[0].mData = output->buf; 
     852 
     853    ilbc_codec->dec_total_packets = npackets; 
     854    ilbc_codec->dec_buffer_offset = 0; 
     855    if (ilbc_codec->dec_buffer) { 
     856        err = AudioConverterFillComplexBuffer(ilbc_codec->dec, decodeDataProc, 
     857                                              ilbc_codec, &npackets, 
     858                                              &theABL, NULL); 
     859        if (err == noErr) { 
     860            output->size = npackets * 
     861                           (ilbc_codec->dec_samples_per_frame << 1); 
     862        } 
     863    } else { 
     864        output->size = npackets * (ilbc_codec->dec_samples_per_frame << 1); 
     865        pj_bzero(output->buf, output->size); 
     866    } 
     867#else 
    651868    iLBC_decode(ilbc_codec->dec_block, NULL, &ilbc_codec->dec, 0); 
    652869 
     
    656873    } 
    657874    output->size = (ilbc_codec->dec_samples_per_frame << 1); 
     875#endif 
    658876    output->type = PJMEDIA_FRAME_TYPE_AUDIO; 
    659877 
     
    663881 
    664882#endif  /* PJMEDIA_HAS_ILBC_CODEC */ 
    665  
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r3172 r3175  
    1919 */ 
    2020#include <pjsua-lib/pjsua.h> 
     21#include "gui.h" 
    2122 
    2223 
     
    150151static void ring_stop(pjsua_call_id call_id); 
    151152 
    152 pj_bool_t app_restart; 
     153pj_bool_t       app_restart; 
     154pj_log_func     *log_cb = NULL; 
    153155 
    154156/***************************************************************************** 
     
    44954497    app_config.cfg.cb.on_mwi_info = &on_mwi_info; 
    44964498    app_config.cfg.cb.on_transport_state = &on_transport_state; 
     4499    app_config.log_cfg.cb = log_cb; 
    44974500 
    44984501    /* Set sound device latency */ 
  • pjproject/trunk/pjsip-apps/src/pjsystest/systest.c

    r3164 r3175  
    2424unsigned    test_item_count; 
    2525test_item_t test_items[SYSTEST_MAX_TEST]; 
     26char        doc_path[PATH_LENGTH] = {0}; 
     27char        res_path[PATH_LENGTH] = {0}; 
     28char        fpath[PATH_LENGTH]; 
    2629 
    2730#define USER_ERROR  "User used said not okay" 
     
    8386/*****************************************************************/ 
    8487 
     88PJ_INLINE(char *) add_path(const char *path, const char *fname) 
     89{ 
     90    strncpy(fpath, path, PATH_LENGTH); 
     91    strncat(fpath, fname, PATH_LENGTH); 
     92    return fpath; 
     93} 
     94 
    8595static void exit_app(void) 
    8696{ 
    87     systest_save_result(RESULT_OUT_PATH); 
     97    systest_save_result(add_path(doc_path, RESULT_OUT_PATH)); 
    8898    gui_destroy(); 
    8999} 
     
    334344static void systest_play_wav1(void) 
    335345{ 
    336     const char *paths[] = { WAV_PLAYBACK_PATH,  
     346    const char *paths[] = { add_path(res_path, WAV_PLAYBACK_PATH), 
    337347                            ALT_PATH1 WAV_PLAYBACK_PATH }; 
    338348    systest_play_wav(PJ_ARRAY_SIZE(paths), paths); 
     
    341351static void systest_play_wav2(void) 
    342352{ 
    343     const char *paths[] = { WAV_TOCK8_PATH,  
     353    const char *paths[] = { add_path(res_path, WAV_TOCK8_PATH), 
    344354                            ALT_PATH1 WAV_TOCK8_PATH}; 
    345355    systest_play_wav(PJ_ARRAY_SIZE(paths), paths); 
     
    352362static void systest_rec_audio(void) 
    353363{ 
    354     const pj_str_t filename = pj_str(WAV_REC_OUT_PATH); 
     364    const pj_str_t filename = pj_str(add_path(doc_path, WAV_REC_OUT_PATH)); 
    355365    pj_pool_t *pool = NULL; 
    356366    enum gui_key key; 
     
    737747static void systest_latency_test(void) 
    738748{ 
    739     const char *ref_wav_paths[] = { WAV_TOCK8_PATH, ALT_PATH1 WAV_TOCK8_PATH }; 
    740     const pj_str_t rec_wav_file = pj_str(WAV_LATENCY_OUT_PATH); 
     749    const char *ref_wav_paths[] = { add_path(res_path, WAV_TOCK8_PATH), ALT_PATH1 WAV_TOCK8_PATH }; 
     750    pj_str_t rec_wav_file; 
    741751    pjsua_player_id play_id = PJSUA_INVALID_ID; 
    742752    pjsua_conf_port_id play_slot = PJSUA_INVALID_ID; 
     
    786796    play_slot = pjsua_player_get_conf_port(play_id); 
    787797 
     798    rec_wav_file = pj_str(add_path(doc_path, WAV_LATENCY_OUT_PATH)); 
    788799    status = pjsua_recorder_create(&rec_wav_file, 0, NULL, -1, 0, &rec_id); 
    789800    if (status != PJ_SUCCESS) 
     
    10621073 
    10631074    pjsua_logging_config_default(&log_cfg); 
    1064     log_cfg.log_filename = pj_str(LOG_OUT_PATH); 
     1075    log_cfg.log_filename = pj_str(add_path(doc_path, LOG_OUT_PATH)); 
    10651076 
    10661077    pjsua_config_default(&systest.ua_cfg); 
  • pjproject/trunk/pjsip-apps/src/pjsystest/systest.h

    r3164 r3175  
    9292extern unsigned     test_item_count; 
    9393extern test_item_t  test_items[SYSTEST_MAX_TEST]; 
     94#define PATH_LENGTH         128 
     95extern char         doc_path[PATH_LENGTH]; 
     96extern char         res_path[PATH_LENGTH]; 
    9497 
    9598test_item_t *systest_alloc_test_item(const char *title); 
Note: See TracChangeset for help on using the changeset viewer.