oRTP
0.25.0
|
00001 /*************************************************************************** 00002 * utils.h 00003 * 00004 * Wed Feb 23 14:15:36 2005 00005 * Copyright 2005 Simon Morlat 00006 * Email simon.morlat@linphone.org 00007 ****************************************************************************/ 00008 /* 00009 The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack. 00010 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org 00011 00012 This library is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU Lesser General Public 00014 License as published by the Free Software Foundation; either 00015 version 2.1 of the License, or (at your option) any later version. 00016 00017 This library is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 Lesser General Public License for more details. 00021 00022 You should have received a copy of the GNU Lesser General Public 00023 License along with this library; if not, write to the Free Software 00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 */ 00026 00027 #ifndef UTILS_H 00028 #define UTILS_H 00029 00030 #include "ortp/event.h" 00031 #include "ortp/rtpsession.h" 00032 00033 struct _OList { 00034 struct _OList *next; 00035 struct _OList *prev; 00036 void *data; 00037 }; 00038 00039 00040 #define o_list_next(elem) ((elem)->next) 00041 #define o_list_prev(elem) ((elem)->prev) 00042 00043 OList * o_list_append(OList *elem, void * data); 00044 OList * o_list_remove(OList *list, void *data); 00045 OList * o_list_free(OList *elem); 00046 OList *o_list_remove_link(OList *list, OList *elem); 00047 00048 00049 #define ORTP_POINTER_TO_INT(p) ((int)(intptr_t)(p)) 00050 #define ORTP_INT_TO_POINTER(i) ((void *)(intptr_t)(i)) 00051 00052 00053 typedef struct _dwsplit_t{ 00054 #ifdef ORTP_BIGENDIAN 00055 uint16_t hi; 00056 uint16_t lo; 00057 #else 00058 uint16_t lo; 00059 uint16_t hi; 00060 #endif 00061 } dwsplit_t; 00062 00063 typedef union{ 00064 dwsplit_t split; 00065 uint32_t one; 00066 } poly32_t; 00067 00068 #ifdef ORTP_BIGENDIAN 00069 #define hton24(x) (x) 00070 #else 00071 #define hton24(x) ((( (x) & 0x00ff0000) >>16) | (( (x) & 0x000000ff) <<16) | ( (x) & 0x0000ff00) ) 00072 #endif 00073 #define ntoh24(x) hton24(x) 00074 00075 #if defined(_WIN32) || defined(_WIN32_WCE) 00076 #define is_would_block_error(errnum) (errnum==WSAEWOULDBLOCK) 00077 #else 00078 #define is_would_block_error(errnum) (errnum==EWOULDBLOCK || errnum==EAGAIN) 00079 #endif 00080 00081 void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev); 00082 00083 uint64_t ortp_timeval_to_ntp(const struct timeval *tv); 00084 00085 bool_t ortp_stream_is_ipv6(OrtpStream *os); 00086 00087 int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen); 00088 int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen); 00089 void _rtp_session_release_sockets(RtpSession *session, bool_t release_transports); 00090 #endif