oRTP  0.16.1
ortp.h
Go to the documentation of this file.
1 /*
2  The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
3  Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
64 #ifndef ORTP_H
65 #define ORTP_H
66 
67 #include <ortp/rtpsession.h>
68 #include <ortp/sessionset.h>
69 
70 #ifdef __cplusplus
71 extern "C"
72 {
73 #endif
74 
75 bool_t ortp_min_version_required(int major, int minor, int micro);
76 void ortp_init(void);
77 void ortp_scheduler_init(void);
78 void ortp_exit(void);
79 
80 /***************/
81 /* logging api */
82 /***************/
83 
84 typedef enum {
85  ORTP_DEBUG=1,
86  ORTP_MESSAGE=1<<1,
87  ORTP_WARNING=1<<2,
88  ORTP_ERROR=1<<3,
89  ORTP_FATAL=1<<4,
90  ORTP_LOGLEV_END=1<<5
91 } OrtpLogLevel;
92 
93 
94 typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
95 
96 void ortp_set_log_file(FILE *file);
97 void ortp_set_log_handler(OrtpLogFunc func);
98 
99 VAR_DECLSPEC OrtpLogFunc ortp_logv_out;
100 
101 extern unsigned int __ortp_log_mask;
102 
103 #define ortp_log_level_enabled(level) (__ortp_log_mask & (level))
104 
105 #if !defined(WIN32) && !defined(_WIN32_WCE)
106 #define ortp_logv(level,fmt,args) \
107 {\
108  if (ortp_logv_out!=NULL && ortp_log_level_enabled(level)) \
109  ortp_logv_out(level,fmt,args);\
110  if ((level)==ORTP_FATAL) abort();\
111 }while(0)
112 #else
113 void ortp_logv(int level, const char *fmt, va_list args);
114 #endif
115 
116 void ortp_set_log_level_mask(int levelmask);
117 
118 #ifdef ORTP_DEBUG_MODE
119 static inline void ortp_debug(const char *fmt,...)
120 {
121  va_list args;
122  va_start (args, fmt);
123  ortp_logv(ORTP_DEBUG, fmt, args);
124  va_end (args);
125 }
126 #else
127 
128 #define ortp_debug(...)
129 
130 #endif
131 
132 #ifdef ORTP_NOMESSAGE_MODE
133 
134 #define ortp_log(...)
135 #define ortp_message(...)
136 #define ortp_warning(...)
137 
138 #else
139 
140 static inline void ortp_log(OrtpLogLevel lev, const char *fmt,...){
141  va_list args;
142  va_start (args, fmt);
143  ortp_logv(lev, fmt, args);
144  va_end (args);
145 }
146 
147 static inline void ortp_message(const char *fmt,...)
148 {
149  va_list args;
150  va_start (args, fmt);
151  ortp_logv(ORTP_MESSAGE, fmt, args);
152  va_end (args);
153 }
154 
155 static inline void ortp_warning(const char *fmt,...)
156 {
157  va_list args;
158  va_start (args, fmt);
159  ortp_logv(ORTP_WARNING, fmt, args);
160  va_end (args);
161 }
162 
163 #endif
164 
165 static inline void ortp_error(const char *fmt,...)
166 {
167  va_list args;
168  va_start (args, fmt);
169  ortp_logv(ORTP_ERROR, fmt, args);
170  va_end (args);
171 }
172 
173 static inline void ortp_fatal(const char *fmt,...)
174 {
175  va_list args;
176  va_start (args, fmt);
177  ortp_logv(ORTP_FATAL, fmt, args);
178  va_end (args);
179 }
180 
181 
182 /****************/
183 /*statistics api*/
184 /****************/
185 
186 extern rtp_stats_t ortp_global_stats;
187 
188 void ortp_global_stats_reset(void);
189 rtp_stats_t *ortp_get_global_stats(void);
190 
191 void ortp_global_stats_display(void);
192 void rtp_stats_display(const rtp_stats_t *stats, const char *header);
193 void rtp_stats_reset(rtp_stats_t *stats);
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
199 #endif