summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2017-06-08 19:38:51 +0000
committerJoshua Colp <jcolp@digium.com>2017-06-13 22:05:28 +0000
commite414833f6e77345f4969116972e9cf1ad9b595fd (patch)
tree04132d145ffbf5116b2a08a73115bbd87d9ece4c /bridges
parent85dff8e26ee9bbe3ce781eefb9b1037e1fb9217a (diff)
bridge: Add a deferred queue.
This change adds a deferred queue to bridging. If a bridge technology determines that a frame can not be written and should be deferred it can indicate back to bridging to do so. Bridging will then requeue any deferred frames upon a new channel joining the bridge. This change has been leveraged for T.38 request negotiate control frames. Without the deferred queue there is a race condition between the bridge receiving the T.38 request negotiate and the second channel joining and being in the bridge. If the channel is not yet in the bridge then the T.38 negotiation fails. A unit test has also been added that confirms that a T.38 request negotiate control frame is deferred when no other channel is in the bridge and that it is requeued when a new channel joins the bridge. ASTERISK-26923 Change-Id: Ie05b08523f399eae579130f4a5f562a344d2e415
Diffstat (limited to 'bridges')
-rw-r--r--bridges/bridge_native_rtp.c32
-rw-r--r--bridges/bridge_simple.c32
2 files changed, 62 insertions, 2 deletions
diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index a80ef4c5a..78e35a16b 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -510,7 +510,37 @@ static void native_rtp_bridge_leave(struct ast_bridge *bridge, struct ast_bridge
static int native_rtp_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
{
- return ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
+ const struct ast_control_t38_parameters *t38_parameters;
+ int defer = 0;
+
+ if (!ast_bridge_queue_everyone_else(bridge, bridge_channel, frame)) {
+ /* This frame was successfully queued so no need to defer */
+ return 0;
+ }
+
+ /* Depending on the frame defer it so when the next channel joins it receives it */
+ switch (frame->frametype) {
+ case AST_FRAME_CONTROL:
+ switch (frame->subclass.integer) {
+ case AST_CONTROL_T38_PARAMETERS:
+ t38_parameters = frame->data.ptr;
+ switch (t38_parameters->request_response) {
+ case AST_T38_REQUEST_NEGOTIATE:
+ defer = -1;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return defer;
}
static struct ast_bridge_technology native_rtp_bridge = {
diff --git a/bridges/bridge_simple.c b/bridges/bridge_simple.c
index 570453500..3e2a73e46 100644
--- a/bridges/bridge_simple.c
+++ b/bridges/bridge_simple.c
@@ -63,7 +63,37 @@ static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chann
static int simple_bridge_write(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
{
- return ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
+ const struct ast_control_t38_parameters *t38_parameters;
+ int defer = 0;
+
+ if (!ast_bridge_queue_everyone_else(bridge, bridge_channel, frame)) {
+ /* This frame was successfully queued so no need to defer */
+ return 0;
+ }
+
+ /* Depending on the frame defer it so when the next channel joins it receives it */
+ switch (frame->frametype) {
+ case AST_FRAME_CONTROL:
+ switch (frame->subclass.integer) {
+ case AST_CONTROL_T38_PARAMETERS:
+ t38_parameters = frame->data.ptr;
+ switch (t38_parameters->request_response) {
+ case AST_T38_REQUEST_NEGOTIATE:
+ defer = -1;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return defer;
}
static struct ast_bridge_technology simple_bridge = {