1 /* 2 * The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) implementation with additional features. 3 * Copyright (C) 2017 Belledonne Communications SARL 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program 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 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 /** 21 * \file telephonyevents.h 22 * \brief Receiving and sending telephone events (RFC2833) 23 * 24 **/ 25 26 27 #ifndef TELEPHONYEVENTS_H 28 #define TELEPHONYEVENTS_H 29 30 #include <ortp/rtpsession.h> 31 32 33 struct _telephone_event 34 { 35 #ifdef ORTP_BIGENDIAN 36 uint32_t event:8; 37 uint32_t E:1; 38 uint32_t R:1; 39 uint32_t volume:6; 40 uint32_t duration:16; 41 #else 42 uint32_t event:8; 43 uint32_t volume:6; 44 uint32_t R:1; 45 uint32_t E:1; 46 uint32_t duration:16; 47 #endif 48 }; 49 50 typedef struct _telephone_event telephone_event_t; 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 /* tell if the session supports telephony events. For this the telephony events payload_type 57 must be present in the rtp profile used by the session */ 58 59 /* low level functions */ 60 ORTP_PUBLIC int rtp_session_telephone_events_supported(RtpSession *session); 61 ORTP_PUBLIC int rtp_session_send_telephone_events_supported(RtpSession *session); 62 ORTP_PUBLIC int rtp_session_recv_telephone_events_supported(RtpSession *session); 63 ORTP_PUBLIC mblk_t *rtp_session_create_telephone_event_packet(RtpSession *session, int start); 64 65 ORTP_PUBLIC int rtp_session_add_telephone_event(RtpSession *session, 66 mblk_t *packet, uint8_t event, int end, uint8_t volume, uint16_t duration); 67 68 ORTP_PUBLIC int rtp_session_read_telephone_event(RtpSession *session, 69 mblk_t *packet,telephone_event_t **tab); 70 71 /* high level functions*/ 72 ORTP_PUBLIC int rtp_session_send_dtmf(RtpSession *session, char dtmf, uint32_t userts); 73 ORTP_PUBLIC int rtp_session_send_dtmf2(RtpSession *session, char dtmf, uint32_t userts, int duration); 74 /* for high level telephony event callback */ 75 ORTP_PUBLIC void rtp_session_check_telephone_events(RtpSession *session, mblk_t *m0); 76 77 #ifdef __cplusplus 78 } 79 #endif 80 81 /* the size allocated for telephony events packets */ 82 #define TELEPHONY_EVENTS_ALLOCATED_SIZE (4*sizeof(telephone_event_t)) 83 84 /* list of named events */ 85 #define TEV_DTMF_0 (0) 86 #define TEV_DTMF_1 (1) 87 #define TEV_DTMF_2 (2) 88 #define TEV_DTMF_3 (3) 89 #define TEV_DTMF_4 (4) 90 #define TEV_DTMF_5 (5) 91 #define TEV_DTMF_6 (6) 92 #define TEV_DTMF_7 (7) 93 #define TEV_DTMF_8 (8) 94 #define TEV_DTMF_9 (9) 95 #define TEV_DTMF_STAR (10) 96 #define TEV_DTMF_POUND (11) 97 #define TEV_DTMF_A (12) 98 #define TEV_DTMF_B (13) 99 #define TEV_DTMF_C (14) 100 #define TEV_DTMF_D (15) 101 #define TEV_FLASH (16) 102 103 104 #endif 105