oRTP
0.20.0
|
00001 /* 00002 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack. 00003 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 */ 00019 00064 #ifndef ORTP_H 00065 #define ORTP_H 00066 00067 #include "ortp/rtpsession.h" 00068 #include "ortp/sessionset.h" 00069 00070 #ifdef __cplusplus 00071 extern "C" 00072 { 00073 #endif 00074 00075 bool_t ortp_min_version_required(int major, int minor, int micro); 00076 void ortp_init(void); 00077 void ortp_scheduler_init(void); 00078 void ortp_exit(void); 00079 00080 /***************/ 00081 /* logging api */ 00082 /***************/ 00083 00084 typedef enum { 00085 ORTP_DEBUG=1, 00086 ORTP_MESSAGE=1<<1, 00087 ORTP_WARNING=1<<2, 00088 ORTP_ERROR=1<<3, 00089 ORTP_FATAL=1<<4, 00090 ORTP_LOGLEV_END=1<<5 00091 } OrtpLogLevel; 00092 00093 00094 typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args); 00095 00096 void ortp_set_log_file(FILE *file); 00097 void ortp_set_log_handler(OrtpLogFunc func); 00098 00099 VAR_DECLSPEC OrtpLogFunc ortp_logv_out; 00100 00101 extern unsigned int __ortp_log_mask; 00102 00103 #define ortp_log_level_enabled(level) (__ortp_log_mask & (level)) 00104 00105 #if !defined(WIN32) && !defined(_WIN32_WCE) 00106 #define ortp_logv(level,fmt,args) \ 00107 {\ 00108 if (ortp_logv_out!=NULL && ortp_log_level_enabled(level)) \ 00109 ortp_logv_out(level,fmt,args);\ 00110 if ((level)==ORTP_FATAL) abort();\ 00111 }while(0) 00112 #else 00113 void ortp_logv(int level, const char *fmt, va_list args); 00114 #endif 00115 00116 void ortp_set_log_level_mask(int levelmask); 00117 00118 #ifdef __GNUC__ 00119 #define CHECK_FORMAT_ARGS(m,n) __attribute__((format(printf,m,n))) 00120 #else 00121 #define CHECK_FORMAT_ARGS(m,n) 00122 #endif 00123 00124 00125 #ifdef ORTP_DEBUG_MODE 00126 static inline void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...) 00127 { 00128 va_list args; 00129 va_start (args, fmt); 00130 ortp_logv(ORTP_DEBUG, fmt, args); 00131 va_end (args); 00132 } 00133 #else 00134 00135 #define ortp_debug(...) 00136 00137 #endif 00138 00139 #ifdef ORTP_NOMESSAGE_MODE 00140 00141 #define ortp_log(...) 00142 #define ortp_message(...) 00143 #define ortp_warning(...) 00144 00145 #else 00146 00147 static inline void CHECK_FORMAT_ARGS(2,3) ortp_log(OrtpLogLevel lev, const char *fmt,...) { 00148 va_list args; 00149 va_start (args, fmt); 00150 ortp_logv(lev, fmt, args); 00151 va_end (args); 00152 } 00153 00154 static inline void CHECK_FORMAT_ARGS(1,2) ortp_message(const char *fmt,...) 00155 { 00156 va_list args; 00157 va_start (args, fmt); 00158 ortp_logv(ORTP_MESSAGE, fmt, args); 00159 va_end (args); 00160 } 00161 00162 static inline void CHECK_FORMAT_ARGS(1,2) ortp_warning(const char *fmt,...) 00163 { 00164 va_list args; 00165 va_start (args, fmt); 00166 ortp_logv(ORTP_WARNING, fmt, args); 00167 va_end (args); 00168 } 00169 00170 #endif 00171 00172 static inline void CHECK_FORMAT_ARGS(1,2) ortp_error(const char *fmt,...) 00173 { 00174 va_list args; 00175 va_start (args, fmt); 00176 ortp_logv(ORTP_ERROR, fmt, args); 00177 va_end (args); 00178 } 00179 00180 static inline void CHECK_FORMAT_ARGS(1,2) ortp_fatal(const char *fmt,...) 00181 { 00182 va_list args; 00183 va_start (args, fmt); 00184 ortp_logv(ORTP_FATAL, fmt, args); 00185 va_end (args); 00186 } 00187 00188 00189 /****************/ 00190 /*statistics api*/ 00191 /****************/ 00192 00193 extern rtp_stats_t ortp_global_stats; 00194 00195 void ortp_global_stats_reset(void); 00196 rtp_stats_t *ortp_get_global_stats(void); 00197 00198 void ortp_global_stats_display(void); 00199 void rtp_stats_display(const rtp_stats_t *stats, const char *header); 00200 void rtp_stats_reset(rtp_stats_t *stats); 00201 00202 #if defined(_MSC_VER) 00203 #define ORTP_PUBLIC __declspec(dllexport) 00204 #else 00205 #define ORTP_PUBLIC 00206 #endif 00207 00208 #ifdef __cplusplus 00209 } 00210 #endif 00211 00212 #endif