Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

rtp.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- A telephony toolkit for Linux.
00003  *
00004  * Real-time Transport Protocol support
00005  * 
00006  * Copyright (C) 1999, Mark Spencer
00007  *
00008  * Mark Spencer <markster@linux-support.net>
00009  *
00010  * This program is free software, distributed under the terms of
00011  * the GNU General Public License
00012  */
00013 
00014 #ifndef _ASTERISK_RTP_H
00015 #define _ASTERISK_RTP_H
00016 
00017 #include <asterisk/frame.h>
00018 #include <asterisk/io.h>
00019 #include <asterisk/sched.h>
00020 #include <asterisk/channel.h>
00021 
00022 #include <netinet/in.h>
00023 
00024 #if defined(__cplusplus) || defined(c_plusplus)
00025 extern "C" {
00026 #endif
00027 
00028 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
00029 /*! DTMF (RFC2833) */
00030 #define AST_RTP_DTMF            (1 << 0)
00031 /*! 'Comfort Noise' (RFC3389) */
00032 #define AST_RTP_CN              (1 << 1)
00033 /*! DTMF (Cisco Proprietary) */
00034 #define AST_RTP_CISCO_DTMF      (1 << 2)
00035 /*! Maximum RTP-specific code */
00036 #define AST_RTP_MAX             AST_RTP_CISCO_DTMF
00037 
00038 struct ast_rtp_protocol {
00039    struct ast_rtp *(*get_rtp_info)(struct ast_channel *chan);           /* Get RTP struct, or NULL if unwilling to transfer */
00040    struct ast_rtp *(*get_vrtp_info)(struct ast_channel *chan);          /* Get RTP struct, or NULL if unwilling to transfer */
00041    int (*set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, int codecs);  /* Set RTP peer */
00042    int (*get_codec)(struct ast_channel *chan);
00043    char *type;
00044    struct ast_rtp_protocol *next;
00045 };
00046 
00047 struct ast_rtp;
00048 
00049 typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
00050 
00051 struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode);
00052 
00053 struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr in);
00054 
00055 void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
00056 
00057 void ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
00058 
00059 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us);
00060 
00061 void ast_rtp_destroy(struct ast_rtp *rtp);
00062 
00063 void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback);
00064 
00065 void ast_rtp_set_data(struct ast_rtp *rtp, void *data);
00066 
00067 int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *f);
00068 
00069 struct ast_frame *ast_rtp_read(struct ast_rtp *rtp);
00070 
00071 struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp);
00072 
00073 int ast_rtp_fd(struct ast_rtp *rtp);
00074 
00075 int ast_rtcp_fd(struct ast_rtp *rtp);
00076 
00077 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
00078 
00079 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
00080 
00081 // Setting RTP payload types from lines in a SDP description:
00082 void ast_rtp_pt_clear(struct ast_rtp* rtp);
00083 /* Set payload types to defaults */
00084 void ast_rtp_pt_default(struct ast_rtp* rtp);
00085 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
00086 void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
00087           char* mimeType, char* mimeSubtype);
00088 
00089 // Mapping between RTP payload format codes and Asterisk codes:
00090 struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
00091 int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code);
00092 void ast_rtp_offered_from_local(struct ast_rtp* rtp, int local);
00093 
00094 void ast_rtp_get_current_formats(struct ast_rtp* rtp,
00095               int* astFormats, int* nonAstFormats);
00096 
00097 // Mapping an Asterisk code into a MIME subtype (string):
00098 char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
00099 
00100 void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
00101 
00102 int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
00103 
00104 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);
00105 
00106 void ast_rtp_proto_unregister(struct ast_rtp_protocol *proto);
00107 
00108 void ast_rtp_stop(struct ast_rtp *rtp);
00109 
00110 void ast_rtp_init(void);
00111 
00112 void ast_rtp_reload(void);
00113 
00114 #if defined(__cplusplus) || defined(c_plusplus)
00115 }
00116 #endif
00117 
00118 #endif

Generated on Sat Nov 25 19:09:45 2006 for Asterisk by  doxygen 1.4.2