Changeset 460


Ignore:
Timestamp:
May 20, 2006 1:01:07 PM (18 years ago)
Author:
bennylp
Message:

Set media thread in siprtp samples to highest priority to make RTCP jitter calculation as accurate as possible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/samples/siprtp.c

    r454 r460  
    8181#define THIS_FILE       "siprtp.c" 
    8282#define MAX_CALLS       1024 
    83 #define RTP_START_PORT  44100 
     83#define RTP_START_PORT  4000 
    8484 
    8585 
     
    368368        app.sip_endpt = NULL; 
    369369    } 
    370  
    371     if (app.pool) { 
    372         pj_pool_release(app.pool); 
    373         app.pool = NULL; 
    374         pj_caching_pool_destroy(&app.cp); 
    375     } 
    376370} 
    377371 
     
    431425         */ 
    432426        retry = 0; 
    433         do { 
     427        status = -1; 
     428        for (retry=0; status!=PJ_SUCCESS && retry<100; ++retry,rtp_port+=2) { 
    434429            struct media_stream *m = &app.call[i].media[0]; 
    435430 
    436             ++retry; 
    437             rtp_port += 2; 
    438431            m->port = rtp_port; 
    439432 
     
    466459            } 
    467460 
    468         } while (status != PJ_SUCCESS && retry < 100); 
     461        } 
    469462 
    470463        if (status != PJ_SUCCESS) 
     
    869862    app.thread_count = 1; 
    870863    app.sip_port = 5060; 
    871     app.rtp_start_port = 4000; 
     864    app.rtp_start_port = RTP_START_PORT; 
    872865    app.local_addr = ip_addr; 
    873866    app.log_level = 5; 
     
    10621055 
    10631056 
     1057#if defined(PJ_WIN32) && PJ_WIN32 != 0 
     1058#include <windows.h> 
     1059static void boost_priority(void) 
     1060{ 
     1061    SetPriorityClass( GetCurrentProcess(), REALTIME_PRIORITY_CLASS); 
     1062    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 
     1063} 
     1064 
     1065#else 
     1066#  define boost_priority() 
     1067#endif 
     1068 
    10641069/*  
    10651070 * Media thread  
     
    10741079    unsigned msec_interval; 
    10751080    pj_timestamp freq, next_rtp, next_rtcp; 
     1081 
     1082 
     1083    /* Boost thread priority if necessary */ 
     1084    boost_priority(); 
     1085 
    10761086 
    10771087    msec_interval = strm->samples_per_frame * 1000 / strm->clock_rate; 
     
    11171127        rc = pj_sock_select(FD_SETSIZE, &set, NULL, NULL, &timeout); 
    11181128 
     1129        if (rc < 0) { 
     1130            pj_thread_sleep(10); 
     1131            continue; 
     1132        } 
     1133 
    11191134        if (rc > 0 && PJ_FD_ISSET(strm->rtp_sock, &set)) { 
    11201135 
     
    11321147            if (status != PJ_SUCCESS) { 
    11331148                app_perror(THIS_FILE, "RTP recv() error", status); 
     1149                pj_thread_sleep(10); 
    11341150                continue; 
    11351151            } 
     
    11641180            size = sizeof(packet); 
    11651181            status = pj_sock_recv( strm->rtcp_sock, packet, &size, 0); 
    1166             if (status != PJ_SUCCESS) 
     1182            if (status != PJ_SUCCESS) { 
    11671183                app_perror(THIS_FILE, "Error receiving RTCP packet", status); 
    1168             else 
     1184                pj_thread_sleep(10); 
     1185            } else 
    11691186                pjmedia_rtcp_rx_rtcp(&strm->rtcp, packet, size); 
    11701187        } 
     
    17051722     
    17061723    /* Shutting down... */ 
     1724    destroy_sip(); 
    17071725    destroy_media(); 
    1708     destroy_sip(); 
     1726 
     1727    if (app.pool) { 
     1728        pj_pool_release(app.pool); 
     1729        app.pool = NULL; 
     1730        pj_caching_pool_destroy(&app.cp); 
     1731    } 
     1732 
    17091733    app_logging_shutdown(); 
    17101734 
Note: See TracChangeset for help on using the changeset viewer.