Changeset 343


Ignore:
Timestamp:
Mar 20, 2006 5:42:37 PM (18 years ago)
Author:
bennylp
Message:

Added clock-rate options in pjsua

Location:
pjproject/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/confsample.c

    r337 r343  
    2020#include <pjmedia.h> 
    2121 
    22 /* 
    23  * FILE: 
    24  * 
    25  *  confsample.c 
    26  * 
    27  * PURPOSE: 
    28  * 
    29  *  Demonstrate how to use conference bridge. 
    30  * 
    31  * USAGE: 
    32  * 
    33  *  confsample [file1.wav] [file2.wav] ... 
    34  * 
    35  * where: 
    36  *  fileN.wav are optional WAV files to be connected to the conference 
    37  *  bridge. The WAV files MUST have single channel (mono) and 16 bit PCM 
    38  *  samples. It can have arbitrary sampling rate. 
    39  * 
    40  * DESCRIPTION: 
    41  * 
    42  *  Here we create a conference bridge, with at least one port (port zero 
    43  *  is always created for the sound device). 
    44  * 
    45  *  If WAV files are specified, the WAV file player ports will be connected 
    46  *  to slot starting from number one in the bridge. The WAV files can have  
    47  *  arbitrary sampling rate; the bridge will convert it to its clock rate.  
    48  *  However, the files MUST have a single audio channel only (i.e. mono). 
    49  */ 
     22static const char *desc =  
     23 " FILE:                                                                    \n" 
     24 "                                                                          \n" 
     25 "  confsample.c                                                            \n" 
     26 "                                                                          \n" 
     27 " PURPOSE:                                                                 \n" 
     28 "                                                                          \n" 
     29 "  Demonstrate how to use conference bridge.                               \n" 
     30 "                                                                          \n" 
     31 " USAGE:                                                                   \n" 
     32 "                                                                          \n" 
     33 "  confsample [file1.wav] [file2.wav] ...                                  \n" 
     34 "                                                                          \n" 
     35 " where:                                                                   \n" 
     36 "  fileN.wav are optional WAV files to be connected to the conference      \n" 
     37 "  bridge. The WAV files MUST have single channel (mono) and 16 bit PCM    \n" 
     38 "  samples. It can have arbitrary sampling rate.                           \n" 
     39 "                                                                          \n" 
     40 " DESCRIPTION:                                                             \n" 
     41 "                                                                          \n" 
     42 "  Here we create a conference bridge, with at least one port (port zero   \n" 
     43 "  is always created for the sound device).                                \n" 
     44 "                                                                          \n" 
     45 "  If WAV files are specified, the WAV file player ports will be connected \n" 
     46 "  to slot starting from number one in the bridge. The WAV files can have  \n" 
     47 "  arbitrary sampling rate; the bridge will convert it to its clock rate.  \n" 
     48 "  However, the files MUST have a single audio channel only (i.e. mono).   \n"; 
    5049 
    5150#include <pjmedia.h> 
     
    5958#define THIS_FILE   "confsample.c" 
    6059 
     60/* Constants */ 
     61#define CLOCK_RATE      44100 
     62#define NSAMPLES        (CLOCK_RATE * 20 / 1000) 
     63#define NCHANNELS       1 
     64#define NBITS           16 
     65 
     66  
    6167/*  
    6268 * Prototypes:  
     
    174180    status = pjmedia_conf_create( pool,     /* pool to use          */ 
    175181                                  port_count,/* number of ports     */ 
    176                                   16000,    /* sampling rate        */ 
    177                                   1,        /* # of channels.       */ 
    178                                   320,      /* samples per frame    */ 
    179                                   16,       /* bits per sample      */ 
     182                                  CLOCK_RATE,/* sampling rate       */ 
     183                                  NCHANNELS,/* # of channels.       */ 
     184                                  NSAMPLES, /* samples per frame    */ 
     185                                  NBITS,    /* bits per sample      */ 
    180186                                  0,        /* options              */ 
    181187                                  &conf     /* result               */ 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r318 r343  
    181181    pjmedia_endpt   *med_endpt;     /**< Media endpoint.                */ 
    182182    unsigned         clock_rate;    /**< Internal clock rate.           */ 
     183    pj_bool_t        has_wb;        /**< Include wideband codecs        */ 
     184    pj_bool_t        has_uwb;       /**< Include ultra-wideband codecs  */ 
    183185    pjmedia_conf    *mconf;         /**< Media conference.              */ 
    184186    pj_bool_t        null_audio;    /**< Null audio flag.               */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r322 r343  
    7878 
    7979    /* Default for media: */ 
     80#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 
     81    pjsua.clock_rate = 44100; 
     82#else 
    8083    pjsua.clock_rate = 8000; 
     84#endif 
    8185    pjsua.complexity = -1; 
    8286    pjsua.quality = 4; 
     87    pjsua.has_wb = 0; 
     88    pjsua.has_uwb = 0; 
    8389 
    8490 
     
    622628 
    623629        /* Register speex. */ 
    624         if (pjsua.clock_rate >= 16000) 
    625             option &= ~(PJMEDIA_SPEEX_NO_WB); 
    626         if (pjsua.clock_rate >= 32000) 
    627             option &= ~(PJMEDIA_SPEEX_NO_UWB); 
     630        if (pjsua.has_wb) 
     631            option &= ~PJMEDIA_SPEEX_NO_WB; 
     632        if (pjsua.has_uwb) 
     633            option &= ~PJMEDIA_SPEEX_NO_UWB; 
    628634 
    629635        status = pjmedia_codec_speex_init(pjsua.med_endpt, option,  
     
    690696 
    691697                /* Register speex. */ 
    692                 if (pjsua.clock_rate >= 16000) 
     698                if (pjsua.has_wb) 
    693699                    option &= ~(PJMEDIA_SPEEX_NO_WB); 
    694                 if (pjsua.clock_rate >= 32000) 
     700                if (pjsua.has_uwb) 
    695701                    option &= ~(PJMEDIA_SPEEX_NO_UWB); 
    696702 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c

    r325 r343  
    8787    puts  ("  --wb                Enable wideband codecs and set clock-rate to 16KHz"); 
    8888    puts  ("  --uwb               Enable ultra-wideband codecs and set clock-rate to 32KHz"); 
     89    puts  ("  --clock-rate=N      Override sound device clock rate"); 
    8990    puts  ("  --null-audio        Use NULL audio device"); 
    9091    puts  ("  --no-mic            Disable microphone device"); 
     
    227228           OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 
    228229           OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP, 
    229            OPT_AUTO_CONF, 
     230           OPT_AUTO_CONF, OPT_CLOCK_RATE, 
    230231           OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT, OPT_ADD_CODEC, 
    231232           OPT_COMPLEXITY, OPT_QUALITY, 
     
    242243        { "wb",         0, 0, OPT_WB}, 
    243244        { "uwb",        0, 0, OPT_UWB}, 
     245        { "clock-rate", 1, 0, OPT_CLOCK_RATE}, 
    244246        { "null-audio", 0, 0, OPT_NULL_AUDIO}, 
    245247        { "no-mic",     0, 0, OPT_NO_MIC}, 
     
    352354 
    353355        case OPT_WB: 
    354             pjsua.clock_rate = 16000; 
     356            pjsua.has_wb = 1; 
    355357            break; 
    356358 
    357359        case OPT_UWB: 
    358             pjsua.clock_rate = 32000; 
     360            pjsua.has_uwb = 1; 
     361            break; 
     362 
     363        case OPT_CLOCK_RATE: 
     364            lval = pj_strtoul(pj_cstr(&tmp, pj_optarg)); 
     365            if (lval < 8000 || lval > 48000) { 
     366                printf("Error: expecting value between 8000-48000 for clock rate\n"); 
     367                return PJ_EINVAL; 
     368            } 
     369            pjsua.clock_rate = (int)lval;  
    359370            break; 
    360371 
     
    573584        return PJ_EINVAL; 
    574585    } 
     586 
     587    /* Adjust clock rate */ 
     588    if (pjsua.clock_rate == 8000 && pjsua.has_uwb) 
     589        pjsua.clock_rate = 32000; 
     590    else if (pjsua.clock_rate == 8000 && pjsua.has_wb) 
     591        pjsua.clock_rate = 16000; 
    575592 
    576593    return PJ_SUCCESS; 
     
    906923    } 
    907924    /* Media clock rate. */ 
    908     if (pjsua.clock_rate >= 32000) 
     925    if (pjsua.has_uwb) 
    909926        pj_strcat2(&cfg, "--uwb\n"); 
    910     else if (pjsua.clock_rate >= 16000) 
     927 
     928    if (pjsua.has_wb) 
    911929        pj_strcat2(&cfg, "--wb\n"); 
     930 
     931    pj_ansi_sprintf(line, "--clock-rate %d\n", 
     932                    pjsua.clock_rate); 
     933    pj_strcat2(&cfg, line); 
     934 
    912935 
    913936    /* Encoding quality and complexity */ 
Note: See TracChangeset for help on using the changeset viewer.