- Main Page
- Data Structures
- Files

- File List
- Globals

# include/ortp/sessionset.h

Go to the documentation of this file.

    00001 /*
    00002   The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
    00003   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
    00004
    00005   This library is free software; you can redistribute it and/or
    00006   modify it under the terms of the GNU Lesser General Public
    00007   License as published by the Free Software Foundation; either
    00008   version 2.1 of the License, or (at your option) any later version.
    00009
    00010   This library is distributed in the hope that it will be useful,
    00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013   Lesser General Public License for more details.
    00014
    00015   You should have received a copy of the GNU Lesser General Public
    00016   License along with this library; if not, write to the Free Software
    00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018 */
    00024 #ifndef SESSIONSET_H
    00025 #define SESSIONSET_H
    00026
    00027
    00028 #include <ortp/rtpsession.h>
    00029
    00030 #ifdef __cplusplus
    00031 extern "C"{
    00032 #endif
    00033
    00034
    00035 #if     !defined(_WIN32) && !defined(_WIN32_WCE)
    00036 /* UNIX */
    00037 #include <sys/time.h>
    00038 #include <sys/types.h>
    00039 #include <unistd.h>
    00040
    00041 #define ORTP_FD_SET(d, s)     FD_SET(d, s)
    00042 #define ORTP_FD_CLR(d, s)     FD_CLR(d, s)
    00043 #define ORTP_FD_ISSET(d, s)   FD_ISSET(d, s)
    00044 #define ORTP_FD_ZERO(s)           FD_ZERO(s)
    00045
    00046 typedef fd_set ortp_fd_set;
    00047
    00048
    00049 #else
    00050 /* WIN32 */
    00051
    00052 #define ORTP_FD_ZERO(s) \
    00053   do {                                                                        \
    00054     unsigned int __i;                                                         \
    00055     ortp_fd_set *__arr = (s);                                                 \
    00056     for (__i = 0; __i < sizeof (ortp_fd_set) / sizeof (ortp__fd_mask); ++__i)         \
    00057       ORTP__FDS_BITS (__arr)[__i] = 0;                                        \
    00058   } while (0)
    00059 #define ORTP_FD_SET(d, s)     (ORTP__FDS_BITS (s)[ORTP__FDELT(d)] |= ORTP__FDMASK(d))
    00060 #define ORTP_FD_CLR(d, s)     (ORTP__FDS_BITS (s)[ORTP__FDELT(d)] &= ~ORTP__FDMASK(d))
    00061 #define ORTP_FD_ISSET(d, s)   ((ORTP__FDS_BITS (s)[ORTP__FDELT(d)] & ORTP__FDMASK(d)) != 0)
    00062
    00063
    00064
    00065 /* The fd_set member is required to be an array of longs.  */
    00066 typedef long int ortp__fd_mask;
    00067
    00068
    00069 /* Number of bits per word of `fd_set' (some code assumes this is 32).  */
    00070 #define ORTP__FD_SETSIZE 1024
    00071
    00072 /* It's easier to assume 8-bit bytes than to get CHAR_BIT.  */
    00073 #define ORTP__NFDBITS   (8 * sizeof (ortp__fd_mask))
    00074 #define ORTP__FDELT(d)  ((d) / ORTP__NFDBITS)
    00075 #define ORTP__FDMASK(d) ((ortp__fd_mask) 1 << ((d) % ORTP__NFDBITS))
    00076
    00077
    00078 /* fd_set for select and pselect.  */
    00079 typedef struct
    00080   {
    00081     ortp__fd_mask fds_bits[ORTP__FD_SETSIZE / ORTP__NFDBITS];
    00082 # define ORTP__FDS_BITS(set) ((set)->fds_bits)
    00083   } ortp_fd_set;
    00084
    00085
    00086 #endif /*end WIN32*/
    00087
    00088 struct _SessionSet
    00089 {
    00090         ortp_fd_set rtpset;
    00091 };
    00092
    00093
    00094 typedef struct _SessionSet SessionSet;
    00095
    00096 #define session_set_init(ss)            ORTP_FD_ZERO(&(ss)->rtpset)
    00097
    00098 SessionSet * session_set_new(void);
    00104 #define session_set_set(ss,rtpsession)          ORTP_FD_SET((rtpsession)->mask_pos,&(ss)->rtpset)
    00105
    00112 #define session_set_is_set(ss,rtpsession)       ORTP_FD_ISSET((rtpsession)->mask_pos,&(ss)->rtpset)
    00113
    00121 #define session_set_clr(ss,rtpsession)          ORTP_FD_CLR((rtpsession)->mask_pos,&(ss)->rtpset)
    00122
    00123 #define session_set_copy(dest,src)              memcpy(&(dest)->rtpset,&(src)->rtpset,sizeof(ortp_fd_set))
    00124
    00125
    00129 void session_set_destroy(SessionSet *set);
    00130
    00131
    00132 int session_set_select(SessionSet *recvs, SessionSet *sends, SessionSet *errors);
    00133 int session_set_timedselect(SessionSet *recvs, SessionSet *sends, SessionSet *errors,  struct timeval *timeout);
    00134
    00135 #ifdef __cplusplus
    00136 }
    00137 #endif
    00138
    00139 #endif