60#define LINKSYS_MCAST_STARTCMD 6
63#define LINKSYS_MCAST_STOPCMD 7
102#define MAX_TIMESTAMP_SKEW 640
146 mcast_options =
ast_calloc(1,
sizeof(*mcast_options)
149 if (!mcast_options) {
153 pos = mcast_options->
buf;
157 mcast_options->
type = pos;
158 pos += strlen(
type) + 1;
172 return mcast_options;
209 if (!strcasecmp(
type,
"basic")) {
211 }
else if (!strcasecmp(
type,
"linksys")) {
221static void set_ttl(
int sock,
const char *ttl_str)
229 ast_debug(3,
"Setting multicast TTL to %s\n", ttl_str);
231 if (sscanf(ttl_str,
"%30d", &ttl) < 1) {
236 if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
sizeof(ttl)) < 0) {
238 ttl_str, strerror(
errno));
242static void set_loop(
int sock,
const char *loop_str)
250 ast_debug(3,
"Setting multicast loop to %s\n", loop_str);
252 if (sscanf(loop_str,
"%30hhu", &loop) < 1) {
257 if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loop,
sizeof(loop)) < 0) {
259 loop_str, strerror(
errno));
263static void set_if(
int sock,
const char *if_str)
265 struct in_addr iface;
271 ast_debug(3,
"Setting multicast if to %s\n", if_str);
277 if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, &iface,
sizeof(iface)) < 0) {
279 if_str, strerror(
errno));
289 if (!(multicast =
ast_calloc(1,
sizeof(*multicast)))) {
298 if ((multicast->
socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
344 return (
unsigned int) ms;
367 "remote address.\n");
375 ast_sendto(multicast->
socket, &control_packet,
sizeof(control_packet), 0, &control_address);
376 ast_sendto(multicast->
socket, &control_packet,
sizeof(control_packet), 0, &control_address);
417 unsigned char *rtpheader;
420 int hdrlen = 12, mark = 0;
427 multicast->
lastts = frame->
ts * rate;
435 int delta =
abs((
int) multicast->
lastts - pred);
439 ast_debug(3,
"Difference is %d, ms is %u\n", delta, ms);
446 rtpheader = (
unsigned char *)(frame->
data.
ptr - hdrlen);
453 multicast->
seqno = 0xFFFF & (multicast->
seqno + 1);
522 if (frame->
offset < hdrlen) {
Access Control of various sorts.
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
General Asterisk PBX channel definitions.
Standard Command Line Interface.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#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.
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.
Configuration File Parser.
Asterisk internal frame definitions.
@ AST_FRFLAG_HAS_TIMING_INFO
#define ast_frdup(fr)
Copies a frame.
struct ast_frame ast_null_frame
#define ast_debug(level,...)
Log a DEBUG message.
Asterisk locking-related definitions:
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
Asterisk module definitions.
@ AST_MODFLAG_GLOBAL_SYMBOLS
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODPRI_CHANNEL_DEPEND
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
@ AST_MODULE_LOAD_SUCCESS
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr)
Get an IPv4 address of an ast_sockaddr.
ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags, const struct ast_sockaddr *dest_addr)
Wrapper around sendto(2) that uses ast_sockaddr.
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
int inet_aton(const char *cp, struct in_addr *pin)
Core PBX routines and definitions.
static struct ast_rtp_engine multicast_rtp_engine
static int multicast_rtp_destroy(struct ast_rtp_instance *instance)
Function called to destroy a multicast instance.
#define MAX_TIMESTAMP_SKEW
static void set_ttl(int sock, const char *ttl_str)
struct ast_multicast_rtp_options * ast_multicast_rtp_create_options(const char *type, const char *options)
Create multicast RTP options.
static int rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame *frame, int codec)
static int multicast_rtp_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Function called to broadcast some audio on a multicast instance.
static unsigned int calc_txstamp(struct multicast_rtp *rtp, struct timeval *delivery)
#define LINKSYS_MCAST_STOPCMD
static int set_type(struct multicast_rtp *multicast, const char *type)
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.
#define LINKSYS_MCAST_STARTCMD
static int rtp_get_rate(struct ast_format *format)
static void set_if(int sock, const char *if_str)
static struct ast_frame * multicast_rtp_read(struct ast_rtp_instance *instance, int rtcp)
Function called to read from a multicast instance.
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.
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.
static int unload_module(void)
static void set_loop(int sock, const char *loop_str)
struct ast_format * ast_multicast_rtp_options_get_format(struct ast_multicast_rtp_options *mcast_options)
Get format specified in multicast options.
static const struct ast_app_option multicast_rtp_options[128]
multicast_type
Type of paging to do.
@ MULTICAST_TYPE_UNSPECIFIED
void ast_multicast_rtp_free_options(struct ast_multicast_rtp_options *mcast_options)
Free multicast RTP options.
Pluggable RTP Architecture.
void * ast_rtp_instance_get_data(struct ast_rtp_instance *instance)
Get the data portion of an RTP instance.
#define ast_rtp_instance_get_remote_address(instance, address)
Get the address of the remote endpoint that we are sending RTP to.
void ast_rtp_instance_set_data(struct ast_rtp_instance *instance, void *data)
Set the data portion of an RTP instance.
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.
int ast_rtp_codecs_payload_code_tx(struct ast_rtp_codecs *codecs, int asterisk_format, const struct ast_format *format, int code)
Retrieve a tx mapped payload type based on whether it is an Asterisk format and the code.
int ast_rtp_engine_unregister(struct ast_rtp_engine *engine)
Unregister an RTP engine.
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
unsigned int ast_rtp_codecs_get_framing(struct ast_rtp_codecs *codecs)
Get the framing used for a set of codecs.
#define ast_rtp_engine_register(engine)
Asterisk internal frame definitions.
void ast_smoother_set_flags(struct ast_smoother *smoother, int flags)
#define ast_smoother_feed_be(s, f)
int ast_smoother_test_flag(struct ast_smoother *s, int flag)
void ast_smoother_free(struct ast_smoother *s)
#define AST_SMOOTHER_FLAG_FORCED
struct ast_frame * ast_smoother_read(struct ast_smoother *s)
#define ast_smoother_feed(s, f)
struct ast_smoother * ast_smoother_new(int bytes)
#define AST_SMOOTHER_FLAG_BE
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Structure used to handle boolean flags.
struct ast_format * format
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
char * opt_args[OPT_ARG_ARRAY_SIZE]
Socket address structure.
Structure for a Linksys control packet.
Structure for a multicast paging instance.
struct ast_smoother * smoother
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Handle unaligned data access.
static void put_unaligned_uint32(void *p, unsigned int datum)
#define ast_test_flag(p, flag)
long int ast_random(void)