[asterisk-commits] bridge native rtp.c: Fixup native rtp framehook() (asterisk[15])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Aug 30 08:47:56 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6326 )

Change subject: bridge_native_rtp.c: Fixup native_rtp_framehook()
......................................................................

bridge_native_rtp.c: Fixup native_rtp_framehook()

* Fix framehook to test frame type for control frame.
* Made framehook exit early if frame type is not a control frame.
* Eliminated RAII_VAR in framehook.
* Use switch instead of else-if ladder for control frame handling.

Change-Id: Ia555fc3600bd85470e3c0141147dbe3ad07c1d18
---
M bridges/bridge_native_rtp.c
1 file changed, 13 insertions(+), 5 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/bridges/bridge_native_rtp.c b/bridges/bridge_native_rtp.c
index 02b27e1..a46b420 100644
--- a/bridges/bridge_native_rtp.c
+++ b/bridges/bridge_native_rtp.c
@@ -539,10 +539,12 @@
 static struct ast_frame *native_rtp_framehook(struct ast_channel *chan,
 	struct ast_frame *f, enum ast_framehook_event event, void *data)
 {
-	RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
+	struct ast_bridge *bridge;
 	struct native_rtp_framehook_data *native_data = data;
 
-	if (!f || (event != AST_FRAMEHOOK_EVENT_WRITE)) {
+	if (!f
+		|| f->frametype != AST_FRAME_CONTROL
+		|| event != AST_FRAMEHOOK_EVENT_WRITE) {
 		return f;
 	}
 
@@ -561,14 +563,20 @@
 		ast_channel_unlock(chan);
 		ast_bridge_lock(bridge);
 		if (!native_data->detached) {
-			if (f->subclass.integer == AST_CONTROL_HOLD) {
+			switch (f->subclass.integer) {
+			case AST_CONTROL_HOLD:
 				native_rtp_bridge_stop(bridge, chan);
-			} else if ((f->subclass.integer == AST_CONTROL_UNHOLD) ||
-				(f->subclass.integer == AST_CONTROL_UPDATE_RTP_PEER)) {
+				break;
+			case AST_CONTROL_UNHOLD:
+			case AST_CONTROL_UPDATE_RTP_PEER:
 				native_rtp_bridge_start(bridge, chan);
+				break;
+			default:
+				break;
 			}
 		}
 		ast_bridge_unlock(bridge);
+		ao2_ref(bridge, -1);
 		ast_channel_lock(chan);
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/6326
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia555fc3600bd85470e3c0141147dbe3ad07c1d18
Gerrit-Change-Number: 6326
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-commits/attachments/20170830/31499ade/attachment-0001.html>


More information about the asterisk-commits mailing list