00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00041
00042 #define AST_RTP_DTMF (1 << 0)
00043
00044 #define AST_RTP_CN (1 << 1)
00045
00046 #define AST_RTP_CISCO_DTMF (1 << 2)
00047
00048 #define AST_RTP_MAX AST_RTP_CISCO_DTMF
00049
00050 struct ast_rtp_protocol {
00051
00052 struct ast_rtp *(* const get_rtp_info)(struct ast_channel *chan);
00053
00054 struct ast_rtp *(* const get_vrtp_info)(struct ast_channel *chan);
00055
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
00064
00065
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
00074
00075
00076
00077
00078
00079
00080
00081 struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode);
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
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 void 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
00128 void ast_rtp_pt_clear(struct ast_rtp* rtp);
00129
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
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
00144 char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
00145
00146
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