Wed Apr 6 11:29:57 2011

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

static void __reg_module (void)
static void __unreg_module (void)
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_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Multicast RTP Paging Channel" , .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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, }
static struct ast_module_infoast_module_info = &__mod_info
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

static void __reg_module ( void   )  [static]

Definition at line 193 of file chan_multicast_rtp.c.

static void __unreg_module ( void   )  [static]

Definition at line 193 of file chan_multicast_rtp.c.

static int load_module ( void   )  [static]

Function called when our module is loaded.

Definition at line 171 of file chan_multicast_rtp.c.

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

00172 {
00173    if (ast_channel_register(&multicast_rtp_tech)) {
00174       ast_log(LOG_ERROR, "Unable to register channel class 'MulticastRTP'\n");
00175       return AST_MODULE_LOAD_DECLINE;
00176    }
00177 
00178    return AST_MODULE_LOAD_SUCCESS;
00179 }

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 88 of file chan_multicast_rtp.c.

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

00089 {
00090    struct ast_rtp_instance *instance = ast->tech_pvt;
00091 
00092    ast_queue_control(ast, AST_CONTROL_ANSWER);
00093 
00094    return ast_rtp_instance_activate(instance);
00095 }

static int multicast_rtp_hangup ( struct ast_channel ast  )  [static]

Function called when we should hang the channel up.

Definition at line 98 of file chan_multicast_rtp.c.

References ast_rtp_instance_destroy(), and ast_channel::tech_pvt.

00099 {
00100    struct ast_rtp_instance *instance = ast->tech_pvt;
00101 
00102    ast_rtp_instance_destroy(instance);
00103 
00104    ast->tech_pvt = NULL;
00105 
00106    return 0;
00107 }

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

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

Definition at line 74 of file chan_multicast_rtp.c.

References ast_null_frame.

00075 {
00076    return &ast_null_frame;
00077 }

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

Function called when we should prepare to call the destination.

Definition at line 110 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::linkedid, multicast_rtp_tech, 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.

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

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 80 of file chan_multicast_rtp.c.

References ast_rtp_instance_write(), f, and ast_channel::tech_pvt.

00081 {
00082    struct ast_rtp_instance *instance = ast->tech_pvt;
00083 
00084    return ast_rtp_instance_write(instance, f);
00085 }

static int unload_module ( void   )  [static]

Function called when our module is unloaded.

Definition at line 182 of file chan_multicast_rtp.c.

References ast_channel_unregister(), and multicast_rtp_tech.

00183 {
00184    ast_channel_unregister(&multicast_rtp_tech);
00185 
00186    return 0;
00187 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Multicast RTP Paging Channel" , .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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, } [static]

Definition at line 193 of file chan_multicast_rtp.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 193 of file chan_multicast_rtp.c.

struct ast_channel_tech multicast_rtp_tech [static]

Definition at line 62 of file chan_multicast_rtp.c.

Referenced by load_module(), multicast_rtp_request(), and unload_module().

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

Definition at line 52 of file chan_multicast_rtp.c.


Generated on Wed Apr 6 11:29:57 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7