[Freeswitch-branches] [commit] r3645 - in freeswitch/branches/knhor/trunk: . src src/mod/endpoints/mod_sofia src/mod/languages/mod_spidermonkey

Freeswitch SVN knhor at freeswitch.org
Wed Dec 13 21:30:40 EST 2006


Author: knhor
Date: Wed Dec 13 21:30:39 2006
New Revision: 3645

Modified:
   freeswitch/branches/knhor/trunk/   (props changed)
   freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
   freeswitch/branches/knhor/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/branches/knhor/trunk/src/switch_rtp.c

Log:
Merged revisions 3640-3642 via svnmerge from trunk


Modified: freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/branches/knhor/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Wed Dec 13 21:30:39 2006
@@ -1468,6 +1468,9 @@
 		if ((vad_in && inb) || (vad_out && !inb)) {
 			switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
 			switch_set_flag_locked(tech_pvt, TFLAG_VAD);
+            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "RTP Engage VAD for %s ( %s %s )\n", 
+                              switch_channel_get_name(switch_core_session_get_channel(tech_pvt->session)),
+                              vad_in ? "in" : "", vad_out ? "out" : "");
 		}
 	} else {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP REPORTS ERROR: [%s]\n", err);
@@ -4367,7 +4370,7 @@
 		}
 	}
 
