Ignore:
Timestamp:
Feb 22, 2006 12:06:39 PM (18 years ago)
Author:
bennylp
Message:

RFC 2833 support!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/session.c

    r205 r215  
    3434    pjmedia_stream_info     stream_info[PJMEDIA_MAX_SDP_MEDIA]; 
    3535    pjmedia_stream         *stream[PJMEDIA_MAX_SDP_MEDIA]; 
     36    void                   *user_data; 
    3637}; 
    3738 
     
    4849static const pj_str_t ID_SDP_NAME = { "pjmedia", 7 }; 
    4950static const pj_str_t ID_RTPMAP = { "rtpmap", 6 }; 
     51static const pj_str_t ID_TELEPHONE_EVENT = { "telephone-event", 15 }; 
    5052 
    5153static const pj_str_t STR_INACTIVE = { "inactive", 8 }; 
     
    6769    const pjmedia_sdp_attr *attr; 
    6870    pjmedia_sdp_rtpmap *rtpmap; 
     71    unsigned i; 
    6972    pj_status_t status; 
    7073 
     
    152155     * type without rtpmap. 
    153156     */ 
    154     attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP, NULL); 
     157    attr = pjmedia_sdp_media_find_attr(local_m, &ID_RTPMAP,  
     158                                       &local_m->desc.fmt[0]); 
    155159    if (attr == NULL) 
    156160        return PJMEDIA_EMISSINGRTPMAP; 
     
    166170    pj_strdup(pool, &si->fmt.encoding_name, &rtpmap->enc_name); 
    167171    si->fmt.sample_rate = rtpmap->clock_rate; 
     172 
     173    /* Get local DTMF payload type */ 
     174    si->tx_event_pt = -1; 
     175    for (i=0; i<local_m->attr_count; ++i) { 
     176        pjmedia_sdp_rtpmap r; 
     177 
     178        attr = local_m->attr[i]; 
     179        if (pj_strcmp(&attr->name, &ID_RTPMAP) != 0) 
     180            continue; 
     181        if (pjmedia_sdp_attr_get_rtpmap(attr, &r) != PJ_SUCCESS) 
     182            continue; 
     183        if (pj_strcmp(&r.enc_name, &ID_TELEPHONE_EVENT) == 0) { 
     184            si->tx_event_pt = pj_strtoul(&r.pt); 
     185            break; 
     186        } 
     187    } 
     188 
     189    /* Get remote DTMF payload type */ 
     190    si->rx_event_pt = -1; 
     191    for (i=0; i<rem_m->attr_count; ++i) { 
     192        pjmedia_sdp_rtpmap r; 
     193 
     194        attr = rem_m->attr[i]; 
     195        if (pj_strcmp(&attr->name, &ID_RTPMAP) != 0) 
     196            continue; 
     197        if (pjmedia_sdp_attr_get_rtpmap(attr, &r) != PJ_SUCCESS) 
     198            continue; 
     199        if (pj_strcmp(&r.enc_name, &ID_TELEPHONE_EVENT) == 0) { 
     200            si->rx_event_pt = pj_strtoul(&r.pt); 
     201            break; 
     202        } 
     203    } 
     204 
    168205 
    169206    /* Leave SSRC to zero. */ 
     
    183220                                            const pjmedia_sdp_session *local_sdp, 
    184221                                            const pjmedia_sdp_session *rem_sdp, 
     222                                            void *user_data, 
    185223                                            pjmedia_session **p_session ) 
    186224{ 
     
    204242    session->endpt = endpt; 
    205243    session->stream_cnt = stream_cnt; 
     244    session->user_data = user_data; 
    206245     
    207246    /* Stream count is the lower number of stream_cnt or SDP m= lines count */ 
     
    240279        status = pjmedia_stream_create(endpt, session->pool, 
    241280                                       &session->stream_info[i], 
     281                                       session, 
    242282                                       &session->stream[i]); 
    243283        if (status == PJ_SUCCESS) 
     
    386426 
    387427 
     428/* 
     429 * Get the port interface. 
     430 */ 
    388431PJ_DEF(pj_status_t) pjmedia_session_get_port(  pjmedia_session *session, 
    389432                                               unsigned index, 
     
    393436} 
    394437 
    395 /** 
     438/* 
    396439 * Get statistics 
    397440 */ 
     
    407450 
    408451 
     452/* 
     453 * Dial DTMF digit to the stream, using RFC 2833 mechanism. 
     454 */ 
     455PJ_DEF(pj_status_t) pjmedia_session_dial_dtmf( pjmedia_session *session, 
     456                                               unsigned index, 
     457                                               const pj_str_t *ascii_digits ) 
     458{ 
     459    PJ_ASSERT_RETURN(session && ascii_digits, PJ_EINVAL); 
     460    return pjmedia_stream_dial_dtmf(session->stream[index], ascii_digits); 
     461} 
     462 
     463/* 
     464 * Check if the specified stream has received DTMF digits. 
     465 */ 
     466PJ_DEF(pj_status_t) pjmedia_session_check_dtmf( pjmedia_session *session, 
     467                                                unsigned index ) 
     468{ 
     469    PJ_ASSERT_RETURN(session, PJ_EINVAL); 
     470    return pjmedia_stream_check_dtmf(session->stream[index]); 
     471} 
     472 
     473 
     474/* 
     475 * Retrieve DTMF digits from the specified stream. 
     476 */ 
     477PJ_DEF(pj_status_t) pjmedia_session_get_dtmf( pjmedia_session *session, 
     478                                              unsigned index, 
     479                                              char *ascii_digits, 
     480                                              unsigned *size ) 
     481{ 
     482    PJ_ASSERT_RETURN(session && ascii_digits && size, PJ_EINVAL); 
     483    return pjmedia_stream_get_dtmf(session->stream[index], ascii_digits, 
     484                                   size); 
     485} 
Note: See TracChangeset for help on using the changeset viewer.