Changeset 3360


Ignore:
Timestamp:
Nov 3, 2010 6:46:27 AM (13 years ago)
Author:
bennylp
Message:

Fixed #1154 (Run-time option to disable telephone-event in outgoing SDP offer (thanks Marcus Froeschl for the suggestion))

Location:
pjproject/trunk/pjmedia
Files:
2 edited

Legend:

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

    r2506 r3360  
    4343 
    4444PJ_BEGIN_DECL 
     45 
     46/** 
     47 * This enumeration describes various flags that can be set or retrieved in 
     48 * the media endpoint, by using pjmedia_endpt_set_flag() and 
     49 * pjmedia_endpt_get_flag() respectively. 
     50 */ 
     51typedef enum pjmedia_endpt_flag 
     52{ 
     53    /** 
     54     * This flag controls whether telephony-event should be offered in SDP. 
     55     * Value is boolean. 
     56     */ 
     57    PJMEDIA_ENDPT_HAS_TELEPHONE_EVENT_FLAG 
     58 
     59} pjmedia_endpt_flag; 
    4560 
    4661 
     
    7489PJ_DECL(pj_status_t) pjmedia_endpt_destroy(pjmedia_endpt *endpt); 
    7590 
    76  
     91/** 
     92 * Change the value of a flag. 
     93 * 
     94 * @param endpt         Media endpoint. 
     95 * @param flag          The flag. 
     96 * @param value         Pointer to the value to be set. 
     97 * 
     98 * @reurn               PJ_SUCCESS on success. 
     99 */ 
     100PJ_DECL(pj_status_t) pjmedia_endpt_set_flag(pjmedia_endpt *endpt, 
     101                                            pjmedia_endpt_flag flag, 
     102                                            const void *value); 
     103 
     104/** 
     105 *  Retrieve the value of a flag. 
     106 * 
     107 *  @param endpt        Media endpoint. 
     108 *  @param flag         The flag. 
     109 *  @param value        Pointer to store the result. 
     110 * 
     111 *  @return             PJ_SUCCESS on success. 
     112 */ 
     113PJ_DECL(pj_status_t) pjmedia_endpt_get_flag(pjmedia_endpt *endpt, 
     114                                            pjmedia_endpt_flag flag, 
     115                                            void *value); 
    77116 
    78117/** 
  • pjproject/trunk/pjmedia/src/pjmedia/endpoint.c

    r3204 r3360  
    8888    /** To signal polling thread to quit. */ 
    8989    pj_bool_t             quit_flag; 
     90 
     91    /** Is telephone-event enable */ 
     92    pj_bool_t             has_telephone_event; 
    9093}; 
    9194 
     
    121124    endpt->ioqueue = ioqueue; 
    122125    endpt->thread_cnt = worker_cnt; 
     126    endpt->has_telephone_event = PJ_TRUE; 
    123127 
    124128    /* Sound */ 
     
    222226} 
    223227 
     228PJ_DEF(pj_status_t) pjmedia_endpt_set_flag( pjmedia_endpt *endpt, 
     229                                            pjmedia_endpt_flag flag, 
     230                                            const void *value) 
     231{ 
     232    PJ_ASSERT_RETURN(endpt, PJ_EINVAL); 
     233 
     234    switch (flag) { 
     235    case PJMEDIA_ENDPT_HAS_TELEPHONE_EVENT_FLAG: 
     236        endpt->has_telephone_event = *(pj_bool_t*)value; 
     237        break; 
     238    default: 
     239        return PJ_EINVAL; 
     240    } 
     241 
     242    return PJ_SUCCESS; 
     243} 
     244 
     245PJ_DEF(pj_status_t) pjmedia_endpt_get_flag( pjmedia_endpt *endpt, 
     246                                            pjmedia_endpt_flag flag, 
     247                                            void *value) 
     248{ 
     249    PJ_ASSERT_RETURN(endpt, PJ_EINVAL); 
     250 
     251    switch (flag) { 
     252    case PJMEDIA_ENDPT_HAS_TELEPHONE_EVENT_FLAG: 
     253        *(pj_bool_t*)value = endpt->has_telephone_event; 
     254        break; 
     255    default: 
     256        return PJ_EINVAL; 
     257    } 
     258 
     259    return PJ_SUCCESS; 
     260} 
    224261 
    225262/** 
     
    490527#if defined(PJMEDIA_RTP_PT_TELEPHONE_EVENTS) && \ 
    491528    PJMEDIA_RTP_PT_TELEPHONE_EVENTS != 0 
    492  
    493529    /* 
    494530     * Add support telephony event 
    495531     */ 
    496     m->desc.fmt[m->desc.fmt_count++] =  
    497         pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR); 
    498  
    499     /* Add rtpmap. */ 
    500     attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 
    501     attr->name = pj_str("rtpmap"); 
    502     attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR  
    503                          " telephone-event/8000"); 
    504     m->attr[m->attr_count++] = attr; 
    505  
    506     /* Add fmtp */ 
    507     attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 
    508     attr->name = pj_str("fmtp"); 
    509     attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-15"); 
    510     m->attr[m->attr_count++] = attr; 
     532    if (endpt->has_telephone_event) { 
     533        m->desc.fmt[m->desc.fmt_count++] = 
     534            pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR); 
     535 
     536        /* Add rtpmap. */ 
     537        attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 
     538        attr->name = pj_str("rtpmap"); 
     539        attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR 
     540                             " telephone-event/8000"); 
     541        m->attr[m->attr_count++] = attr; 
     542 
     543        /* Add fmtp */ 
     544        attr = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_attr); 
     545        attr->name = pj_str("fmtp"); 
     546        attr->value = pj_str(PJMEDIA_RTP_PT_TELEPHONE_EVENTS_STR " 0-15"); 
     547        m->attr[m->attr_count++] = attr; 
     548    } 
    511549#endif 
    512550 
Note: See TracChangeset for help on using the changeset viewer.