Wed Jan 8 2020 09:49:58

Asterisk developer's documentation


bridge_simple.c File Reference

Simple two channel bridging module. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/bridging.h"
#include "asterisk/bridging_technology.h"
#include "asterisk/frame.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)
 
static int simple_bridge_join (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 
static enum ast_bridge_write_result simple_bridge_write (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Simple two channel bridging module" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_bridge_technology simple_bridge
 

Detailed Description

Simple two channel bridging module.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file bridge_simple.c.

Function Documentation

static void __reg_module ( void  )
static

Definition at line 107 of file bridge_simple.c.

static void __unreg_module ( void  )
static

Definition at line 107 of file bridge_simple.c.

static int load_module ( void  )
static

Definition at line 102 of file bridge_simple.c.

References ast_bridge_technology_register.

103 {
105 }
static struct ast_bridge_technology simple_bridge
Definition: bridge_simple.c:88
#define ast_bridge_technology_register(technology)
See __ast_bridge_technology_register()
static int simple_bridge_join ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel 
)
static

Definition at line 48 of file bridge_simple.c.

References ast_channel_make_compatible(), AST_LIST_FIRST, AST_LIST_LAST, ast_channel::nativeformats, ast_channel::readformat, and ast_channel::writeformat.

49 {
50  struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan, *c1 = AST_LIST_LAST(&bridge->channels)->chan;
51 
52  /* If this is the first channel we can't make it compatible... unless we make it compatible with itself O.o */
53  if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
54  return 0;
55  }
56 
57  /* See if we need to make these compatible */
58  if (((c0->writeformat == c1->readformat) && (c0->readformat == c1->writeformat) && (c0->nativeformats == c1->nativeformats))) {
59  return 0;
60  }
61 
62  /* BOOM! We do. */
63  return ast_channel_make_compatible(c0, c1);
64 }
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
format_t writeformat
Definition: channel.h:854
format_t nativeformats
Definition: channel.h:852
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1)
Makes two channel formats compatible.
Definition: channel.c:5970
format_t readformat
Definition: channel.h:853
static enum ast_bridge_write_result simple_bridge_write ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel,
struct ast_frame frame 
)
static

Definition at line 66 of file bridge_simple.c.

References AST_BRIDGE_CHANNEL_STATE_WAIT, AST_BRIDGE_WRITE_FAILED, AST_BRIDGE_WRITE_SUCCESS, AST_LIST_FIRST, AST_LIST_LAST, ast_write(), ast_bridge_channel::chan, and ast_bridge_channel::state.

67 {
68  struct ast_bridge_channel *other = NULL;
69 
70  /* If this is the only channel in this bridge then immediately exit */
71  if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
73  }
74 
75  /* Find the channel we actually want to write to */
76  if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels) : AST_LIST_FIRST(&bridge->channels)))) {
78  }
79 
80  /* Write the frame out if they are in the waiting state... don't worry about freeing it, the bridging core will take care of it */
81  if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
82  ast_write(other->chan, frame);
83  }
84 
86 }
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:420
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:428
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
Definition: channel.c:4916
struct ast_channel * chan
Definition: bridging.h:125
Structure that contains information regarding a channel in a bridge.
Definition: bridging.h:117
enum ast_bridge_channel_state state
Definition: bridging.h:123
static int unload_module ( void  )
static

Definition at line 97 of file bridge_simple.c.

References ast_bridge_technology_unregister().

98 {
100 }
static struct ast_bridge_technology simple_bridge
Definition: bridge_simple.c:88
int ast_bridge_technology_unregister(struct ast_bridge_technology *technology)
Unregister a bridge technology from use.
Definition: bridging.c:99

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Simple two channel bridging module" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 107 of file bridge_simple.c.

Definition at line 107 of file bridge_simple.c.

struct ast_bridge_technology simple_bridge
static

Definition at line 88 of file bridge_simple.c.