[svn-commits] file: branch 12 r413667 - in /branches/12: bridges/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat May 10 20:07:51 CDT 2014


Author: file
Date: Sat May 10 20:07:44 2014
New Revision: 413667

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=413667
Log:
Undoing framehook support. Issues were uncovered by Bamboo.

Modified:
    branches/12/bridges/bridge_native_rtp.c
    branches/12/include/asterisk/channel.h
    branches/12/include/asterisk/framehook.h
    branches/12/main/bridge_basic.c
    branches/12/main/channel.c
    branches/12/main/framehook.c

Modified: branches/12/bridges/bridge_native_rtp.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/bridges/bridge_native_rtp.c?view=diff&rev=413667&r1=413666&r2=413667
==============================================================================
--- branches/12/bridges/bridge_native_rtp.c (original)
+++ branches/12/bridges/bridge_native_rtp.c Sat May 10 20:07:44 2014
@@ -288,12 +288,6 @@
 	return f;
 }
 
-/*! \brief Callback function which informs upstream if we are consuming a frame of a specific type */
-static int native_rtp_framehook_consume(void *data, enum ast_frame_type type)
-{
-	return (type == AST_FRAME_CONTROL ? 1 : 0);
-}
-
 /*! \brief Internal helper function which checks whether the channels are compatible with our native bridging */
 static int native_rtp_bridge_capable(struct ast_channel *chan)
 {
@@ -398,7 +392,6 @@
 	static struct ast_framehook_interface hook = {
 		.version = AST_FRAMEHOOK_INTERFACE_VERSION,
 		.event_cb = native_rtp_framehook,
-		.consume_cb = native_rtp_framehook_consume,
 	};
 
 	if (!data) {

Modified: branches/12/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/channel.h?view=diff&rev=413667&r1=413666&r2=413667
==============================================================================
--- branches/12/include/asterisk/channel.h (original)
+++ branches/12/include/asterisk/channel.h Sat May 10 20:07:44 2014
@@ -1049,8 +1049,8 @@
 	 */
 	AST_SOFTHANGUP_EXPLICIT =  (1 << 5),
 	/*!
-	 * Used to request that the bridge core re-evaluate the current
-	 * bridging technology in use by the bridge this channel is in.
+	 * Used to break a bridge so the channel can be spied upon
+	 * instead of actually hanging up.
 	 */
 	AST_SOFTHANGUP_UNBRIDGE =  (1 << 6),
 	/*!
@@ -4413,16 +4413,6 @@
 int ast_channel_has_audio_frame_or_monitor(struct ast_channel *chan);
 
 /*!
- * \brief Check if the channel has any active hooks that require audio.
- * \since 12.3.0
- *
- * \param chan The channel to check.
- *
- * \retval non-zero if channel has active audiohooks, audio framehooks, or monitor.
- */
-int ast_channel_has_hook_requiring_audio(struct ast_channel *chan);
-
-/*!
  * \brief Removes the trailing identifiers from a channel name string
  * \since 12.0.0
  *

Modified: branches/12/include/asterisk/framehook.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/framehook.h?view=diff&rev=413667&r1=413666&r2=413667
==============================================================================
--- branches/12/include/asterisk/framehook.h (original)
+++ branches/12/include/asterisk/framehook.h Sat May 10 20:07:44 2014
@@ -25,114 +25,114 @@
 \page AstFrameHookAPI Asterisk FrameHook API
 
 \section FrameHookFunctionality How FrameHooks Work
-	FrameHooks work by intercepting all frames being written and read off
-	a channel and allowing those frames to be viewed and manipulated within a
-	call back function.  Frame interception occurs before any processing is
-	done on the frame, which means this hook can be used to transparently
-	manipulate a frame before it is read from the channel or written
-	to the tech_pvt.  This API can be thought of as a layer between the
-	channel API and the Asterisk core when going in the READ direction, and
-	as a layer between the Channel API and the tech_pvt when going in the
-	WRITE direction.
+    FrameHooks work by intercepting all frames being written and read off
+    a channel and allowing those frames to be viewed and manipulated within a
+    call back function.  Frame interception occurs before any processing is
+    done on the frame, which means this hook can be used to transparently
+    manipulate a frame before it is read from the channel or written
+    to the tech_pvt.  This API can be thought of as a layer between the
+    channel API and the Asterisk core when going in the READ direction, and
+    as a layer between the Channel API and the tech_pvt when going in the
+    WRITE direction.
 
 \section FrameHookAPIUsage How to Use an FrameHook
-	Attaching and detaching an FrameHook to a channel is very simple.  There are only
-	two functions involved, ast_framehook_attach() which will return an id representing
-	the new FrameHook on the channel, and ast_framehook_detach() which signals the
-	FrameHook for detachment and destruction. Below is detailed information each of these
-	functions and their usage.
+    Attaching and detaching an FrameHook to a channel is very simple.  There are only
+    two functions involved, ast_framehook_attach() which will return an id representing
+    the new FrameHook on the channel, and ast_framehook_detach() which signals the
+    FrameHook for detachment and destruction. Below is detailed information each of these
+    functions and their usage.
 
 \code
-	struct ast_framehook_interface interface = {
-		.version = AST_FRAMEHOOK_INTERFACE_VERSION,
-		.event_cb = hook_event_cb,
-		.destroy_cb = hook_destroy_cb,
-		.data = data, // where the data ptr points to any custom data used later by the hook cb.
-	};
-	int id = ast_framehook_attach(channel, &interface);
+    struct ast_framehook_interface interface = {
+        .version = AST_FRAMEHOOK_INTERFACE_VERSION,
+        .event_cb = hook_event_cb,
+        .destroy_cb = hook_destroy_cb,
+        .data = data, // where the data ptr points to any custom data used later by the hook cb.
+    };
+    int id = ast_framehook_attach(channel, &interface);
 \endcode
 
-	The ast_framehook_attach() function creates and attaches a new FrameHook onto
-	a channel. Once attached to the channel, the FrameHook will call the event_callback
-	function each time a frame is written or read on the channel.  A custom data
-	pointer can be provided to this function to store on the FrameHook as well.  This
-	pointer can be used to keep up with any statefull information associated with the FrameHook
-	and is provided during the event_callback function.  The destroy_callback function is optional.
-	This function exists so any custom data stored on the FrameHook can be destroyed before
-	the Framehook if destroyed.
+    The ast_framehook_attach() function creates and attaches a new FrameHook onto
+    a channel. Once attached to the channel, the FrameHook will call the event_callback
+    function each time a frame is written or read on the channel.  A custom data
+    pointer can be provided to this function to store on the FrameHook as well.  This
+    pointer can be used to keep up with any statefull information associated with the FrameHook
+    and is provided during the event_callback function.  The destroy_callback function is optional.
+    This function exists so any custom data stored on the FrameHook can be destroyed before
+    the Framehook if destroyed.
 
 \code
-	ast_framehook_detach(channel, id);
+    ast_framehook_detach(channel, id);
 \endcode
 
-	The ast_framehook_detach() function signals the FrameHook represented by an id to
-	be detached and destroyed on a channel.  Since it is possible this function may be called
-	during the FrameHook's event callback, it is impossible to synchronously detach the
-	FrameHook from the channel during this function call.  It is guaranteed that the next
-	event proceeding the ast_framehook_detach() will be of type AST_FRAMEHOOK_EVENT_DETACH,
-	and that after that event occurs no other event will ever be issued for that FrameHook.
-	Once the FrameHook is destroyed, the destroy callback function will be called if it was
-	provided. Note that if this function is never called, the FrameHook will be detached
-	on channel destruction.
+    The ast_framehook_detach() function signals the FrameHook represented by an id to
+    be detached and destroyed on a channel.  Since it is possible this function may be called
+    during the FrameHook's event callback, it is impossible to synchronously detach the
+    FrameHook from the channel during this function call.  It is guaranteed that the next
+    event proceeding the ast_framehook_detach() will be of type AST_FRAMEHOOK_EVENT_DETACH,
+    and that after that event occurs no other event will ever be issued for that FrameHook.
+    Once the FrameHook is destroyed, the destroy callback function will be called if it was
+    provided. Note that if this function is never called, the FrameHook will be detached
+    on channel destruction.
 
 \section FrameHookAPICodeExample FrameHook Example Code
-	The example code below attaches an FrameHook on a channel, and then detachs it when
-	the first ast_frame is read or written to the event callback function.  The Framehook's id
-	is stored on the FrameHook's data pointer so it can be detached within the callback.
+    The example code below attaches an FrameHook on a channel, and then detachs it when
+    the first ast_frame is read or written to the event callback function.  The Framehook's id
+    is stored on the FrameHook's data pointer so it can be detached within the callback.
 
 \code
-	static void destroy_cb(void *data) {
-		ast_free(data);
-	}
-
-	static struct ast_frame *event_cb(struct ast_channel *chan,
-			struct ast_frame *frame,
-			enum ast_framehook_event event,
-			void *data) {
-
-		int *id = data;
-
-		if (!frame) {
-			return frame;
-		}
-
-		if (event == AST_FRAMEHOOK_EVENT_WRITE) {
-			ast_log(LOG_NOTICE, "YAY we received a frame in the write direction, Type: %d\n", frame->frametype)
-			ast_framehook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
-		} else if (event == AST_FRAMEHOOK_EVENT_READ) {
-			ast_log(LOG_NOTICE, "YAY we received a frame in the read direction: Type: %d\n", frame->frametype);
-			ast_framehook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
-		}
-
-		return frame;
-	{
-
-	int some_function()
-	{
-		struct ast_framehook_interface interface = {
-			.version = AST_FRAMEHOOK_INTERFACE_VERSION,
-			.event_cb = hook_event_cb,
-			.destroy_cb = hook_destroy_cb,
-		};
-		int *id = ast_calloc(1, sizeof(int));
-
-		if (!id) {
-			return -1;
-		}
-
-		interface.data = id; // This data will be returned to us in the callbacks.
-
-		ast_channel_lock(chan);
-		*id = ast_framehook_attach(chan, &interface);
-		ast_channel_unlock(chan);
-
-		if (*id < 0) {
-			// framehook attach failed, free data
-			ast_free(id);
-			return -1;
-		}
-		return 0;
-	}
+    static void destroy_cb(void *data) {
+	    ast_free(data);
+    }
+
+    static struct ast_frame *event_cb(struct ast_channel *chan,
+            struct ast_frame *frame,
+            enum ast_framehook_event event,
+            void *data) {
+
+        int *id = data;
+
+        if (!frame) {
+            return frame;
+        }
+
+        if (event == AST_FRAMEHOOK_EVENT_WRITE) {
+            ast_log(LOG_NOTICE, "YAY we received a frame in the write direction, Type: %d\n", frame->frametype)
+            ast_framehook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
+        } else if (event == AST_FRAMEHOOK_EVENT_READ) {
+            ast_log(LOG_NOTICE, "YAY we received a frame in the read direction: Type: %d\n", frame->frametype);
+            ast_framehook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
+        }
+
+        return frame;
+    {
+
+    int some_function()
+    {
+        struct ast_framehook_interface interface = {
+            .version = AST_FRAMEHOOK_INTERFACE_VERSION,
+            .event_cb = hook_event_cb,
+            .destroy_cb = hook_destroy_cb,
+        };
+        int *id = ast_calloc(1, sizeof(int));
+
+        if (!id) {
+            return -1;
+        }
+
+        interface.data = id; // This data will be returned to us in the callbacks.
+
+        ast_channel_lock(chan);
+        *id = ast_framehook_attach(chan, &interface);
+        ast_channel_unlock(chan);
+
+        if (*id < 0) {
+            // framehook attach failed, free data
+            ast_free(id);
+            return -1;
+        }
+        return 0;
+    }
 \endcode
 */
 
@@ -199,20 +199,7 @@
  */
 typedef void (*ast_framehook_destroy_callback)(void *data);
 
-/*!
- * \brief This callback is called to determine if the framehook is currently consuming
- * frames of a given type
- * \since 12
- *
- * \param data, The data pointer provided at framehook initilization.
- * \param type, The type of frame.
- *
- * \return 0 if frame type is being ignored
- * \return 1 if frame type is not being ignored
- */
-typedef int (*ast_framehook_consume_callback)(void *data, enum ast_frame_type type);
-
-#define AST_FRAMEHOOK_INTERFACE_VERSION 2
+#define AST_FRAMEHOOK_INTERFACE_VERSION 1
 /*! This interface is required for attaching a framehook to a channel. */
 struct ast_framehook_interface {
 	/*! framehook interface version number */
@@ -222,10 +209,6 @@
 	/*! destroy_cb is optional.  This function is called immediately before the framehook
 	 * is destroyed to allow for stored_data cleanup. */
 	ast_framehook_destroy_callback destroy_cb;
-	/*! consume_cb is optional. This function is called to query whether the framehook is consuming
-	* frames of a specific type at this time. If this callback is not implemented it is assumed that the
-	* framehook will consume frames of all types. */
-	ast_framehook_consume_callback consume_cb;
 	 /*! This pointer can represent any custom data to be stored on the !framehook. This
 	 * data pointer will be provided during each event callback which allows the framehook
 	 * to store any stateful data associated with the application using the hook. */
@@ -239,7 +222,7 @@
  * \param chan ast_channel The channel to attach the hook on to.
  * \param i framehook interface, The framehook's callback functions and stored data.
  *
- * \pre The Channel must be locked during this function call.
+ * \pre The Channel must be locked during this function all.
  *
  * \note The data pointer is never touched by the framehook API except to
  * provide it during the event and destruction callbacks.  It is entirely up to the
@@ -254,7 +237,7 @@
  * \brief Detach an framehook from a channel.
  * \since 1.8
  * 
- * \pre The Channel must be locked during this function call.
+ * \pre The Channel must be locked during this function all.
  * If this function is never called after attaching an framehook,
  * the framehook will be detached and destroyed during channel
  * destruction.
@@ -273,7 +256,7 @@
  * framehooks on a channel during channel destruction.
  * \since 1.8
  *
- * \pre The Channel must be locked during this function call.
+ * \pre The Channel must be locked during this function all.
  * 
  * \param chan channel containing the framehook list to destroy.
  * \retval 0 success
@@ -289,7 +272,7 @@
  * even NULL.  There is nothing to keep up with after this function. If the frame is modified, the
  * framehook callback is in charge of any memory management associated with that modification.
  *
- * \pre The Channel must be locked during this function call.
+ * \pre The Channel must be locked during this function all.
  *
  * \param framehooks list to push event to.
  * \param frame being pushed to the framehook list.
@@ -306,7 +289,7 @@
  * even NULL.  There is nothing to keep up with after this function. If the frame is modified, the
  * framehook callback is in charge of any memory management associated with that modification.
  *
- * \pre The Channel must be locked during this function call.
+ * \pre The Channel must be locked during this function all.
  *
  * \param framehooks list to push event to.
  * \param frame being pushed to the framehook list.
@@ -318,7 +301,7 @@
 /*!
  * \brief Determine if an framehook list is empty or not
  * \since 1.8
- * \pre The Channel must be locked during this function call.
+ * \pre The Channel must be locked during this function all.
  *
  * \param framehooks the framehook list
  * \retval 0, not empty
@@ -329,7 +312,7 @@
 /*!
  * \brief Determine if a framehook list is free of active framehooks or not
  * \since 12.0.0
- * \pre The channel must be locked during this function call.
+ * \pre The channel must be locked during this function all.
  *
  * \param framehooks the framehook list
  * \retval 0, not empty
@@ -340,19 +323,4 @@
  */
 int ast_framehook_list_contains_no_active(struct ast_framehook_list *framehooks);
 
-/*!
- * \brief Determine if a framehook list is free of active framehooks consuming a specific type of frame
- * \since 12.3.0
- * \pre The channel must be locked during this function call.
- *
- * \param framehooks the framehook list
- * \retval 0, not empty
- * \retval 1, is empty (aside from dying framehooks)
- *
- * \note This function is very similar to ast_framehook_list_is_empty, but it checks individual
- *       framehooks to see if they have been marked for destruction and doesn't count them if they are.
- */
-int ast_framehook_list_contains_no_active_of_type(struct ast_framehook_list *framehooks,
-	enum ast_frame_type type);
-
 #endif /* _AST_FRAMEHOOK_H */

Modified: branches/12/main/bridge_basic.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/bridge_basic.c?view=diff&rev=413667&r1=413666&r2=413667
==============================================================================
--- branches/12/main/bridge_basic.c (original)
+++ branches/12/main/bridge_basic.c Sat May 10 20:07:44 2014
@@ -2614,12 +2614,6 @@
 	return frame;
 }
 
-/*! \brief Callback function which informs upstream if we are consuming a frame of a specific type */
-static int transfer_target_framehook_consume(void *data, enum ast_frame_type type)
-{
-	return (type == AST_FRAME_CONTROL ? 1 : 0);
-}
-
 static void transfer_target_framehook_destroy_cb(void *data)
 {
 	struct attended_transfer_properties *props = data;
@@ -2853,7 +2847,6 @@
 		.version = AST_FRAMEHOOK_INTERFACE_VERSION,
 		.event_cb = transfer_target_framehook_cb,
 		.destroy_cb = transfer_target_framehook_destroy_cb,
-		.consume_cb = transfer_target_framehook_consume,
 	};
 
 	ao2_ref(props, +1);

Modified: branches/12/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/channel.c?view=diff&rev=413667&r1=413666&r2=413667
==============================================================================
--- branches/12/main/channel.c (original)
+++ branches/12/main/channel.c Sat May 10 20:07:44 2014
@@ -2666,13 +2666,6 @@
 	return ast_channel_monitor(chan)
 		|| !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))
 		|| !ast_framehook_list_contains_no_active(ast_channel_framehooks(chan));
