oRTP  0.22.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 typedef struct RtpEndpoint{
00035 #ifdef ORTP_INET6
00036         struct sockaddr_storage addr;
00037 #else
00038         struct sockaddr addr;
00039 #endif
00040         socklen_t addrlen;
00041 }RtpEndpoint;
00042 
00043 
00044 struct _OrtpEventData{
00045         mblk_t *packet; /* most events are associated to a received packet */
00046         RtpEndpoint *ep;
00047         ortpTimeSpec ts;
00048         union {
00049                 int telephone_event;
00050                 int payload_type;
00051                 bool_t zrtp_stream_encrypted;
00052                 struct _ZrtpSas{
00053                         char sas[5]; // 4 characters
00054                         bool_t verified;
00055                 } zrtp_sas;
00056                 OrtpSocketType socket_type;
00057                 bool_t ice_processing_successful;
00058         } info;
00059 };
00060 
00061 typedef struct _OrtpEventData OrtpEventData;
00062 
00063 
00064 
00065 #ifdef __cplusplus
00066 extern "C"{
00067 #endif
00068 
00069 ORTP_PUBLIC RtpEndpoint *rtp_endpoint_new(struct sockaddr *addr, socklen_t addrlen);
00070 ORTP_PUBLIC RtpEndpoint *rtp_endpoint_dup(const RtpEndpoint *ep);
00071 
00072 ORTP_PUBLIC OrtpEvent * ortp_event_new(OrtpEventType tp);
00073 ORTP_PUBLIC OrtpEventType ortp_event_get_type(const OrtpEvent *ev);
00074 /* type is one of the following*/
00075 #define ORTP_EVENT_STUN_PACKET_RECEIVED         1
00076 #define ORTP_EVENT_PAYLOAD_TYPE_CHANGED         2
00077 #define ORTP_EVENT_TELEPHONE_EVENT              3
00078 #define ORTP_EVENT_RTCP_PACKET_RECEIVED         4 
00079 #define ORTP_EVENT_RTCP_PACKET_EMITTED          5 
00080 #define ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED      6
00081 #define ORTP_EVENT_ZRTP_SAS_READY               7
00082 #define ORTP_EVENT_ICE_CHECK_LIST_PROCESSING_FINISHED   8
00083 #define ORTP_EVENT_ICE_SESSION_PROCESSING_FINISHED      9
00084 #define ORTP_EVENT_ICE_GATHERING_FINISHED               10
00085 #define ORTP_EVENT_ICE_LOSING_PAIRS_COMPLETED           11
00086 #define ORTP_EVENT_ICE_RESTART_NEEDED                   12
00087 
00088 ORTP_PUBLIC OrtpEventData * ortp_event_get_data(OrtpEvent *ev);
00089 ORTP_PUBLIC void ortp_event_destroy(OrtpEvent *ev);
00090 ORTP_PUBLIC OrtpEvent *ortp_event_dup(OrtpEvent *ev);
00091 
00092 typedef struct OrtpEvQueue{
00093         queue_t q;
00094         ortp_mutex_t mutex;
00095 } OrtpEvQueue;
00096 
00097 ORTP_PUBLIC OrtpEvQueue * ortp_ev_queue_new(void);
00098 ORTP_PUBLIC void ortp_ev_queue_destroy(OrtpEvQueue *q);
00099 ORTP_PUBLIC OrtpEvent * ortp_ev_queue_get(OrtpEvQueue *q);
00100 ORTP_PUBLIC void ortp_ev_queue_flush(OrtpEvQueue * qp);
00101 
00102 #ifdef __cplusplus
00103 }
00104 #endif
00105 
00106 #endif
00107