oRTP  0.20.0
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 __GNUC__
119 #define CHECK_FORMAT_ARGS(m,n) __attribute__((format(printf,m,n)))
120 #else
121 #define CHECK_FORMAT_ARGS(m,n)
122 #endif
123 
124 
125 #ifdef ORTP_DEBUG_MODE
126 static inline void CHECK_FORMAT_ARGS(1,2) ortp_debug(const char *fmt,...)
127 {
128  va_list args;
129  va_start (args, fmt);
130  ortp_logv(ORTP_DEBUG, fmt, args);
131  va_end (args);
132 }
133 #else
134 
135 #define ortp_debug(...)
136 
137 #endif
138 
139 #ifdef ORTP_NOMESSAGE_MODE
140 
141 #define ortp_log(...)
142 #define ortp_message(...)
143 #define ortp_warning(...)
144 
145 #else
146 
147 static inline void CHECK_FORMAT_ARGS(2,3) ortp_log(OrtpLogLevel lev, const char *fmt,...) {
148  va_list args;
149  va_start (args, fmt);
150  ortp_logv(lev, fmt, args);
151  va_end (args);
152 }
153 
154 static inline void CHECK_FORMAT_ARGS(1,2) ortp_message(const char *fmt,...)
155 {
156  va_list args;
157  va_start (args, fmt);
158  ortp_logv(ORTP_MESSAGE, fmt, args);
159  va_end (args);
160 }
161 
162 static inline void CHECK_FORMAT_ARGS(1,2) ortp_warning(const char *fmt,...)
163 {
164  va_list args;
165  va_start (args, fmt);
166  ortp_logv(ORTP_WARNING, fmt, args);
167  va_end (args);
168 }
169 
170 #endif
171 
172 static inline void CHECK_FORMAT_ARGS(1,2) ortp_error(const char *fmt,...)
173 {
174  va_list args;
175  va_start (args, fmt);
176  ortp_logv(ORTP_ERROR, fmt, args);
177  va_end (args);
178 }
179 
180 static inline void CHECK_FORMAT_ARGS(1,2) ortp_fatal(const char *fmt,...)
181 {
182  va_list args;
183  va_start (args, fmt);
184  ortp_logv(ORTP_FATAL, fmt, args);
185  va_end (args);
186 }
187 
188 
189 /****************/
190 /*statistics api*/
191 /****************/
192 
193 extern rtp_stats_t ortp_global_stats;
194 
195 void ortp_global_stats_reset(void);
196 rtp_stats_t *ortp_get_global_stats(void);
197 
198 void ortp_global_stats_display(void);
199 void rtp_stats_display(const rtp_stats_t *stats, const char *header);
200 void rtp_stats_reset(rtp_stats_t *stats);
201 
202 #if defined(_MSC_VER)
203 #define ORTP_PUBLIC __declspec(dllexport)
204 #else
205 #define ORTP_PUBLIC
206 #endif
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif
void ortp_set_log_file(FILE *file)
Definition: ortp.c:155
void ortp_global_stats_display(void)
Definition: ortp.c:287
bool_t ortp_min_version_required(int major, int minor, int micro)
Definition: ortp.c:384
void rtp_stats_display(const rtp_stats_t *stats, const char *header)
Definition: ortp.c:298
void ortp_exit(void)
Definition: ortp.c:132
void ortp_init(void)
Definition: ortp.c:77
void ortp_scheduler_init(void)
Definition: ortp.c:107
void ortp_set_log_handler(OrtpLogFunc func)
Definition: ortp.c:168
Definition: rtp.h:63
The RtpSession api.
Sending and receiving multiple streams together with only one thread.
void ortp_set_log_level_mask(int levelmask)
Definition: ortp.c:179