2002-06-16 16:06:38 +00:00
/*
2005-08-30 18:32:10 +00:00
* Asterisk - - An open source telephony toolkit .
2002-06-16 16:06:38 +00:00
*
2006-01-03 22:16:23 +00:00
* Copyright ( C ) 1999 - 2006 , Digium , Inc .
2002-06-16 16:06:38 +00:00
*
2004-12-28 16:35:31 +00:00
* Mark Spencer < markster @ digium . com >
2002-06-16 16:06:38 +00:00
*
2005-08-30 18:32:10 +00:00
* See http : //www.asterisk.org for more information about
* the Asterisk project . Please do not directly contact
* any of the maintainers of this project for assistance ;
* the project provides a web site , mailing lists and IRC
* channels for your use .
*
2002-06-16 16:06:38 +00:00
* This program is free software , distributed under the terms of
2005-08-30 18:32:10 +00:00
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree .
*/
2005-10-12 20:45:18 +00:00
/*!
* \ file rtp . h
* \ brief Supports RTP and RTCP with Symmetric RTP support for NAT traversal .
*
2005-10-24 20:12:06 +00:00
* RTP is defined in RFC 3550.
2002-06-16 16:06:38 +00:00
*/
# ifndef _ASTERISK_RTP_H
# define _ASTERISK_RTP_H
2006-01-03 09:30:19 +00:00
# include <netinet/in.h>
2005-04-21 06:02:45 +00:00
# include "asterisk/frame.h"
# include "asterisk/io.h"
# include "asterisk/sched.h"
# include "asterisk/channel.h"
2006-01-03 09:30:19 +00:00
# include "asterisk/linkedlists.h"
2002-06-16 16:06:38 +00:00
# if defined(__cplusplus) || defined(c_plusplus)
extern " C " {
# endif
2003-03-12 06:00:18 +00:00
/* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
/*! DTMF (RFC2833) */
# define AST_RTP_DTMF (1 << 0)
/*! 'Comfort Noise' (RFC3389) */
# define AST_RTP_CN (1 << 1)
2003-05-02 15:37:34 +00:00
/*! DTMF (Cisco Proprietary) */
# define AST_RTP_CISCO_DTMF (1 << 2)
2003-03-12 06:00:18 +00:00
/*! Maximum RTP-specific code */
2003-05-02 15:37:34 +00:00
# define AST_RTP_MAX AST_RTP_CISCO_DTMF
2003-03-12 06:00:18 +00:00
2003-02-16 06:00:12 +00:00
struct ast_rtp_protocol {
2006-01-03 09:30:19 +00:00
/*! Get RTP struct, or NULL if unwilling to transfer */
2005-03-04 06:47:24 +00:00
struct ast_rtp * ( * const get_rtp_info ) ( struct ast_channel * chan ) ;
2006-01-03 09:30:19 +00:00
/*! Get RTP struct, or NULL if unwilling to transfer */
2005-03-04 06:47:24 +00:00
struct ast_rtp * ( * const get_vrtp_info ) ( struct ast_channel * chan ) ;
2006-01-03 09:30:19 +00:00
/*! Set RTP peer */
2005-09-09 19:54:34 +00:00
int ( * const set_rtp_peer ) ( struct ast_channel * chan , struct ast_rtp * peer , struct ast_rtp * vpeer , int codecs , int nat_active ) ;
2005-03-04 06:47:24 +00:00
int ( * const get_codec ) ( struct ast_channel * chan ) ;
const char * const type ;
2006-01-03 09:30:19 +00:00
AST_LIST_ENTRY ( ast_rtp_protocol ) list ;
2003-02-16 06:00:12 +00:00
} ;
2005-10-12 20:45:18 +00:00
/*!
* \ brief Structure representing a RTP session .
*
* RTP session is defined on page 9 of RFC 3550 : " An association among a set of participants communicating with RTP. A participant may be involved in multiple RTP sessions at the same time [...] "
*
*/
2002-06-16 16:06:38 +00:00
struct ast_rtp ;
typedef int ( * ast_rtp_callback ) ( struct ast_rtp * rtp , struct ast_frame * f , void * data ) ;
2005-10-12 20:45:18 +00:00
/*!
* \ brief Initializate a RTP session .
*
* \ param sched
* \ param io
* \ param rtcpenable
* \ param callbackmode
* \ returns A representation ( structure ) of an RTP session .
*/
2003-06-28 16:40:02 +00:00
struct ast_rtp * ast_rtp_new ( struct sched_context * sched , struct io_context * io , int rtcpenable , int callbackmode ) ;
2002-06-16 16:06:38 +00:00
2005-10-12 20:45:18 +00:00
/*!
* \ brief Initializate a RTP session using an in_addr structure .
*
* This fuction gets called by ast_rtp_new ( ) .
*
* \ param sched
* \ param io
* \ param rtcpenable
* \ param callbackmode
* \ param in
* \ returns A representation ( structure ) of an RTP session .
*/
2004-07-08 11:46:15 +00:00
struct ast_rtp * ast_rtp_new_with_bindaddr ( struct sched_context * sched , struct io_context * io , int rtcpenable , int callbackmode , struct in_addr in ) ;
2002-06-16 16:06:38 +00:00
void ast_rtp_set_peer ( struct ast_rtp * rtp , struct sockaddr_in * them ) ;
2003-06-28 16:40:02 +00:00
void ast_rtp_get_peer ( struct ast_rtp * rtp , struct sockaddr_in * them ) ;
2003-01-17 19:50:12 +00:00
2002-06-16 16:06:38 +00:00
void ast_rtp_get_us ( struct ast_rtp * rtp , struct sockaddr_in * us ) ;
void ast_rtp_destroy ( struct ast_rtp * rtp ) ;
2004-12-28 16:35:31 +00:00
void ast_rtp_reset ( struct ast_rtp * rtp ) ;
2002-06-16 16:06:38 +00:00
void ast_rtp_set_callback ( struct ast_rtp * rtp , ast_rtp_callback callback ) ;
void ast_rtp_set_data ( struct ast_rtp * rtp , void * data ) ;
int ast_rtp_write ( struct ast_rtp * rtp , struct ast_frame * f ) ;
2003-02-12 13:59:15 +00:00
struct ast_frame * ast_rtp_read ( struct ast_rtp * rtp ) ;
2003-06-28 16:40:02 +00:00
struct ast_frame * ast_rtcp_read ( struct ast_rtp * rtp ) ;
2003-02-12 13:59:15 +00:00
int ast_rtp_fd ( struct ast_rtp * rtp ) ;
2003-06-28 16:40:02 +00:00
int ast_rtcp_fd ( struct ast_rtp * rtp ) ;
2003-01-17 19:50:12 +00:00
int ast_rtp_senddigit ( struct ast_rtp * rtp , char digit ) ;
2005-01-07 07:11:40 +00:00
int ast_rtp_sendcng ( struct ast_rtp * rtp , int level ) ;
2003-01-17 19:50:12 +00:00
int ast_rtp_settos ( struct ast_rtp * rtp , int tos ) ;
2006-01-03 09:30:19 +00:00
/*! \brief Setting RTP payload types from lines in a SDP description: */
2003-03-13 06:00:20 +00:00
void ast_rtp_pt_clear ( struct ast_rtp * rtp ) ;
2006-01-03 09:30:19 +00:00
/*! \brief Set payload types to defaults */
2003-03-13 06:00:20 +00:00
void ast_rtp_pt_default ( struct ast_rtp * rtp ) ;
void ast_rtp_set_m_type ( struct ast_rtp * rtp , int pt ) ;
void ast_rtp_set_rtpmap_type ( struct ast_rtp * rtp , int pt ,
2003-03-12 06:00:18 +00:00
char * mimeType , char * mimeSubtype ) ;
2003-03-07 06:00:13 +00:00
2006-01-03 09:30:19 +00:00
/*! \brief Mapping between RTP payload format codes and Asterisk codes: */
2003-03-13 06:00:20 +00:00
struct rtpPayloadType ast_rtp_lookup_pt ( struct ast_rtp * rtp , int pt ) ;
int ast_rtp_lookup_code ( struct ast_rtp * rtp , int isAstFormat , int code ) ;
2002-06-16 16:06:38 +00:00
2003-03-13 06:00:20 +00:00
void ast_rtp_get_current_formats ( struct ast_rtp * rtp ,
2003-03-12 06:00:18 +00:00
int * astFormats , int * nonAstFormats ) ;
2002-06-16 16:06:38 +00:00
2006-01-03 09:30:19 +00:00
/*! \brief Mapping an Asterisk code into a MIME subtype (string): */
2003-03-13 06:00:20 +00:00
char * ast_rtp_lookup_mime_subtype ( int isAstFormat , int code ) ;
2003-03-12 06:00:18 +00:00
2006-01-03 09:30:19 +00:00
/*! \brief Build a string of MIME subtype names from a capability list */
2005-04-05 23:34:56 +00:00
char * ast_rtp_lookup_mime_multiple ( char * buf , int size , const int capability , const int isAstFormat ) ;
2003-03-12 06:00:18 +00:00
void ast_rtp_setnat ( struct ast_rtp * rtp , int nat ) ;
2002-06-16 16:06:38 +00:00
2005-10-13 18:27:54 +00:00
int ast_rtp_bridge ( struct ast_channel * c0 , struct ast_channel * c1 , int flags , struct ast_frame * * fo , struct ast_channel * * rc , int timeoutms ) ;
2003-02-16 06:00:12 +00:00
int ast_rtp_proto_register ( struct ast_rtp_protocol * proto ) ;
void ast_rtp_proto_unregister ( struct ast_rtp_protocol * proto ) ;
2005-12-20 17:52:31 +00:00
int ast_rtp_make_compatible ( struct ast_channel * dest , struct ast_channel * src ) ;
2003-03-20 22:01:53 +00:00
void ast_rtp_stop ( struct ast_rtp * rtp ) ;
2003-05-16 02:50:46 +00:00
void ast_rtp_init ( void ) ;
void ast_rtp_reload ( void ) ;
2002-06-16 16:06:38 +00:00
# if defined(__cplusplus) || defined(c_plusplus)
}
# endif
2005-08-30 18:32:10 +00:00
# endif /* _ASTERISK_RTP_H */