a-oRTP  5.2.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 
60 #ifndef ORTP_H
61 #define ORTP_H
62 
63 #include "ortp/rtpsession.h"
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
69 bool_t ortp_min_version_required(int major, int minor, int micro);
70 void ortp_init(void);
71 void ortp_scheduler_init(void);
72 void ortp_exit(void);
73 uint32_t ortp_random(void);
74 
75 /***************/
76 /* logging api */
77 /***************/
78 
79 typedef enum { ORTP_DEBUG = 1, ORTP_MESSAGE = 1 << 1, ORTP_WARNING = 1 << 2, ORTP_ERROR = 1 << 3, ORTP_FATAL = 1 << 4, ORTP_LOGLEV_END = 1 << 5 } OrtpLogLevel;
80 
81 typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
82 
83 void ortp_set_log_file(FILE *file);
84 void ortp_set_log_handler(OrtpLogFunc func);
85 
86 VAR_DECLSPEC OrtpLogFunc ortp_logv_out;
87 
88 extern unsigned int __ortp_log_mask;
89 
90 #define ortp_log_level_enabled(level) (__ortp_log_mask & (level))
91 
92 void ortp_logv(int level, const char *fmt, va_list args);
93 
94 void ortp_set_log_level_mask(int levelmask);
95 
96 #ifdef ORTP_DEBUG_MODE
97 static inline void ortp_debug(const char *fmt, ...) {
98  va_list args;
99  va_start(args, fmt);
100  ortp_logv(ORTP_DEBUG, fmt, args);
101  va_end(args);
102 }
103 #else
104 
105 #define ortp_debug(...)
106 
107 #endif
108 
109 #ifdef ORTP_NOMESSAGE_MODE
110 
111 #define ortp_log(...)
112 #define ortp_message(...)
113 #define ortp_warning(...)
114 
115 #else
116 
117 static inline void ortp_log(OrtpLogLevel lev, const char *fmt, ...) {
118  va_list args;
119  va_start(args, fmt);
120  ortp_logv(lev, fmt, args);
121  va_end(args);
122 }
123 
124 static inline void ortp_message(const char *fmt, ...) {
125  va_list args;
126  va_start(args, fmt);
127  ortp_logv(ORTP_MESSAGE, fmt, args);
128  va_end(args);
129 }
130 
131 static inline void ortp_warning(const char *fmt, ...) {
132  va_list args;
133  va_start(args, fmt);
134  ortp_logv(ORTP_WARNING, fmt, args);
135  va_end(args);
136 }
137 
138 #endif
139 
140 static inline void ortp_error(const char *fmt, ...) {
141  va_list args;
142  va_start(args, fmt);
143  ortp_logv(ORTP_ERROR, fmt, args);
144  va_end(args);
145 }
146 
147 static inline void ortp_fatal(const char *fmt, ...) {
148  va_list args;
149  va_start(args, fmt);
150  ortp_logv(ORTP_FATAL, fmt, args);
151  va_end(args);
152 }
153 
154 /****************/
155 /*statistics api*/
156 /****************/
157 
158 extern rtp_stats_t ortp_global_stats;
159 
160 void ortp_global_stats_reset(void);
161 rtp_stats_t *ortp_get_global_stats(void);
162 
163 void ortp_global_stats_display(void);
164 void rtp_stats_display(const rtp_stats_t *stats, const char *header);
165 void rtp_stats_reset(rtp_stats_t *stats);
166 
167 struct _OList {
168  struct _OList *next;
169  struct _OList *prev;
170  void *data;
171 };
172 
173 typedef struct _OList OList;
174 
175 #define o_list_next(elem) ((elem)->next)
176 #define o_list_prev(elem) ((elem)->prev)
177 
178 OList *o_list_append(OList *elem, void *data);
179 OList *o_list_insert(OList *before_elem, void *data);
180 OList *o_list_remove(OList *list, void *data);
181 OList *o_list_free(OList *elem);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif
The RtpSession api.
Definition: ortp.h:167
Definition: rtp.h:65