Changeset 222


Ignore:
Timestamp:
Feb 23, 2006 2:09:10 AM (18 years ago)
Author:
bennylp
Message:

Added support for playing WAV file

Location:
pjproject/trunk
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/build/pjmedia.dsp

    r214 r222  
    109109# Begin Source File 
    110110 
     111SOURCE=..\src\pjmedia\file_port.c 
     112# End Source File 
     113# Begin Source File 
     114 
    111115SOURCE=..\src\pjmedia\g711.c 
    112116# End Source File 
     
    194198# Begin Source File 
    195199 
     200SOURCE=..\include\pjmedia\file_port.h 
     201# End Source File 
     202# Begin Source File 
     203 
    196204SOURCE=..\include\pjmedia\jbuf.h 
    197205# End Source File 
     
    243251 
    244252SOURCE=..\include\pjmedia\vad.h 
     253# End Source File 
     254# Begin Source File 
     255 
     256SOURCE=..\include\pjmedia\wave.h 
    245257# End Source File 
    246258# End Group 
  • pjproject/trunk/pjmedia/include/pjmedia.h

    r205 r222  
    3030#include <pjmedia/endpoint.h> 
    3131#include <pjmedia/errno.h> 
     32#include <pjmedia/file_port.h> 
    3233#include <pjmedia/jbuf.h> 
    3334#include <pjmedia/port.h> 
     
    3839#include <pjmedia/session.h> 
    3940#include <pjmedia/sound.h> 
     41#include <pjmedia/wave.h> 
    4042 
    4143#endif  /* __PJMEDIA_H__ */ 
  • pjproject/trunk/pjmedia/include/pjmedia/conference.h

    r205 r222  
    4141typedef struct pjmedia_conf_port_info 
    4242{ 
     43    unsigned            slot; 
    4344    pj_str_t            name; 
    4445    pjmedia_port_op     tx_setting; 
     
    151152/** 
    152153 * Get port info. 
     154 * 
     155 * @param conf          The conference bridge. 
     156 * @param slot          Port index. 
     157 * @param info          Pointer to receive the info. 
     158 * 
     159 * @return              PJ_SUCCESS on success. 
    153160 */ 
    154161PJ_DECL(pj_status_t) pjmedia_conf_get_port_info( pjmedia_conf *conf, 
    155162                                                 unsigned slot, 
    156163                                                 pjmedia_conf_port_info *info); 
     164 
     165 
     166/** 
     167 * Get occupied ports info. 
     168 * 
     169 * @param conf          The conference bridge. 
     170 * @param size          On input, contains maximum number of infos 
     171 *                      to be retrieved. On output, contains the actual 
     172 *                      number of infos that have been copied. 
     173 * @param info          Array of info. 
     174 * 
     175 * @return              PJ_SUCCESS on success. 
     176 */ 
     177PJ_DECL(pj_status_t) pjmedia_conf_get_ports_info(pjmedia_conf *conf, 
     178                                                 unsigned *size, 
     179                                                 pjmedia_conf_port_info info[]); 
    157180 
    158181 
  • pjproject/trunk/pjmedia/include/pjmedia/errno.h

    r215 r222  
    407407 
    408408 
     409/************************************************************ 
     410 * FILE ERRORS 
     411 ***********************************************************/ 
     412/** 
     413 * @hideinitializer 
     414 * Not a valid WAVE file. 
     415 */ 
     416#define PJMEDIA_ENOTVALIDWAVE       (PJMEDIA_ERRNO_START+180)    /* 220180 */ 
     417/** 
     418 * @hideinitializer 
     419 * Unsupported WAVE file. 
     420 */ 
     421#define PJMEDIA_EWAVEUNSUPP         (PJMEDIA_ERRNO_START+181)    /* 220181 */ 
     422/** 
     423 * @hideinitializer 
     424 * Wave file too short. 
     425 */ 
     426#define PJMEDIA_EWAVETOOSHORT       (PJMEDIA_ERRNO_START+182)    /* 220182 */ 
     427 
    409428 
    410429PJ_END_DECL 
  • pjproject/trunk/pjmedia/include/pjmedia/vad.h

    r203 r222  
    2323/** 
    2424 * @file vad.h 
    25  * @brief Voice Activity Detector. 
     25 * @brief Simple, adaptive silence detector. 
    2626 */ 
    2727#include <pjmedia/types.h> 
  • pjproject/trunk/pjmedia/src/pjmedia/conference.c

    r214 r222  
    600600    conf_port = conf->ports[slot]; 
    601601 
     602    info->slot = slot; 
    602603    info->name = conf_port->name; 
    603604    info->tx_setting = conf_port->tx_setting; 
     
    605606    info->listener = conf_port->listeners; 
    606607 
     608    return PJ_SUCCESS; 
     609} 
     610 
     611 
     612PJ_DEF(pj_status_t) pjmedia_conf_get_ports_info(pjmedia_conf *conf, 
     613                                                unsigned *size, 
     614                                                pjmedia_conf_port_info info[]) 
     615{ 
     616    unsigned i, count=0; 
     617 
     618    PJ_ASSERT_RETURN(conf && size && info, PJ_EINVAL); 
     619 
     620    for (i=0; i<conf->max_ports && count<*size; ++i) { 
     621        if (!conf->ports[i]) 
     622            continue; 
     623 
     624        pjmedia_conf_get_port_info(conf, i, &info[count]); 
     625        ++count; 
     626    } 
     627 
     628    *size = count; 
    607629    return PJ_SUCCESS; 
    608630} 
  • pjproject/trunk/pjmedia/src/pjmedia/errno.c

    r215 r222  
    113113    { PJMEDIA_ENCBITS,              "Media ports have incompatible bits per sample" }, 
    114114    { PJMEDIA_ENCBYTES,             "Media ports have incompatible bytes per frame" }, 
     115 
     116    /* Media file errors: */ 
     117    { PJMEDIA_ENOTVALIDWAVE,        "Not a valid WAVE file" }, 
     118    { PJMEDIA_EWAVEUNSUPP,          "Unsupported WAVE file format" }, 
     119    { PJMEDIA_EWAVETOOSHORT,        "WAVE file too short" }, 
    115120}; 
    116121 
  • pjproject/trunk/pjsip/src/pjsua/main.c

    r215 r222  
    262262static void conf_list(void) 
    263263{ 
    264     pjmedia_conf_port_info info; 
    265     struct pjsua_inv_data *inv_data; 
     264    unsigned i, count; 
     265    pjmedia_conf_port_info info[16]; 
    266266 
    267267    printf("Conference ports:\n"); 
    268268 
    269     inv_data = pjsua.inv_list.next; 
    270     while (inv_data != &pjsua.inv_list) { 
     269    count = PJ_ARRAY_SIZE(info); 
     270    pjmedia_conf_get_ports_info(pjsua.mconf, &count, info); 
     271    for (i=0; i<count; ++i) { 
     272        char txlist[80]; 
     273        unsigned j; 
     274        pjmedia_conf_port_info *port_info = &info[i];    
    271275         
    272         pjmedia_conf_get_port_info(pjsua.mconf, inv_data->conf_slot, &info); 
    273  
    274         printf("Port %2d %.*s\n", inv_data->conf_slot,  
    275                                   (int)info.name.slen, info.name.ptr); 
    276  
    277         inv_data = inv_data->next; 
    278     } 
     276        txlist[0] = '\0'; 
     277        for (j=0; j<pjsua.max_ports; ++j) { 
     278            char s[10]; 
     279            if (port_info->listener[j]) { 
     280                pj_sprintf(s, "#%d ", j); 
     281                pj_ansi_strcat(txlist, s); 
     282            } 
     283        } 
     284        printf("Port #%02d %20.*s  tx to: %s\n",  
     285               port_info->slot,  
     286               (int)port_info->name.slen,  
     287               port_info->name.ptr, 
     288               txlist); 
     289 
     290    } 
     291    puts(""); 
    279292} 
    280293 
  • pjproject/trunk/pjsip/src/pjsua/pjsua.h

    r212 r222  
    116116 
    117117    pjmedia_endpt   *med_endpt;     /**< Media endpoint.                */ 
     118    unsigned         max_ports;     /**< Max ports in conf.             */ 
    118119    pjmedia_conf    *mconf;         /**< Media conference.              */ 
    119120    pj_bool_t        null_audio;    /**< Null audio flag.               */ 
     121    char            *wav_file;      /**< WAV file name to play.         */ 
     122    unsigned         wav_slot;      /**< WAV player slot in bridge      */ 
    120123 
    121124 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_core.c

    r220 r222  
    7676 
    7777    pjsua.reg_timeout = 55; 
     78 
     79    /* Default maximum conference ports: */ 
     80 
     81    pjsua.max_ports = 8; 
    7882 
    7983    /* Init route set list: */ 
     
    518522    /* Init conference bridge. */ 
    519523 
    520     status = pjmedia_conf_create(pjsua.pool, 8, 8000, 160, 16, &pjsua.mconf); 
     524    status = pjmedia_conf_create(pjsua.pool, pjsua.max_ports,  
     525                                 8000, 160, 16, &pjsua.mconf); 
    521526    if (status != PJ_SUCCESS) { 
    522527        pj_caching_pool_destroy(&pjsua.cp); 
     
    554559    pjsip_transport *udp_transport; 
    555560    pj_status_t status = PJ_SUCCESS; 
     561 
     562    /* Create WAV file player if required: */ 
     563 
     564    if (pjsua.wav_file) { 
     565        pjmedia_port *port; 
     566        pj_str_t port_name; 
     567 
     568        /* Create the file player port. */ 
     569        status = pjmedia_file_player_port_create( pjsua.pool, pjsua.wav_file, 
     570                                                  0, -1, NULL, &port); 
     571        if (status != PJ_SUCCESS) { 
     572            pjsua_perror(THIS_FILE,  
     573                         "Error playing media file",  
     574                         status); 
     575            return status; 
     576        } 
     577 
     578        /* Add port to conference bridge: */ 
     579        status = pjmedia_conf_add_port(pjsua.mconf, pjsua.pool, port,  
     580                                       pj_cstr(&port_name, pjsua.wav_file), 
     581                                       &pjsua.wav_slot); 
     582        if (status != PJ_SUCCESS) { 
     583            pjsua_perror(THIS_FILE,  
     584                         "Unable to add file player to conference bridge",  
     585                         status); 
     586            return status; 
     587        } 
     588    } 
     589 
    556590 
    557591    /* Init sockets (STUN etc): */ 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_opt.c

    r197 r222  
    5656    puts("Media options:"); 
    5757    puts("  --null-audio        Use NULL audio device"); 
     58    puts("  --wav-file=file     Play WAV file in conference bridge"); 
     59    puts(""); 
    5860    //puts(""); 
    5961    //puts("User Agent options:"); 
     
    197199           OPT_USE_STUN1, OPT_USE_STUN2,  
    198200           OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE, 
    199            OPT_AUTO_ANSWER, OPT_AUTO_HANGUP}; 
     201           OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_WAV_FILE}; 
    200202    struct option long_options[] = { 
    201203        { "config-file",1, 0, OPT_CONFIG_FILE}, 
     
    223225        { "auto-answer",1, 0, OPT_AUTO_ANSWER}, 
    224226        { "auto-hangup",1, 0, OPT_AUTO_HANGUP}, 
     227        { "wav-file",  1, 0, OPT_WAV_FILE}, 
    225228        { NULL, 0, 0, 0} 
    226229    }; 
     
    405408            } 
    406409            pjsua.buddies[pjsua.buddy_cnt++].uri = pj_str(optarg); 
     410            break; 
     411 
     412        case OPT_WAV_FILE: 
     413            pjsua.wav_file = optarg; 
    407414            break; 
    408415        } 
Note: See TracChangeset for help on using the changeset viewer.