oRTP 0.16.3
|
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 ORTP_DEBUG_MODE 00119 static inline void ortp_debug(const char *fmt,...) 00120 { 00121 va_list args; 00122 va_start (args, fmt); 00123 ortp_logv(ORTP_DEBUG, fmt, args); 00124 va_end (args); 00125 } 00126 #else 00127 00128 #define ortp_debug(...) 00129 00130 #endif 00131 00132 #ifdef ORTP_NOMESSAGE_MODE 00133 00134 #define ortp_log(...) 00135 #define ortp_message(...) 00136 #define ortp_warning(...) 00137 00138 #else 00139 00140 static inline void ortp_log(OrtpLogLevel lev, const char *fmt,...){ 00141 va_list args; 00142 va_start (args, fmt); 00143 ortp_logv(lev, fmt, args); 00144 va_end (args); 00145 } 00146 00147 static inline void ortp_message(const char *fmt,...) 00148 { 00149 va_list args; 00150 va_start (args, fmt); 00151 ortp_logv(ORTP_MESSAGE, fmt, args); 00152 va_end (args); 00153 } 00154 00155 static inline void ortp_warning(const char *fmt,...) 00156 { 00157 va_list args; 00158 va_start (args, fmt); 00159 ortp_logv(ORTP_WARNING, fmt, args); 00160 va_end (args); 00161 } 00162 00163 #endif 00164 00165 static inline void ortp_error(const char *fmt,...) 00166 { 00167 va_list args; 00168 va_start (args, fmt); 00169 ortp_logv(ORTP_ERROR, fmt, args); 00170 va_end (args); 00171 } 00172 00173 static inline void ortp_fatal(const char *fmt,...) 00174 { 00175 va_list args; 00176 va_start (args, fmt); 00177 ortp_logv(ORTP_FATAL, fmt, args); 00178 va_end (args); 00179 } 00180 00181 00182 /****************/ 00183 /*statistics api*/ 00184 /****************/ 00185 00186 extern rtp_stats_t ortp_global_stats; 00187 00188 void ortp_global_stats_reset(void); 00189 rtp_stats_t *ortp_get_global_stats(void); 00190 00191 void ortp_global_stats_display(void); 00192 void rtp_stats_display(const rtp_stats_t *stats, const char *header); 00193 void rtp_stats_reset(rtp_stats_t *stats); 00194 00195 #ifdef __cplusplus 00196 } 00197 #endif 00198 00199 #endif