📄 rtpport.h
字号:
/* The oRTP LinPhone RTP library intends to provide basics for a RTP stack. Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*//* this file is responsible of the portability of the stack */#ifndef RTPPORT_H#define RTPPORT_H#include "../config.h"#ifdef HAVE_GLIB#include <glib.h>#endif#ifndef HAVE_GLIB /* things that are normally defined in glib, but are used both in HPUX kernel and user space */ #include <sys/types.h>/* integer types */typedef uint64_t guint64;typedef uint16_t guint16;typedef uint32_t guint32;typedef int32_t gint32;typedef unsigned int guint;typedef int gint;typedef char gchar;typedef unsigned char guchar;typedef unsigned char guint8;typedef void* gpointer;/*misc*/#define g_return_if_fail(expr) if (!(expr)) {printf("%s:%i- assertion expr failed\n",__FILE__,__LINE__); return;}#define g_return_val_if_fail(expr,ret) if (!(expr)) {printf("%s:%i- assertion expr failed\n",__FILE__,__LINE__); return (ret);}#ifdef RTP_DEBUG #define g_message printf#define g_warning printf#define g_error printf#else #define g_message#define g_warning printf#define g_error printf#endif#endif /* HAVE_GLIB */#ifdef TARGET_IS_HPUXKERNEL/* REVISIT: are all HP-UX kernel big endian ? */#define htons(x) (x)#define htonl(x) (x)#define ntohs(x) (x)#define ntohl(x) (x)#define memcpy(dest,src,size) bcopy((src),(dest),(size))#define memset(p,v,n) do { int _i; for (_i=0;_i<(n);_i++) ((char*)(p))[_i]=(v);}while (0)#include <h/malloc.h>#include <h/spinlock.h>typedef lock_t GMutex;static GMutex * g_mutex_new(){ lock_t *lock; MALLOC(lock,lock_t*,sizeof(lock_t),M_SPINLOCK, M_WAITOK|M_ALIGN); initlock(lock,0,0,"RtpSession lock"); return lock;}#define g_mutex_lock(mutex) spinlock((mutex))#define g_mutex_unlock(mutex) spinunlock((mutex))#define g_mutex_free(mutex) FREE((void*)(mutex),M_SPINLOCK)#define g_malloc(sz) kmem_alloc(sz)#define g_free(p) kmem_free(p)/* include the HPUX streams header*/#include <h/stream.h>#include <h/socket.h>#include <netinet/in.h> #include <h/tihdr.h>#else /*TARGET_IS_HPUXKERNEL */#include <string.h>#ifndef HAVE_GLIB/* things that in glib, but should only be defined when we are not in the HPUX kernel. */#include <stdlib.h>#include <pthread.h>#ifdef ENABLE_MEMCHECKextern gint ortp_allocations;#endif/* memory allocation functions */static inline void * g_malloc(int sz) { void *p=malloc(sz); if (p==NULL) { printf("g_malloc: Failed to allocate %i bytes: %s.\n",sz,strerror(errno)); exit(-1); }#ifdef ENABLE_MEMCHECK ortp_allocations++;#endif return p;}#define g_realloc(p,sz) realloc((p),(sz))static inline g_free(void *p){#ifdef ENABLE_MEMCHECK ortp_allocations--;#endif free(p);}typedef pthread_mutex_t GMutex;static inline GMutex * g_mutex_new(){ pthread_mutex_t *mutex=g_malloc(sizeof(pthread_mutex_t)); pthread_mutex_init(mutex,NULL); return mutex;}#define g_mutex_lock(mutex) pthread_mutex_lock((mutex))#define g_mutex_unlock(mutex) pthread_mutex_unlock((mutex))#define g_mutex_free(mutex) pthread_mutex_destroy((mutex));g_free((mutex))typedef pthread_cond_t GCond;static inline GCond * g_cond_new(){ pthread_cond_t *cond=g_malloc(sizeof(pthread_cond_t)); pthread_cond_init(cond,NULL); return cond;}#define g_cond_wait(cond,mutex) pthread_cond_wait((cond),(mutex))#define g_cond_signal(cond) pthread_cond_signal((cond))#define g_cond_broadcast(cond) pthread_cond_broadcast((cond))#define g_cond_free(cond) pthread_cond_destroy((cond)); g_free((cond))#define g_thread_init(vtable)#endif /* HAVE_GLIB */#endif /*TARGET_IS_HPUXKERNEL */#ifndef RTP_DEBUG#undef g_message#define g_message#endif#endif /*RTPPORT_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -