Commit 878dcde5 authored by Ghislain MARY's avatar Ghislain MARY

Move time spec definition from ms2 to oRTP.

parent efe109e8
......@@ -174,6 +174,14 @@ AC_ARG_WITH(thread-stack-size,
AC_DEFINE_UNQUOTED(ORTP_DEFAULT_THREAD_STACK_SIZE, $thread_stack_size, [Default thread stack size (0 = let uperating system decide)])
dnl check if we can use the rt library
AC_CHECK_LIB(rt, clock_gettime, [rt_enabled=yes])
if test $rt_enabled = "yes" ; then
RT_LIBS="-lrt"
AC_SUBST(RT_LIBS)
fi
dnl check for libsrtp support (secure rtp)
AC_ARG_WITH(srtp,
AC_HELP_STRING([--with-srtp],[Set prefix where libsrtp can be found or "none" to disable (ex:/usr or /usr/local) [[default=/usr]]]),
......@@ -331,7 +339,7 @@ fi
AC_SUBST(SSL_LIBS)
ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LIBS $PTHREAD_LDFLAGS $SRTP_LIBS $SSL_LIBS"
ORTPDEPS_LIBS="$ORTPDEPS_LIBS $PTHREAD_LIBS $PTHREAD_LDFLAGS $RT_LIBS $SRTP_LIBS $SSL_LIBS"
ORTPDEPS_CFLAGS="$ORTPDEPS_CFLAGS $PTHREAD_CFLAGS $ORTP_DEFS $SRTP_CFLAGS"
CFLAGS="$CFLAGS $ORTP_DEFS"
echo "$ORTPDEPS_CFLAGS" > ortp.defs
......
......@@ -219,13 +219,6 @@ const char *getWinSocketError(int error);
#define snprintf _snprintf
#define strcasecmp _stricmp
#if 0
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif
#ifdef __cplusplus
extern "C"{
......@@ -246,6 +239,11 @@ typedef unsigned char bool_t;
#define TRUE 1
#define FALSE 0
typedef struct ortpTimeSpec{
int64_t tv_sec;
int64_t tv_nsec;
}ortpTimeSpec;
#ifdef __cplusplus
extern "C"{
#endif
......@@ -277,6 +275,8 @@ char *ortp_strdup_vprintf(const char *fmt, va_list ap);
int ortp_file_exist(const char *pathname);
void ortp_get_cur_time(ortpTimeSpec *ret);
/* portable named pipes and shared memory*/
#if !defined(_WIN32_WCE)
#ifdef WIN32
......
......@@ -39,7 +39,7 @@ AM_CFLAGS+= $(LIBZRTPCPP_CFLAGS)
AM_LDFLAGS+= $(LIBZRTPCPP_LDFLAGS)
endif
libortp_la_LIBADD= $(PTHREAD_LIBS) -lm $(SRTP_LIBS) $(SSL_LIBS) $(LIBZRTPCPP_LIBS)
libortp_la_LIBADD= $(PTHREAD_LIBS) $(RT_LIBS) -lm $(SRTP_LIBS) $(SSL_LIBS) $(LIBZRTPCPP_LIBS)
libortp_la_LDFLAGS= -version-info $(LIBORTP_SO_VERSION) -no-undefined
......
......@@ -629,3 +629,40 @@ void ortp_shm_close(void *mem){
#endif
#ifdef __MACH__
#include <sys/types.h>
#include <sys/timeb.h>
#endif
void ortp_get_cur_time(ortpTimeSpec *ret){
#if defined(_WIN32_WCE) || defined(WIN32)
DWORD timemillis;
# if defined(_WIN32_WCE)
timemillis=GetTickCount();
# else
timemillis=timeGetTime();
# endif
ret->tv_sec=timemillis/1000;
ret->tv_nsec=(timemillis%1000)*1000000LL;
#elif defined(__MACH__) && defined(__GNUC__) && (__GNUC__ >= 3)
struct timeval tv;
gettimeofday(&tv, NULL);
ret->tv_sec=tv.tv_sec;
ret->tv_nsec=tv.tv_usec*1000LL;
#elif defined(__MACH__)
struct timeb time_val;
ftime (&time_val);
ret->tv_sec = time_val.time;
ret->tv_nsec = time_val.millitm * 1000000LL;
#else
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC,&ts)<0){
ortp_fatal("clock_gettime() doesn't work: %s",strerror(errno));
}
ret->tv_sec=ts.tv_sec;
ret->tv_nsec=ts.tv_nsec;
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment