2 * Asterisk -- A telephony toolkit for Linux.
4 * Real-time Transport Protocol support
6 * Copyright (C) 1999, Mark Spencer
8 * Mark Spencer <markster@linux-support.net>
10 * This program is free software, distributed under the terms of
11 * the GNU General Public License
14 #ifndef _ASTERISK_RTP_H
15 #define _ASTERISK_RTP_H
17 #include <asterisk/frame.h>
18 #include <asterisk/io.h>
19 #include <asterisk/sched.h>
20 #include <asterisk/channel.h>
22 #include <netinet/in.h>
24 #if defined(__cplusplus) || defined(c_plusplus)
28 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
30 #define AST_RTP_DTMF (1 << 0)
31 /*! 'Comfort Noise' (RFC3389) */
32 #define AST_RTP_CN (1 << 1)
33 /*! Maximum RTP-specific code */
34 #define AST_RTP_MAX AST_RTP_CN
36 struct ast_rtp_protocol {
37 struct ast_rtp *(*get_rtp_info)(struct ast_channel *chan); /* Get RTP struct, or NULL if unwilling to transfer */
38 int (*set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer); /* Set RTP peer */
39 int (*get_rtp_willing)(struct ast_channel *chan); /* Willing to native bridge */
41 struct ast_rtp_protocol *next;
46 typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
48 struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io);
50 void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
52 void ast_rtp_get_peer(struct ast_rtp *rpt, struct sockaddr_in *them);
54 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us);
56 void ast_rtp_destroy(struct ast_rtp *rtp);
58 void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback);
60 void ast_rtp_set_data(struct ast_rtp *rtp, void *data);
62 int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *f);
64 struct ast_frame *ast_rtp_read(struct ast_rtp *rtp);
66 int ast_rtp_fd(struct ast_rtp *rtp);
68 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
70 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
72 // Setting RTP payload types from lines in a SDP description:
73 void ast_rtp_pt_clear(struct ast_rtp* rtp);
74 /* Set payload types to defaults */
75 void ast_rtp_pt_default(struct ast_rtp* rtp);
76 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
77 void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
78 char* mimeType, char* mimeSubtype);
80 // Mapping between RTP payload format codes and Asterisk codes:
81 struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
82 int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code);
84 void ast_rtp_get_current_formats(struct ast_rtp* rtp,
85 int* astFormats, int* nonAstFormats);
87 // Mapping an Asterisk code into a MIME subtype (string):
88 char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
90 void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
92 int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
94 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);
96 void ast_rtp_proto_unregister(struct ast_rtp_protocol *proto);
98 #if defined(__cplusplus) || defined(c_plusplus)