Thu Sep 7 01:03:18 2017

Asterisk developer's documentation


chan_multicast_rtp.c File Reference

Multicast RTP Paging Channel. More...

#include "asterisk.h"
#include <fcntl.h>
#include <sys/signal.h>
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/acl.h"
#include "asterisk/callerid.h"
#include "asterisk/file.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/causes.h"

Go to the source code of this file.

Functions

 AST_MODULE_INFO (ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,"Multicast RTP Paging Channel",.load=load_module,.unload=unload_module,.load_pri=AST_MODPRI_CHANNEL_DRIVER,)
static int load_module (void)
 Function called when our module is loaded.
static int multicast_rtp_call (struct ast_channel *ast, char *dest, int timeout)
 Function called when we should actually call the destination.
static int multicast_rtp_hangup (struct ast_channel *ast)
 Function called when we should hang the channel up.
static struct ast_framemulticast_rtp_read (struct ast_channel *ast)
 Function called when we should read a frame from the channel.
static struct ast_channelmulticast_rtp_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
 Function called when we should prepare to call the destination.
static int multicast_rtp_write (struct ast_channel *ast, struct ast_frame *f)
 Function called when we should write a frame to the channel.
static int unload_module (void)
 Function called when our module is unloaded.

Variables

static struct ast_channel_tech multicast_rtp_tech
static const char tdesc [] = "Multicast RTP Paging Channel Driver"

Detailed Description

Multicast RTP Paging Channel.

Author:
Joshua Colp <jcolp@digium.com>
Andreas 'MacBrody' Broadmann <andreas.brodmann@gmail.com>

Definition in file chan_multicast_rtp.c.


Function Documentation

AST_MODULE_INFO ( ASTERISK_GPL_KEY  ,
AST_MODFLAG_LOAD_ORDER  ,
"Multicast RTP Paging Channel"  ,
load = load_module,
unload = unload_module,
load_pri = AST_MODPRI_CHANNEL_DRIVER 
)
static int load_module ( void   )  [static]

Function called when our module is loaded.

Definition at line 175 of file chan_multicast_rtp.c.

