[asterisk-commits] wedhorn: branch wedhorn/skinny-subs r190945 - /team/wedhorn/skinny-subs/chann...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 28 16:44:39 CDT 2009


Author: wedhorn
Date: Tue Apr 28 16:44:35 2009
New Revision: 190945

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=190945
Log:
Fixed some display issues on old phones, fixed autohangup, cleaned up start/stop rtp. Rename SKINNY_SPEAKERXXX to SKINNY_SPEAKER_XXX

Modified:
    team/wedhorn/skinny-subs/channels/chan_skinny.c

Modified: team/wedhorn/skinny-subs/channels/chan_skinny.c
URL: http://svn.digium.com/svn-view/asterisk/team/wedhorn/skinny-subs/channels/chan_skinny.c?view=diff&rev=190945&r1=190944&r2=190945
==============================================================================
--- team/wedhorn/skinny-subs/channels/chan_skinny.c (original)
+++ team/wedhorn/skinny-subs/channels/chan_skinny.c Tue Apr 28 16:44:35 2009
@@ -1051,8 +1051,8 @@
 #define SKINNY_DEVICE_SCCPGATEWAY_AN 30027 /* Analog gateway */
 #define SKINNY_DEVICE_SCCPGATEWAY_BRI 30028 /* BRI gateway */
 
-#define SKINNY_SPEAKERON 1
-#define SKINNY_SPEAKEROFF 2
+#define SKINNY_SPEAKER_ON 1
+#define SKINNY_SPEAKER_OFF 2
 
 #define SKINNY_MICON 1
 #define SKINNY_MICOFF 2
@@ -1966,9 +1966,9 @@
 	char *tmp;
 
 	switch (ind) {
-	case SKINNY_SPEAKERON:
+	case SKINNY_SPEAKER_ON:
 		return "SPEAKERON";
-	case SKINNY_SPEAKEROFF:
+	case SKINNY_SPEAKER_OFF:
 		return "SPEAKEROFF";
 	default:
 		if (!(tmp = ast_threadstorage_get(&speakermode2str_threadbuf, SPEAKERMODE2STR_BUFSIZE)))
@@ -2876,7 +2876,7 @@
 		SKINNY_DEBUG(DEBUG_DEVICE, ast_verb(4, "Transmitting STOP_MEDIA_TRANSMISSION() to %s (%p)\n", d->name, (void *)pthread_self()))
 		transmit_response(d, req);
 
-		transmit_speaker_mode(d, SKINNY_SPEAKEROFF);
+		transmit_speaker_mode(d, SKINNY_SPEAKER_OFF);
 
 		transmit_displaypromptstatus(d, NULL, 0, instance, callid);
 	}
@@ -4474,6 +4474,14 @@
 /* -------------------------------------------------------------------------------------------------------------------------------------------------------------- 
  *	RTP Functions
  * -------------------------------------------------------------------------------------------------------------------------------------------------------------- */
