oRTP  0.25.0
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 #include <ortp/rtcp.h>
25 
26 typedef mblk_t OrtpEvent;
27 
28 typedef unsigned long OrtpEventType;
29 
30 typedef enum {
31  OrtpRTPSocket,
32  OrtpRTCPSocket
33 } OrtpSocketType;
34 
36  mblk_t *packet; /* most events are associated to a received packet */
37  struct sockaddr_storage source_addr;
38  socklen_t source_addrlen;
39  ortpTimeSpec ts;
40  union {
41  int telephone_event;
42  int payload_type;
43  bool_t dtls_stream_encrypted;
44  bool_t zrtp_stream_encrypted;
45  struct _ZrtpSas{
46  char sas[32]; // up to 31 + null characters
47  bool_t verified;
48  } zrtp_sas;
49  OrtpSocketType socket_type;
50  bool_t ice_processing_successful;
51  uint64_t tmmbr_mxtbr;
52  uint32_t received_rtt_character;
53  } info;
54 };
55 
56 typedef struct _OrtpEventData OrtpEventData;
57 
58 
59 
60 #ifdef __cplusplus
61 extern "C"{
62 #endif
63 
64 ORTP_PUBLIC OrtpEvent * ortp_event_new(OrtpEventType tp);
65 ORTP_PUBLIC OrtpEventType ortp_event_get_type(const OrtpEvent *ev);
66 /* type is one of the following*/
67 #define ORTP_EVENT_STUN_PACKET_RECEIVED 1
68 #define ORTP_EVENT_PAYLOAD_TYPE_CHANGED 2
69 #define ORTP_EVENT_TELEPHONE_EVENT 3
70 #define ORTP_EVENT_RTCP_PACKET_RECEIVED 4
71 #define ORTP_EVENT_RTCP_PACKET_EMITTED 5
72 #define ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED 6
73 #define ORTP_EVENT_ZRTP_SAS_READY 7
74 #define ORTP_EVENT_ICE_CHECK_LIST_PROCESSING_FINISHED 8
75 #define ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED 9
76 #define ORTP_EVENT_ICE_GATHERING_FINISHED 10
77 #define ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED 11
78 #define ORTP_EVENT_ICE_RESTART_NEEDED 12
79 #define ORTP_EVENT_DTLS_ENCRYPTION_CHANGED 13
80 #define ORTP_EVENT_TMMBR_RECEIVED 14
81 #define ORTP_EVENT_RTT_CHARACTER_RECEIVED 15
82 
83 ORTP_PUBLIC OrtpEventData * ortp_event_get_data(OrtpEvent *ev);
84 ORTP_PUBLIC void ortp_event_destroy(OrtpEvent *ev);
85 ORTP_PUBLIC OrtpEvent *ortp_event_dup(OrtpEvent *ev);
86 
87 typedef struct OrtpEvQueue{
88  queue_t q;
89  ortp_mutex_t mutex;
90 } OrtpEvQueue;
91 
92 ORTP_PUBLIC OrtpEvQueue * ortp_ev_queue_new(void);
93 ORTP_PUBLIC void ortp_ev_queue_destroy(OrtpEvQueue *q);
94 ORTP_PUBLIC OrtpEvent * ortp_ev_queue_get(OrtpEvQueue *q);
95 ORTP_PUBLIC void ortp_ev_queue_flush(OrtpEvQueue * qp);
96 
97 struct _RtpSession;
98 
106 typedef void (*OrtpEvDispatcherCb)(const OrtpEventData *evd, void *user_data);
107 typedef struct OrtpEvDispatcherData{
108  OrtpEventType type;
109  rtcp_type_t subtype;
110  OrtpEvDispatcherCb on_found;
111  void* user_data;
113 
114 typedef struct OrtpEvDispatcher{
115  OrtpEvQueue *q;
116  struct _RtpSession* session;
117  OList *cbs;
119 
129 ORTP_PUBLIC OrtpEvDispatcher * ortp_ev_dispatcher_new(struct _RtpSession* session);
136 ORTP_PUBLIC void ortp_ev_dispatcher_destroy(OrtpEvDispatcher *d);
144 ORTP_PUBLIC void ortp_ev_dispatcher_iterate(OrtpEvDispatcher *d);
158 ORTP_PUBLIC void ortp_ev_dispatcher_connect(OrtpEvDispatcher *d
159  , OrtpEventType type
160  , rtcp_type_t subtype
161  , OrtpEvDispatcherCb on_receive
162  , void *user_data);
163 
167 void ortp_ev_dispatcher_disconnect(OrtpEvDispatcher *d
168  , OrtpEventType type
169  , rtcp_type_t subtype
170  , OrtpEvDispatcherCb cb);
171 
172 #ifdef __cplusplus
173 }
174 #endif
175 
176 #endif
177 
Definition: port.h:285
Definition: rtpsession.h:354
Definition: str_utils.h:49
Definition: event.h:35
Definition: str_utils.h:78
Definition: event.h:87
Definition: utils.h:33
Definition: event.h:114
Definition: event.h:107