Asterisk - The Open Source Telephony Project GIT-master-35be64c
Loading...
Searching...
No Matches
chan_rtp.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2009 - 2014, Digium, Inc.
5 *
6 * Joshua Colp <jcolp@digium.com>
7 * Andreas 'MacBrody' Brodmann <andreas.brodmann@gmail.com>
8 *
9 * See http://www.asterisk.org for more information about
10 * the Asterisk project. Please do not directly contact
11 * any of the maintainers of this project for assistance;
12 * the project provides a web site, mailing lists and IRC
13 * channels for your use.
14 *
15 * This program is free software, distributed under the terms of
16 * the GNU General Public License Version 2. See the LICENSE file
17 * at the top of the source tree.
18 */
19
20/*! \file
21 *
22 * \author Joshua Colp <jcolp@digium.com>
23 * \author Andreas 'MacBrody' Brodmann <andreas.brodmann@gmail.com>
24 *
25 * \brief RTP (Multicast and Unicast) Media Channel
26 *
27 * \ingroup channel_drivers
28 */
29
30/*** MODULEINFO
31 <depend>res_rtp_multicast</depend>
32 <support_level>core</support_level>
33 ***/
34
35#include "asterisk.h"
36
37#include "asterisk/channel.h"
38#include "asterisk/module.h"
39#include "asterisk/pbx.h"
40#include "asterisk/acl.h"
41#include "asterisk/app.h"
42#include "asterisk/rtp_engine.h"
43#include "asterisk/causes.h"
47#include "asterisk/dns_core.h"
48
49/* Forward declarations */
50static struct ast_channel *multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause);
51static struct ast_channel *unicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause);
52static int rtp_call(struct ast_channel *ast, const char *dest, int timeout);
53static int rtp_hangup(struct ast_channel *ast);
54static struct ast_frame *rtp_read(struct ast_channel *ast);
55static int rtp_write(struct ast_channel *ast, struct ast_frame *f);
56
57/* Multicast channel driver declaration */
59 .type = "MulticastRTP",
60 .description = "Multicast RTP Paging Channel Driver",
61 .requester = multicast_rtp_request,
62 .call = rtp_call,
63 .hangup = rtp_hangup,
64 .read = rtp_read,
65 .write = rtp_write,
66};
67
68/* Unicast channel driver declaration */
70 .type = "UnicastRTP",
71 .description = "Unicast RTP Media Channel Driver",
72 .requester = unicast_rtp_request,
73 .call = rtp_call,
74 .hangup = rtp_hangup,
75 .read = rtp_read,
76 .write = rtp_write,
77};
78
79/*! \brief Function called when we should read a frame from the channel */
80static struct ast_frame *rtp_read(struct ast_channel *ast)
81{
82 struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
83 int fdno = ast_channel_fdno(ast);
84
85 switch (fdno) {
86 case 0:
87 return ast_rtp_instance_read(instance, 0);
88 default:
89 return &ast_null_frame;
90 }
91}
92
93/*! \brief Function called when we should write a frame to the channel */
94static int rtp_write(struct ast_channel *ast, struct ast_frame *f)
95{
96 struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
97
98 return ast_rtp_instance_write(instance, f);
99}
100
101/*! \brief Function called when we should actually call the destination */
102static int rtp_call(struct ast_channel *ast, const char *dest, int timeout)
103{
104 struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
105
107
108 return ast_rtp_instance_activate(instance);
109}
110
111/*! \brief Function called when we should hang the channel up */
112static int rtp_hangup(struct ast_channel *ast)
113{
114 struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);
115
116 ast_rtp_instance_destroy(instance);
117
119
120 return 0;
121}
122
124{
125 struct ast_format *fmt = ast_format_cap_get_format(cap, 0);
126
127 if (ast_format_cap_count(cap) == 1 && fmt == ast_format_slin) {
128 /*
129 * Because we have no SDP, we must use one of the static RTP payload
130 * assignments. Signed linear @ 8kHz does not map, so if that is our
131 * only capability, we force μ-law instead.
132 */
133 ao2_ref(fmt, -1);
135 }
136
137 return fmt;
138}
139
140/*! \brief Function called when we should prepare to call the multicast destination */
141static struct ast_channel *multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
142{
143 char *parse;
144 struct ast_rtp_instance *instance;
145 struct ast_sockaddr control_address;
146 struct ast_sockaddr destination_address;
147 struct ast_channel *chan;
148 struct ast_format_cap *caps = NULL;
149 struct ast_format *fmt = NULL;
152 AST_APP_ARG(destination);
153 AST_APP_ARG(control);
155 );
156 struct ast_multicast_rtp_options *mcast_options = NULL;
157
158 if (ast_strlen_zero(data)) {
159 ast_log(LOG_ERROR, "A multicast type and destination must be given to the 'MulticastRTP' channel\n");
160 goto failure;
161 }
162 parse = ast_strdupa(data);
163 AST_NONSTANDARD_APP_ARGS(args, parse, '/');
164
165 if (ast_strlen_zero(args.type)) {
166 ast_log(LOG_ERROR, "Type is required for the 'MulticastRTP' channel\n");
167 goto failure;
168 }
169
170 if (ast_strlen_zero(args.destination)) {
171 ast_log(LOG_ERROR, "Destination is required for the 'MulticastRTP' channel\n");
172 goto failure;
173 }
174 if (!ast_sockaddr_parse(&destination_address, args.destination, PARSE_PORT_REQUIRE)) {
175 ast_log(LOG_ERROR, "Destination address '%s' could not be parsed\n",
176 args.destination);
177 goto failure;
178 }
179
180 ast_sockaddr_setnull(&control_address);
181 if (!ast_strlen_zero(args.control)
182 && !ast_sockaddr_parse(&control_address, args.control, PARSE_PORT_REQUIRE)) {
183 ast_log(LOG_ERROR, "Control address '%s' could not be parsed\n", args.control);
184 goto failure;
185 }
186
187 mcast_options = ast_multicast_rtp_create_options(args.type, args.options);
188 if (!mcast_options) {
189 goto failure;
190 }
191
193 if (!fmt) {
195 }
196 if (!fmt) {
197 ast_log(LOG_ERROR, "No codec available for sending RTP to '%s'\n",
198 args.destination);
199 goto failure;
200 }
201
203 if (!caps) {
204 goto failure;
205 }
206
207 instance = ast_rtp_instance_new("multicast", NULL, &control_address, mcast_options);
208 if (!instance) {
210 "Could not create '%s' multicast RTP instance for sending media to '%s'\n",
211 args.type, args.destination);
212 goto failure;
213 }
214
215 chan = ast_channel_alloc(1, AST_STATE_DOWN, "", "", "", "", "", assignedids,
216 requestor, 0, "MulticastRTP/%s-%p", args.destination, instance);
217 if (!chan) {
218 ast_rtp_instance_destroy(instance);
219 goto failure;
220 }
221 /* Prevent device state caching as this channel involves ephemeral destinations or sources */
224 ast_rtp_instance_set_remote_address(instance, &destination_address);
225
227
228 ast_format_cap_append(caps, fmt, 0);
234
235 ast_channel_tech_pvt_set(chan, instance);
236
237 ast_channel_unlock(chan);
238
239 ao2_ref(fmt, -1);
240 ao2_ref(caps, -1);
241 ast_multicast_rtp_free_options(mcast_options);
242
243 return chan;
244
245failure:
247 ao2_cleanup(caps);
248 ast_multicast_rtp_free_options(mcast_options);
249 *cause = AST_CAUSE_FAILURE;
250 return NULL;
251}
252
253enum {
254 OPT_RTP_CODEC = (1 << 0),
255 OPT_RTP_ENGINE = (1 << 1),
256 OPT_RTP_GLUE = (1 << 2),
257 OPT_RTP_PAYLOAD = (1 << 3),
258};
259
260enum {
264 /* note: this entry _MUST_ be the last one in the enum */
267
269 /*! Set the codec to be used for unicast RTP */
271 /*! Set the RTP engine to use for unicast RTP */
273 /*! Provide RTP glue for the channel */
275 /*! Set the dynamic payload type (96-127) to send and receive with */
278
280 .type = "CHAN_RTP_GLUE",
281};
282
283/*! \brief Function called when we should prepare to call the unicast destination */
284static struct ast_channel *unicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
285{
286 char *parse;
287 struct ast_rtp_instance *instance;
288 struct ast_sockaddr address;
289 struct ast_sockaddr local_address;
290 struct ast_channel *chan;
291 struct ast_format_cap *caps = NULL;
292 struct ast_format *fmt = NULL;
293 int payload = -1;
294 const char *engine_name;
296 AST_APP_ARG(destination);
298 );
299 struct ast_flags opts = { 0, };
300 char *opt_args[OPT_ARG_ARRAY_SIZE];
301
302 if (ast_strlen_zero(data)) {
303 ast_log(LOG_ERROR, "Destination is required for the 'UnicastRTP' channel\n");
304 goto failure;
305 }
306 parse = ast_strdupa(data);
307 AST_NONSTANDARD_APP_ARGS(args, parse, '/');
308
309 if (ast_strlen_zero(args.destination)) {
310 ast_log(LOG_ERROR, "Destination is required for the 'UnicastRTP' channel\n");
311 goto failure;
312 }
313
314 if (!ast_sockaddr_parse(&address, args.destination, PARSE_PORT_REQUIRE)) {
315 int rc;
316 char *host;
317 char *port;
318
319 rc = ast_sockaddr_split_hostport(args.destination, &host, &port, PARSE_PORT_REQUIRE);
320 if (!rc) {
321 ast_log(LOG_ERROR, "Unable to parse destination '%s' into host and port\n", args.destination);
322 goto failure;
323 }
324
325 rc = ast_dns_resolve_ipv6_and_ipv4(&address, host, port);
326 if (rc != 0) {
327 ast_log(LOG_ERROR, "Unable to resolve host '%s'\n", host);
328 goto failure;
329 }
330 }
331
332 if (!ast_strlen_zero(args.options)
333 && ast_app_parse_options(unicast_rtp_options, &opts, opt_args,
334 ast_strdupa(args.options))) {
335 ast_log(LOG_ERROR, "'UnicastRTP' channel options '%s' parse error\n",
336 args.options);
337 goto failure;
338 }
339
340 if (ast_test_flag(&opts, OPT_RTP_CODEC)
341 && !ast_strlen_zero(opt_args[OPT_ARG_RTP_CODEC])) {
343 if (!fmt) {
344 ast_log(LOG_ERROR, "Codec '%s' not found for sending RTP to '%s'\n",
345 opt_args[OPT_ARG_RTP_CODEC], args.destination);
346 goto failure;
347 }
348 } else {
349 fmt = derive_format_from_cap(cap);
350 if (!fmt) {
351 ast_log(LOG_ERROR, "No codec available for sending RTP to '%s'\n",
352 args.destination);
353 goto failure;
354 }
355 }
356
358 && (ast_str_to_int(opt_args[OPT_ARG_RTP_PAYLOAD], &payload)
359 || payload < AST_RTP_PT_FIRST_DYNAMIC || payload >= AST_RTP_MAX_PT)) {
360 ast_log(LOG_ERROR, "Payload type '%s' for '%s' is not in the dynamic range %d-%d\n",
361 opt_args[OPT_ARG_RTP_PAYLOAD], args.destination,
363 goto failure;
364 }
365
367 if (!caps) {
368 goto failure;
369 }
370
371 engine_name = S_COR(ast_test_flag(&opts, OPT_RTP_ENGINE),
372 opt_args[OPT_ARG_RTP_ENGINE], "asterisk");
373
374 ast_sockaddr_copy(&local_address, &address);
375 if (ast_ouraddrfor(&address, &local_address)) {
376 ast_log(LOG_ERROR, "Could not get our address for sending media to '%s'\n",
377 args.destination);
378 goto failure;
379 }
380 instance = ast_rtp_instance_new(engine_name, NULL, &local_address, NULL);
381 if (!instance) {
383 "Could not create %s RTP instance for sending media to '%s'\n",
384 S_OR(engine_name, "default"), args.destination);
385 goto failure;
386 }
387
388 if (payload >= 0) {
390
392 || ast_rtp_codecs_payload_set_rx(codecs, payload, fmt) < 0) {
393 ast_rtp_instance_destroy(instance);
394 goto failure;
395 }
396 }
397
398 chan = ast_channel_alloc(1, AST_STATE_DOWN, "", "", "", "", "", assignedids,
399 requestor, 0, "UnicastRTP/%s-%p", args.destination, instance);
400 if (!chan) {
401 ast_rtp_instance_destroy(instance);
402 goto failure;
403 }
404 /*Prevent device state caching as this channel involves ephemeral destinations or sources */
408 ast_channel_set_fd(chan, 0, ast_rtp_instance_fd(instance, 0));
409
411
412 if (ast_test_flag(&opts, OPT_RTP_GLUE)) {
413 struct ast_datastore *datastore;
414 if ((datastore = ast_datastore_alloc(&chan_rtp_datastore_info, NULL))) {
415 ast_channel_datastore_add(chan, datastore);
416 }
417 }
418
419 ast_format_cap_append(caps, fmt, 0);
425
426 ast_channel_tech_pvt_set(chan, instance);
427
428 ast_rtp_instance_get_local_address(instance, &local_address);
429 pbx_builtin_setvar_helper(chan, "UNICASTRTP_LOCAL_ADDRESS",
430 ast_sockaddr_stringify_addr(&local_address));
431 pbx_builtin_setvar_helper(chan, "UNICASTRTP_LOCAL_PORT",
432 ast_sockaddr_stringify_port(&local_address));
433
434 ast_channel_unlock(chan);
435
436 ao2_ref(fmt, -1);
437 ao2_ref(caps, -1);
438
439 return chan;
440
441failure:
442 ao2_cleanup(fmt);
443 ao2_cleanup(caps);
444 *cause = AST_CAUSE_FAILURE;
445 return NULL;
446}
447
448/*! \brief Function called by RTP engine to get peer capabilities */
456
457/*! \brief Function called by RTP engine to change where the remote party should send media.
458 *
459 * chan_rtp is not able to actually update the peer, so this function has no effect.
460 * */
461static int chan_rtp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, const struct ast_format_cap *cap, int nat_active)
462{
463 return -1;
464}
465
466/*! \brief Function called by RTP engine to get local audio RTP peer */
467static enum ast_rtp_glue_result chan_rtp_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
468{
470}
471
472/*! \brief Function called by RTP engine to get local audio RTP peer */
473static enum ast_rtp_glue_result chan_rtp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
474{
475 struct ast_rtp_instance *rtp_instance = ast_channel_tech_pvt(chan);
476 struct ast_datastore *datastore;
477
478 if (!rtp_instance) {
480 }
481
482 if ((datastore = ast_channel_datastore_find(chan, &chan_rtp_datastore_info, NULL))) {
483 ao2_ref(datastore, -1);
484
485 *instance = rtp_instance;
486 ao2_ref(*instance, +1);
487
489 }
490
492}
493
494/*! \brief Local glue for interacting with the RTP engine core */
496 .type = "UnicastRTP",
497 .get_rtp_info = chan_rtp_get_rtp_peer,
498 .get_vrtp_info = chan_rtp_get_vrtp_peer,
499 .get_codec = chan_rtp_get_codec,
500 .update_peer = chan_rtp_set_rtp_peer,
501};
502
503/*! \brief Function called when our module is unloaded */
518
519/*! \brief Function called when our module is loaded */
548
550 .support_level = AST_MODULE_SUPPORT_CORE,
551 .load = load_module,
552 .unload = unload_module,
553 .load_pri = AST_MODPRI_CHANNEL_DRIVER,
554 .requires = "res_rtp_multicast",
Access Control of various sorts.
int ast_ouraddrfor(const struct ast_sockaddr *them, struct ast_sockaddr *us)
Get our local IP address when contacting a remote host.
Definition acl.c:1021
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
#define ast_log
Definition astobj2.c:42
#define ao2_cleanup(obj)
Definition astobj2.h:1934
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition astobj2.h:480
Internal Asterisk hangup causes.
#define AST_CAUSE_FAILURE
Definition causes.h:150
static PGresult * result
Definition cel_pgsql.c:84
static const char type[]
static struct ast_channel * multicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
Function called when we should prepare to call the multicast destination.
Definition chan_rtp.c:141
static enum ast_rtp_glue_result chan_rtp_get_vrtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
Function called by RTP engine to get local audio RTP peer.
Definition chan_rtp.c:467
static void chan_rtp_get_codec(struct ast_channel *chan, struct ast_format_cap *result)
Function called by RTP engine to get peer capabilities.
Definition chan_rtp.c:449
static const struct ast_datastore_info chan_rtp_datastore_info
Definition chan_rtp.c:279
@ OPT_RTP_GLUE
Definition chan_rtp.c:256
@ OPT_RTP_CODEC
Definition chan_rtp.c:254
@ OPT_RTP_PAYLOAD
Definition chan_rtp.c:257
@ OPT_RTP_ENGINE
Definition chan_rtp.c:255
static struct ast_format * derive_format_from_cap(struct ast_format_cap *cap)
Definition chan_rtp.c:123
static struct ast_frame * rtp_read(struct ast_channel *ast)
Function called when we should read a frame from the channel.
Definition chan_rtp.c:80
static struct ast_channel_tech unicast_rtp_tech
Definition chan_rtp.c:69
static int rtp_write(struct ast_channel *ast, struct ast_frame *f)
Function called when we should write a frame to the channel.
Definition chan_rtp.c:94
static struct ast_rtp_glue unicast_rtp_glue
Local glue for interacting with the RTP engine core.
Definition chan_rtp.c:495
static int rtp_call(struct ast_channel *ast, const char *dest, int timeout)
Function called when we should actually call the destination.
Definition chan_rtp.c:102
@ OPT_ARG_RTP_PAYLOAD
Definition chan_rtp.c:263
@ OPT_ARG_RTP_CODEC
Definition chan_rtp.c:261
@ OPT_ARG_RTP_ENGINE
Definition chan_rtp.c:262
@ OPT_ARG_ARRAY_SIZE
Definition chan_rtp.c:265
static enum ast_rtp_glue_result chan_rtp_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
Function called by RTP engine to get local audio RTP peer.
Definition chan_rtp.c:473
static int rtp_hangup(struct ast_channel *ast)
Function called when we should hang the channel up.
Definition chan_rtp.c:112
static struct ast_channel * unicast_rtp_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
Function called when we should prepare to call the unicast destination.
Definition chan_rtp.c:284
static int chan_rtp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, const struct ast_format_cap *cap, int nat_active)
Function called by RTP engine to change where the remote party should send media.
Definition chan_rtp.c:461
static int load_module(void)
Function called when our module is loaded.
Definition chan_rtp.c:520
static int unload_module(void)
Function called when our module is unloaded.
Definition chan_rtp.c:504
static const struct ast_app_option unicast_rtp_options[128]
Definition chan_rtp.c:277
static struct ast_channel_tech multicast_rtp_tech
Definition chan_rtp.c:58
General Asterisk PBX channel definitions.
const char * ast_channel_name(const struct ast_channel *chan)
void * ast_channel_tech_pvt(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition channel.c:2376
#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, assignedids, requestor, amaflag,...)
Create a channel structure.
Definition channel.h:1299
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
int ast_channel_fdno(const struct ast_channel *chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
@ AST_FLAG_DISABLE_DEVSTATE_CACHE
Definition channel.h:1049
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition channel.c:571
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame without payload.
Definition channel.c:1289
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_tech_pvt_set(struct ast_channel *chan, void *value)
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition channel.c:540
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition channel.c:2417
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
#define ast_channel_unlock(chan)
Definition channel.h:2984
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
Definition channel.c:2390
@ AST_STATE_DOWN
static struct ao2_container * codecs
Registered codecs.
Definition codec.c:48
@ AST_MEDIA_TYPE_UNKNOWN
Definition codec.h:31
Conversion utility functions.
int ast_str_to_int(const char *str, int *res)
Convert the given string to a signed integer.
Definition conversions.c:44
#define ast_datastore_alloc(info, uid)
Definition datastore.h:85
Core DNS API.
int ast_dns_resolve_ipv6_and_ipv4(struct ast_sockaddr *address, const char *host, const char *port)
Synchronously resolves host to an AAAA or A record.
Definition dns_core.c:370
char * address
Definition f2c.h:59
Media Format Cache API.
struct ast_format * ast_format_ulaw
Built-in cached ulaw format.
#define ast_format_cache_get(name)
Retrieve a named format from the cache.
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
#define AST_FORMAT_CAP_NAMES_LEN
Definition format_cap.h:324
int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
Definition format_cap.c:216
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition format_cap.c:408
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition format_cap.h:38
int ast_format_cap_append_from_cap(struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
Append the formats of provided type in src to dst.
Definition format_cap.c:269
const char * ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf)
Get the names of codecs of a set of formats.
Definition format_cap.c:742
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition format_cap.h:49
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition format_cap.c:403
#define SCOPE_EXIT_RTN(...)
#define SCOPE_ENTER(level,...)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define END_OPTIONS
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define BEGIN_OPTIONS
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
#define AST_NONSTANDARD_APP_ARGS(args, parse, sep)
Performs the 'nonstandard' argument separation process for an application.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition main/app.c:3067
@ AST_CONTROL_ANSWER
struct ast_frame ast_null_frame
Definition main/frame.c:79
#define LOG_ERROR
Asterisk module definitions.
@ AST_MODFLAG_LOAD_ORDER
Definition module.h:331
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Definition module.h:557
@ AST_MODPRI_CHANNEL_DRIVER
Definition module.h:341
@ AST_MODULE_SUPPORT_CORE
Definition module.h:121
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
struct ast_multicast_rtp_options * ast_multicast_rtp_create_options(const char *type, const char *options)
Create multicast RTP options.
struct ast_format * ast_multicast_rtp_options_get_format(struct ast_multicast_rtp_options *mcast_options)
Get format specified in multicast options.
void ast_multicast_rtp_free_options(struct ast_multicast_rtp_options *mcast_options)
Free multicast RTP options.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
Definition netsock2.h:167
int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags)
Splits a string into its host and port components.
Definition netsock2.c:164
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Definition netsock2.c:230
static char * ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return a port only.
Definition netsock2.h:358
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition netsock2.h:286
static void ast_sockaddr_setnull(struct ast_sockaddr *addr)
Sets address addr to null.
Definition netsock2.h:138
Core PBX routines and definitions.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
static struct @523 args
#define NULL
Definition resample.c:96
Pluggable RTP Architecture.
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
Definition rtp_engine.c:468
int ast_rtp_codecs_payload_set_rx(struct ast_rtp_codecs *codecs, int code, struct ast_format *format)
Set a payload code for use with a specific Asterisk format.
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct ast_sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
Definition rtp_engine.c:497
ast_rtp_glue_result
Definition rtp_engine.h:161
@ AST_RTP_GLUE_RESULT_LOCAL
Definition rtp_engine.h:167
@ AST_RTP_GLUE_RESULT_FORBID
Definition rtp_engine.h:163
#define AST_RTP_MAX_PT
Definition rtp_engine.h:83
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
Definition rtp_engine.c:629
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Definition rtp_engine.c:694
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
Definition rtp_engine.c:619
#define ast_rtp_instance_set_remote_address(instance, address)
Set the address of the remote endpoint that we are sending RTP to.
#define AST_RTP_PT_FIRST_DYNAMIC
Definition rtp_engine.h:92
int ast_rtp_instance_activate(struct ast_rtp_instance *instance)
Indicate to the RTP engine that packets are now expected to be sent/received on the RTP instance.
void ast_rtp_instance_set_channel_id(struct ast_rtp_instance *instance, const char *uniqueid)
Set the channel that owns this RTP instance.
Definition rtp_engine.c:604
int ast_rtp_codecs_payload_replace_format(struct ast_rtp_codecs *codecs, int payload, struct ast_format *format)
Update the format associated with a tx payload type in a codecs structure.
#define ast_rtp_glue_register(glue)
Definition rtp_engine.h:905
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
Definition rtp_engine.c:778
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Definition rtp_engine.c:418
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition strings.h:80
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition strings.h:87
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition strings.h:65
#define ast_str_tmp(init_len, __expr)
Provides a temporary ast_str and returns a copy of its buffer.
Definition strings.h:1189
Structure to pass both assignedid values to channel drivers.
Definition channel.h:606
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition channel.h:648
struct ast_format_cap * capabilities
Definition channel.h:652
const char *const type
Definition channel.h:649
Main Channel structure associated with a channel.
const char * data
Structure for a data store type.
Definition datastore.h:31
const char * type
Definition datastore.h:32
Structure for a data store object.
Definition datastore.h:64
Structure used to handle boolean flags.
Definition utils.h:220
Format capabilities structure, holds formats + preference order + etc.
Definition format_cap.c:54
Definition of a media format.
Definition format.c:43
Data structure associated with a single frame of data.
const char * type
Definition rtp_engine.h:780
Socket address structure.
Definition netsock2.h:97
static struct test_options options
#define ast_test_flag(p, flag)
Definition utils.h:64
#define ast_set_flag(p, flag)
Definition utils.h:71