-}
-
-int ast_channel_has_hook_requiring_audio(struct ast_channel *chan)
-{
-	return ast_channel_monitor(chan)
-		|| !ast_audiohook_write_list_empty(ast_channel_audiohooks(chan))
-		|| !ast_framehook_list_contains_no_active_of_type(ast_channel_framehooks(chan), AST_FRAME_VOICE);
 }
 
 static void destroy_hooks(struct ast_channel *chan)

Modified: branches/12/main/framehook.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/framehook.c?view=diff&rev=413667&r1=413666&r2=413667
==============================================================================
--- branches/12/main/framehook.c (original)
+++ branches/12/main/framehook.c Sat May 10 20:07:44 2014
@@ -160,10 +160,6 @@
 		ast_frfree(frame);
 	}
 
-	if (ast_channel_is_bridged(chan)) {
-		ast_softhangup_nolock(chan, AST_SOFTHANGUP_UNBRIDGE);
-	}
-
 	return framehook->id;
 }
 
@@ -189,10 +185,6 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 
-	if (!res && ast_channel_is_bridged(chan)) {
-		ast_softhangup_nolock(chan, AST_SOFTHANGUP_UNBRIDGE);
-	}
-
 	return res;
 }
 
@@ -223,12 +215,6 @@
 
 int ast_framehook_list_contains_no_active(struct ast_framehook_list *framehooks)
 {
-	return ast_framehook_list_contains_no_active_of_type(framehooks, 0);
-}
-
-int ast_framehook_list_contains_no_active_of_type(struct ast_framehook_list *framehooks,
-	enum ast_frame_type type)
-{
 	struct ast_framehook *cur;
 
 	if (!framehooks) {
@@ -243,9 +229,6 @@
 		if (cur->detach_and_destroy_me) {
 			continue;
 		}
-		if (type && cur->i.consume_cb && !cur->i.consume_cb(cur->i.data, type)) {
-			continue;
-		}
 		return 0;
 	}
 




More information about the svn-commits mailing list