Changes in [1368:ac122ded501e:1376:38e481f9389c] in mediastreamer2
- Files:
-
- 8 edited
-
autogen.sh (modified) (2 diffs)
-
configure.ac (modified) (2 diffs)
-
include/mediastreamer2/mscommon.h (modified) (2 diffs)
-
include/mediastreamer2/msticker.h (modified) (2 diffs)
-
src/mscommon.c (modified) (2 diffs)
-
src/msfilter.c (modified) (1 diff)
-
src/msticker.c (modified) (7 diffs)
-
tests/mediastream.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
autogen.sh
r1344 r1370 10 10 AUTOMAKE=automake-${AM_VERSION} 11 11 fi 12 13 INTLTOOLIZE=/usr/bin/intltoolize 14 15 if test -f /opt/local/bin/intltoolize ; then 16 INTLTOOLIZE=/opt/local/bin/intltoolize 17 else 18 INTLTOOLIZE=/usr/bin/intltoolize 19 fi 20 12 21 13 22 libtoolize="libtoolize" … … 44 53 set -x 45 54 $libtoolize --copy --force 46 intltoolize--copy --force --automake55 $INTLTOOLIZE --copy --force --automake 47 56 $ACLOCAL $ACLOCAL_ARGS 48 57 autoheader -
configure.ac
r1361 r1374 81 81 82 82 AC_SUBST([LIBTOOL_DEPS]) 83 84 dnl localization tools85 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"93 83 94 84 if test "$GCC" != "yes" ; then … … 178 168 esac 179 169 170 171 dnl localization tools 172 IT_PROG_INTLTOOL([0.40], [no-xml]) 173 174 175 GETTEXT_PACKAGE="mediastreamer" 176 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,["mediastreamer"],[name of the gettext domain. Used in the call to 'bindtextdomain()']) 177 AC_SUBST([GETTEXT_PACKAGE]) 178 if 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" 183 else 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" 187 fi 188 180 189 AM_CONDITIONAL(BUILD_MACOSX, test x$macosx_found = xyes) 181 190 -
include/mediastreamer2/mscommon.h
r1344 r1372 94 94 #define ms_thread_join ortp_thread_join 95 95 96 typedef struct MSTimeSpec{ 97 uint64_t tv_sec; 98 uint64_t tv_nsec; 99 }MSTimeSpec; 96 100 97 101 struct _MSList { … … 114 118 115 119 void ms_thread_exit(void* ret_val); 120 MS2_PUBLIC void ms_get_cur_time(MSTimeSpec *ret); 116 121 MS2_PUBLIC MSList * ms_list_append(MSList *elem, void * data); 117 122 MS2_PUBLIC MSList * ms_list_prepend(MSList *elem, void * data); -
include/mediastreamer2/msticker.h
r1344 r1372 60 60 void *get_cur_time_data; 61 61 char *name; 62 double av_load; /*average load of the ticker */ 62 63 bool_t run; /* flag to indicate whether the ticker must be run or not */ 63 #ifdef WIN32_TIMERS64 HANDLE TimeEvent;65 #endif66 64 }; 67 65 … … 141 139 MS2_PUBLIC void ms_ticker_print_graphs(MSTicker *ticker); 142 140 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 **/ 148 MS2_PUBLIC float ms_ticker_get_average_load(MSTicker *ticker); 149 143 150 /* private functions:*/ 144 151 -
src/mscommon.c
r1344 r1372 685 685 686 686 extern void _android_key_cleanup(void*); 687 687 688 void ms_thread_exit(void* ref_val) { 688 689 #ifdef ANDROID … … 696 697 697 698 698 699 #ifdef __MACH__ 700 #include <sys/types.h> 701 #include <sys/timeb.h> 702 #endif 703 704 void 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 234 234 } 235 235 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 #else258 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 #endif264 }265 266 267 236 void ms_filter_process(MSFilter *f){ 268 uint64_t start=0,stop;237 MSTimeSpec start,stop; 269 238 ms_debug("Executing process of filter %s:%p",f->desc->name,f); 270 239 271 240 if (f->stats) 272 start = get_cur_time_ns();241 ms_get_cur_time(&start); 273 242 274 243 f->desc->process(f); 275 244 if (f->stats){ 276 stop = get_cur_time_ns();245 ms_get_cur_time(&stop); 277 246 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); 279 248 } 280 249 -
src/msticker.c
r1344 r1372 20 20 #include "mediastreamer2/msticker.h" 21 21 22 static 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 22 37 23 38 void * ms_ticker_run(void *s); 24 static uint64_t get_cur_time (void *);39 static uint64_t get_cur_time_ms(void *); 25 40 26 41 void ms_ticker_start(MSTicker *s){ … … 39 54 ticker->run=FALSE; 40 55 ticker->exec_id=0; 41 ticker->get_cur_time_ptr=&get_cur_time ;56 ticker->get_cur_time_ptr=&get_cur_time_ms; 42 57 ticker->get_cur_time_data=NULL; 43 #ifdef WIN32_TIMERS44 ticker->TimeEvent=NULL;45 #endif46 58 ticker->name=ms_strdup("MSTicker"); 59 ticker->av_load=0; 47 60 ms_ticker_start(ticker); 48 61 } … … 220 233 } 221 234 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; 235 static uint64_t get_cur_time_ms(void *unused){ 236 MSTimeSpec ts; 237 ms_get_cur_time(&ts); 244 238 return (ts.tv_sec*1000LL) + ((ts.tv_nsec+500000LL)/1000000LL); 245 #else246 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 #endif252 239 } 253 240 … … 317 304 } 318 305 319 #ifndef WIN32_TIMERS 320 306 /*the ticker thread function that executes the filters */ 321 307 void * ms_ticker_run(void *arg) 322 308 { … … 337 323 while(s->run){ 338 324 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 340 340 s->time+=s->interval; 341 341 while(1){ … … 366 366 } 367 367 368 #else369 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 #endif414 415 368 void 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; 417 370 /*ms_mutex_lock(&ticker->lock);*/ 418 371 ticker->get_cur_time_ptr=func; … … 466 419 print_graphs(ticker,ticker->execution_list,FALSE); 467 420 } 421 422 float 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 473 473 } 474 474 #endif // target MAC 475 }475 } 476 476 477 477 printf("stopping all...\n");
Note: See TracChangeset
for help on using the changeset viewer.