+static void stop_rtp(struct skinny_subchannel *sub)
+{
+	struct skinny_device *d;
+	if (sub && sub->rtp && sub->parent && (d = sub->parent->device)) {
+		transmit_closereceivechannel(d, sub);
+		transmit_stopmediatransmission(d, sub);
+	}
+}
 
 static void start_rtp(struct skinny_subchannel *sub)
 {
@@ -4481,37 +4489,39 @@
 	struct skinny_device *d = l->device;
 	int hasvideo = 0;
 
-	/* Allocate the RTP */
-	sub->rtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
-	if (hasvideo)
-		sub->vrtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
-
-	if (sub->rtp) {
-		ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
-	}
-	if (sub->vrtp) {
-		ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_RTCP, 1);
-	}
-
-	if (sub->rtp && sub->owner) {
-		ast_channel_set_fd(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
-		ast_channel_set_fd(sub->owner, 1, ast_rtp_instance_fd(sub->rtp, 1));
-	}
-	if (hasvideo && sub->vrtp && sub->owner) {
-		ast_channel_set_fd(sub->owner, 2, ast_rtp_instance_fd(sub->vrtp, 0));
-		ast_channel_set_fd(sub->owner, 3, ast_rtp_instance_fd(sub->vrtp, 1));
-	}
-	if (sub->rtp) {
-		ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
-		ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, l->nat);
-	}
-	if (sub->vrtp) {
-		ast_rtp_instance_set_qos(sub->vrtp, qos.tos_video, qos.cos_video, "Skinny VRTP");
-		ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_NAT, l->nat);
-	}
-	/* Set Frame packetization */
-	if (sub->rtp)
-		ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp, &l->prefs);
+	if (!sub->rtp) {
+		/* Allocate the RTP */
+		sub->rtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
+		if (hasvideo)
+			sub->vrtp = ast_rtp_instance_new(NULL, sched, &bindaddr, NULL);
+
+		if (sub->rtp) {
+			ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
+		}
+		if (sub->vrtp) {
+			ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_RTCP, 1);
+		}
+
+		if (sub->rtp && sub->owner) {
+			ast_channel_set_fd(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
+			ast_channel_set_fd(sub->owner, 1, ast_rtp_instance_fd(sub->rtp, 1));
+		}
+		if (hasvideo && sub->vrtp && sub->owner) {
+			ast_channel_set_fd(sub->owner, 2, ast_rtp_instance_fd(sub->vrtp, 0));
+			ast_channel_set_fd(sub->owner, 3, ast_rtp_instance_fd(sub->vrtp, 1));
+		}
+		if (sub->rtp) {
+			ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
+			ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, l->nat);
+		}
+		if (sub->vrtp) {
+			ast_rtp_instance_set_qos(sub->vrtp, qos.tos_video, qos.cos_video, "Skinny VRTP");
+			ast_rtp_instance_set_prop(sub->vrtp, AST_RTP_PROPERTY_NAT, l->nat);
+		}
+		/* Set Frame packetization */
+		if (sub->rtp)
+			ast_rtp_codecs_packetization_set(ast_rtp_instance_get_codecs(sub->rtp), sub->rtp, &l->prefs);
+	}
 
 	/* Create the RTP connection */
 	transmit_connect(d, sub);
@@ -4953,6 +4963,8 @@
 		if (sub == d->activesub && d->hookstate == SKINNY_OFFHOOK) {
 			transmit_displaymessageold(d, sub->oldcallingname, substate2str(sub->substate));
 			//transmit_displaymessageold(d, sub->oldcallingname, substate2str(sub->substate));
+		} else if (d->hookstate == SKINNY_ONHOOK) {
+			transmit_definttimedate_message(d);
 		}
 		//if (!d->activesub) {
 		//	transmit_definttimedate_message(d);
@@ -5441,7 +5453,7 @@
 		transmit_ringer_mode(d, SKINNY_RING_OFF);
 	}
 	d->hookstate = SKINNY_OFFHOOK;
