Changeset 4255 for pjproject


Ignore:
Timestamp:
Sep 14, 2012 1:18:57 PM (12 years ago)
Author:
bennylp
Message:

Transmit DTMF with 'End' bit when the stream is being destroyed. This closes #1582

File:
1 edited

Legend:

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

    r4254 r4255  
    877877static void create_dtmf_payload(pjmedia_stream *stream,  
    878878                                struct pjmedia_frame *frame_out, 
    879                                 int *first, int *last) 
     879                                int forced_last, int *first, int *last) 
    880880{ 
    881881    pjmedia_rtp_dtmf_event *event; 
     
    903903 
    904904 
    905     if (digit->duration >= PJMEDIA_DTMF_DURATION) { 
     905    if (forced_last || digit->duration >= PJMEDIA_DTMF_DURATION) { 
    906906 
    907907        event->e_vol |= 0x80; 
     
    12181218        int first=0, last=0; 
    12191219 
    1220         create_dtmf_payload(stream, &frame_out, &first, &last); 
     1220        create_dtmf_payload(stream, &frame_out, 0, &first, &last); 
    12211221 
    12221222        /* Encapsulate into RTP packet. Note that: 
     
    24162416PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream ) 
    24172417{ 
     2418    pj_status_t status; 
     2419 
    24182420    PJ_ASSERT_RETURN(stream != NULL, PJ_EINVAL); 
    24192421 
     
    24212423    if (!stream->rtcp_sdes_bye_disabled) { 
    24222424        send_rtcp(stream, PJ_TRUE, PJ_TRUE, PJ_TRUE); 
     2425    } 
     2426 
     2427    /* If we're in the middle of transmitting DTMF digit, send one last 
     2428     * RFC 2833 RTP packet with 'End' flag set. 
     2429     */ 
     2430    if (stream->tx_dtmf_count && stream->tx_dtmf_buf[0].duration != 0) { 
     2431        pjmedia_frame frame_out; 
     2432        pjmedia_channel *channel = stream->enc; 
     2433        int first=0, last=0; 
     2434        void *rtphdr; 
     2435        int rtphdrlen; 
     2436 
     2437        pj_bzero(&frame_out, sizeof(frame_out)); 
     2438        frame_out.buf = ((char*)channel->out_pkt) + sizeof(pjmedia_rtp_hdr); 
     2439        frame_out.size = 0; 
     2440 
     2441        create_dtmf_payload(stream, &frame_out, 1, &first, &last); 
     2442 
     2443        /* Encapsulate into RTP packet. Note that: 
     2444         *  - RTP marker should be set on the beginning of a new event 
     2445         *  - RTP timestamp is constant for the same packet. 
     2446         */ 
     2447        status = pjmedia_rtp_encode_rtp( &channel->rtp, 
     2448                                         stream->tx_event_pt, first, 
     2449                                         frame_out.size, 0, 
     2450                                         (const void**)&rtphdr, 
     2451                                         &rtphdrlen); 
     2452        if (status == PJ_SUCCESS) { 
     2453            /* Copy RTP header to the beginning of packet */ 
     2454            pj_memcpy(channel->out_pkt, rtphdr, sizeof(pjmedia_rtp_hdr)); 
     2455 
     2456            /* Send the RTP packet to the transport. */ 
     2457            status = pjmedia_transport_send_rtp(stream->transport, 
     2458                                                channel->out_pkt, 
     2459                                                frame_out.size + 
     2460                                                    sizeof(pjmedia_rtp_hdr)); 
     2461        } 
     2462 
     2463        if (status != PJ_SUCCESS) { 
     2464            PJ_PERROR(4,(stream->port.info.name.ptr, status, 
     2465                         "Error sending RTP/DTMF end packet")); 
     2466        } 
    24232467    } 
    24242468 
Note: See TracChangeset for help on using the changeset viewer.