[Freeswitch-svn] [commit] r2387 - in freeswitch/trunk/src: . include

Freeswitch SVN anthm at freeswitch.org
Thu Aug 24 21:33:35 EDT 2006


Author: anthm
Date: Thu Aug 24 21:33:28 2006
New Revision: 2387

Modified:
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_event.c

Log:
codec sql

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Thu Aug 24 21:33:28 2006
@@ -558,6 +558,7 @@
 	SWITCH_EVENT_MODULE_LOAD		- Module was loaded
 	SWITCH_EVENT_DTMF				- DTMF was sent
 	SWITCH_EVENT_MESSAGE			- A Basic Message
+	SWITCH_EVENT_CODEC				- Codec Change
     SWITCH_EVENT_ALL				- All events at once
 </pre>
 
@@ -586,6 +587,7 @@
 	SWITCH_EVENT_MODULE_LOAD,
 	SWITCH_EVENT_DTMF,
 	SWITCH_EVENT_MESSAGE,
+	SWITCH_EVENT_CODEC,
 	SWITCH_EVENT_ALL
 } switch_event_types_t;
 

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Thu Aug 24 21:33:28 2006
@@ -353,8 +353,17 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec)
 {
+	switch_event_t *event;
+
 	assert(session != NULL);
 
+	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-name", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-read-codec-rate", "%d", codec->implementation->samples_per_second);
+		switch_event_fire(&event);
+	}
+				
 	session->read_codec = codec;
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -366,8 +375,16 @@
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec)
 {
+	switch_event_t *event;
 	assert(session != NULL);
 
+	if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
+		switch_channel_event_set_data(session->channel, event);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-name", codec->implementation->iananame);
+		switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-write-codec-rate", "%d", codec->implementation->samples_per_second);
+		switch_event_fire(&event);
+	}
+
 	session->write_codec = codec;
 	return SWITCH_STATUS_SUCCESS;
 }
@@ -2867,14 +2884,18 @@
 									 switch_event_get_header(event, "channel-state")
 									 );
 		break;
-	case SWITCH_EVENT_CHANNEL_EXECUTE:
-		sql = switch_core_db_mprintf("update channels set application='%q',application_data='%q', read_codec='%q',read_rate='%q',write_codec='%q',write_rate='%q' where uuid='%q'",
-									 switch_event_get_header(event, "application"),
-									 switch_event_get_header(event, "application-data"),
+	case SWITCH_EVENT_CODEC:
+		sql = switch_core_db_mprintf("update channels set read_codec='%q',read_rate='%q',write_codec='%q',write_rate='%q' where uuid='%q'",
 									 switch_event_get_header(event, "channel-read-codec-name"),
 									 switch_event_get_header(event, "channel-read-codec-rate"),
 									 switch_event_get_header(event, "channel-write-codec-name"),
 									 switch_event_get_header(event, "channel-write-codec-rate"),
+									 switch_event_get_header(event, "unique-id"));
+		break;
+	case SWITCH_EVENT_CHANNEL_EXECUTE:
+		sql = switch_core_db_mprintf("update channels set application='%q',application_data='%q' where uuid='%q'",
+									 switch_event_get_header(event, "application"),
+									 switch_event_get_header(event, "application-data"),
 									 switch_event_get_header(event, "unique-id")
 									 );
 		break;

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Thu Aug 24 21:33:28 2006
@@ -113,6 +113,7 @@
 	"MODULE_LOAD",
 	"DTMF",
 	"MESSAGE",
+	"CODEC",
 	"ALL"
 };
 



More information about the Freeswitch-svn mailing list