-	transmit_speaker_mode(d, SKINNY_SPEAKERON);
+	transmit_speaker_mode(d, SKINNY_SPEAKER_ON);
 	sub->substate = SUBSTATE_AUTOANS;
 	set_sub_state(sub, SUBSTATE_CONNECTED);
 	if (sub->autoans_tone) {
@@ -5579,10 +5591,7 @@
 		} else {
 			sub->substate = SUBSTATE_ENDCALL;
 			transmit_activatecallplane(d, l);
-			if (sub->rtp) {  //stop_rtp???
-				transmit_closereceivechannel(d, sub);
-				transmit_stopmediatransmission(d, sub);
-			}
+			stop_rtp(sub);
 			sub->devstate = SKINNY_ONHOOK;
 			skinny_end_thread(sub);
 			if (ast_pthread_create(&sub->thread, NULL, skinny_thread_endcall, sub)) {
@@ -5599,13 +5608,10 @@
 		if (sub != d->activesub) {
 			set_sub_state(sub, SUBSTATE_ONHOOK);
 		} else if (d->autohangup || sub->autohangup) {
-			transmit_speaker_mode(d, SKINNY_SPEAKEROFF);
+			transmit_speaker_mode(d, SKINNY_SPEAKER_OFF);
 		} else {
 			transmit_activatecallplane(d, l);
-			if (sub->rtp) {  //stop_rtp???
-				transmit_closereceivechannel(d, sub);
-				transmit_stopmediatransmission(d, sub);
-			}
+			stop_rtp(sub);
 			sub->devstate = SKINNY_ONHOOK;
 			skinny_end_thread(sub);
 			if (ast_pthread_create(&sub->thread, NULL, skinny_thread_endcall, sub)) {
@@ -5633,11 +5639,9 @@
 		break;
 	case SUBSTATE_ONHOOK:			/* Destroy sub */
 		if (sub == d->activesub) {
-			if (sub->rtp) {  //stop_rtp???
-				transmit_closereceivechannel(d, sub);
-				transmit_stopmediatransmission(d, sub);
-			}
+			stop_rtp(sub);
 			transmit_ringer_mode(d, SKINNY_RING_OFF);
+			transmit_speaker_mode(d, SKINNY_SPEAKER_OFF);
 			d->hookstate = SKINNY_ONHOOK;
 			transmit_tone(d, SKINNY_SILENCE, l->instance, sub->callid);
 			d->activesub = NULL;
@@ -5651,7 +5655,6 @@
 		}
 		sub->substate = SUBSTATE_ONHOOK;
 		sub->devstate = SKINNY_ONHOOK;
-
 		sub->alreadygone = 1;
 
 		sub->cxmode = SKINNY_CX_RECVONLY;
@@ -5659,7 +5662,7 @@
 		//	l->startfortraverse = NULL;
 		//}
 
-		//set_call_info(sub);
+		set_call_info(sub);
 		destroy_sub(sub);
 		sub = NULL;
 //		set_line_lamp(l);
@@ -5817,8 +5820,7 @@
 		ast_queue_control_data(sub->owner, AST_CONTROL_HOLD,
 			S_OR(l->mohsuggest, NULL),
 			!ast_strlen_zero(l->mohsuggest) ? strlen(l->mohsuggest) + 1 : 0);
-		transmit_closereceivechannel(d, sub);
-		transmit_stopmediatransmission(d, sub);
+		stop_rtp(sub);
 		sub->onhold = 1;
 		break;
 	case SUBSTATE_TRANSFER:			/* This sub is waiting to be transferred */
@@ -5887,7 +5889,7 @@
 		l->getforward ^= cfwd;
 	}
 	if (d->hookstate == SKINNY_ONHOOK) {
-		transmit_speaker_mode(d, SKINNY_SPEAKERON);
+		transmit_speaker_mode(d, SKINNY_SPEAKER_ON);
 		d->hookstate = SKINNY_OFFHOOK;
 	}
 	if (ast_strlen_zero(exten)) {
@@ -6246,7 +6248,7 @@
 				d->activeline = l;
 				d->activesub = l->activesub;
 			}
-			transmit_speaker_mode(d, SKINNY_SPEAKERON);
+			transmit_speaker_mode(d, SKINNY_SPEAKER_ON);
 		} else {
 			if (l == d->activeline) {
 				next_active_sub(l);
@@ -6980,6 +6982,7 @@
 		SIMPLE_LOCK_SUB;
 		d = sub->parent->device;
 		SIMPLE_LOCK_DEVICE;
+		stop_rtp(sub);
 		detach_channel(sub);
 		set_sub_state(sub, SUBSTATE_ENDCALL);
 		SIMPLE_UNLOCK_DEVICE;




More information about the asterisk-commits mailing list