oRTP  0.16.1
event.h
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 #ifndef ortp_events_h
21 #define ortp_events_h
22 
23 #include <ortp/str_utils.h>
24 
25 typedef mblk_t OrtpEvent;
26 
27 typedef unsigned long OrtpEventType;
28 
29 typedef struct RtpEndpoint{
30 #ifdef ORTP_INET6
31  struct sockaddr_storage addr;
32 #else
33  struct sockaddr addr;
34 #endif
35  socklen_t addrlen;
37 
38 
40  mblk_t *packet; /* most events are associated to a received packet */
41  RtpEndpoint *ep;
42  union {
43  int telephone_event;
44  int payload_type;
45  } info;
46 };
47 
48 typedef struct _OrtpEventData OrtpEventData;
49 
50 
51 
52 #ifdef __cplusplus
53 extern "C"{
54 #endif
55 
56 RtpEndpoint *rtp_endpoint_new(struct sockaddr *addr, socklen_t addrlen);
57 RtpEndpoint *rtp_endpoint_dup(const RtpEndpoint *ep);
58 
59 OrtpEvent * ortp_event_new(OrtpEventType tp);
60 OrtpEventType ortp_event_get_type(const OrtpEvent *ev);
61 /* type is one of the following*/
62 #define ORTP_EVENT_STUN_PACKET_RECEIVED 1
63 #define ORTP_EVENT_PAYLOAD_TYPE_CHANGED 2
64 #define ORTP_EVENT_TELEPHONE_EVENT 3
65 #define ORTP_EVENT_RTCP_PACKET_RECEIVED 4
66 OrtpEventData * ortp_event_get_data(OrtpEvent *ev);
67 void ortp_event_destroy(OrtpEvent *ev);
68 OrtpEvent *ortp_event_dup(OrtpEvent *ev);
69 
70 typedef struct OrtpEvQueue{
71  queue_t q;
72  ortp_mutex_t mutex;
73 } OrtpEvQueue;
74 
75 OrtpEvQueue * ortp_ev_queue_new(void);
76 void ortp_ev_queue_destroy(OrtpEvQueue *q);
77 OrtpEvent * ortp_ev_queue_get(OrtpEvQueue *q);
78 void ortp_ev_queue_flush(OrtpEvQueue * qp);
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif
85