report non-codec capabilities in 'sip debug' properly (bug #3960)
[asterisk/asterisk.git] / include / asterisk / rtp.h
1 /*
2  * Asterisk -- A telephony toolkit for Linux.
3  *
4  * Real-time Transport Protocol support
5  * 
6  * Copyright (C) 1999-2005, Digium
7  *
8  * Mark Spencer <markster@digium.com>
9  *
10  * This program is free software, distributed under the terms of
11  * the GNU General Public License
12  */
13
14 #ifndef _ASTERISK_RTP_H
15 #define _ASTERISK_RTP_H
16
17 #include <asterisk/frame.h>
18 #include <asterisk/io.h>
19 #include <asterisk/sched.h>
20 #include <asterisk/channel.h>
21
22 #include <netinet/in.h>
23
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27
28 /* Codes for RTP-specific data - not defined by our AST_FORMAT codes */
29 /*! DTMF (RFC2833) */
30 #define AST_RTP_DTMF            (1 << 0)
31 /*! 'Comfort Noise' (RFC3389) */
32 #define AST_RTP_CN              (1 << 1)
33 /*! DTMF (Cisco Proprietary) */
34 #define AST_RTP_CISCO_DTMF      (1 << 2)
35 /*! Maximum RTP-specific code */
36 #define AST_RTP_MAX             AST_RTP_CISCO_DTMF
37
38 struct ast_rtp_protocol {
39         /* Get RTP struct, or NULL if unwilling to transfer */
40         struct ast_rtp *(* const get_rtp_info)(struct ast_channel *chan);
41         /* Get RTP struct, or NULL if unwilling to transfer */
42         struct ast_rtp *(* const get_vrtp_info)(struct ast_channel *chan);
43         /* Set RTP peer */
44         int (* const set_rtp_peer)(struct ast_channel *chan, struct ast_rtp *peer, struct ast_rtp *vpeer, int codecs);
45         int (* const get_codec)(struct ast_channel *chan);
46         const char * const type;
47         struct ast_rtp_protocol *next;
48 };
49
50 struct ast_rtp;
51
52 typedef int (*ast_rtp_callback)(struct ast_rtp *rtp, struct ast_frame *f, void *data);
53
54 struct ast_rtp *ast_rtp_new(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode);
55
56 struct ast_rtp *ast_rtp_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int rtcpenable, int callbackmode, struct in_addr in);
57
58 void ast_rtp_set_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
59
60 void ast_rtp_get_peer(struct ast_rtp *rtp, struct sockaddr_in *them);
61
62 void ast_rtp_get_us(struct ast_rtp *rtp, struct sockaddr_in *us);
63
64 void ast_rtp_destroy(struct ast_rtp *rtp);
65
66 void ast_rtp_reset(struct ast_rtp *rtp);
67
68 void ast_rtp_set_callback(struct ast_rtp *rtp, ast_rtp_callback callback);
69
70 void ast_rtp_set_data(struct ast_rtp *rtp, void *data);
71
72 int ast_rtp_write(struct ast_rtp *rtp, struct ast_frame *f);
73
74 struct ast_frame *ast_rtp_read(struct ast_rtp *rtp);
75
76 struct ast_frame *ast_rtcp_read(struct ast_rtp *rtp);
77
78 int ast_rtp_fd(struct ast_rtp *rtp);
79
80 int ast_rtcp_fd(struct ast_rtp *rtp);
81
82 int ast_rtp_senddigit(struct ast_rtp *rtp, char digit);
83
84 int ast_rtp_sendcng(struct ast_rtp *rtp, int level);
85
86 int ast_rtp_settos(struct ast_rtp *rtp, int tos);
87
88 /*  Setting RTP payload types from lines in a SDP description: */
89 void ast_rtp_pt_clear(struct ast_rtp* rtp);
90 /* Set payload types to defaults */
91 void ast_rtp_pt_default(struct ast_rtp* rtp);
92 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
93 void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,
94                          char* mimeType, char* mimeSubtype);
95
96 /*  Mapping between RTP payload format codes and Asterisk codes: */
97 struct rtpPayloadType ast_rtp_lookup_pt(struct ast_rtp* rtp, int pt);
98 int ast_rtp_lookup_code(struct ast_rtp* rtp, int isAstFormat, int code);
99 void ast_rtp_offered_from_local(struct ast_rtp* rtp, int local);
100
101 void ast_rtp_get_current_formats(struct ast_rtp* rtp,
102                              int* astFormats, int* nonAstFormats);
103
104 /*  Mapping an Asterisk code into a MIME subtype (string): */
105 char* ast_rtp_lookup_mime_subtype(int isAstFormat, int code);
106
107 /* Build a string of MIME subtype names from a capability list */
108 char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat);
109
110 void ast_rtp_setnat(struct ast_rtp *rtp, int nat);
111
112 int ast_rtp_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc);
113
114 int ast_rtp_proto_register(struct ast_rtp_protocol *proto);
115
116 void ast_rtp_proto_unregister(struct ast_rtp_protocol *proto);
117
118 void ast_rtp_stop(struct ast_rtp *rtp);
119
120 void ast_rtp_init(void);
121
122 void ast_rtp_reload(void);
123
124 #if defined(__cplusplus) || defined(c_plusplus)
125 }
126 #endif
127
128 #endif