oRTP  0.24.0
include/ortp/event.h
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 */
00019 
00020 #ifndef ortp_events_h
00021 #define ortp_events_h
00022 
00023 #include <ortp/str_utils.h>
00024 
00025 typedef mblk_t OrtpEvent;
00026 
00027 typedef unsigned long OrtpEventType;
00028 
00029 typedef enum {
00030         OrtpRTPSocket,
00031         OrtpRTCPSocket
00032 } OrtpSocketType;
00033 
00034 struct _OrtpEventData{
00035         mblk_t *packet; /* most events are associated to a received packet */
00036         struct sockaddr_storage source_addr;
00037         socklen_t source_addrlen;
00038         ortpTimeSpec ts;
00039         union {
00040                 int telephone_event;
00041                 int payload_type;
00042                 bool_t dtls_stream_encrypted;
00043                 bool_t zrtp_stream_encrypted;
00044                 struct _ZrtpSas{
00045                         char sas[5]; // 4 characters
00046                         bool_t verified;
00047                 } zrtp_sas;
00048                 OrtpSocketType socket_type;
00049                 bool_t ice_processing_successful;
00050         } info;
00051 };
00052 
00053 typedef struct _OrtpEventData OrtpEventData;
00054 
00055 
00056 
00057 #ifdef __cplusplus
00058 extern "C"{
00059 #endif
00060 
00061 ORTP_PUBLIC OrtpEvent * ortp_event_new(OrtpEventType tp);
00062 ORTP_PUBLIC OrtpEventType ortp_event_get_type(const OrtpEvent *ev);
00063 /* type is one of the following*/
00064 #define ORTP_EVENT_STUN_PACKET_RECEIVED         1
00065 #define ORTP_EVENT_PAYLOAD_TYPE_CHANGED         2
00066 #define ORTP_EVENT_TELEPHONE_EVENT              3
00067 #define ORTP_EVENT_RTCP_PACKET_RECEIVED         4 
00068 #define ORTP_EVENT_RTCP_PACKET_EMITTED          5 
00069 #define ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED      6
00070 #define ORTP_EVENT_ZRTP_SAS_READY               7
00071 #define ORTP_EVENT_ICE_CHECK_LIST_PROCESSING_FINISHED   8
00072 #define ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED      9
00073 #define ORTP_EVENT_ICE_GATHERING_FINISHED               10
00074 #define ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED           11
00075 #define ORTP_EVENT_ICE_RESTART_NEEDED                   12
00076 #define ORTP_EVENT_DTLS_ENCRYPTION_CHANGED              13
00077 
00078 ORTP_PUBLIC OrtpEventData * ortp_event_get_data(OrtpEvent *ev);
00079 ORTP_PUBLIC void ortp_event_destroy(OrtpEvent *ev);
00080 ORTP_PUBLIC OrtpEvent *ortp_event_dup(OrtpEvent *ev);
00081 
00082 typedef struct OrtpEvQueue{
00083         queue_t q;
00084         ortp_mutex_t mutex;
00085 } OrtpEvQueue;
00086 
00087 ORTP_PUBLIC OrtpEvQueue * ortp_ev_queue_new(void);
00088 ORTP_PUBLIC void ortp_ev_queue_destroy(OrtpEvQueue *q);
00089 ORTP_PUBLIC OrtpEvent * ortp_ev_queue_get(OrtpEvQueue *q);
00090 ORTP_PUBLIC void ortp_ev_queue_flush(OrtpEvQueue * qp);
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #endif
00097