References ast_channel_register(), ast_log(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and LOG_ERROR.

00176 {
00177    if (ast_channel_register(&multicast_rtp_tech)) {
00178       ast_log(LOG_ERROR, "Unable to register channel class 'MulticastRTP'\n");
00179       return AST_MODULE_LOAD_DECLINE;
00180    }
00181 
00182    return AST_MODULE_LOAD_SUCCESS;
00183 }

static int multicast_rtp_call ( struct ast_channel ast,
char *  dest,
int  timeout 
) [static]

Function called when we should actually call the destination.

Definition at line 92 of file chan_multicast_rtp.c.

References AST_CONTROL_ANSWER, ast_queue_control(), ast_rtp_instance_activate(), and ast_channel::tech_pvt.

00093 {
00094    struct ast_rtp_instance *instance = ast->tech_pvt;
00095 
00096    ast_queue_control(ast, AST_CONTROL_ANSWER);
00097 
00098    return ast_rtp_instance_activate(instance);
00099 }

static int multicast_rtp_hangup ( struct ast_channel ast  )  [static]

Function called when we should hang the channel up.

Definition at line 102 of file chan_multicast_rtp.c.

References ast_rtp_instance_destroy(), and ast_channel::tech_pvt.

00103 {
00104    struct ast_rtp_instance *instance = ast->tech_pvt;
00105 
00106    ast_rtp_instance_destroy(instance);
00107 
00108    ast->tech_pvt = NULL;
00109 
00110    return 0;
00111 }

static struct ast_frame * multicast_rtp_read ( struct ast_channel ast  )  [static, read]

Function called when we should read a frame from the channel.

Definition at line 78 of file chan_multicast_rtp.c.

References ast_null_frame.

00079 {
00080    return &ast_null_frame;
00081 }

static struct ast_channel * multicast_rtp_request ( const char *  type,
format_t  format,
const struct ast_channel requestor,
void *  data,
int *  cause 
) [static, read]

Function called when we should prepare to call the destination.

Definition at line 114 of file chan_multicast_rtp.c.

References ast_best_codec(), AST_CAUSE_FAILURE, ast_channel_alloc, ast_rtp_instance_destroy(), ast_rtp_instance_new(), ast_rtp_instance_set_remote_address(), ast_sockaddr_parse(), ast_sockaddr_setnull(), AST_STATE_DOWN, ast_strdupa, ast_strlen_zero(), ast_channel::nativeformats, PARSE_PORT_REQUIRE, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::tech, ast_channel::tech_pvt, and ast_channel::writeformat.

00115 {
00116    char *tmp = ast_strdupa(data), *multicast_type = tmp, *destination, *control;
00117    struct ast_rtp_instance *instance;
00118    struct ast_sockaddr control_address;
00119    struct ast_sockaddr destination_address;
00120    struct ast_channel *chan;
00121    format_t fmt = ast_best_codec(format);
00122 
00123    ast_sockaddr_setnull(&control_address);
00124 
00125    /* If no type was given we can't do anything */
00126    if (ast_strlen_zero(multicast_type)) {
00127       goto failure;
00128    }
00129 
00130    if (!(destination = strchr(tmp, '/'))) {
00131       goto failure;
00132    }
00133    *destination++ = '\0';
00134 
00135    if ((control = strchr(destination, '/'))) {
00136       *control++ = '\0';
00137       if (!ast_sockaddr_parse(&control_address, control,
00138                PARSE_PORT_REQUIRE)) {
00139          goto failure;
00140       }
00141    }
00142 
00143    if (!ast_sockaddr_parse(&destination_address, destination,
00144             PARSE_PORT_REQUIRE)) {
00145       goto failure;
00146    }
00147 
00148    if (!(instance = ast_rtp_instance_new("multicast", NULL, &control_address, multicast_type))) {
00149       goto failure;
00150    }
00151 
00152    if (!(chan = ast_channel_alloc(1, AST_STATE_DOWN, "", "", "", "", "", requestor ? requestor->linkedid : "", 0, "MulticastRTP/%p", instance))) {
00153       ast_rtp_instance_destroy(instance);
00154       goto failure;
00155    }
00156 
00157    ast_rtp_instance_set_remote_address(instance, &destination_address);
00158 
00159    chan->tech = &multicast_rtp_tech;
00160    chan->nativeformats = fmt;
00161    chan->writeformat = fmt;
00162    chan->readformat = fmt;
00163    chan->rawwriteformat = fmt;
00164    chan->rawreadformat = fmt;
00165    chan->tech_pvt = instance;
00166 
00167    return chan;
00168 
00169 failure:
00170    *cause = AST_CAUSE_FAILURE;
00171    return NULL;
00172 }

static int multicast_rtp_write ( struct ast_channel ast,
struct ast_frame f 
) [static]

Function called when we should write a frame to the channel.

Definition at line 84 of file chan_multicast_rtp.c.

References ast_rtp_instance_write(), and ast_channel::tech_pvt.

00085 {
00086    struct ast_rtp_instance *instance = ast->tech_pvt;
00087 
00088    return ast_rtp_instance_write(instance, f);
00089 }

static int unload_module ( void   )  [static]

Function called when our module is unloaded.

Definition at line 186 of file chan_multicast_rtp.c.

References ast_channel_unregister().

00187 {
00188    ast_channel_unregister(&multicast_rtp_tech);
00189 
00190    return 0;
00191 }


Variable Documentation

Definition at line 66 of file chan_multicast_rtp.c.

const char tdesc[] = "Multicast RTP Paging Channel Driver" [static]

Definition at line 56 of file chan_multicast_rtp.c.


Generated on 7 Sep 2017 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1