Wed Jan 27 20:02:23 2016

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

 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 102 of file bridge_simple.c.

References ast_bridge_technology_register.

00103 {
00104    return ast_bridge_technology_register(&simple_bridge);
00105 }

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.

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

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.

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

static int unload_module ( void   )  [static]

Definition at line 97 of file bridge_simple.c.

References ast_bridge_technology_unregister().

00098 {
00099    return ast_bridge_technology_unregister(&simple_bridge);
00100 }


Variable Documentation

Definition at line 88 of file bridge_simple.c.


Generated on 27 Jan 2016 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1