[asterisk-commits] oej: branch group/rana-moh-sip-transfer-1.8 r390009 - in /team/group/rana-moh...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 29 04:39:05 CDT 2013


Author: oej
Date: Wed May 29 04:38:54 2013
New Revision: 390009

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390009
Log:
First stab at a core API extension for hold states

Modified:
    team/group/rana-moh-sip-transfer-1.8/include/asterisk/channel.h
    team/group/rana-moh-sip-transfer-1.8/main/channel.c

Modified: team/group/rana-moh-sip-transfer-1.8/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/include/asterisk/channel.h?view=diff&rev=390009&r1=390008&r2=390009
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/include/asterisk/channel.h (original)
+++ team/group/rana-moh-sip-transfer-1.8/include/asterisk/channel.h Wed May 29 04:38:54 2013
@@ -489,6 +489,18 @@
 	char *data;
 	const char *value;
 } ast_chan_write_info_t;
+
+/*! \brief Enum for hold states */
+enum ast_hold_state {
+	AST_MEDIA_LOCAL_HOLD = (1 << 0),		/* The device owning this channel put it on hold/mute */
+	AST_MEDIA_REMOTE_HOLD = (1 << 1),		/* The bridged device put this channel on hold, typically playing music */
+};
+
+/*! \brief Structure for hold states */
+struct media_hold_state {
+	char musicclass[128];
+	enum ast_hold_state state;
+};
 
 /*!
  * \brief
@@ -812,6 +824,8 @@
 
 	/*! \brief Redirecting/Diversion information */
 	struct ast_party_redirecting redirecting;
+
+	struct media_hold_state hold_state;		/*!< Hold state for this channel */
 
 	struct ast_frame dtmff;				/*!< DTMF frame */
 	struct varshead varshead;			/*!< A linked list for channel variables. See \ref AstChanVar */
@@ -3518,6 +3532,29 @@
  * \param size The size of the buffer to write to
  */
 int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
+
+/* \brief Set musicclass used if this channel puts another channel on hold */
+int ast_channel_set_musicclass(struct ast_channel *chan, const char *musicclass);
+
+/* \brief Set local hold - the device connected to the line to Asterisk puts a call on hold, i.e. mutes the audio stream */
+int ast_channel_set_local_hold(struct ast_channel *chan, int hold);
+
+/* \brief Set remote hold - the device on the other side of the bridge puts this channel on hold */
+int ast_channel_set_remote_hold(struct ast_channel *chan, int hold);
+
+/* \brief Get local hold state from channel 
+
+Has the device on the other end of this channel put the call on hold?
+*/
+int ast_channel_get_local_hold_state(struct ast_channel *chan);
+
+/* \brief Get remote hold state from channel
+
+Has this channel been put on hold by another channel?
+*/
+int ast_channel_get_remote_hold_state(struct ast_channel *chan);
+
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/group/rana-moh-sip-transfer-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/rana-moh-sip-transfer-1.8/main/channel.c?view=diff&rev=390009&r1=390008&r2=390009
==============================================================================
--- team/group/rana-moh-sip-transfer-1.8/main/channel.c (original)
+++ team/group/rana-moh-sip-transfer-1.8/main/channel.c Wed May 29 04:38:54 2013
@@ -9732,6 +9732,61 @@
 	return 0;
 }
 
+
+int ast_channel_set_musicclass(struct ast_channel *chan, const char *musicclass)
+{
+	if (!chan || musicclass == NULL) {
+		return -1;
+	}
+
+	ast_copy_string(chan->hold_state.musicclass, musicclass, sizeof(chan->hold_state.musicclass));
+	return 0;
+}
+
+int ast_channel_set_local_hold(struct ast_channel *chan, int hold)
+{
+	if (!chan) {
+		return -1;
+	}
+	if (hold) {
+		chan->hold_state.state &= AST_MEDIA_LOCAL_HOLD;
+	} else {
+		chan->hold_state.state |= AST_MEDIA_LOCAL_HOLD;	/* ?? */
+	}
+	return 0;
+}
+
+int ast_channel_set_remote_hold(struct ast_channel *chan, int hold)
+{
+	if (!chan) {
+		return -1;
+	}
+	if (hold) {
+		chan->hold_state.state &= AST_MEDIA_REMOTE_HOLD;
+	} else {
+		chan->hold_state.state |= AST_MEDIA_REMOTE_HOLD;	/* ?? */
+	}
+	return 0;
+}
+
+int ast_channel_get_local_hold_state(struct ast_channel *chan)
+{
+	if (!chan) {
+		return -1;
+	}
+	return ((int) chan->hold_state.state & AST_MEDIA_LOCAL_HOLD);
+}
+
+int ast_channel_get_remote_hold_state(struct ast_channel *chan)
+{
+	if (!chan) {
+		return -1;
+	}
+	return ((int) chan->hold_state.state & AST_MEDIA_REMOTE_HOLD);
+}
+
+
+
 /* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
  *
  * ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE




More information about the asterisk-commits mailing list