00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00029
00030 #define AST_RTP_DTMF (1 << 0)
00031
00032 #define AST_RTP_CN (1 << 1)
00033
00034 #define AST_RTP_CISCO_DTMF (1 << 2)
00035
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);
00040 struct ast_rtp *(*get_vrtp_info)(struct ast_channel *chan);
00041 int (*set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer);
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 void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
00054
00055 void ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
00056
00057 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us);
00058
00059 void ast_rtp_destroy(struct ast_rtp *rtp);
00060
00061 void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback);
00062
00063 void ast_rtp_set_data(struct ast_rtp *rtp, void *data);
00064
00065 int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *f);
00066
00067 struct ast_frame *ast_rtp_read(struct ast_rtp *rtp);
00068
00069 struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp);
00070
00071 int ast_rtp_fd(struct ast_rtp *rtp);
00072
00073 int ast_rtcp_fd(struct ast_rtp *rtp);
00074
00075 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
00076
00077 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
00078
00079
00080 void ast_rtp_pt_clear(struct ast_rtp* rtp);
00081
00082 void ast_rtp_pt_default(struct ast_rtp* rtp);
00083 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
00084 void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
00085 char* mimeType, char* mimeSubtype);
00086
00087
00088 struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
00089 int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code);
00090
00091 void ast_rtp_get_current_formats(struct ast_rtp* rtp,
00092 int* astFormats, int* nonAstFormats);
00093
00094
00095 char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
00096
00097 void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
00098
00099 int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
00100
00101 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);
00102
00103 void ast_rtp_proto_unregister(struct ast_rtp_protocol *proto);
00104
00105 void ast_rtp_stop(struct ast_rtp *rtp);
00106
00107 void ast_rtp_init(void);
00108
00109 void ast_rtp_reload(void);
00110
00111 #if defined(__cplusplus) || defined(c_plusplus)
00112 }
00113 #endif
00114
00115 #endif