oRTP
0.24.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 INT_TO_POINTER(truc) ((long)(long)(truc)) 00050 #define POINTER_TO_INT(truc) ((int)(long)(truc)) 00051 00052 typedef struct _dwsplit_t{ 00053 #ifdef ORTP_BIGENDIAN 00054 uint16_t hi; 00055 uint16_t lo; 00056 #else 00057 uint16_t lo; 00058 uint16_t hi; 00059 #endif 00060 } dwsplit_t; 00061 00062 typedef union{ 00063 dwsplit_t split; 00064 uint32_t one; 00065 } poly32_t; 00066 00067 #ifdef ORTP_BIGENDIAN 00068 #define hton24(x) (x) 00069 #else 00070 #define hton24(x) ((( (x) & 0x00ff0000) >>16) | (( (x) & 0x000000ff) <<16) | ( (x) & 0x0000ff00) ) 00071 #endif 00072 #define ntoh24(x) hton24(x) 00073 00074 #if defined(WIN32) || defined(_WIN32_WCE) 00075 #define is_would_block_error(errnum) (errnum==WSAEWOULDBLOCK) 00076 #else 00077 #define is_would_block_error(errnum) (errnum==EWOULDBLOCK || errnum==EAGAIN) 00078 #endif 00079 00080 void ortp_ev_queue_put(OrtpEvQueue *q, OrtpEvent *ev); 00081 00082 uint64_t ortp_timeval_to_ntp(const struct timeval *tv); 00083 00084 bool_t ortp_stream_is_ipv6(OrtpStream *os); 00085 00086 int _rtp_session_sendto(RtpSession *session, bool_t is_rtp, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen); 00087 int _ortp_sendto(ortp_socket_t sockfd, mblk_t *m, int flags, const struct sockaddr *destaddr, socklen_t destlen); 00088 #endif