~ubuntu-branches/ubuntu/vivid/linphone/vivid

« back to all changes in this revision

Viewing changes to oRTP/include/ortp/port.h

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2006-11-15 10:34:50 UTC
  • mfrom: (1.2.1 upstream) (2.1.8 feisty)
  • Revision ID: james.westby@ubuntu.com-20061115103450-qgafwcks2lkhctlj
* New upstream release.
* Enable video support.
* Fix mismatched #endif in mscommon.h, closes: #398307.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/* this file is responsible of the portability of the stack */
 
20
 
 
21
#ifndef ORTP_PORT_H
 
22
#define ORTP_PORT_H
 
23
 
 
24
 
 
25
#if !defined(WIN32) && !defined(_WIN32_WCE)
 
26
/********************************/
 
27
/* definitions for UNIX flavour */
 
28
/********************************/
 
29
 
 
30
#include <errno.h>
 
31
#include <sys/types.h>
 
32
#include <pthread.h>
 
33
#include <unistd.h>
 
34
#include <fcntl.h>
 
35
#include <stdlib.h>
 
36
#include <stdio.h>
 
37
#include <stdarg.h>
 
38
#include <string.h>
 
39
 
 
40
#ifdef __linux
 
41
#include <stdint.h>
 
42
#endif
 
43
 
 
44
 
 
45
#include <sys/types.h>
 
46
#include <sys/socket.h>
 
47
#include <netinet/in.h>
 
48
#if defined(_XOPEN_SOURCE_EXTENDED) || !defined(__hpux)
 
49
#include <arpa/inet.h>
 
50
#endif
 
51
 
 
52
 
 
53
 
 
54
#include <sys/time.h>
 
55
 
 
56
#ifdef ORTP_INET6
 
57
#include <netdb.h>
 
58
#endif
 
59
 
 
60
typedef int ortp_socket_t;
 
61
typedef pthread_t ortp_thread_t;
 
62
typedef pthread_mutex_t ortp_mutex_t;
 
63
typedef pthread_cond_t ortp_cond_t;
 
64
 
 
65
#ifdef __INTEL_COMPILER
 
66
#pragma warning(disable : 111)          // statement is unreachable
 
67
#pragma warning(disable : 181)          // argument is incompatible with corresponding format string conversion
 
68
#pragma warning(disable : 188)          // enumerated type mixed with another type
 
69
#pragma warning(disable : 593)          // variable "xxx" was set but never used
 
70
#pragma warning(disable : 810)          // conversion from "int" to "unsigned short" may lose significant bits
 
71
#pragma warning(disable : 869)          // parameter "xxx" was never referenced
 
72
#pragma warning(disable : 981)          // operands are evaluated in unspecified order
 
73
#pragma warning(disable : 1418)         // external function definition with no prior declaration
 
74
#pragma warning(disable : 1419)         // external declaration in primary source file
 
75
#pragma warning(disable : 1469)         // "cc" clobber ignored
 
76
#endif
 
77
 
 
78
int __ortp_thread_join(ortp_thread_t thread, void **ptr);
 
79
 
 
80
#define ortp_thread_create      pthread_create
 
81
#define ortp_thread_join        __ortp_thread_join
 
82
#define ortp_thread_exit        pthread_exit
 
83
#define ortp_mutex_init         pthread_mutex_init
 
84
#define ortp_mutex_lock         pthread_mutex_lock
 
85
#define ortp_mutex_unlock       pthread_mutex_unlock
 
86
#define ortp_mutex_destroy      pthread_mutex_destroy
 
87
#define ortp_cond_init          pthread_cond_init
 
88
#define ortp_cond_signal        pthread_cond_signal
 
89
#define ortp_cond_broadcast     pthread_cond_broadcast
 
90
#define ortp_cond_wait          pthread_cond_wait
 
91
#define ortp_cond_destroy       pthread_cond_destroy
 
92
 
 
93
#define SOCKET_OPTION_VALUE     void *
 
94
#define SOCKET_BUFFER           void *
 
95
 
 
96
#define getSocketError() strerror(errno)
 
97
#define getSocketErrorCode() (errno)
 
98
 
 
99
#else
 
100
/*********************************/
 
101
/* definitions for WIN32 flavour */
 
102
/*********************************/
 
103
 
 
104
#include <stdio.h>
 
105
#include <stdlib.h>
 
106
#include <stdarg.h>
 
107
#include <winsock2.h>
 
108
#include <ws2tcpip.h>
 
109
 
 
110
 
 
111
#ifdef _MSC_VER
 
112
#pragma push_macro("_WINSOCKAPI_")
 
113
#ifndef _WINSOCKAPI_
 
114
#define _WINSOCKAPI_
 
115
#endif
 
116
 
 
117
typedef  unsigned __int64 uint64_t;
 
118
typedef  __int64 int64_t;
 
119
typedef  unsigned short uint16_t;
 
120
typedef  unsigned int uint32_t;
 
121
typedef  int int32_t;
 
