[asterisk-commits] file: trunk r39500 - in /trunk:
channels/chan_sip.c devicestate.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Aug 9 19:41:20 MST 2006
Author: file
Date: Wed Aug 9 21:41:20 2006
New Revision: 39500
URL: http://svn.digium.com/view/asterisk?rev=39500&view=rev
Log:
Add support to see if a peer has someone on hold, and fix a small bug with getting the state name. This one goes out to you mog!
Modified:
trunk/channels/chan_sip.c
trunk/devicestate.c
Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=39500&r1=39499&r2=39500&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Aug 9 21:41:20 2006
@@ -1031,6 +1031,7 @@
int callingpres; /*!< Calling id presentation */
int inUse; /*!< Number of calls in use */
int inRinging; /*!< Number of calls ringing */
+ int onHold; /*!< Peer has someone on hold */
int call_limit; /*!< Limit of concurrent calls */
enum transfermodes allowtransfer; /*! SIP Refer restriction scheme */
char vmexten[AST_MAX_EXTENSION]; /*!< Dialplan extension for MWI notify message*/
@@ -1282,7 +1283,7 @@
static int sip_poke_noanswer(void *data);
static int sip_poke_peer(struct sip_peer *peer);
static void sip_poke_all_peers(void);
-
+static void sip_peer_hold(struct sip_pvt *p, int hold);
/*--- Applications, functions, CLI and manager command helpers */
static const char *sip_nat_mode(const struct sip_pvt *p);
@@ -4916,29 +4917,33 @@
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
-
- if ((bridgepeer = ast_bridged_channel(p->owner))) {
- /* We have a bridge */
- /* Turn on/off music on hold if we are holding/unholding */
- if (sin.sin_addr.s_addr && !sendonly) {
+
+ bridgepeer = ast_bridged_channel(p->owner);
+
+ /* Turn on/off music on hold if we are holding/unholding */
+ if (sin.sin_addr.s_addr && !sendonly) {
+ /* Update peer state */
+ sip_peer_hold(p, 0);
+ if (bridgepeer)
ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
- /* Activate a re-invite */
- ast_queue_frame(p->owner, &ast_null_frame);
- } else if (!sin.sin_addr.s_addr || sendonly) {
- /* No address for RTP, we're on hold */
+ /* Activate a re-invite */
+ ast_queue_frame(p->owner, &ast_null_frame);
+ } else if (!sin.sin_addr.s_addr || sendonly) {
+ /* Update peer state */
+ sip_peer_hold(p, 1);
+ /* No address for RTP, we're on hold */
+ if (bridgepeer)
ast_queue_control_data(p->owner, AST_CONTROL_HOLD,
- S_OR(p->mohsuggest, NULL),
- !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
-
- if (sendonly)
- ast_rtp_stop(p->rtp);
- /* RTCP needs to go ahead, even if we're on hold!!! */
-
- /* Activate a re-invite */
- ast_queue_frame(p->owner, &ast_null_frame);
- }
- /* guess we got a re-invite for changing media or IP - not hold/unhold */
+ S_OR(p->mohsuggest, NULL),
+ !ast_strlen_zero(p->mohsuggest) ? strlen(p->mohsuggest) + 1 : 0);
+
+ if (sendonly)
+ ast_rtp_stop(p->rtp);
+ /* RTCP needs to go ahead, even if we're on hold!!! */
+
+ /* Activate a re-invite */
+ ast_queue_frame(p->owner, &ast_null_frame);
}
/* Manager Hold and Unhold events must be generated, if necessary */
@@ -6534,6 +6539,8 @@
pidfstate = "away";
pidfnote = "Unavailable";
break;
+ case AST_EXTENSION_ONHOLD:
+ break;
case AST_EXTENSION_NOT_INUSE:
default:
/* Default setting */
@@ -7775,6 +7782,26 @@
sip_scheddestroy(p, SIP_TRANS_TIMEOUT);
return AUTH_CHALLENGE_SENT;
+}
+
+/*! \brief Change onhold state of a peer using a pvt structure */
+static void sip_peer_hold(struct sip_pvt *p, int hold)
+{
+ struct sip_peer *peer = find_peer(p->peername, NULL, 1);
+
+ if (!peer)
+ return;
+
+ /* If they put someone on hold, increment the value... otherwise decrement it */
+ if (hold)
+ peer->onHold++;
+ else
+ peer->onHold--;
+
+ /* Request device state update */
+ ast_device_state_changed("SIP/%s", peer->name);
+
+ return;
}
/*! \brief Callback for the devicestate notification (SUBSCRIBE) support subsystem
@@ -14578,7 +14605,9 @@
res = AST_DEVICE_INUSE;
else
res = AST_DEVICE_NOT_INUSE;
- if (p->inRinging) {
+ if (p->onHold)
+ res = AST_DEVICE_ONHOLD;
+ else if (p->inRinging) {
if (p->inRinging == p->inUse)
res = AST_DEVICE_RINGING;
else
Modified: trunk/devicestate.c
URL: http://svn.digium.com/view/asterisk/trunk/devicestate.c?rev=39500&r1=39499&r2=39500&view=diff
==============================================================================
--- trunk/devicestate.c (original)
+++ trunk/devicestate.c Wed Aug 9 21:41:20 2006
@@ -51,8 +51,8 @@
/* 3 AST_DEVICE_BUSY */ "Busy", /*!< Busy */
/* 4 AST_DEVICE_INVALID */ "Invalid", /*!< Invalid - not known to Asterisk */
/* 5 AST_DEVICE_UNAVAILABLE */ "Unavailable", /*!< Unavailable (not registred) */
- /* 6 AST_DEVICE_RINGING */ "Ringing" /*!< Ring, ring, ring */
- /* 7 AST_DEVICE_RINGINUSE */ "Ring+Inuse" /*!< Ring and in use */
+ /* 6 AST_DEVICE_RINGING */ "Ringing", /*!< Ring, ring, ring */
+ /* 7 AST_DEVICE_RINGINUSE */ "Ring+Inuse", /*!< Ring and in use */
/* 8 AST_DEVICE_ONHOLD */ "On Hold" /*!< On Hold */
};
More information about the asterisk-commits
mailing list