Sat Apr 26 2014 22:02:15

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"
Include dependency graph for chan_multicast_rtp.c:

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, const 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, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *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 = AST_BUILDOPT_SUM, .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 204 of file chan_multicast_rtp.c.

static void __unreg_module ( void  ) [static]

Definition at line 204 of file chan_multicast_rtp.c.

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

Function called when we should actually call the destination.

Definition at line 91 of file chan_multicast_rtp.c.

References ast_channel_tech_pvt(), AST_CONTROL_ANSWER, ast_queue_control(), and ast_rtp_instance_activate().

static int multicast_rtp_hangup ( struct ast_channel ast) [static]

Function called when we should hang the channel up.

Definition at line 101 of file chan_multicast_rtp.c.

References ast_channel_tech_pvt(), ast_channel_tech_pvt_set(), and ast_rtp_instance_destroy().

{
   struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);

   ast_rtp_instance_destroy(instance);

   ast_channel_tech_pvt_set(ast, NULL);

   return 0;
}
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 77 of file chan_multicast_rtp.c.

References ast_null_frame.

{
   return &ast_null_frame;
}
static struct ast_channel * multicast_rtp_request ( const char *  type,
struct ast_format_cap cap,
const struct ast_channel requestor,
const char *  data,
int *  cause 
) [static, read]

Function called when we should prepare to call the destination.

Definition at line 113 of file chan_multicast_rtp.c.

References ast_best_codec(), AST_CAUSE_FAILURE, ast_channel_alloc(), ast_channel_linkedid(), ast_channel_nativeformats(), ast_channel_rawreadformat(), ast_channel_rawwriteformat(), ast_channel_readformat(), ast_channel_tech_pvt_set(), ast_channel_tech_set(), ast_channel_writeformat(), ast_format_cap_add(), ast_format_copy(), ast_rtp_instance_destroy(), ast_rtp_instance_new(), ast_rtp_instance_set_remote_address(), ast_sockaddr_parse(), ast_sockaddr_setnull(), AST_STATE_DOWN, ast_strlen_zero(), and PARSE_PORT_REQUIRE.

{
   char *tmp = ast_strdupa(data), *multicast_type = tmp, *destination, *control;
   struct ast_rtp_instance *instance;
   struct ast_sockaddr control_address;
   struct ast_sockaddr destination_address;
   struct ast_channel *chan;
   struct ast_format fmt;
   ast_best_codec(cap, &fmt);

   ast_sockaddr_setnull(&control_address);

   /* If no type was given we can't do anything */
   if (ast_strlen_zero(multicast_type)) {
      goto failure;
   }

   if (!(destination = strchr(tmp, '/'))) {
      goto failure;
   }
   *destination++ = '\0';

   if ((control = strchr(destination, '/'))) {
      *control++ = '\0';
      if (!ast_sockaddr_parse(&control_address, control,
               PARSE_PORT_REQUIRE)) {
         goto failure;
      }
   }

   if (!ast_sockaddr_parse(&destination_address, destination,
            PARSE_PORT_REQUIRE)) {
      goto failure;
   }

   if (!(instance = ast_rtp_instance_new("multicast", NULL, &control_address, multicast_type))) {
      goto failure;
   }

   if (!(chan = ast_channel_alloc(1, AST_STATE_DOWN, "", "", "", "", "", requestor ? ast_channel_linkedid(requestor) : "", 0, "MulticastRTP/%p", instance))) {
      ast_rtp_instance_destroy(instance);
      goto failure;
   }

   ast_rtp_instance_set_remote_address(instance, &destination_address);

   ast_channel_tech_set(chan, &multicast_rtp_tech);

   ast_format_cap_add(ast_channel_nativeformats(chan), &fmt);
   ast_format_copy(ast_channel_writeformat(chan), &fmt);
   ast_format_copy(ast_channel_rawwriteformat(chan), &fmt);
   ast_format_copy(ast_channel_readformat(chan), &fmt);
   ast_format_copy(ast_channel_rawreadformat(chan), &fmt);

   ast_channel_tech_pvt_set(chan, instance);

   return chan;

failure:
   *cause = AST_CAUSE_FAILURE;
   return NULL;
}
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 83 of file chan_multicast_rtp.c.

References ast_channel_tech_pvt(), and ast_rtp_instance_write().

{
   struct ast_rtp_instance *instance = ast_channel_tech_pvt(ast);

   return ast_rtp_instance_write(instance, f);
}

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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DRIVER, } [static]

Definition at line 204 of file chan_multicast_rtp.c.

Definition at line 204 of file chan_multicast_rtp.c.

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.