Changeset 5786


Ignore:
Timestamp:
04/24/18 00:27:57 (8 months ago)
Author:
ming
Message:

Fixed #2111: Add compile-time setting to specify DTMF duration in ms

Location:
pjproject/trunk/pjmedia
Files:
2 edited

Legend:

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

    r5752 r5786  
    413413 
    414414/** 
    415  * DTMF/telephone-event duration, in timestamp. 
     415 * DTMF/telephone-event duration, in timestamp. To specify the duration in 
     416 * milliseconds, use the setting PJMEDIA_DTMF_DURATION_MSEC instead. 
    416417 */ 
    417418#ifndef PJMEDIA_DTMF_DURATION            
    418419#  define PJMEDIA_DTMF_DURATION                 1600    /* in timestamp */ 
     420#endif 
     421 
     422 
     423/** 
     424 * DTMF/telephone-event duration, in milliseconds. If the value is greater 
     425 * than zero, than this setting will be used instead of PJMEDIA_DTMF_DURATION. 
     426 * 
     427 * Note that for a clockrate of 8 KHz, a dtmf duration of 1600 timestamp 
     428 * units (the default value of PJMEDIA_DTMF_DURATION) is equivalent to 200 ms.  
     429 */ 
     430#ifndef PJMEDIA_DTMF_DURATION_MSEC               
     431#  define PJMEDIA_DTMF_DURATION_MSEC            0 
    419432#endif 
    420433 
  • pjproject/trunk/pjmedia/src/pjmedia/stream.c

    r5785 r5786  
    174174 
    175175    /* RFC 2833 DTMF transmission queue: */ 
     176    unsigned                 dtmf_duration; /**< DTMF duration(in timestamp)*/ 
    176177    int                      tx_event_pt;   /**< Outgoing pt for dtmf.      */ 
    177178    int                      tx_dtmf_count; /**< # of digits in tx dtmf buf.*/ 
     
    956957 
    957958    digit->duration += stream->rtp_tx_ts_len_per_pkt; 
    958     if (digit->duration >= PJMEDIA_DTMF_DURATION) 
    959         digit->duration = PJMEDIA_DTMF_DURATION; 
     959    if (digit->duration >= stream->dtmf_duration) 
     960        digit->duration = stream->dtmf_duration; 
    960961 
    961962    event->event = (pj_uint8_t)digit->event; 
     
    964965 
    965966    if (forced_last) { 
    966         digit->duration = PJMEDIA_DTMF_DURATION; 
    967     } 
    968  
    969     if (digit->duration >= PJMEDIA_DTMF_DURATION) { 
     967        digit->duration = stream->dtmf_duration; 
     968    } 
     969 
     970    if (digit->duration >= stream->dtmf_duration) { 
    970971 
    971972        event->e_vol |= 0x80; 
     
    13041305             * RTP packets. 
    13051306             */ 
    1306             inc_timestamp = PJMEDIA_DTMF_DURATION + 
     1307            inc_timestamp = stream->dtmf_duration + 
    13071308                            ((DTMF_EBIT_RETRANSMIT_CNT-1) * 
    13081309                             stream->rtp_tx_ts_len_per_pkt) 
     
    23612362    stream->plc_cnt = stream->max_plc_cnt; 
    23622363 
     2364#if defined(PJMEDIA_DTMF_DURATION_MSEC) && (PJMEDIA_DTMF_DURATION_MSEC > 0) 
     2365    stream->dtmf_duration = PJMEDIA_DTMF_DURATION_MSEC * 
     2366                            afd->clock_rate / 1000; 
     2367#else 
     2368    stream->dtmf_duration = PJMEDIA_DTMF_DURATION; 
     2369#endif 
     2370 
    23632371#if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0) 
    23642372    stream->rtp_rx_check_cnt = 50; 
     
    23762384        /* RTP clock rate = 1/2 real clock rate */ 
    23772385        stream->rtp_tx_ts_len_per_pkt >>= 1; 
     2386#if defined(PJMEDIA_DTMF_DURATION_MSEC) && (PJMEDIA_DTMF_DURATION_MSEC > 0) 
     2387        stream->dtmf_duration >>= 1; 
     2388#endif 
    23782389    } else if (!pj_stricmp2(&info->fmt.encoding_name, "opus")) { 
    23792390        unsigned opus_ts_modifier = 48000 / afd->clock_rate; 
     
    23832394        stream->rtp_rx_ts_len_per_frame *= opus_ts_modifier; 
    23842395        stream->detect_ptime_change = PJ_TRUE; 
     2396#if defined(PJMEDIA_DTMF_DURATION_MSEC) && (PJMEDIA_DTMF_DURATION_MSEC > 0) 
     2397        stream->dtmf_duration *= opus_ts_modifier; 
     2398#endif 
    23852399    } 
    23862400#endif 
Note: See TracChangeset for help on using the changeset viewer.