Wed Oct 28 15:47:56 2009

Asterisk developer's documentation


rtp.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! 
00020  * \file rtp.h
00021  * \brief Supports RTP and RTCP with Symmetric RTP support for NAT traversal.
00022  * 
00023  * RTP is defined in RFC 3550.
00024  */
00025 
00026 #ifndef _ASTERISK_RTP_H
00027 #define _ASTERISK_RTP_H
00028 
00029 #include "asterisk/frame.h"
00030 #include "asterisk/io.h"
00031 #include "asterisk/sched.h"
00032 #include "asterisk/channel.h"
00033 
00034 #include <netinet/in.h>
00035 
00036 #if defined(__cplusplus) || defined(c_plusplus)
00037 extern "C" {
00038 #endif
00039 
00040 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
00041 /*! DTMF (RFC2833) */
00042 #define AST_RTP_DTMF            (1 << 0)
00043 /*! 'Comfort Noise' (RFC3389) */
00044 #define AST_RTP_CN              (1 << 1)
00045 /*! DTMF (Cisco Proprietary) */
00046 #define AST_RTP_CISCO_DTMF      (1 << 2)
00047 /*! Maximum RTP-specific code */
00048 #define AST_RTP_MAX             AST_RTP_CISCO_DTMF
00049 
00050 struct ast_rtp_protocol {
00051    /* Get RTP struct, or NULL if unwilling to transfer */
00052    struct ast_rtp *(* const get_rtp_info)(struct ast_channel *chan);
00053    /* Get RTP struct, or NULL if unwilling to transfer */
00054    struct ast_rtp *(* const get_vrtp_info)(struct ast_channel *chan);
00055    /* Set RTP peer */
00056    int (* const set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, int codecs, int nat_active);
00057    int (* const get_codec)(struct ast_channel *chan);
00058    const char * const type;
00059    struct ast_rtp_protocol *next;
00060 };
00061 
00062 /*!
00063  * \brief Structure representing a RTP session.
00064  * 
00065  * 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 [...]"
00066  * 
00067  */
00068 struct ast_rtp;
00069 
00070 typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
00071 
00072 /*!
00073  * \brief Initializate a RTP session.
00074  * 
00075  * \param sched
00076  * \param io
00077  * \param rtcpenable
00078  * \param callbackmode
00079  * \returns A representation (structure) of an RTP session.
00080  */
00081 struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode);
00082 
00083 /*!
00084  * \brief Initializate a RTP session using an in_addr structure.
00085  * 
00086  * This fuction gets called by ast_rtp_new().
00087  * 
00088  * \param sched
00089  * \param io
00090  * \param rtcpenable
00091  * \param callbackmode
00092  * \param in
00093  * \returns A representation (structure) of an RTP session.
00094  */
00095 struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr in);
00096 
00097 void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
00098 
00099 int ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
00100 
00101 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us);
00102 
00103 void ast_rtp_destroy(struct ast_rtp *rtp);
00104 
00105 void ast_rtp_reset(struct ast_rtp *rtp);
00106 
00107 void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback);
00108 
00109 void ast_rtp_set_data(struct ast_rtp *rtp, void *data);
00110 
00111 int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *f);
00112 
00113 struct ast_frame *ast_rtp_read(struct ast_rtp *rtp);
00114 
00115 struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp);
00116 
00117 int ast_rtp_fd(struct ast_rtp *rtp);
00118 
00119 int ast_rtcp_fd(struct ast_rtp *rtp);
00120 
00121 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
00122 
00123 int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
00124 
00125 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
00126 
00127 /*  Setting RTP payload types from lines in a SDP description: */
00128 void ast_rtp_pt_clear(struct ast_rtp* rtp);
00129 /* Set payload types to defaults */
00130 void ast_rtp_pt_default(struct ast_rtp* rtp);
00131 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
00132 void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
00133           char* mimeType, char* mimeSubtype);
00134 
00135 /*  Mapping between RTP payload format codes and Asterisk codes: */
00136 struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
00137 int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code);
00138 void ast_rtp_offered_from_local(struct ast_rtp* rtp, int local);
00139 
00140 void ast_rtp_get_current_formats(struct ast_rtp* rtp,
00141               int* astFormats, int* nonAstFormats);
00142 
00143 /*  Mapping an Asterisk code into a MIME subtype (string): */
00144 char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
00145 
00146 /* Build a string of MIME subtype names from a capability list */
00147 char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat);
00148 
00149 void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
00150 
00151 int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
00152 
00153 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);
00154 
00155 void ast_rtp_proto_unregister(struct ast_rtp_protocol *proto);
00156 
00157 void ast_rtp_stop(struct ast_rtp *rtp);
00158 
00159 void ast_rtp_init(void);
00160 
00161 void ast_rtp_reload(void);
00162 
00163 #if defined(__cplusplus) || defined(c_plusplus)
00164 }
00165 #endif
00166 
00167 #endif /* _ASTERISK_RTP_H */

Generated on Wed Oct 28 15:47:56 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6