[asterisk-commits] file: branch file/bridging r79686 - in /team/file/bridging: bridges/ include/...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 16 10:04:31 CDT 2007


Author: file
Date: Thu Aug 16 10:04:30 2007
New Revision: 79686

URL: http://svn.digium.com/view/asterisk?view=rev&rev=79686
Log:
Add more return values for bridge technology write function. While this isn't currently used a bridge technology can return back that a frame is unsupported and the bridging core can use alternate methods to make sure it is exchanged.

Modified:
    team/file/bridging/bridges/bridge_simple.c
    team/file/bridging/bridges/bridge_softmix.c
    team/file/bridging/bridges/bridge_zaptel.c
    team/file/bridging/include/asterisk/bridging.h

Modified: team/file/bridging/bridges/bridge_simple.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/bridges/bridge_simple.c?view=diff&rev=79686&r1=79685&r2=79686
==============================================================================
--- team/file/bridging/bridges/bridge_simple.c (original)
+++ team/file/bridging/bridges/bridge_simple.c Thu Aug 16 10:04:30 2007
@@ -56,22 +56,22 @@
 	return ast_channel_make_compatible(c0, c1);
 }
 
-static int simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static enum ast_bridge_write_result simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	struct ast_channel *other = NULL;
 
 	/* If this is the only channel in this bridge then immediately exit */
 	if (AST_LIST_FIRST(&bridge->channels) == AST_LIST_LAST(&bridge->channels))
-		return -1;
+		return AST_BRIDGE_WRITE_FAILED;
 
 	/* Find the channel we actually want to write to */
 	if (!(other = (AST_LIST_FIRST(&bridge->channels) == bridge_channel ? AST_LIST_LAST(&bridge->channels)->chan : AST_LIST_FIRST(&bridge->channels)->chan)))
-		return -1;
+		return AST_BRIDGE_WRITE_FAILED;
 
 	/* Write the frame out... don't worry about freeing it, the bridging core will take care of it */
 	ast_write(other, frame);
 
-	return 0;
+	return AST_BRIDGE_WRITE_SUCCESS;
 }
 
 static struct ast_bridge_technology simple_bridge = {

Modified: team/file/bridging/bridges/bridge_softmix.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/bridges/bridge_softmix.c?view=diff&rev=79686&r1=79685&r2=79686
==============================================================================
--- team/file/bridging/bridges/bridge_softmix.c (original)
+++ team/file/bridging/bridges/bridge_softmix.c Thu Aug 16 10:04:30 2007
@@ -88,9 +88,9 @@
 }
 
 /* Called when a frame comes from a channel and should go into the bridge */
-static int softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static enum ast_bridge_write_result softmix_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
-	return 0;
+	return AST_BRIDGE_WRITE_FAILED;
 }
 
 static struct ast_bridge_technology softmix_bridge = {

Modified: team/file/bridging/bridges/bridge_zaptel.c
URL: http://svn.digium.com/view/asterisk/team/file/bridging/bridges/bridge_zaptel.c?view=diff&rev=79686&r1=79685&r2=79686
==============================================================================
--- team/file/bridging/bridges/bridge_zaptel.c (original)
+++ team/file/bridging/bridges/bridge_zaptel.c Thu Aug 16 10:04:30 2007
@@ -197,14 +197,18 @@
 	return 0;
 }
 
-static int zaptel_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
+static enum ast_bridge_write_result zaptel_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
 	int fd = (int)(long)bridge_channel->bridge_pvt;
+
+	/* Only accept audio frames, all others are unsupported */
+	if (frame->frametype != AST_FRAME_VOICE)
+		return AST_BRIDGE_WRITE_UNSUPPORTED;
 
 	/* Write audio into zaptel conference */
 	careful_write(fd, frame->data, frame->datalen);
 
-	return 0;
+	return AST_BRIDGE_WRITE_SUCCESS;
 }
 
 static int zaptel_bridge_fd(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int fd)

Modified: team/file/bridging/include/asterisk/bridging.h
URL: http://svn.digium.com/view/asterisk/team/file/bridging/include/asterisk/bridging.h?view=diff&rev=79686&r1=79685&r2=79686
==============================================================================
--- team/file/bridging/include/asterisk/bridging.h (original)
+++ team/file/bridging/include/asterisk/bridging.h Thu Aug 16 10:04:30 2007
@@ -58,24 +58,31 @@
 	AST_BRIDGE_FLAG_SMART = (1 << 1),    /*! Move between bridge technologies as needed */
 };
 
+/*! \brief Return values for bridge technology write function */
+enum ast_bridge_write_result {
+	AST_BRIDGE_WRITE_SUCCESS = 0, /*! Frame was written out fine */
+	AST_BRIDGE_WRITE_FAILED,      /*! Tried to write out the frame but failed */
+	AST_BRIDGE_WRITE_UNSUPPORTED, /*! Bridge technology can't write out this frame type */
+};
+
 struct ast_bridge;
 struct ast_bridge_channel;
 
 struct ast_bridge_technology {
-	const char *name;                                                                                             /*! Unique name to this bridge technology */
-	int capabilities;                                                                                             /*! What this bridge technology is capable of */
-	enum ast_bridge_preference preference;                                                                        /*! Preference level of this bridge technology */
-	int (*create)(struct ast_bridge *bridge);                                                                     /*! Callback for when a bridge is created */
-	int (*destroy)(struct ast_bridge *bridge);                                                                    /*! Callback for when a bridge is destroyed */
-	int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);                            /*! Callback for when a channel joins a bridge */
-	int (*leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);                           /*! Callback for when a channel leaves a bridge */
-	int (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame); /*! Callback for writing a frame to the bridge */
-	int (*fd)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int fd);                      /*! Callback for when a file descriptor trips */
-	int (*thread)(struct ast_bridge *bridge);                                                                     /*! Callback for replacement thread function */
-	int (*poke)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);                            /*! Callback for poking a bridge technology */
-	int formats;                                                                                                  /*! Formats this bridge technology can support */
-	int suspended:1;                                                                                              /*! Is this bridge technology suspended from use or not? */
-	AST_RWLIST_ENTRY(ast_bridge_technology) list;                                                                 /*! Linked list information */
+	const char *name;                                                                                                                      /*! Unique name to this bridge technology */
+	int capabilities;                                                                                                                      /*! What this bridge technology is capable of */
+	enum ast_bridge_preference preference;                                                                                                 /*! Preference level of this bridge technology */
+	int (*create)(struct ast_bridge *bridge);                                                                                              /*! Callback for when a bridge is created */
+	int (*destroy)(struct ast_bridge *bridge);                                                                                             /*! Callback for when a bridge is destroyed */
+	int (*join)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);                                                     /*! Callback for when a channel joins a bridge */
+	int (*leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);                                                    /*! Callback for when a channel leaves a bridge */
+	enum ast_bridge_write_result (*write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridged_channel, struct ast_frame *frame); /*! Callback for writing a frame to the bridge */
+	int (*fd)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, int fd);                                               /*! Callback for when a file descriptor trips */
+	int (*thread)(struct ast_bridge *bridge);                                                                                              /*! Callback for replacement thread function */
+	int (*poke)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel);                                                     /*! Callback for poking a bridge technology */
+	int formats;                                                                                                                           /*! Formats this bridge technology can support */
+	int suspended:1;                                                                                                                       /*! Is this bridge technology suspended from use or not? */
+	AST_RWLIST_ENTRY(ast_bridge_technology) list;                                                                                          /*! Linked list information */
 };
 
 struct ast_bridge_channel {




More information about the asterisk-commits mailing list