Ignore:
Timestamp:
Feb 17, 2009 3:19:45 PM (15 years ago)
Author:
bennylp
Message:

Added bitrate and vad info in pjmedia_format, and changed audio route to use enumeration rather than boolean

Location:
pjproject/branches/projects/aps-direct
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/codec.h

    r2456 r2457  
    276276       pj_uint8_t  pcm_bits_per_sample; /**< Bits/sample in the PCM side    */ 
    277277       pj_uint8_t  pt;                  /**< Payload type.                  */ 
    278        pjmedia_format format;           /**< Source format, it's format of 
     278       pjmedia_format_id fmt_id;        /**< Source format, it's format of 
    279279                                             encoder input and decoder  
    280280                                             output.                        */ 
  • pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/sound.h

    r2456 r2457  
    9393} pjmedia_snd_stream_info; 
    9494 
     95/** 
     96 * Audio routing destination. 
     97 */ 
     98typedef enum pjmedia_snd_route 
     99{ 
     100    /** Route to default destination */ 
     101    PJMEDIA_SND_ROUTE_DEFAULT, 
     102 
     103    /** Route to loudspeaker */ 
     104    PJMEDIA_SND_ROUTE_LOUDSPEAKER, 
     105 
     106    /** Route to earpiece */ 
     107    PJMEDIA_SND_ROUTE_EARPIECE, 
     108 
     109} pjmedia_snd_route; 
     110 
    95111 
    96112/**  
     
    100116{ 
    101117    pjmedia_format      format;   /**< Format.                      */  
    102     pj_uint32_t         bitrate;  /**< Bitrate (bps).               */ 
    103     pj_uint32_t         mode;     /**< Mode, e.g: iLBC format has 
    104                                        20ms or 30ms frame size.     */ 
    105118    pj_bool_t           plc;      /**< PLC enabled/disabled.        */ 
    106     pj_bool_t           vad;      /**< VAD enabled/disabled.        */ 
    107119    pj_bool_t           cng;      /**< CNG enabled/disabled.        */ 
    108     pj_bool_t           loudspk;  /**< Audio routed to loudspeaker. */ 
     120    pjmedia_snd_route   route;    /**< Audio routing.              */ 
    109121} pjmedia_snd_setting; 
    110122 
  • pjproject/branches/projects/aps-direct/pjmedia/include/pjmedia/types.h

    r2456 r2457  
    179179} pjmedia_sock_info; 
    180180 
    181 /** 
    182  * Declaration of format. 
    183  */ 
    184 typedef union pjmedia_format { 
    185    pj_uint32_t  u32; 
    186    char         c[4]; 
     181 
     182/** 
     183 * Macro for packing format. 
     184 */ 
     185#define PJMEDIA_FORMAT_PACK(C1, C2, C3, C4) ( C4<<24 | C3<<16 | C2<<8 | C1 ) 
     186 
     187/** 
     188 * Format identifier definition. 
     189 */ 
     190typedef enum pjmedia_format_id 
     191{ 
     192    PJMEDIA_FORMAT_L16      = 0, 
     193    PJMEDIA_FORMAT_PCMA     = PJMEDIA_FORMAT_PACK('A', 'L', 'A', 'W'), 
     194    PJMEDIA_FORMAT_PCMU     = PJMEDIA_FORMAT_PACK('u', 'L', 'A', 'W'), 
     195    PJMEDIA_FORMAT_AMR      = PJMEDIA_FORMAT_PACK(' ', 'A', 'M', 'R'), 
     196    PJMEDIA_FORMAT_G729     = PJMEDIA_FORMAT_PACK('G', '7', '2', '9'), 
     197    PJMEDIA_FORMAT_ILBC     = PJMEDIA_FORMAT_PACK('I', 'L', 'B', 'C') 
     198} pjmedia_format_id; 
     199 
     200 
     201/** 
     202 * Media format information. 
     203 */ 
     204typedef struct pjmedia_format 
     205{ 
     206    /** Format ID */ 
     207    pjmedia_format_id   fmt_id; 
     208 
     209    /** Bitrate. */ 
     210    pj_uint32_t         bitrate; 
     211 
     212    /** Flag to indicate whether VAD is enabled */ 
     213    pj_bool_t           vad; 
     214 
    187215} pjmedia_format; 
    188216 
    189  
    190 /** 
    191  * Macro for packing format. 
    192  */ 
    193 #define PJMEDIA_FORMAT_PACK(C1, C2, C3, C4) ( C4<<24 | C3<<16 | C2<<8 | C1 ) 
    194  
    195 /** 
    196  * Format identifier definitions. 
    197  */ 
    198 #define PJMEDIA_FORMAT_L16      0 
    199 #define PJMEDIA_FORMAT_PCMA     PJMEDIA_FORMAT_PACK('A', 'L', 'A', 'W') 
    200 #define PJMEDIA_FORMAT_PCMU     PJMEDIA_FORMAT_PACK('u', 'L', 'A', 'W') 
    201 #define PJMEDIA_FORMAT_AMR      PJMEDIA_FORMAT_PACK(' ', 'A', 'M', 'R') 
    202 #define PJMEDIA_FORMAT_G729     PJMEDIA_FORMAT_PACK('G', '7', '2', '9') 
    203 #define PJMEDIA_FORMAT_ILBC     PJMEDIA_FORMAT_PACK('I', 'L', 'B', 'C') 
    204217 
    205218 
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia-codec/passthrough.c

    r2456 r2457  
    156156    const char      *name;              /* Codec name.                      */ 
    157157    pj_uint8_t       pt;                /* Payload type.                    */ 
    158     pjmedia_format   format;            /* Source format.                   */ 
     158    pjmedia_format_id fmt_id;           /* Source format.                   */ 
    159159    unsigned         clock_rate;        /* Codec's clock rate.              */ 
    160160    unsigned         channel_count;     /* Codec's channel count.           */ 
     
    173173{ 
    174174#   if PJMEDIA_HAS_PASSTHROUGH_CODEC_AMR 
    175     {1, "AMR",      PJMEDIA_RTP_PT_AMR,       {PJMEDIA_FORMAT_AMR}, 
     175    {1, "AMR",      PJMEDIA_RTP_PT_AMR,       PJMEDIA_FORMAT_AMR, 
    176176                    8000, 1, 160,  
    177177                    7400, 12200, 2, 1, 1, 
     
    182182 
    183183#   if PJMEDIA_HAS_PASSTHROUGH_CODEC_G729 
    184     {1, "G729",     PJMEDIA_RTP_PT_G729,      {PJMEDIA_FORMAT_G729}, 
     184    {1, "G729",     PJMEDIA_RTP_PT_G729,      PJMEDIA_FORMAT_G729, 
    185185                    8000, 1,  80, 
    186186                    8000, 8000, 2, 1, 1 
     
    189189 
    190190#   if PJMEDIA_HAS_PASSTHROUGH_CODEC_ILBC 
    191     {1, "iLBC",     PJMEDIA_RTP_PT_ILBC,      {PJMEDIA_FORMAT_ILBC}, 
     191    {1, "iLBC",     PJMEDIA_RTP_PT_ILBC,      PJMEDIA_FORMAT_ILBC, 
    192192                    8000, 1,  240, 
    193193                    13333, 15200, 1, 1, 1, 
     
    198198 
    199199#   if PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMU 
    200     {1, "PCMU",     PJMEDIA_RTP_PT_PCMU,      {PJMEDIA_FORMAT_PCMU}, 
     200    {1, "PCMU",     PJMEDIA_RTP_PT_PCMU,      PJMEDIA_FORMAT_PCMU, 
    201201                    8000, 1,  80, 
    202202                    64000, 64000, 2, 1, 1 
     
    205205 
    206206#   if PJMEDIA_HAS_PASSTHROUGH_CODEC_PCMA 
    207     {1, "PCMA",     PJMEDIA_RTP_PT_PCMA,      {PJMEDIA_FORMAT_PCMA}, 
     207    {1, "PCMA",     PJMEDIA_RTP_PT_PCMA,      PJMEDIA_FORMAT_PCMA, 
    208208                    8000, 1,  80, 
    209209                    64000, 64000, 2, 1, 1 
     
    450450                                    codec_desc[i].channel_count /  
    451451                                    codec_desc[i].clock_rate); 
    452             attr->info.format = codec_desc[i].format; 
     452            attr->info.fmt_id = codec_desc[i].fmt_id; 
    453453 
    454454            /* Default flags. */ 
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c

    r2456 r2457  
    589589 
    590590    /* Source and sink format must match. */ 
    591     if (src_port->info->format.u32 != dst_port->info->format.u32) { 
     591    if (src_port->info->format.fmt_id != dst_port->info->format.fmt_id) { 
    592592        pj_mutex_unlock(conf->mutex); 
    593593        return PJMEDIA_ENOTCOMPATIBLE; 
     
    952952 
    953953    /* Level adjustment is applicable only for ports that work with raw PCM. */ 
    954     PJ_ASSERT_RETURN(conf_port->info->format.u32 == PJMEDIA_FORMAT_L16, 
     954    PJ_ASSERT_RETURN(conf_port->info->format.fmt_id == PJMEDIA_FORMAT_L16, 
    955955                     PJ_EIGNORED); 
    956956 
     
    986986 
    987987    /* Level adjustment is applicable only for ports that work with raw PCM. */ 
    988     PJ_ASSERT_RETURN(conf_port->info->format.u32 == PJMEDIA_FORMAT_L16, 
     988    PJ_ASSERT_RETURN(conf_port->info->format.fmt_id == PJMEDIA_FORMAT_L16, 
    989989                     PJ_EIGNORED); 
    990990 
     
    11111111        /* Check port format. */ 
    11121112        if (cport_dst->port && 
    1113             cport_dst->port->info.format.u32 == PJMEDIA_FORMAT_L16) 
     1113            cport_dst->port->info.format.fmt_id == PJMEDIA_FORMAT_L16) 
    11141114        { 
    11151115            /* When there is already some samples in listener's TX buffer,  
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/sound_port.c

    r2456 r2457  
    290290        unsigned i, size_decoded; 
    291291 
    292         switch (snd_port->setting.format.u32) { 
     292        switch (snd_port->setting.format.fmt_id) { 
    293293        case PJMEDIA_FORMAT_PCMA: 
    294294            decoder = &pjmedia_alaw_decode; 
     
    299299        default: 
    300300            PJ_LOG(1,(THIS_FILE, "Unsupported format %d",  
    301                       snd_port->setting.format.u32)); 
     301                      snd_port->setting.format.fmt_id)); 
    302302            goto no_frame; 
    303303        } 
     
    392392    fx->base.timestamp.u32.lo = timestamp; 
    393393 
    394     switch (snd_port->setting.format.u32) { 
     394    switch (snd_port->setting.format.fmt_id) { 
    395395    case PJMEDIA_FORMAT_PCMA: 
    396396        encoder = &pjmedia_alaw_encode; 
     
    401401    default: 
    402402        PJ_LOG(1,(THIS_FILE, "Unsupported format %d",  
    403                   snd_port->setting.format.u32)); 
     403                  snd_port->setting.format.fmt_id)); 
    404404        return PJ_SUCCESS; 
    405405    } 
     
    435435                     PJ_EBUG); 
    436436 
    437     if (snd_port->setting.format.u32 == PJMEDIA_FORMAT_L16) { 
     437    if (snd_port->setting.format.fmt_id == PJMEDIA_FORMAT_L16) { 
    438438        snd_rec_cb = &rec_cb; 
    439439        snd_play_cb = &play_cb; 
     
    716716#if !defined(PJMEDIA_SND_SUPPORT_OPEN2) || PJMEDIA_SND_SUPPORT_OPEN2==0 
    717717    /* For devices that doesn't support open2(), enable simulation */ 
    718     if (snd_port->setting.format.u32 != PJMEDIA_FORMAT_L16) { 
     718    if (snd_port->setting.format.fmt_id != PJMEDIA_FORMAT_L16) { 
    719719        snd_port->frm_buf_size = sizeof(pjmedia_frame_ext) +  
    720720                                 (samples_per_frame << 1) + 
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/stream.c

    r2456 r2457  
    868868    } else if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO && 
    869869               frame->buf == NULL && 
    870                stream->port.info.format.u32 == PJMEDIA_FORMAT_L16 && 
     870               stream->port.info.format.fmt_id == PJMEDIA_FORMAT_L16 && 
    871871               (stream->dir & PJMEDIA_DIR_ENCODING) && 
    872872               stream->codec_param.info.frm_ptime * 
     
    16061606    stream->port.info.clock_rate = info->fmt.clock_rate; 
    16071607    stream->port.info.channel_count = info->fmt.channel_cnt; 
    1608     stream->port.info.format = info->param->info.format; 
     1608    stream->port.info.format.fmt_id = info->param->info.fmt_id; 
     1609    stream->port.info.format.bitrate = info->param->info.avg_bps; 
     1610    stream->port.info.format.vad = (info->param->setting.vad != 0); 
    16091611    stream->port.port_data.pdata = stream; 
    1610     if (stream->port.info.format.u32 == PJMEDIA_FORMAT_L16) { 
     1612    if (stream->port.info.format.fmt_id == PJMEDIA_FORMAT_L16) { 
    16111613        stream->port.put_frame = &put_frame; 
    16121614        stream->port.get_frame = &get_frame; 
  • pjproject/branches/projects/aps-direct/pjsip-apps/src/pjsua/pjsua_app.c

    r2454 r2457  
    24342434    pjmedia_port *conf; 
    24352435    pjmedia_session_info sess_info; 
     2436    pjmedia_port *port; 
    24362437    pjmedia_stream_info *strm_info; 
    24372438    pjmedia_snd_setting setting; 
     
    24462447    strm_info = &sess_info.stream_info[stream_idx]; 
    24472448 
     2449    pjmedia_session_get_port(sess, stream_idx, &port); 
     2450 
    24482451    /* Init sound device setting based on stream info. */ 
    24492452    pj_bzero(&setting, sizeof(setting)); 
    2450     setting.format = strm_info->param->info.format; 
    2451     setting.bitrate = strm_info->param->info.avg_bps; 
     2453    setting.format = port->info.format; 
    24522454    setting.cng = strm_info->param->setting.cng; 
    2453     setting.vad = strm_info->param->setting.vad; 
    24542455    setting.plc = strm_info->param->setting.plc; 
    24552456 
Note: See TracChangeset for help on using the changeset viewer.