Tue Aug 24 20:34:39 2010

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

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Simple two channel bridging module")
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_bridge_technology simple_bridge

Detailed Description

Simple two channel bridging module.

Author:
Joshua Colp <jcolp@digium.com>

Definition in file bridge_simple.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Simple two channel bridging module"   
)
static int load_module ( void   )  [static]

Definition at line 98 of file bridge_simple.c.

References ast_bridge_technology_register.

00099 {
00100    return ast_bridge_technology_register(&simple_bridge);
00101 }

static int simple_bridge_join ( struct ast_bridge *  bridge,
struct ast_bridge_channel *  bridge_channel 
) [static]

Definition at line 44 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.

00045 {
00046    struct ast_channel *c0 = AST_LIST_FIRST(&bridge->channels)->chan, *c1 = AST_LIST_LAST(&bridge->channels)->chan;
00047 
00048    /* If this is the first channel we can't make it compatible... unless we make it compatible with itself O.o */
00049    if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
00050       return 0;
00051    }
00052 
00053    /* See if we need to make these compatible */
00054    if (((c0->writeformat == c1->readformat) && (c0->readformat == c1->writeformat) && (c0->nativeformats == c1->nativeformats))) {
00055       return 0;
00056    }
00057 
00058    /* BOOM! We do. */
00059    return ast_channel_make_compatible(c0, c1);
00060 }

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 62 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.

00063 {
00064    struct ast_bridge_channel *other = NULL;
00065 
00066    /* If this is the only channel in this bridge then immediately exit */
00067    if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels)) {
00068       return AST_BRIDGE_WRITE_FAILED;
00069    }
00070 
00071    /* Find the channel we actually want to write to */
00072    if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels) : AST_LIST_FIRST(&bridge->channels)))) {
00073       return AST_BRIDGE_WRITE_FAILED;
00074    }
00075 
00076    /* 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 */
00077    if (other->state == AST_BRIDGE_CHANNEL_STATE_WAIT) {
00078       ast_write(other->chan, frame);
00079    }
00080 
00081    return AST_BRIDGE_WRITE_SUCCESS;
00082 }

static int unload_module ( void   )  [static]

Definition at line 93 of file bridge_simple.c.

References ast_bridge_technology_unregister().

00094 {
00095    return ast_bridge_technology_unregister(&simple_bridge);
00096 }


Variable Documentation

Definition at line 84 of file bridge_simple.c.


Generated on 24 Aug 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1