source: mediastreamer2/linphone/oRTP/include/ortp/sessionset.h @ 0:5a6e836a86a3

Last change on this file since 0:5a6e836a86a3 was 0:5a6e836a86a3, checked in by aymeric <aymeric@…>, 5 years ago

Initial import

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@1 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File size: 3.7 KB
Line 
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/**
20 * \file sessionset.h
21 * \brief Sending and receiving multiple streams together with only one thread.
22 *
23**/
24#ifndef SESSIONSET_H
25#define SESSIONSET_H
26
27
28#include <ortp/rtpsession.h>
29
30#ifdef __cplusplus
31extern "C"{
32#endif
33
34
35#if     !defined(_WIN32) && !defined(_WIN32_WCE)
36/* UNIX */
37#include <sys/time.h>
38#include <sys/types.h>
39#include <unistd.h>
40
41#define ORTP_FD_SET(d, s)     FD_SET(d, s)
42#define ORTP_FD_CLR(d, s)     FD_CLR(d, s)
43#define ORTP_FD_ISSET(d, s)   FD_ISSET(d, s)
44#define ORTP_FD_ZERO(s)           FD_ZERO(s)
45
46typedef fd_set ortp_fd_set;
47
48
49#else
50/* WIN32 */
51
52#define ORTP_FD_ZERO(s) \
53  do {                                                                        \
54    unsigned int __i;                                                         \
55    ortp_fd_set *__arr = (s);                                                 \
56    for (__i = 0; __i < sizeof (ortp_fd_set) / sizeof (ortp__fd_mask); ++__i)         \
57      ORTP__FDS_BITS (__arr)[__i] = 0;                                        \
58  } while (0)
59#define ORTP_FD_SET(d, s)     (ORTP__FDS_BITS (s)[ORTP__FDELT(d)] |= ORTP__FDMASK(d))
60#define ORTP_FD_CLR(d, s)     (ORTP__FDS_BITS (s)[ORTP__FDELT(d)] &= ~ORTP__FDMASK(d))
61#define ORTP_FD_ISSET(d, s)   ((ORTP__FDS_BITS (s)[ORTP__FDELT(d)] & ORTP__FDMASK(d)) != 0)
62
63
64
65/* The fd_set member is required to be an array of longs.  */
66typedef long int ortp__fd_mask;
67
68
69/* Number of bits per word of `fd_set' (some code assumes this is 32).  */
70#define ORTP__FD_SETSIZE 1024
71
72/* It's easier to assume 8-bit bytes than to get CHAR_BIT.  */
73#define ORTP__NFDBITS   (8 * sizeof (ortp__fd_mask))
74#define ORTP__FDELT(d)  ((d) / ORTP__NFDBITS)
75#define ORTP__FDMASK(d) ((ortp__fd_mask) 1 << ((d) % ORTP__NFDBITS))
76
77
78/* fd_set for select and pselect.  */
79typedef struct
80  {
81    ortp__fd_mask fds_bits[ORTP__FD_SETSIZE / ORTP__NFDBITS];
82# define ORTP__FDS_BITS(set) ((set)->fds_bits)
83  } ortp_fd_set;
84
85
86#endif /*end WIN32*/
87
88struct _SessionSet
89{
90        ortp_fd_set rtpset;
91};
92
93
94typedef struct _SessionSet SessionSet;
95
96#define session_set_init(ss)            ORTP_FD_ZERO(&(ss)->rtpset)
97
98SessionSet * session_set_new(void);
99/**
100 * This macro adds the rtp session to the set.
101 * @param ss a set (SessionSet object)
102 * @param rtpsession a RtpSession
103**/
104#define session_set_set(ss,rtpsession)          ORTP_FD_SET((rtpsession)->mask_pos,&(ss)->rtpset)
105
106/**
107 * This macro tests if the session is part of the set. 1 is returned if true, 0 else.
108 *@param ss a set (#SessionSet object)
109 *@param rtpsession a rtp session
110 *
111**/
112#define session_set_is_set(ss,rtpsession)       ORTP_FD_ISSET((rtpsession)->mask_pos,&(ss)->rtpset)
113
114/**
115 * Removes the session from the set.
116 *@param ss a set of sessions.
117 *@param rtpsession a rtp session.
118 *
119 *
120**/
121#define session_set_clr(ss,rtpsession)          ORTP_FD_CLR((rtpsession)->mask_pos,&(ss)->rtpset)
122
123#define session_set_copy(dest,src)              memcpy(&(dest)->rtpset,&(src)->rtpset,sizeof(ortp_fd_set))
124
125
126/**
127 * Frees a SessionSet.
128**/
129void session_set_destroy(SessionSet *set);
130
131       
132int session_set_select(SessionSet *recvs, SessionSet *sends, SessionSet *errors);
133
134
135#ifdef __cplusplus
136}
137#endif
138       
139#endif
Note: See TracBrowser for help on using the repository browser.