-	if (status == 401 || status == 407) {
+	if (sip && (status == 401 || status == 407)) {
 		sip_r_challenge(status, phrase, nua, profile, nh, sofia_private, sip, tags);
 		goto done;
 	}

Modified: freeswitch/branches/knhor/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	(original)
+++ freeswitch/branches/knhor/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c	Wed Dec 13 21:30:39 2006
@@ -793,13 +793,19 @@
 static JSBool session_flush_digits(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
-	switch_channel_t *channel;
 	char buf[256];
 	switch_size_t has;
+	switch_channel_t *channel;
 
 	channel = switch_core_session_get_channel(jss->session);
     assert(channel != NULL);
 
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	if ((has = switch_channel_has_dtmf(channel))) {
 		switch_channel_dequeue_dtmf(channel, buf, has);
 	}
@@ -812,7 +818,17 @@
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_event_t *event;
+    switch_channel_t *channel;
 
+    channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	while (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
 		switch_event_destroy(&event);
 	}
@@ -837,6 +853,13 @@
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	
 	if (argc > 0) {
 		file_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -885,7 +908,7 @@
     JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
 
-	return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
+	return JS_TRUE;
 }
 
 
@@ -902,6 +925,13 @@
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	
 	if (argc > 0) {
 		if ((function = JS_ValueToFunction(cx, argv[0]))) {
@@ -931,7 +961,7 @@
 
 	*rval = cb_state.ret;
 
-	return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
+	return JS_TRUE;
 }
 
 static JSBool session_streamfile(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
@@ -950,6 +980,13 @@
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	
 	if (argc > 0) {
 		file_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -994,7 +1031,7 @@
     JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
 	
-	return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
+	return JS_TRUE;
 }
 
 static JSBool session_set_variable(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
@@ -1005,6 +1042,13 @@
 	channel = switch_core_session_get_channel(jss->session);
     assert(channel != NULL);
 
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
+
 	if (argc > 1) {
 		char *var, *val;
 
@@ -1027,6 +1071,13 @@
 	channel = switch_core_session_get_channel(jss->session);
     assert(channel != NULL);
 
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
+
 	if (argc > 0) {
 		char *var, *val;
 		
@@ -1063,6 +1114,13 @@
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	
 	if (argc > 0) {
 		tts_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1113,7 +1171,7 @@
     JS_ResumeRequest(cx, cb_state.saveDepth);
 	*rval = cb_state.ret;
 
-	return (switch_channel_ready(channel)) ? JS_TRUE : JS_FALSE;
+	return JS_TRUE;
 }
 
 static JSBool session_get_digits(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
@@ -1123,6 +1181,17 @@
 	char *buf;
 	int digits;
 	int32 timeout = 5000;
+	switch_channel_t *channel;
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	
 	if (argc > 0) {
 		char term;
@@ -1151,6 +1220,13 @@
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
 
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
+
 	switch_channel_answer(channel);
 	return JS_TRUE;
 }
@@ -1162,6 +1238,7 @@
 
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
 	*rval = BOOLEAN_TO_JSVAL( switch_channel_ready(channel) ? JS_TRUE : JS_FALSE );
 
 	return JS_TRUE;
@@ -1176,8 +1253,10 @@
 	switch_time_t started;
 	unsigned int elapsed;
 	int32 timeout = 60;
+
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
 	started = switch_time_now();
 
 	if (argc > 0) {
@@ -1209,8 +1288,10 @@
 	switch_time_t started;
 	unsigned int elapsed;
 	int32 timeout = 60;
+
 	channel = switch_core_session_get_channel(jss->session);
 	assert(channel != NULL);
+
 	started = switch_time_now();
 
 	if (argc > 0) {
@@ -1237,6 +1318,19 @@
 static JSBool session_execute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
 	JSBool retval = JS_FALSE;
+	switch_channel_t *channel;
+    struct js_session *jss = JS_GetPrivate(cx, obj);
+
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
+
 	if (argc > 1) {
 		const switch_application_interface_t *application_interface;
 		char *app_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
@@ -1262,7 +1356,18 @@
 {
 	struct js_session *jss = JS_GetPrivate(cx, obj);
 	switch_event_t *event;
+	switch_channel_t *channel;
 
+	channel = switch_core_session_get_channel(jss->session);
+    assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
+
 	if (switch_core_session_dequeue_event(jss->session, &event) == SWITCH_STATUS_SUCCESS) {
 		JSObject *Event;
 		struct event_obj *eo;
@@ -1319,13 +1424,20 @@
 	char *cause_name = NULL;
 	switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
+	channel = switch_core_session_get_channel(jss->session);
+	assert(channel != NULL);
+
+    if (!switch_channel_ready(channel)) {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session is not active!\n");
+        *rval = BOOLEAN_TO_JSVAL( JS_FALSE );
+        return JS_TRUE;
+    }
+
 	if (argc > 1) {
 		cause_name = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
 		cause = switch_channel_str2cause(cause_name);
 	}
 
-	channel = switch_core_session_get_channel(jss->session);
-	assert(channel != NULL);
 
 	switch_channel_hangup(channel, cause);
 	switch_core_session_kill_channel(jss->session, SWITCH_SIG_KILL);

Modified: freeswitch/branches/knhor/trunk/src/switch_rtp.c
==============================================================================
--- freeswitch/branches/knhor/trunk/src/switch_rtp.c	(original)
+++ freeswitch/branches/knhor/trunk/src/switch_rtp.c	Wed Dec 13 21:30:39 2006
@@ -1160,7 +1160,7 @@
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_GOOGLEHACK) && rtp_session->send_msg.header.pt == 97) {
 		rtp_session->recv_msg.header.pt = 102;
 	}
-	
+
 	if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VAD) && 
 		rtp_session->recv_msg.header.pt == rtp_session->vad_data.read_codec->implementation->ianacode &&
 		((datalen == rtp_session->vad_data.read_codec->implementation->encoded_bytes_per_frame) || 
@@ -1171,7 +1171,8 @@
 		uint32_t len = sizeof(decoded);
 		time_t now = time(NULL);
 		send = 0;
-		
+
+        
 		if (rtp_session->vad_data.scan_freq && rtp_session->vad_data.next_scan <= now) {
 			rtp_session->vad_data.bg_count = rtp_session->vad_data.bg_level = 0;
 			rtp_session->vad_data.next_scan = now + rtp_session->vad_data.scan_freq;
@@ -1191,7 +1192,7 @@
 			uint32_t energy = 0;
 			uint32_t x, y = 0, z = len / sizeof(int16_t);
 			uint32_t score = 0;
-			
+
 			if (z) {
 				for (x = 0; x < z; x++) {
 					energy += abs(decoded[y]);



More information about the Freeswitch-branches mailing list