122
typedef  unsigned char uint8_t;
 
123
typedef __int16 int16_t;
 
124
#else
 
125
#include <stdint.h> /*provided by mingw32*/
 
126
#endif
 
127
 
 
128
#define vsnprintf       _vsnprintf
 
129
#define srandom         srand
 
130
#define random          rand
 
131
 
 
132
 
 
133
typedef SOCKET ortp_socket_t;
 
134
typedef HANDLE ortp_cond_t;
 
135
typedef HANDLE ortp_mutex_t;
 
136
typedef HANDLE ortp_thread_t;
 
137
 
 
138
#define ortp_thread_create      WIN_thread_create
 
139
#define ortp_thread_join        WIN_thread_join
 
140
#define ortp_thread_exit(arg)           
 
141
#define ortp_mutex_init         WIN_mutex_init
 
142
#define ortp_mutex_lock         WIN_mutex_lock
 
143
#define ortp_mutex_unlock       WIN_mutex_unlock
 
144
#define ortp_mutex_destroy      WIN_mutex_destroy
 
145
#define ortp_cond_init          WIN_cond_init
 
146
#define ortp_cond_signal        WIN_cond_signal
 
147
#define ortp_cond_broadcast     WIN_cond_broadcast
 
148
#define ortp_cond_wait          WIN_cond_wait
 
149
#define ortp_cond_destroy       WIN_cond_destroy
 
150
 
 
151
int WIN_mutex_init(ortp_mutex_t *m, void *attr_unused);
 
152
int WIN_mutex_lock(ortp_mutex_t *mutex);
 
153
int WIN_mutex_unlock(ortp_mutex_t *mutex);
 
154
int WIN_mutex_destroy(ortp_mutex_t *mutex);
 
155
int WIN_thread_create(ortp_thread_t *t, void *attr_unused, void *(*func)(void*), void *arg); 
 
156
int WIN_thread_join(ortp_thread_t thread, void **unused);
 
157
int WIN_cond_init(ortp_cond_t *cond, void *attr_unused);
 
158
int WIN_cond_wait(ortp_cond_t * cond, ortp_mutex_t * mutex);
 
159
int WIN_cond_signal(ortp_cond_t * cond);
 
160
int WIN_cond_broadcast(ortp_cond_t * cond);
 
161
int WIN_cond_destroy(ortp_cond_t * cond);
 
162
 
 
163
 
 
164
#define SOCKET_OPTION_VALUE     char *
 
165
#define inline                  __inline
 
166
 
 
167
const char *getWinSocketError(int error);
 
168
#define getSocketErrorCode() WSAGetLastError()
 
169
#define getSocketError() getWinSocketError(WSAGetLastError())
 
170
 
 
171
#define snprintf _snprintf
 
172
#define strcasecmp _stricmp
 
173
 
 
174
#if 0
 
175
struct timeval {
 
176
        long    tv_sec;         /* seconds */
 
177
        long    tv_usec;        /* and microseconds */
 
178
};
 
179
#endif
 
180
 
 
181
int gettimeofday (struct timeval *tv, void* tz);
 
182
#ifdef _WORKAROUND_MINGW32_BUGS
 
183
char * WSAAPI gai_strerror(int errnum);
 
184
#endif
 
185
 
 
186
 
 
187
#endif
 
188
 
 
189
typedef unsigned char bool_t;
 
190
#undef TRUE
 
191
#undef FALSE
 
192
#define TRUE 1
 
193
#define FALSE 0
 
194
 
 
195
#ifdef __cplusplus
 
196
extern "C"{
 
197
#endif
 
198
 
 
199
void* ortp_malloc(size_t sz);
 
200
void ortp_free(void *ptr);
 
201
void* ortp_realloc(void *ptr, size_t sz);
 
202
void* ortp_malloc0(size_t sz);
 
203
char * ortp_strdup(const char *tmp);
 
204
 
 
205
#define ortp_new(type,count)    ortp_malloc(sizeof(type)*(count))
 
206
#define ortp_new0(type,count)   ortp_malloc0(sizeof(type)*(count))
 
207
 
 
208
int close_socket(ortp_socket_t sock);
 
209
int set_non_blocking_socket(ortp_socket_t sock);
 
210
 
 
211
char *ortp_strndup(const char *str,int n);
 
212
char *ortp_strdup_printf(const char *fmt,...);
 
213
 
 
214
#ifdef __cplusplus
 
215
}
 
216
#endif
 
217
 
 
218
 
 
219
#if (defined(WIN32) || defined(_WIN32_WCE)) && !defined(ORTP_STATIC)
 
220
#ifdef ORTP_EXPORTS
 
221
   #define VAR_DECLSPEC    __declspec(dllexport)
 
222
#else
 
223
   #define VAR_DECLSPEC    __declspec(dllimport)
 
224
#endif
 
225
#else
 
226
   #define VAR_DECLSPEC    extern
 
227
#endif
 
228
 
 
229
 
 
230
#endif
 
231
 
 
232