Changes in [1368:ac122ded501e:1376:38e481f9389c] in mediastreamer2


Ignore:
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • autogen.sh

    r1344 r1370  
    1010        AUTOMAKE=automake-${AM_VERSION} 
    1111fi 
     12 
     13INTLTOOLIZE=/usr/bin/intltoolize 
     14 
     15if test -f /opt/local/bin/intltoolize ; then 
     16INTLTOOLIZE=/opt/local/bin/intltoolize 
     17else 
     18INTLTOOLIZE=/usr/bin/intltoolize 
     19fi 
     20 
    1221 
    1322libtoolize="libtoolize" 
     
    4453set -x 
    4554$libtoolize --copy --force 
    46 intltoolize --copy --force --automake 
     55$INTLTOOLIZE --copy --force --automake 
    4756$ACLOCAL  $ACLOCAL_ARGS 
    4857autoheader 
  • configure.ac

    r1361 r1374  
    8181 
    8282AC_SUBST([LIBTOOL_DEPS]) 
    83  
    84 dnl localization tools 
    85 IT_PROG_INTLTOOL([0.40], [no-xml]) 
    86  
    87 AM_GNU_GETTEXT([external]) 
    88 AM_GNU_GETTEXT_VERSION([0.18]) 
    89 GETTEXT_PACKAGE="mediastreamer" 
    90 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,["mediastreamer"],[name of the gettext domain. Used in the call to 'bindtextdomain()']) 
    91 AC_SUBST([GETTEXT_PACKAGE]) 
    92 LIBS="$LIBS $LIBINTL" 
    9383 
    9484if test "$GCC" != "yes" ; then 
     
    178168esac 
    179169 
     170 
     171dnl localization tools 
     172IT_PROG_INTLTOOL([0.40], [no-xml]) 
     173 
     174 
     175GETTEXT_PACKAGE="mediastreamer" 
     176AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,["mediastreamer"],[name of the gettext domain. Used in the call to 'bindtextdomain()']) 
     177AC_SUBST([GETTEXT_PACKAGE]) 
     178if test "$mingw_found" != "yes" ; then 
     179        dnl gettext macro does not work properly under mingw. And we want to use the one provided by GTK. 
     180        AM_GNU_GETTEXT([external]) 
     181        AM_GNU_GETTEXT_VERSION([0.18]) 
     182        LIBS="$LIBS $LIBINTL" 
     183else 
     184        AC_DEFINE(ENABLE_NLS,1,[Tells whether localisation is possible]) 
     185        AC_DEFINE(HAVE_GETTEXT,1,[Tells wheter localisation is possible]) 
     186        LIBS="$LIBS -lintl" 
     187fi 
     188 
    180189AM_CONDITIONAL(BUILD_MACOSX, test x$macosx_found = xyes) 
    181190 
  • include/mediastreamer2/mscommon.h

    r1344 r1372  
    9494#define ms_thread_join          ortp_thread_join 
    9595 
     96typedef struct MSTimeSpec{ 
     97        uint64_t tv_sec; 
     98        uint64_t tv_nsec; 
     99}MSTimeSpec; 
    96100 
    97101struct _MSList { 
     
    114118 
    115119void ms_thread_exit(void* ret_val); 
     120MS2_PUBLIC void ms_get_cur_time(MSTimeSpec *ret); 
    116121MS2_PUBLIC MSList * ms_list_append(MSList *elem, void * data); 
    117122MS2_PUBLIC MSList * ms_list_prepend(MSList *elem, void * data); 
  • include/mediastreamer2/msticker.h

    r1344 r1372  
    6060        void *get_cur_time_data; 
    6161        char *name; 
     62        double av_load; /*average load of the ticker */ 
    6263        bool_t run;       /* flag to indicate whether the ticker must be run or not */ 
    63 #ifdef WIN32_TIMERS 
    64         HANDLE TimeEvent; 
    65 #endif 
    6664}; 
    6765 
     
    141139MS2_PUBLIC void ms_ticker_print_graphs(MSTicker *ticker); 
    142140 
     141/** 
     142 * Get the average load of the ticker. 
     143 * It is expressed as the ratio between real time spent in processing all graphs for a tick divided by the 
     144 * tick interval (default is 10 ms). 
     145 * This value is averaged over several ticks to get consistent and useful value. 
     146 * A load greater than 100% clearly means that the ticker is over loaded and runs late. 
     147**/ 
     148MS2_PUBLIC float ms_ticker_get_average_load(MSTicker *ticker); 
     149         
    143150/* private functions:*/ 
    144151 
  • src/mscommon.c

    r1344 r1372  
    685685 
    686686extern void _android_key_cleanup(void*); 
     687 
    687688void ms_thread_exit(void* ref_val) { 
    688689#ifdef ANDROID 
     
    696697 
    697698 
    698  
     699#ifdef __MACH__ 
     700#include <sys/types.h> 
     701#include <sys/timeb.h> 
     702#endif 
     703 
     704void ms_get_cur_time(MSTimeSpec *ret){ 
     705#if defined(_WIN32_WCE) || defined(WIN32) 
     706        DWORD timemillis; 
     707#       if defined(_WIN32_WCE) 
     708        timemillis=GetTickCount(); 
     709#       else 
     710        timemillis=timeGetTime(); 
     711#       endif 
     712        ret->tv_sec=timemillis/1000; 
     713        ret->tv_nsec=(timemillis%1000)*1000000LL; 
     714#elif defined(__MACH__) && defined(__GNUC__) && (__GNUC__ >= 3) 
     715        struct timeval tv; 
     716        gettimeofday(&tv, NULL); 
     717        ret->tv_sec=tv.tv_sec; 
     718        ret->tv_nsec=tv.tv_usec*1000LL; 
     719#elif defined(__MACH__) 
     720        struct timeb time_val; 
     721         
     722        ftime (&time_val); 
     723        ret->tv_sec = time_val.time; 
     724        ret->tv_nsec = time_val.millitm * 1000000LL; 
     725#else 
     726        struct timespec ts; 
     727        if (clock_gettime(CLOCK_MONOTONIC,&ts)<0){ 
     728                ms_fatal("clock_gettime() doesn't work: %s",strerror(errno)); 
     729        } 
     730        ret->tv_sec=ts.tv_sec; 
     731        ret->tv_nsec=ts.tv_nsec; 
     732#endif 
     733} 
     734 
     735 
  • src/msfilter.c

    r1359 r1372  
    234234} 
    235235 
    236  
    237  
    238 static uint64_t get_cur_time_ns(void) 
    239 { 
    240 #if defined(_WIN32_WCE) 
    241         DWORD timemillis = GetTickCount(); 
    242         return (uint64_t)timemillis*1000000; 
    243 #elif defined(WIN32) 
    244         return timeGetTime()*1000000LL ; 
    245 #elif defined(__MACH__) && defined(__GNUC__) && (__GNUC__ >= 3) 
    246         struct timeval tv; 
    247         gettimeofday(&tv, NULL); 
    248         return (tv.tv_sec*1000000000LL) + (tv.tv_usec*1000LL); 
    249 #elif defined(__MACH__) 
    250         struct timespec ts; 
    251         struct timeb time_val; 
    252  
    253         ftime (&time_val); 
    254         ts.tv_sec = time_val.time; 
    255         ts.tv_nsec = time_val.millitm * 1000000; 
    256         return (ts.tv_sec*1000000000LL) + ts.tv_nsec; 
    257 #else 
    258         struct timespec ts; 
    259         if (clock_gettime(CLOCK_MONOTONIC,&ts)<0){ 
    260                 ms_fatal("clock_gettime() doesn't work: %s",strerror(errno)); 
    261         } 
    262         return (ts.tv_sec*1000000000LL) + ts.tv_nsec; 
    263 #endif 
    264 } 
    265  
    266  
    267236void ms_filter_process(MSFilter *f){ 
    268         uint64_t start=0,stop; 
     237        MSTimeSpec start,stop; 
    269238        ms_debug("Executing process of filter %s:%p",f->desc->name,f); 
    270239 
    271240        if (f->stats) 
    272                 start = get_cur_time_ns(); 
     241                ms_get_cur_time(&start); 
    273242 
    274243        f->desc->process(f); 
    275244        if (f->stats){ 
    276                 stop = get_cur_time_ns(); 
     245                ms_get_cur_time(&stop); 
    277246                f->stats->count++; 
    278                 f->stats->elapsed+=stop-start; 
     247                f->stats->elapsed+=(stop.tv_sec-start.tv_sec)*1000000000LL + (stop.tv_nsec-start.tv_nsec); 
    279248        } 
    280249 
  • src/msticker.c

    r1344 r1372  
    2020#include "mediastreamer2/msticker.h" 
    2121 
     22static const double smooth_coef=0.9; 
     23 
     24#ifndef TICKER_MEASUREMENTS 
     25 
     26#define TICKER_MEASUREMENTS 1 
     27 
     28#if defined(__ARM_ARCH__)  
     29#       if __ARM_ARCH__ < 7 
     30/* as MSTicker load computation requires floating point, we prefer to disable it on ARM processors without FPU*/ 
     31#               undef TICKER_MEASUREMENTS 
     32#               define TICKER_MEASUREMENTS 0  
     33#       endif 
     34#endif 
     35 
     36#endif 
    2237 
    2338void * ms_ticker_run(void *s); 
    24 static uint64_t get_cur_time(void *); 
     39static uint64_t get_cur_time_ms(void *); 
    2540 
    2641void ms_ticker_start(MSTicker *s){ 
     
    3954        ticker->run=FALSE; 
    4055        ticker->exec_id=0; 
    41         ticker->get_cur_time_ptr=&get_cur_time; 
     56        ticker->get_cur_time_ptr=&get_cur_time_ms; 
    4257        ticker->get_cur_time_data=NULL; 
    43 #ifdef WIN32_TIMERS 
    44         ticker->TimeEvent=NULL; 
    45 #endif 
    4658        ticker->name=ms_strdup("MSTicker"); 
     59        ticker->av_load=0; 
    4760        ms_ticker_start(ticker); 
    4861} 
     
    220233} 
    221234 
    222 #ifdef __MACH__ 
    223 #include <sys/types.h> 
    224 #include <sys/timeb.h> 
    225 #endif 
    226  
    227 static uint64_t get_cur_time(void *unused){ 
    228 #if defined(_WIN32_WCE) 
    229         DWORD timemillis = GetTickCount(); 
    230         return timemillis; 
    231 #elif defined(WIN32) 
    232         return timeGetTime() ; 
    233 #elif defined(__MACH__) && defined(__GNUC__) && (__GNUC__ >= 3) 
    234         struct timeval tv; 
    235         gettimeofday(&tv, NULL); 
    236         return (tv.tv_sec*1000LL) + ((tv.tv_usec+500LL)/1000LL); 
    237 #elif defined(__MACH__) 
    238         struct timespec ts; 
    239         struct timeb time_val; 
    240          
    241         ftime (&time_val); 
    242         ts.tv_sec = time_val.time; 
    243         ts.tv_nsec = time_val.millitm * 1000000; 
     235static uint64_t get_cur_time_ms(void *unused){ 
     236        MSTimeSpec ts; 
     237        ms_get_cur_time(&ts); 
    244238        return (ts.tv_sec*1000LL) + ((ts.tv_nsec+500000LL)/1000000LL); 
    245 #else 
    246         struct timespec ts; 
    247         if (clock_gettime(CLOCK_MONOTONIC,&ts)<0){ 
    248                 ms_fatal("clock_gettime() doesn't work: %s",strerror(errno)); 
    249         } 
    250         return (ts.tv_sec*1000LL) + ((ts.tv_nsec+500000LL)/1000000LL); 
    251 #endif 
    252239} 
    253240 
     
    317304} 
    318305 
    319 #ifndef WIN32_TIMERS 
    320  
     306/*the ticker thread function that executes the filters */ 
    321307void * ms_ticker_run(void *arg) 
    322308{ 
     
    337323        while(s->run){ 
    338324                s->ticks++; 
    339                 run_graphs(s,s->execution_list,FALSE); 
     325                { 
     326#if TICKER_MEASUREMENTS 
     327                        MSTimeSpec begin,end;/*used to measure time spent in processing one tick*/ 
     328                        double iload; 
     329 
     330                        ms_get_cur_time(&begin); 
     331#endif 
     332                        run_graphs(s,s->execution_list,FALSE); 
     333#if TICKER_MEASUREMENTS 
     334                        ms_get_cur_time(&end); 
     335                        iload=100*((end.tv_sec-begin.tv_sec)*1000.0 + (end.tv_nsec-begin.tv_nsec)/1000000.0)/s->interval; 
     336                        s->av_load=(smooth_coef*s->av_load)+((1.0-smooth_coef)*iload); 
     337#endif 
     338                } 
     339                 
    340340                s->time+=s->interval; 
    341341                while(1){ 
     
    366366} 
    367367 
    368 #else 
    369  
    370 void * ms_ticker_run(void *arg) 
    371 { 
    372         MSTicker *s=(MSTicker*)arg; 
    373         uint64_t realtime; 
    374         int precision=2; 
    375         UINT timerId; 
    376  
    377         precision = set_high_prio(); 
    378  
    379         s->TimeEvent = CreateEvent (NULL, FALSE, FALSE, NULL); 
    380  
    381         s->ticks=1; 
    382         ms_mutex_lock(&s->lock); 
    383         s->orig=s->get_cur_time_ptr(s->get_cur_time_data); 
    384  
    385         timerId = timeSetEvent (s->interval, precision, (LPTIMECALLBACK)s->TimeEvent, 0, 
    386                                   TIME_PERIODIC | TIME_CALLBACK_EVENT_SET); 
    387         while(s->run){ 
    388                 DWORD err; 
    389  
    390                 s->ticks++; 
    391                 run_graphs(s,s->execution_list,FALSE); 
    392  
    393                 /* elapsed time since origin */ 
    394                 s->time = s->get_cur_time_ptr(s->get_cur_time_data)- s->orig; 
    395  
    396                 ms_mutex_unlock(&s->lock); 
    397                 err = WaitForSingleObject (s->TimeEvent, s->interval*1000 ); /* wake up each diff */ 
    398                 if (err==WAIT_FAILED) 
    399                         ms_message("WaitForSingleObject is failing"); 
    400  
    401                 ms_mutex_lock(&s->lock); 
    402         } 
    403         ms_mutex_unlock(&s->lock); 
    404         timeKillEvent (timerId); 
    405         CloseHandle (s->TimeEvent); 
    406         s->TimeEvent=NULL; 
    407         unset_high_prio(precision); 
    408         ms_message("MSTicker thread exiting"); 
    409         ms_thread_exit(NULL); 
    410         return NULL; 
    411 } 
    412  
    413 #endif 
    414  
    415368void ms_ticker_set_time_func(MSTicker *ticker, MSTickerTimeFunc func, void *user_data){ 
    416         if (func==NULL) func=get_cur_time; 
     369        if (func==NULL) func=get_cur_time_ms; 
    417370        /*ms_mutex_lock(&ticker->lock);*/ 
    418371        ticker->get_cur_time_ptr=func; 
     
    466419        print_graphs(ticker,ticker->execution_list,FALSE); 
    467420} 
     421 
     422float ms_ticker_get_average_load(MSTicker *ticker){ 
     423#if     !TICKER_MEASUREMENTS 
     424        static bool_t once=FALSE; 
     425        if (once==FALSE){ 
     426                ms_warning("ms_ticker_get_average_load(): ticker load measurements disabled for performance reasons."); 
     427                once=TRUE; 
     428        } 
     429#endif 
     430        return ticker->av_load; 
     431} 
     432 
  • tests/mediastream.c

    r1366 r1375  
    473473                } 
    474474        #endif // target MAC 
    475                                         } 
     475        } 
    476476         
    477477        printf("stopping all...\n"); 
Note: See TracChangeset for help on using the changeset viewer.