Changeset 2024


Ignore:
Timestamp:
Jun 14, 2008 10:43:56 PM (16 years ago)
Author:
bennylp
Message:

Changed tonegen to use native clock rate, and other minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r2023 r2024  
    2525//#define STEREO_DEMO 
    2626 
    27 /* Ringtones */ 
    28 #define RINGBACK_FREQ1  440 
    29 #define RINGBACK_FREQ2  480 
    30 #define RINGBACK_ON     2000 
    31 #define RINGBACK_OFF    4000 
    32  
    33 #define RING_FREQ1      500 
    34 #define RING_FREQ2      660 
    35 #define RING_ON         100 
    36 #define RING_OFF        100 
    37 #define RING_INTERVAL   4000 
     27/* Ringtones                US         UK  */ 
     28#define RINGBACK_FREQ1      440     /* 400 */ 
     29#define RINGBACK_FREQ2      480     /* 450 */ 
     30#define RINGBACK_ON         2000    /* 400 */ 
     31#define RINGBACK_OFF        4000    /* 200 */ 
     32#define RINGBACK_CNT        1       /* 2   */ 
     33#define RINGBACK_INTERVAL   4000    /* 2000 */ 
     34 
     35#define RING_FREQ1          800 
     36#define RING_FREQ2          640 
     37#define RING_ON             200 
     38#define RING_OFF            100 
     39#define RING_CNT            3 
     40#define RING_INTERVAL       3000 
    3841 
    3942 
     
    38113814    /* Create ringback tones */ 
    38123815    if (app_config.no_tones == PJ_FALSE) { 
    3813         unsigned i; 
    3814         pjmedia_tone_desc tone[3]; 
     3816        unsigned i, samples_per_frame; 
     3817        pjmedia_tone_desc tone[RING_CNT+RINGBACK_CNT]; 
    38153818        pj_str_t name; 
     3819 
     3820        samples_per_frame = app_config.media_cfg.audio_frame_ptime *  
     3821                            app_config.media_cfg.clock_rate * 
     3822                            app_config.media_cfg.channel_count / 1000; 
    38163823 
    38173824        /* Ringback tone (call is ringing) */ 
    38183825        name = pj_str("ringback"); 
    3819         status = pjmedia_tonegen_create2(app_config.pool, &name, 8000, 1, 160, 
     3826        status = pjmedia_tonegen_create2(app_config.pool, &name,  
     3827                                         app_config.media_cfg.clock_rate, 
     3828                                         app_config.media_cfg.channel_count,  
     3829                                         samples_per_frame, 
    38203830                                         16, PJMEDIA_TONEGEN_LOOP,  
    38213831                                         &app_config.ringback_port); 
     
    38243834 
    38253835        pj_bzero(&tone, sizeof(tone)); 
    3826         tone[0].freq1 = RINGBACK_FREQ1; 
    3827         tone[0].freq2 = RINGBACK_FREQ2; 
    3828         tone[0].on_msec = RINGBACK_ON; 
    3829         tone[0].off_msec = RINGBACK_OFF; 
    3830  
    3831         pjmedia_tonegen_play(app_config.ringback_port, 1, &tone[0],  
     3836        for (i=0; i<RINGBACK_CNT; ++i) { 
     3837            tone[i].freq1 = RINGBACK_FREQ1; 
     3838            tone[i].freq2 = RINGBACK_FREQ2; 
     3839            tone[i].on_msec = RINGBACK_ON; 
     3840            tone[i].off_msec = RINGBACK_OFF; 
     3841        } 
     3842        tone[RINGBACK_CNT-1].off_msec = RINGBACK_INTERVAL; 
     3843 
     3844        pjmedia_tonegen_play(app_config.ringback_port, RINGBACK_CNT, tone, 
    38323845                             PJMEDIA_TONEGEN_LOOP); 
    38333846 
     
    38403853        /* Ring (to alert incoming call) */ 
    38413854        name = pj_str("ring"); 
    3842         status = pjmedia_tonegen_create2(app_config.pool, &name, 8000, 1, 160, 
     3855        status = pjmedia_tonegen_create2(app_config.pool, &name,  
     3856                                         app_config.media_cfg.clock_rate, 
     3857                                         app_config.media_cfg.channel_count,  
     3858                                         samples_per_frame, 
    38433859                                         16, PJMEDIA_TONEGEN_LOOP,  
    38443860                                         &app_config.ring_port); 
     
    38463862            goto on_error; 
    38473863 
    3848         for (i=0; i<PJ_ARRAY_SIZE(tone); ++i) { 
     3864        for (i=0; i<RING_CNT; ++i) { 
    38493865            tone[i].freq1 = RING_FREQ1; 
    38503866            tone[i].freq2 = RING_FREQ2; 
     
    38523868            tone[i].off_msec = RING_OFF; 
    38533869        } 
    3854         tone[PJ_ARRAY_SIZE(tone)-1].off_msec = RING_INTERVAL; 
    3855  
    3856         pjmedia_tonegen_play(app_config.ring_port, PJ_ARRAY_SIZE(tone),  
     3870        tone[RING_CNT-1].off_msec = RING_INTERVAL; 
     3871 
     3872        pjmedia_tonegen_play(app_config.ring_port, RING_CNT,  
    38573873                             tone, PJMEDIA_TONEGEN_LOOP); 
    38583874 
Note: See TracChangeset for help on using the changeset viewer.