Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
Multicast RTP Engine. More...
#include "asterisk.h"
#include <sys/time.h>
#include <signal.h>
#include <fcntl.h>
#include <math.h>
#include "asterisk/pbx.h"
#include "asterisk/frame.h"
#include "asterisk/channel.h"
#include "asterisk/acl.h"
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
#include "asterisk/manager.h"
#include "asterisk/unaligned.h"
#include "asterisk/module.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/format_cache.h"
#include "asterisk/multicast_rtp.h"
#include "asterisk/app.h"
#include "asterisk/smoother.h"
Go to the source code of this file.
Data Structures | |
struct | ast_multicast_rtp_options |
struct | multicast_control_packet |
Structure for a Linksys control packet. More... | |
struct | multicast_rtp |
Structure for a multicast paging instance. More... | |
Macros | |
#define | LINKSYS_MCAST_STARTCMD 6 |
#define | LINKSYS_MCAST_STOPCMD 7 |
#define | MAX_TIMESTAMP_SKEW 640 |
Enumerations | |
enum | { OPT_CODEC = (1 << 0) , OPT_LOOP = (1 << 1) , OPT_TTL = (1 << 2) , OPT_IF = (1 << 3) } |
enum | { OPT_ARG_CODEC = 0 , OPT_ARG_LOOP , OPT_ARG_TTL , OPT_ARG_IF , OPT_ARG_ARRAY_SIZE } |
enum | multicast_type { MULTICAST_TYPE_UNSPECIFIED = 0 , MULTICAST_TYPE_BASIC , MULTICAST_TYPE_LINKSYS } |
Type of paging to do. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
struct ast_multicast_rtp_options * | ast_multicast_rtp_create_options (const char *type, const char *options) |
Create multicast RTP options. More... | |
void | ast_multicast_rtp_free_options (struct ast_multicast_rtp_options *mcast_options) |
Free multicast RTP options. More... | |
struct ast_format * | ast_multicast_rtp_options_get_format (struct ast_multicast_rtp_options *mcast_options) |
Get format specified in multicast options. More... | |
static unsigned int | calc_txstamp (struct multicast_rtp *rtp, struct timeval *delivery) |
static int | load_module (void) |
static int | multicast_rtp_activate (struct ast_rtp_instance *instance) |
Function called to indicate that audio is now going to flow. More... | |
static int | multicast_rtp_destroy (struct ast_rtp_instance *instance) |
Function called to destroy a multicast instance. More... | |
static int | multicast_rtp_new (struct ast_rtp_instance *instance, struct ast_sched_context *sched, struct ast_sockaddr *addr, void *data) |
Function called to create a new multicast instance. More... | |
static struct ast_frame * | multicast_rtp_read (struct ast_rtp_instance *instance, int rtcp) |
Function called to read from a multicast instance. More... | |
static int | multicast_rtp_write (struct ast_rtp_instance *instance, struct ast_frame *frame) |
Function called to broadcast some audio on a multicast instance. More... | |
static int | multicast_send_control_packet (struct ast_rtp_instance *instance, struct multicast_rtp *multicast, int command) |
Helper function which populates a control packet with useful information and sends it. More... | |
static int | rtp_get_rate (struct ast_format *format) |
static int | rtp_raw_write (struct ast_rtp_instance *instance, struct ast_frame *frame, int codec) |
static void | set_if (int sock, const char *if_str) |
static void | set_loop (int sock, const char *loop_str) |
static void | set_ttl (int sock, const char *ttl_str) |
static int | set_type (struct multicast_rtp *multicast, const char *type) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Multicast RTP Engine" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_rtp_engine | multicast_rtp_engine |
static const struct ast_app_option | multicast_rtp_options [128] = { [ 'c' ] = { .flag = OPT_CODEC , .arg_index = OPT_ARG_CODEC + 1 }, [ 'l' ] = { .flag = OPT_LOOP , .arg_index = OPT_ARG_LOOP + 1 }, [ 't' ] = { .flag = OPT_TTL , .arg_index = OPT_ARG_TTL + 1 }, [ 'i' ] = { .flag = OPT_IF , .arg_index = OPT_ARG_IF + 1 }, } |
Multicast RTP Engine.
Definition in file res_rtp_multicast.c.
#define LINKSYS_MCAST_STARTCMD 6 |
Command value used for Linksys paging to indicate we are starting
Definition at line 60 of file res_rtp_multicast.c.
#define LINKSYS_MCAST_STOPCMD 7 |
Command value used for Linksys paging to indicate we are stopping
Definition at line 63 of file res_rtp_multicast.c.
#define MAX_TIMESTAMP_SKEW 640 |
Definition at line 102 of file res_rtp_multicast.c.
anonymous enum |
anonymous enum |
Enumerator | |
---|---|
OPT_ARG_CODEC | |
OPT_ARG_LOOP | |
OPT_ARG_TTL | |
OPT_ARG_IF | |
OPT_ARG_ARRAY_SIZE |
Definition at line 111 of file res_rtp_multicast.c.
enum multicast_type |
Type of paging to do.
Definition at line 66 of file res_rtp_multicast.c.
|
static |
Definition at line 567 of file res_rtp_multicast.c.
|
static |
Definition at line 567 of file res_rtp_multicast.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 567 of file res_rtp_multicast.c.
struct ast_multicast_rtp_options * ast_multicast_rtp_create_options | ( | const char * | type, |
const char * | options | ||
) |
Create multicast RTP options.
These are passed to the multicast RTP engine on its creation.
type | The type of multicast RTP, either "basic" or "linksys" |
options | Miscellaneous options |
NULL | Failure |
non-NULL | success |
Definition at line 140 of file res_rtp_multicast.c.
References ast_app_parse_options(), ast_calloc, ast_log, ast_multicast_rtp_free_options(), ast_strlen_zero(), ast_multicast_rtp_options::buf, LOG_WARNING, multicast_rtp_options, NULL, ast_multicast_rtp_options::opt_args, ast_multicast_rtp_options::options, options, ast_multicast_rtp_options::opts, S_OR, type, and ast_multicast_rtp_options::type.
Referenced by multicast_rtp_request().
void ast_multicast_rtp_free_options | ( | struct ast_multicast_rtp_options * | mcast_options | ) |
Free multicast RTP options.
This function is NULL-tolerant
mcast_options | Options to free |
Definition at line 175 of file res_rtp_multicast.c.
References ast_free.
Referenced by ast_multicast_rtp_create_options(), and multicast_rtp_request().
struct ast_format * ast_multicast_rtp_options_get_format | ( | struct ast_multicast_rtp_options * | mcast_options | ) |
Get format specified in multicast options.
Multicast options allow for a format to be selected. This function accesses the selected format and creates an ast_format structure for it.
mcast_options | The options where a codec was specified |
NULL | No format specified in the options |
non-NULL | The format to use for communication |
Definition at line 180 of file res_rtp_multicast.c.
References ast_format_cache_get, ast_strlen_zero(), ast_test_flag, NULL, OPT_ARG_CODEC, ast_multicast_rtp_options::opt_args, OPT_CODEC, and ast_multicast_rtp_options::opts.
Referenced by multicast_rtp_request().
|
static |
Definition at line 328 of file res_rtp_multicast.c.
References ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and multicast_rtp::txcore.
Referenced by rtp_raw_write().
|
static |
Definition at line 546 of file res_rtp_multicast.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_rtp_engine_register, and multicast_rtp_engine.
|
static |
Function called to indicate that audio is now going to flow.
Definition at line 382 of file res_rtp_multicast.c.
References ast_rtp_instance_get_data(), LINKSYS_MCAST_STARTCMD, multicast_send_control_packet(), MULTICAST_TYPE_LINKSYS, and multicast_rtp::type.
|
static |
Function called to destroy a multicast instance.
Definition at line 394 of file res_rtp_multicast.c.
References ast_free, ast_rtp_instance_get_data(), ast_smoother_free(), LINKSYS_MCAST_STOPCMD, multicast_send_control_packet(), MULTICAST_TYPE_LINKSYS, multicast_rtp::smoother, multicast_rtp::socket, and multicast_rtp::type.
|
static |
Function called to create a new multicast instance.
Definition at line 284 of file res_rtp_multicast.c.
References ast_calloc, ast_free, ast_random(), ast_rtp_instance_set_data(), ast_test_flag, OPT_ARG_IF, OPT_ARG_LOOP, OPT_ARG_TTL, ast_multicast_rtp_options::opt_args, OPT_IF, OPT_LOOP, OPT_TTL, ast_multicast_rtp_options::opts, set_if(), set_loop(), set_ttl(), set_type(), multicast_rtp::socket, multicast_rtp::ssrc, and ast_multicast_rtp_options::type.
|
static |
Function called to read from a multicast instance.
Definition at line 541 of file res_rtp_multicast.c.
References ast_null_frame.
|
static |
Function called to broadcast some audio on a multicast instance.
Definition at line 469 of file res_rtp_multicast.c.
References ast_format_can_be_smoothed(), ast_format_get_default_ms(), ast_format_get_minimum_bytes(), ast_format_get_minimum_ms(), ast_format_get_name(), ast_format_get_smoother_flags(), AST_FRAME_VOICE, ast_frdup, ast_frfree, ast_log, ast_rtp_codecs_get_framing(), ast_rtp_codecs_payload_code_tx(), ast_rtp_instance_get_codecs(), ast_rtp_instance_get_data(), ast_smoother_feed, ast_smoother_feed_be, AST_SMOOTHER_FLAG_BE, AST_SMOOTHER_FLAG_FORCED, ast_smoother_new(), ast_smoother_read(), ast_smoother_set_flags(), ast_smoother_test_flag(), ast_frame::data, ast_frame_subclass::format, ast_frame::frametype, LOG_WARNING, ast_frame::offset, ast_frame::ptr, rtp_raw_write(), multicast_rtp::smoother, and ast_frame::subclass.
|
static |
Helper function which populates a control packet with useful information and sends it.
Definition at line 348 of file res_rtp_multicast.c.
References ast_log, ast_rtp_instance_get_local_address(), ast_rtp_instance_get_remote_address, ast_sendto(), ast_sockaddr_ipv4(), ast_sockaddr_is_ipv6(), ast_sockaddr_isnull(), ast_sockaddr_port, multicast_control_packet::command, multicast_control_packet::ip, LOG_WARNING, NULL, multicast_control_packet::port, multicast_rtp::socket, and multicast_control_packet::unique_id.
Referenced by multicast_rtp_activate(), and multicast_rtp_destroy().
|
static |
Definition at line 322 of file res_rtp_multicast.c.
References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g722, and ast_format_get_sample_rate().
Referenced by rtp_raw_write().
|
static |
Definition at line 413 of file res_rtp_multicast.c.
References abs, ast_debug, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_g722, AST_FRFLAG_HAS_TIMING_INFO, ast_log, ast_rtp_instance_get_data(), ast_rtp_instance_get_remote_address, ast_sendto(), ast_sockaddr_stringify(), ast_test_flag, ast_tvzero(), calc_txstamp(), ast_frame::data, ast_frame::datalen, ast_frame::delivery, errno, ast_frame_subclass::format, multicast_rtp::lastts, LOG_ERROR, MAX_TIMESTAMP_SKEW, ast_frame::ptr, put_unaligned_uint32(), rtp_get_rate(), ast_frame::samples, multicast_rtp::seqno, multicast_rtp::socket, multicast_rtp::ssrc, ast_frame::subclass, and ast_frame::ts.
Referenced by multicast_rtp_write().
|
static |
Definition at line 263 of file res_rtp_multicast.c.
References ast_debug, ast_log, ast_strlen_zero(), errno, inet_aton(), and LOG_WARNING.
Referenced by multicast_rtp_new().
|
static |
Definition at line 242 of file res_rtp_multicast.c.
References ast_debug, ast_log, ast_strlen_zero(), errno, and LOG_WARNING.
Referenced by multicast_rtp_new().
|
static |
Definition at line 221 of file res_rtp_multicast.c.
References ast_debug, ast_log, ast_strlen_zero(), errno, and LOG_WARNING.
Referenced by multicast_rtp_new().
|
static |
Definition at line 207 of file res_rtp_multicast.c.
References ast_log, LOG_WARNING, MULTICAST_TYPE_BASIC, MULTICAST_TYPE_LINKSYS, type, and multicast_rtp::type.
Referenced by multicast_rtp_new().
|
static |
Definition at line 555 of file res_rtp_multicast.c.
References ast_rtp_engine_unregister(), and multicast_rtp_engine.
|
static |
Definition at line 567 of file res_rtp_multicast.c.
|
static |
Definition at line 567 of file res_rtp_multicast.c.
|
static |
Definition at line 198 of file res_rtp_multicast.c.
Referenced by load_module(), and unload_module().
|
static |
Set the codec to be used for multicast RTP
Set whether multicast RTP is looped back to the sender
Set the hop count for multicast RTP
Set the interface from which multicast RTP is sent
Definition at line 128 of file res_rtp_multicast.c.
Referenced by ast_multicast_rtp_create_options().