aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/udptl.h
blob: 3cbfeebb296746cc31838948084a446265f12184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
 * Asterisk -- A telephony toolkit for Linux.
 *
 * UDPTL support for T.38
 * 
 * Copyright (C) 2005, Steve Underwood, partly based on RTP code which is
 * Copyright (C) 1999-2004, Digium, Inc.
 *
 * Steve Underwood <steveu@coppice.org>
 *
 * This program is free software, distributed under the terms of
 * the GNU General Public License
 *
 * A license has been granted to Digium (via disclaimer) for the use of
 * this code.
 */

/*! \file
 * \brief UDPTL support for T.38
 * \author Steve Underwood <steveu@coppice.org>
 * \ref udptl.c
 * \todo add doxygen documentation to this file!
 */


#ifndef _ASTERISK_UDPTL_H
#define _ASTERISK_UDPTL_H

#include "asterisk/network.h"
#include "asterisk/frame.h"
#include "asterisk/io.h"
#include "asterisk/sched.h"
#include "asterisk/channel.h"


enum ast_t38_ec_modes {
    UDPTL_ERROR_CORRECTION_NONE,
    UDPTL_ERROR_CORRECTION_FEC,
    UDPTL_ERROR_CORRECTION_REDUNDANCY
};

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

struct ast_udptl_protocol {
	/*! \brief Get UDPTL struct, or NULL if unwilling to transfer */
	struct ast_udptl *(*get_udptl_info)(struct ast_channel *chan);
	/*! \brief Set UDPTL peer */
	int (* const set_udptl_peer)(struct ast_channel *chan, struct ast_udptl *peer);
	const char * const type;
	AST_RWLIST_ENTRY(ast_udptl_protocol) list;
};

struct ast_udptl;

typedef int (*ast_udptl_callback)(struct ast_udptl *udptl, struct ast_frame *f, void *data);

struct ast_udptl *ast_udptl_new(struct sched_context *sched, struct io_context *io, int callbackmode);

struct ast_udptl *ast_udptl_new_with_bindaddr(struct sched_context *sched, struct io_context *io, int callbackmode, struct in_addr in);

/*!
 * \brief Associates a character string 'tag' with a UDPTL session.
 * \param udptl The UDPTL session.
 * \param format printf-style format string used to construct the tag
 * 
 * This function formats a tag for the specified UDPTL
 * session, so that any log messages generated by the UDPTL stack
 * related to that session will include the tag and the reader of
 * the messages will be able to identify which endpoint caused them
 * to be generated.
 *
 * \retval none
 */
void __attribute__((format(printf, 2, 3))) ast_udptl_set_tag(struct ast_udptl *udptl, const char *format, ...);

void ast_udptl_set_peer(struct ast_udptl *udptl, const struct sockaddr_in *them);

void ast_udptl_get_peer(const struct ast_udptl *udptl, struct sockaddr_in *them);

void ast_udptl_get_us(const struct ast_udptl *udptl, struct sockaddr_in *us);

void ast_udptl_destroy(struct ast_udptl *udptl);

void ast_udptl_reset(struct ast_udptl *udptl);

void ast_udptl_set_callback(struct ast_udptl *udptl, ast_udptl_callback callback);

void ast_udptl_set_data(struct ast_udptl *udptl, void *data);

int ast_udptl_write(struct ast_udptl *udptl, struct ast_frame *f);

struct ast_frame *ast_udptl_read(struct ast_udptl *udptl);

int ast_udptl_fd(const struct ast_udptl *udptl);

int ast_udptl_setqos(struct ast_udptl *udptl, unsigned int tos, unsigned int cos);

void ast_udptl_set_m_type(struct ast_udptl *udptl, unsigned int pt);

void ast_udptl_set_udptlmap_type(struct ast_udptl *udptl, unsigned int pt,
				 char *mimeType, char *mimeSubtype);

enum ast_t38_ec_modes ast_udptl_get_error_correction_scheme(const struct ast_udptl *udptl);

void ast_udptl_set_error_correction_scheme(struct ast_udptl *udptl, enum ast_t38_ec_modes ec);

void ast_udptl_set_local_max_ifp(struct ast_udptl *udptl, unsigned int max_ifp);

/*! 
 * \brief retrieves local_max_datagram.
 * 
 * \retval positive value representing max datagram size.
 * \retval 0 if no value is present
 */
unsigned int ast_udptl_get_local_max_datagram(struct ast_udptl *udptl);

/*! 
 * \brief sets far max datagram size.  If max_datagram is = 0, the far max datagram
 *  size is set to a default value.
 */
void ast_udptl_set_far_max_datagram(struct ast_udptl *udptl, unsigned int max_datagram);

unsigned int ast_udptl_get_far_max_datagram(const struct ast_udptl *udptl);

/*! 
 * \brief retrieves far max ifp
 * 
 * \retval positive value representing max ifp size
 * \retval 0 if no value is present
 */
unsigned int ast_udptl_get_far_max_ifp(struct ast_udptl *udptl);

void ast_udptl_setnat(struct ast_udptl *udptl, int nat);

int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
		     struct ast_frame **fo, struct ast_channel **rc);

int ast_udptl_proto_register(struct ast_udptl_protocol *proto);

void ast_udptl_proto_unregister(struct ast_udptl_protocol *proto);

void ast_udptl_stop(struct ast_udptl *udptl);

void ast_udptl_init(void);

/*!
 * \version 1.6.1 return changed to int
 */
int ast_udptl_reload(void);

#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif