[asterisk-commits] irroot: branch irroot/distrotech-customers-1.8 r324910 - in /team/irroot/dist...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jun 25 12:44:31 CDT 2011


Author: irroot
Date: Sat Jun 25 12:44:22 2011
New Revision: 324910

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=324910
Log:
Changes To the MWI Lastmsgcnt problem to bring it inline with RB: 1272
Move the codec fixup from chan_sip.c to main/channel.c if the frame is a native format set the writeformat this is a problem in chan_dahdi too 

Modified:
    team/irroot/distrotech-customers-1.8/channels/chan_sip.c
    team/irroot/distrotech-customers-1.8/main/channel.c

Modified: team/irroot/distrotech-customers-1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/channels/chan_sip.c?view=diff&rev=324910&r1=324909&r2=324910
==============================================================================
--- team/irroot/distrotech-customers-1.8/channels/chan_sip.c (original)
+++ team/irroot/distrotech-customers-1.8/channels/chan_sip.c Sat Jun 25 12:44:22 2011
@@ -4908,9 +4908,6 @@
 					unref_peer(p, "Wrong type of realtime SIP endpoint");
 					return NULL;
 				}
-				if (!ast_test_flag(&p->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY)) {
-					sip_send_mwi_to_peer(p, NULL, 0);
-				}
 				break;
 			case FINDALLDEVICES:
 				break;
@@ -6328,20 +6325,12 @@
 	switch (frame->frametype) {
 	case AST_FRAME_VOICE:
 		if (!(frame->subclass.codec & ast->nativeformats)) {
-			struct ast_channel *bridge;
 			char s1[512], s2[512], s3[512];
 			ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
 				ast_getformatname(frame->subclass.codec),
 				ast_getformatname_multiple(s1, sizeof(s1), ast->nativeformats & AST_FORMAT_AUDIO_MASK),
 				ast_getformatname_multiple(s2, sizeof(s2), ast->readformat),
 				ast_getformatname_multiple(s3, sizeof(s3), ast->writeformat));
-			ast_set_write_format(ast, frame->subclass.codec);
-			bridge = ast_bridged_channel(ast);
-			if (bridge && !ast_channel_trylock(bridge)) {
-				ast_log(LOG_WARNING, "Attempting to change formats making %s and %s compat.\n", ast->name, bridge->name);
-				ast_channel_make_compatible(ast, bridge);
-				ast_channel_unlock(bridge);
-			}
 			return 0;
 		}
 		if (p) {
@@ -14326,24 +14315,21 @@
 				} else {
 
 					/* We have a successful registration attempt with proper authentication,
-				   	now, update the peer */
+					now, update the peer */
 					switch (parse_register_contact(p, peer, req)) {
 					case PARSE_REGISTER_DENIED:
 						ast_log(LOG_WARNING, "Registration denied because of contact ACL\n");
 						transmit_response_with_date(p, "603 Denied", req);
-						peer->lastmsgssent = -1;
 						res = 0;
 						break;
 					case PARSE_REGISTER_FAILED:
 						ast_log(LOG_WARNING, "Failed to parse contact info\n");
 						transmit_response_with_date(p, "400 Bad Request", req);
-						peer->lastmsgssent = -1;
 						res = 0;
 						break;
 					case PARSE_REGISTER_QUERY:
 						ast_string_field_set(p, fullcontact, peer->fullcontact);
 						transmit_response_with_date(p, "200 OK", req);
-						peer->lastmsgssent = -1;
 						res = 0;
 						break;
 					case PARSE_REGISTER_UPDATE:
@@ -14351,8 +14337,6 @@
 						update_peer(peer, p->expiry);
 						/* Say OK and ask subsystem to retransmit msg counter */
 						transmit_response_with_date(p, "200 OK", req);
-						if (!ast_test_flag((&peer->flags[1]), SIP_PAGE2_SUBSCRIBEMWIONLY))
-							peer->lastmsgssent = -1;
 						res = 0;
 						break;
 					}
@@ -14377,19 +14361,16 @@
 			case PARSE_REGISTER_DENIED:
 				ast_log(LOG_WARNING, "Registration denied because of contact ACL\n");
 				transmit_response_with_date(p, "403 Forbidden (ACL)", req);
-				peer->lastmsgssent = -1;
 				res = 0;
 				break;
 			case PARSE_REGISTER_FAILED:
 				ast_log(LOG_WARNING, "Failed to parse contact info\n");
 				transmit_response_with_date(p, "400 Bad Request", req);
-				peer->lastmsgssent = -1;
 				res = 0;
 				break;
 			case PARSE_REGISTER_QUERY:
 				ast_string_field_set(p, fullcontact, peer->fullcontact);
 				transmit_response_with_date(p, "200 OK", req);
-				peer->lastmsgssent = -1;
 				res = 0;
 				break;
 			case PARSE_REGISTER_UPDATE:
@@ -14397,7 +14378,6 @@
 				/* Say OK and ask subsystem to retransmit msg counter */
 				transmit_response_with_date(p, "200 OK", req);
 				manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "ChannelType: SIP\r\nPeer: SIP/%s\r\nPeerStatus: Registered\r\nAddress: %s\r\n", peer->name, ast_sockaddr_stringify(addr));
