Changeset 312


Ignore:
Timestamp:
Mar 8, 2006 12:37:22 PM (18 years ago)
Author:
bennylp
Message:

Added options to disable microphone device, usefull for streaming server (some systems only have sound player)

Location:
pjproject/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/conference.h

    r277 r312  
    4141typedef struct pjmedia_conf_port_info 
    4242{ 
    43     unsigned            slot; 
    44     pj_str_t            name; 
    45     pjmedia_port_op     tx_setting; 
    46     pjmedia_port_op     rx_setting; 
    47     pj_bool_t          *listener; 
    48     unsigned            clock_rate; 
    49     unsigned            samples_per_frame; 
     43    unsigned            slot;               /**< Slot number.               */ 
     44    pj_str_t            name;               /**< Port name.                 */ 
     45    pjmedia_port_op     tx_setting;         /**< Transmit settings.         */ 
     46    pjmedia_port_op     rx_setting;         /**< Receive settings.          */ 
     47    pj_bool_t          *listener;           /**< Array of listeners.        */ 
     48    unsigned            clock_rate;         /**< Clock rate of the port.    */ 
     49    unsigned            samples_per_frame;  /**< Samples per frame          */ 
    5050} pjmedia_conf_port_info; 
    5151 
    5252 
    5353/** 
    54  * Create conference bridge. 
     54 * Conference port options. The values here can be combined in bitmask to 
     55 * be specified when the conference bridge is created. 
     56 */ 
     57enum pjmedia_conf_option 
     58{ 
     59    PJMEDIA_CONF_NO_MIC  = 1,   /**< Disable audio streams from the 
     60                                     microphone device.                     */ 
     61}; 
     62 
     63 
     64/** 
     65 * Create conference bridge. This normally will also create instances of 
     66 * sound device to be attached to the port zero of the bridge. 
     67 * 
     68 * @param pool              Pool to use to allocate the bridge and  
     69 *                          additional buffers for the sound device. 
     70 * @param max_slots         Maximum number of slots/ports to be created in 
     71 *                          the bridge. Note that the bridge internally uses 
     72 *                          one port for the sound device, so the actual  
     73 *                          maximum number of ports will be less one than 
     74 *                          this value. 
     75 * @param sampling_rate     Set the sampling rate of the bridge. This value 
     76 *                          is also used to set the sampling rate of the 
     77 *                          sound device. 
     78 * @param samples_per_frame Set the number of samples per frame. This value 
     79 *                          is also used to set the sound device. 
     80 * @param bits_per_sample   Set the number of bits per sample. This value 
     81 *                          is also used to set the sound device. Currently 
     82 *                          only 16bit per sample is supported. 
     83 * @param options           Bitmask options to be set for the bridge. The 
     84 *                          options are constructed from #pjmedia_conf_option 
     85 *                          enumeration. 
     86 * @param p_conf            Pointer to receive the conference bridge instance. 
     87 * 
     88 * @return                  PJ_SUCCESS if conference bridge can be created. 
    5589 */ 
    5690PJ_DECL(pj_status_t) pjmedia_conf_create( pj_pool_t *pool, 
     
    5993                                          unsigned samples_per_frame, 
    6094                                          unsigned bits_per_sample, 
     95                                          unsigned options, 
    6196                                          pjmedia_conf **p_conf ); 
    6297 
     
    6499/** 
    65100 * Destroy conference bridge. 
     101 * 
     102 * @param conf              The conference bridge. 
     103 * 
     104 * @return                  PJ_SUCCESS on success. 
    66105 */ 
    67106PJ_DECL(pj_status_t) pjmedia_conf_destroy( pjmedia_conf *conf ); 
  • pjproject/trunk/pjmedia/src/pjmedia/conference.c

    r279 r312  
    128128struct pjmedia_conf 
    129129{ 
     130    unsigned              options;      /**< Bitmask options.               */ 
    130131    unsigned              max_ports;    /**< Maximum ports.                 */ 
    131132    unsigned              port_cnt;     /**< Current number of ports.       */ 
     
    334335                                         unsigned samples_per_frame, 
    335336                                         unsigned bits_per_sample, 
     337                                         unsigned options, 
    336338                                         pjmedia_conf **p_conf ) 
    337339{ 
     
    352354    PJ_ASSERT_RETURN(conf->ports, PJ_ENOMEM); 
    353355 
     356    conf->options = options; 
    354357    conf->max_ports = max_ports; 
    355358    conf->clock_rate = clock_rate; 
     
    386389static pj_status_t create_sound( pjmedia_conf *conf ) 
    387390{ 
    388     /* Open recorder. */ 
    389     conf->snd_rec = pj_snd_open_recorder(-1 ,&conf->snd_info, &rec_cb, conf); 
    390     if (conf->snd_rec == NULL) { 
    391         return -1; 
     391    /* Open recorder only if mic is not disabled. */ 
     392    if ((conf->options & PJMEDIA_CONF_NO_MIC) == 0) { 
     393        conf->snd_rec = pj_snd_open_recorder(-1 ,&conf->snd_info,  
     394                                             &rec_cb, conf); 
     395        if (conf->snd_rec == NULL) { 
     396            return -1; 
     397        } 
    392398    } 
    393399 
     
    395401    conf->snd_player = pj_snd_open_player(-1, &conf->snd_info, &play_cb, conf); 
    396402    if (conf->snd_player == NULL) { 
    397         pj_snd_stream_close(conf->snd_rec); 
     403        if (conf->snd_rec) { 
     404            pj_snd_stream_close(conf->snd_rec); 
     405        } 
    398406        return -1; 
    399407    } 
     
    426434    pj_status_t status; 
    427435 
    428     if (conf->snd_rec == NULL) { 
     436    if (conf->snd_player == NULL) { 
    429437        status = create_sound(conf); 
    430438        if (status != PJ_SUCCESS) 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r305 r312  
    183183    pjmedia_conf    *mconf;         /**< Media conference.              */ 
    184184    pj_bool_t        null_audio;    /**< Null audio flag.               */ 
     185    pj_bool_t        no_mic;        /**< Disable microphone.            */ 
    185186    char            *wav_file;      /**< WAV file name to play.         */ 
    186187    unsigned         wav_slot;      /**< WAV player slot in bridge      */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r305 r312  
    612612static pj_status_t init_media(void) 
    613613{ 
    614  
     614    unsigned options; 
    615615    pj_status_t status; 
    616616 
     
    733733    } 
    734734 
     735    /* Init options for conference bridge. */ 
     736    options = 0; 
     737    if (pjsua.no_mic) 
     738        options |= PJMEDIA_CONF_NO_MIC; 
     739 
    735740    /* Init conference bridge. */ 
    736741 
     
    739744                                 pjsua.clock_rate,  
    740745                                 pjsua.clock_rate * 20 / 1000, 16,  
     746                                 options, 
    741747                                 &pjsua.mconf); 
    742748    if (status != PJ_SUCCESS) { 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c

    r305 r312  
    8787    puts  ("  --uwb               Enable ultra-wideband codecs and set clock-rate to 32KHz"); 
    8888    puts  ("  --null-audio        Use NULL audio device"); 
     89    puts  ("  --no-mic            Disable microphone device"); 
    8990    puts  ("  --play-file=file    Play WAV file in conference bridge"); 
    9091    puts  ("  --auto-play         Automatically play the file (to incoming calls only)"); 
     
    218219    int option_index; 
    219220    enum { OPT_CONFIG_FILE, OPT_LOG_FILE, OPT_LOG_LEVEL, OPT_APP_LOG_LEVEL,  
    220            OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, 
     221           OPT_HELP, OPT_VERSION, OPT_NULL_AUDIO, OPT_NO_MIC, 
    221222           OPT_LOCAL_PORT, OPT_PROXY, OPT_OUTBOUND_PROXY, OPT_REGISTRAR, 
    222223           OPT_REG_TIMEOUT, OPT_ID, OPT_CONTACT,  
     
    241242        { "uwb",        0, 0, OPT_UWB}, 
    242243        { "null-audio", 0, 0, OPT_NULL_AUDIO}, 
     244        { "no-mic",     0, 0, OPT_NO_MIC}, 
    243245        { "local-port", 1, 0, OPT_LOCAL_PORT}, 
    244246        { "proxy",      1, 0, OPT_PROXY}, 
     
    344346            break; 
    345347 
     348        case OPT_NO_MIC: 
     349            pjsua.no_mic = 1; 
     350            break; 
     351 
    346352        case OPT_WB: 
    347353            pjsua.clock_rate = 16000; 
Note: See TracChangeset for help on using the changeset viewer.