-				peer->lastmsgssent = -1;
 				res = 0;
 				break;
 			}
@@ -14413,10 +14393,10 @@
 		sched_yield();
 	}
 	if (!res) {
+		if (!sip_send_mwi_to_peer(peer, NULL, 0)) {
+			peer->lastmsgssent = -1;
+		}
 		ast_devstate_changed(AST_DEVICE_UNKNOWN, "SIP/%s", peer->name);
-		if (!ast_test_flag(&peer->flags[1], SIP_PAGE2_SUBSCRIBEMWIONLY)) {
-			sip_send_mwi_to_peer(peer, NULL, 0);
-		}
 	}
 	if (res < 0) {
 		switch (res) {
@@ -24872,9 +24852,14 @@
 	struct sip_pvt *p;
 	int newmsgs = 0, oldmsgs = 0;
 
+	if (ast_test_flag((&peer->flags[1]), SIP_PAGE2_SUBSCRIBEMWIONLY) && !peer->mwipvt) {
+		return -1;
+	}
+
 	/* Do we have an IP address? If not, skip this peer */
-	if (ast_sockaddr_isnull(&peer->addr) && ast_sockaddr_isnull(&peer->defaddr))
-		return 0;
+	if (ast_sockaddr_isnull(&peer->addr) && ast_sockaddr_isnull(&peer->defaddr)) {
+		return -1;
+	}
 
 	if (event) {
 		newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
@@ -24882,11 +24867,15 @@
 	} else if (!cache_only) { /* Fall back to manually checking the mailbox */
 		struct ast_str *mailbox_str = ast_str_alloca(512);
 		peer_mailboxes_to_str(&mailbox_str, peer);
+		/* if there is no mailbox do nothing */
+		if (ast_strlen_zero(mailbox_str->str)) {
+			return -1;
+		}
 		ast_app_inboxcount(mailbox_str->str, &newmsgs, &oldmsgs);
 	} else {
 		get_cached_mwi(peer, &newmsgs, &oldmsgs);
 	}
-	
+
 	if (peer->mwipvt) {
 		/* Base message on subscription */
 		p = dialog_ref(peer->mwipvt, "sip_send_mwi_to_peer: Setting dialog ptr p from peer->mwipvt-- should this be done?");
@@ -24904,7 +24893,7 @@
 			dialog_unlink_all(p, TRUE, TRUE);
 			dialog_unref(p, "unref dialog p just created via sip_alloc");
 			/* sip_destroy(p); */
-			return 0;
+			return -1;
 		}
 		/* Recalculate our side, and recalculate Call ID */
 		ast_sip_ouraddrfor(&p->sa, &p->ourip, p);

Modified: team/irroot/distrotech-customers-1.8/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/irroot/distrotech-customers-1.8/main/channel.c?view=diff&rev=324910&r1=324909&r2=324910
==============================================================================
--- team/irroot/distrotech-customers-1.8/main/channel.c (original)
+++ team/irroot/distrotech-customers-1.8/main/channel.c Sat Jun 25 12:44:22 2011
@@ -4878,6 +4878,10 @@
 			apply_plc(chan, fr);
 		}
 
+		if (!(fr->subclass.codec & chan->nativeformats)) {
+			ast_set_write_format(chan, fr->subclass.codec);
+		}
+
 		/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
 		if (fr->subclass.codec == chan->rawwriteformat)
 			f = fr;




More information about the asterisk-commits mailing list