freeswitch-branches
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
August 2006
- 13 participants
- 92 discussions
12 Aug '06
Author: sphere
Date: Sat Aug 12 17:26:23 2006
New Revision: 2275
Added:
freeswitch/branches/mksoley/
Log:
Creating empty folder for mksoley
1
0
12 Aug '06
Author: sphere
Date: Sat Aug 12 17:16:23 2006
New Revision: 2274
Added:
freeswitch/branches/roman/
Log:
Creating empty folder for roman
1
0
[Freeswitch-branches] [commit] r2273 - freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip
by Freeswitch SVN 12 Aug '06
by Freeswitch SVN 12 Aug '06
12 Aug '06
Author: bennylp
Date: Sat Aug 12 13:59:21 2006
New Revision: 2273
Modified:
freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
Log:
As good as it gets: less crashes, less deadlocks
Modified: freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c Sat Aug 12 13:59:21 2006
@@ -83,6 +83,7 @@
int max_calls;
int calls;
+ int thread_cnt;
int flags;
switch_hash_t *call_hash;
@@ -418,15 +419,17 @@
/* Hangup PJSIP call */
if (tech_pvt->sip_invite && tech_pvt->sip_invite->state < PJSIP_INV_STATE_DISCONNECTED) {
- status = pjsip_inv_end_session( tech_pvt->sip_invite, 200, NULL, &txdata );
- if( status == PJ_SUCCESS ) {
+ pjsip_dlg_inc_lock(tech_pvt->sip_dialog);
+ status = pjsip_inv_end_session( tech_pvt->sip_invite, PJSIP_SC_DECLINE, NULL, &txdata );
+ if( status == PJ_SUCCESS && txdata) {
add_server_header(txdata);
status = pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
}
if (status != PJ_SUCCESS) {
- perror_(tech_pvt->sip_invite->dlg->obj_name, "Unable to hangup", status);
+ perror_(THIS_FILE, "Unable to hangup", status);
}
+ pjsip_dlg_dec_lock(tech_pvt->sip_dialog);
}
if (switch_test_flag( tech_pvt, TFLAG_USING_CODEC ) ) {
@@ -494,6 +497,9 @@
tech_pvt = switch_core_session_get_private( session );
assert( tech_pvt != NULL );
+ if ( tech_pvt->sip_invite == NULL )
+ return SWITCH_STATUS_SUCCESS;
+
PJ_LOG(4,(THIS_FILE, "* Answering call %s", tech_pvt->call_id));
if( !switch_test_flag( tech_pvt, TFLAG_ANSWERED ) &&
@@ -502,17 +508,17 @@
pjsip_tx_data *txdata;
pj_status_t status;
- assert( tech_pvt->sip_invite != NULL );
PJ_LOG(4,(THIS_FILE, "* Sending 200 on INVITE to %s (%s)",
tech_pvt->call_id, switch_channel_get_name( channel ) ));
/* create SIP 200 with SDP */
status = pjsip_inv_answer( tech_pvt->sip_invite, 200, NULL, NULL, &txdata );
- if( status != PJ_SUCCESS ) {
- perror_(tech_pvt->sip_invite->dlg->obj_name, "pjsip_inv_answer error", status);
-
- pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_TRUE );
+ if( status != PJ_SUCCESS || tech_pvt->sip_invite==NULL || txdata==NULL) {
+ if (tech_pvt->sip_invite) {
+ perror_(tech_pvt->sip_invite->dlg->obj_name, "pjsip_inv_answer error", status);
+ pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_TRUE );
+ }
switch_core_session_destroy( &session );
TRACE_((THIS_FILE, "LEAVE pjsip_answer_channel"));
return SWITCH_STATUS_GENERR;
@@ -540,6 +546,16 @@
struct private_object *tech_pvt;
switch_channel_t *channel;
+#if 0
+ pj_thread_desc tmp_desc;
+
+ if (!pj_thread_is_registered()) {
+ /* Kidz.. don't do this at home! */
+ pj_thread_t *thread;
+ pj_thread_register("kill%p", tmp_desc, &thread);
+ }
+#endif
+
TRACE_((THIS_FILE, "ENTER pjsip_kill_channel"));
assert( session != NULL );
@@ -698,6 +714,8 @@
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
switch_status_t status;
+ if (tech_pvt->rtp_session == NULL)
+ return SWITCH_STATUS_FALSE;
assert(tech_pvt->rtp_session != NULL);
tech_pvt->read_frame.datalen = 0;
@@ -800,6 +818,10 @@
return SWITCH_STATUS_SUCCESS;
}
+ if (!tech_pvt->rtp_session) {
+ return SWITCH_STATUS_SUCCESS;
+ }
+
if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
TRACE_((THIS_FILE, "switch_channel_hangup(%x) called by pjsip_write_frame()", channel));
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
@@ -817,7 +839,9 @@
}
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
- switch_rtp_write_frame( tech_pvt->rtp_session, frame, samples );
+ if (tech_pvt->rtp_session) {
+ switch_rtp_write_frame( tech_pvt->rtp_session, frame, samples );
+ }
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
return status;
@@ -976,7 +1000,6 @@
sip_uri = pjsip_uri_get_uri(rxdata->msg_info.to->uri);
pj_strdup_with_null( dialog->pool, &destination, &sip_uri->user);
- PJ_LOG(3,(dialog->obj_name, "Destination set to %s", destination.ptr));
} else {
destination = pj_str("unknown");
}
@@ -1281,18 +1304,16 @@
switch( inv->state )
{
case PJSIP_INV_STATE_DISCONNECTED:
- /* Remove association between PJSIP call and channel, to prevent
- * other channels from re-entering PJSIP for the context of this INVITE
- * (which is guaranteed to cause deadlock!)
- */
pjsip_dlg_inc_lock(inv->dlg);
- switch_mutex_lock(tech_pvt->flag_mutex);
- inv->mod_data[globals.mod_app.id] = NULL;
- tech_pvt->sip_invite = NULL;
- tech_pvt->sip_dialog = NULL;
- switch_mutex_unlock(tech_pvt->flag_mutex);
+ //switch_mutex_lock(tech_pvt->flag_mutex);
+ //inv->mod_data[globals.mod_app.id] = NULL;
+ //tech_pvt->sip_invite = NULL;
+ //tech_pvt->sip_dialog = NULL;
+ //switch_mutex_unlock(tech_pvt->flag_mutex);
+ pjsip_on_hangup(session);
+
PJ_LOG(4,(THIS_FILE, "* Call %s (%s) has been disconnected", tech_pvt->call_id,
switch_channel_get_name( channel ) ));
@@ -1382,6 +1403,10 @@
int ms, rate;
pj_sockaddr addr;
+
+//#define ASSERT_FAIL() assert(!"call_on_media_update failed");
+#define ASSERT_FAIL()
+
TRACE_((THIS_FILE, "ENTER call_on_media_update"));
tech_pvt = inv->mod_data[globals.mod_app.id];
@@ -1414,6 +1439,7 @@
PJ_LOG(1,(THIS_FILE, "SDP negotiation failed for call %s, reason: %s", tech_pvt->call_id, tmp ));
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
TRACE_((THIS_FILE, "LEAVE call_on_media_update"));
+ ASSERT_FAIL()
return;
}
@@ -1470,6 +1496,7 @@
switch_clear_flag_locked( tech_pvt, TFLAG_IO );
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
TRACE_((THIS_FILE, "LEAVE call_on_media_update"));
+ ASSERT_FAIL()
return;
}
@@ -1488,6 +1515,7 @@
perror_(THIS_FILE, "Failed to initialize read codec", -1);
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
TRACE_((THIS_FILE, "LEAVE call_on_media_update"));
+ ASSERT_FAIL()
return;
}
@@ -1499,6 +1527,7 @@
perror_(THIS_FILE, "ERROR: Failed to initialize write codec", -1 );
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
TRACE_((THIS_FILE, "LEAVE call_on_media_update"));
+ ASSERT_FAIL()
return;
}
@@ -1797,8 +1826,10 @@
}
switch_mutex_lock(tech_pvt->flag_mutex);
- switch_rtp_destroy( &tech_pvt->rtp_session );
- tech_pvt->rtp_session = NULL;
+ if (tech_pvt->rtp_session) {
+ switch_rtp_destroy( &tech_pvt->rtp_session );
+ tech_pvt->rtp_session = NULL;
+ }
switch_mutex_unlock(tech_pvt->flag_mutex);
TRACE_((THIS_FILE, "LEAVE stop_rtp"));
@@ -1913,6 +1944,9 @@
}
}
}
+ else if (!strcmp(var, "thread-cnt")) {
+ profile->thread_cnt = atoi( val );
+ }
else {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown option %s (ignored)\n", var );
}
@@ -2051,21 +2085,25 @@
/* PJSIP worker thread */
static int pjsip_worker_thread(void *arg)
{
+ PJ_LOG(3,(THIS_FILE, "PJSIP Worker Thread starting.."));
+
while ( globals.running > 0 ) {
pj_time_val timeout = { 1, 0 };
TRACE_((THIS_FILE, "ENTER pjsip_endpt_handle_events"));
pjsip_endpt_handle_events( globals.sip_endpt, &timeout );
TRACE_((THIS_FILE, "LEAVE pjsip_endpt_handle_events"));
}
+
+
+ PJ_LOG(3,(THIS_FILE, "PJSIP Worker Thread quitting.."));
return 0;
}
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
{
- enum { WORKER_COUNT=0 };
pj_thread_t *worker_threads[16];
- int i;
+ int thread_cnt=0, i;
switch_hash_index_t *p_entry;
pj_status_t status;
@@ -2133,6 +2171,9 @@
switch_hash_this( p_entry, NULL, NULL, &val );
profile = val;
+ if (profile->thread_cnt > thread_cnt)
+ thread_cnt = profile->thread_cnt;
+
if( switch_test_flag( profile, PFLAG_TRANSPORT_UDP ) ) {
pjsip_transport *transport;
@@ -2237,7 +2278,7 @@
globals.running = 1;
/* Create PJSIP from worker threads */
- for (i=0; i<WORKER_COUNT; ++i) {
+ for (i=0; i<thread_cnt; ++i) {
status = pj_thread_create(pjsip_pool, "sip%p", &pjsip_worker_thread, NULL, 0, 0, &worker_threads[i]);
if (status != PJ_SUCCESS) {
perror_(THIS_FILE, "Unable to create thread!", status);
@@ -2257,7 +2298,7 @@
globals.running = 0;
/* Wait for all worker threads to quit */
- for (i=0; i<WORKER_COUNT; ++i) {
+ for (i=0; i<thread_cnt; ++i) {
status = pj_thread_join(worker_threads[i]);
}
1
0
12 Aug '06
Author: sphere
Date: Sat Aug 12 11:59:27 2006
New Revision: 2271
Added:
freeswitch/branches/silik0n/
Log:
Creating empty folder for silik0n
1
0
[Freeswitch-branches] [commit] r2270 - freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip
by Freeswitch SVN 12 Aug '06
by Freeswitch SVN 12 Aug '06
12 Aug '06
Author: bennylp
Date: Sat Aug 12 09:56:55 2006
New Revision: 2270
Modified:
freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
Log:
mod_pjsip looks okay, but there is deadlock in switch_channel_hangup()
Modified: freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c Sat Aug 12 09:56:55 2006
@@ -42,11 +42,7 @@
#define MOD_PJSIP_CFG "pjsip.conf"
#define THIS_FILE pj_thread_get_name(pj_thread_this())
-#if 0
-#define TRACE_(x) PJ_LOG(4,x)
-#else
-#define TRACE_(x)
-#endif
+#define TRACE_(x) PJ_LOG(6,x)
static switch_memory_pool_t *module_pool = NULL;
static pj_caching_pool cp;
@@ -195,16 +191,20 @@
void log_func(int level, const char *data, int len)
{
-#if 1
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, (char *) data);
-#else
- static FILE *pjsip_log;
- if (pjsip_log == NULL)
- pjsip_log = fopen("/tmp/pjsip-fs.log", "w");
+ char msg[1024];
+ pj_ansi_snprintf(msg, sizeof(msg), "[%s] %s", THIS_FILE, data);
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, msg);
- if (pjsip_log != NULL) {
- fwrite(data, len, 1, pjsip_log);
- fflush(pjsip_log);
+#if PJ_LOG_MAX_LEVEL >= 6
+ {
+ static FILE *pjsip_log;
+ if (pjsip_log == NULL)
+ pjsip_log = fopen("/tmp/pjsip-fs.log", "w");
+
+ if (pjsip_log != NULL) {
+ fwrite(data, len, 1, pjsip_log);
+ fflush(pjsip_log);
+ }
}
#endif
}
@@ -406,7 +406,7 @@
assert( profile != NULL );
PJ_LOG(4,(THIS_FILE, "Hangup call %s dialog=%s", tech_pvt->call_id,
- tech_pvt->sip_invite->dlg->obj_name));
+ (tech_pvt->sip_invite ? tech_pvt->sip_invite->dlg->obj_name : "none")));
/* remove call from hash */
switch_core_hash_delete( profile->call_hash, tech_pvt->call_id );
@@ -416,18 +416,19 @@
stop_rtp( tech_pvt );
- //PJ_TODO(should_we_clear_dlg_data_here);
+ /* Hangup PJSIP call */
+ if (tech_pvt->sip_invite && tech_pvt->sip_invite->state < PJSIP_INV_STATE_DISCONNECTED) {
+ status = pjsip_inv_end_session( tech_pvt->sip_invite, 200, NULL, &txdata );
+ if( status == PJ_SUCCESS ) {
+ add_server_header(txdata);
+ status = pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
+ }
- status = pjsip_inv_end_session( tech_pvt->sip_invite, 200, NULL, &txdata );
- if( status == PJ_SUCCESS ) {
- add_server_header(txdata);
- status = pjsip_inv_send_msg( tech_pvt->sip_invite, txdata );
+ if (status != PJ_SUCCESS) {
+ perror_(tech_pvt->sip_invite->dlg->obj_name, "Unable to hangup", status);
+ }
}
- if (status != PJ_SUCCESS) {
- perror_(tech_pvt->sip_invite->dlg->obj_name, "Unable to hangup", status);
- }
-
if (switch_test_flag( tech_pvt, TFLAG_USING_CODEC ) ) {
switch_core_codec_destroy( &tech_pvt->read_codec );
switch_core_codec_destroy( &tech_pvt->write_codec );
@@ -442,6 +443,8 @@
struct private_object *tech_pvt;
switch_channel_t *channel;
+ TRACE_((THIS_FILE, "ENTER pjsip_on_loopback"));
+
channel = switch_core_session_get_channel( session );
assert( channel != NULL );
@@ -450,6 +453,7 @@
/* do nothing */
+ TRACE_((THIS_FILE, "LEAVE pjsip_on_loopback"));
return SWITCH_STATUS_SUCCESS;
}
@@ -458,6 +462,8 @@
struct private_object *tech_pvt;
switch_channel_t *channel;
+ TRACE_((THIS_FILE, "ENTER pjsip_on_transmit"));
+
assert( session != NULL );
channel = switch_core_session_get_channel( session );
@@ -468,6 +474,7 @@
/* do nothing */
+ TRACE_((THIS_FILE, "LEAVE pjsip_on_transmit"));
return SWITCH_STATUS_SUCCESS;
}
@@ -763,6 +770,7 @@
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
+ TRACE_((THIS_FILE, "switch_channel_hangup(%x) called by pjsip_read_frame()", channel));
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
return SWITCH_STATUS_FALSE;
}
@@ -793,6 +801,7 @@
}
if (switch_test_flag(tech_pvt, TFLAG_BYE)) {
+ TRACE_((THIS_FILE, "switch_channel_hangup(%x) called by pjsip_write_frame()", channel));
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
return SWITCH_STATUS_FALSE;
}
@@ -1146,7 +1155,7 @@
}
/* Add Server header */
- add_server_header(tdata);
+ add_server_header(tdata);
/* TODO: it would be nice if we could add SDP body here (dunno how) */
//PJ_TODO(ADD_SDP_TO_OPTIONS_RESPONSE);
@@ -1170,8 +1179,6 @@
{
pj_str_t reason;
- PJ_LOG(4,(THIS_FILE,"%s: received new request", __FUNCTION__ ));
-
switch( rxdata->msg_info.msg->line.req.method.id ) {
case PJSIP_INVITE_METHOD:
on_incoming_call( rxdata );
@@ -1241,7 +1248,10 @@
switch_core_session_t *session;
switch_channel_t *channel;
+ /* evt may be NULL if invite is terminated by pjsip_inv_terminate()
assert ( evt != NULL);
+ */
+
assert ( inv != NULL );
if (!(tech_pvt = inv->mod_data[globals.mod_app.id])) {
@@ -1271,28 +1281,35 @@
switch( inv->state )
{
case PJSIP_INV_STATE_DISCONNECTED:
+ /* Remove association between PJSIP call and channel, to prevent
+ * other channels from re-entering PJSIP for the context of this INVITE
+ * (which is guaranteed to cause deadlock!)
+ */
+ pjsip_dlg_inc_lock(inv->dlg);
+
+ switch_mutex_lock(tech_pvt->flag_mutex);
inv->mod_data[globals.mod_app.id] = NULL;
+ tech_pvt->sip_invite = NULL;
+ tech_pvt->sip_dialog = NULL;
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+
PJ_LOG(4,(THIS_FILE, "* Call %s (%s) has been disconnected", tech_pvt->call_id,
switch_channel_get_name( channel ) ));
if( !switch_test_flag( tech_pvt, TFLAG_BYE ) ) {
switch_call_cause_t cause;
- switch( evt->body.rx_msg.rdata->msg_info.msg->line.status.code )
+ switch( inv->cause )
{
default:
- /* bennylp: we can get the INVITE disconnect cause from inv->cause.
- * and the reason in inv->cause_text.
- * But how do we map it to switch cause?
- */
- //PJ_TODO(MAP_SIP_STATUS_CODE_TO_SWITCH_CAUSE_CODE);
cause = SWITCH_CAUSE_NORMAL_CLEARING;
}
- TRACE_((THIS_FILE, "LOOK HERE!!! Entering switch_channel_hangup for dialog %s",
- inv->dlg->obj_name));
+ TRACE_((THIS_FILE, "LOOK HERE!!! Entering switch_channel_hangup(%x) for dialog %s",
+ channel, inv->dlg->obj_name));
switch_channel_hangup( channel, cause );
TRACE_((THIS_FILE, "LOOK HERE!!! Leaving switch_channel_hangup"));
}
+ pjsip_dlg_dec_lock(inv->dlg);
break;
case PJSIP_INV_STATE_CONFIRMED:
PJ_LOG(4,(THIS_FILE, "* Call %s (%s) has been connected", tech_pvt->call_id,
@@ -1392,7 +1409,7 @@
}
if( status != PJ_SUCCESS ) {
- char tmp[1024];
+ char tmp[PJ_ERR_MSG_SIZE];
pj_strerror( status, tmp, sizeof(tmp) );
PJ_LOG(1,(THIS_FILE, "SDP negotiation failed for call %s, reason: %s", tech_pvt->call_id, tmp ));
switch_channel_hangup( channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER );
@@ -1775,7 +1792,7 @@
( switch_test_flag( tech_pvt, TFLAG_READING ) ||
switch_test_flag( tech_pvt, TFLAG_WRITING ) ) )
{
- switch_yield( 1000 );
+ switch_yield( 10 );
loop++;
}
@@ -2124,10 +2141,15 @@
*/
status = pjsip_udp_transport_start( globals.sip_endpt, &profile->sip_addr, NULL, 1, &transport );
if ( status != PJ_SUCCESS ) {
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create UDP transport: %s [%s:%d]\n", profile->name, profile->sip_ip, profile->sip_port );
+ PJ_LOG( 1, (THIS_FILE, "Failed to create UDP transport: %s [%s:%d]",
+ profile->name, profile->sip_ip, profile->sip_port ));
return SWITCH_STATUS_TERM;
}
+ PJ_LOG(3,(THIS_FILE, "UDP transport created, listening on %.*s:%d",
+ (int)transport->local_name.host.slen, transport->local_name.host.ptr,
+ transport->local_name.port));
+
/* add transports name to hash */
switch_core_hash_insert( globals.transport_hash, transport->obj_name, profile );
}
@@ -2212,8 +2234,6 @@
return SWITCH_STATUS_TERM;
}
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Monitor thread running\n" );
-
globals.running = 1;
/* Create PJSIP from worker threads */
@@ -2225,9 +2245,11 @@
}
}
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Monitor thread running\n" );
+
/* Another worker */
while ( globals.running > 0 ) {
- pj_time_val timeout = { 1, 0 };
+ pj_time_val timeout = { 0, 100 };
TRACE_((THIS_FILE, "ENTER pjsip_endpt_handle_events"));
pjsip_endpt_handle_events( globals.sip_endpt, &timeout );
TRACE_((THIS_FILE, "LEAVE pjsip_endpt_handle_events"));
1
0
12 Aug '06
Author: sphere
Date: Sat Aug 12 08:08:25 2006
New Revision: 2269
Added:
freeswitch/branches/lubard/
Log:
Creating empty folder for lubard
1
0
Author: james
Date: Sat Aug 12 00:43:19 2006
New Revision: 2268
Added:
freeswitch/branches/james/src/dotnet/FreeSwitchDotNet.csproj (contents, props changed)
freeswitch/branches/james/src/dotnet/Marshaling/StreamHandleMarshaler.cs (contents, props changed)
freeswitch/branches/james/src/dotnet/Switch/StreamHandle.cs (contents, props changed)
freeswitch/branches/james/src/dotnet/Types/Module.cs (contents, props changed)
freeswitch/branches/james/src/dotnet/Types/ModuleInterfaces.cs (contents, props changed)
freeswitch/branches/james/src/dotnet/Types/StreamHandle.cs (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/
freeswitch/branches/james/src/mod/dotnet/Info/Info.cs (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/Info.csproj (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/Info.dll (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/Info.suo (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/Makefile
freeswitch/branches/james/src/mod/dotnet/Info/Properties/
freeswitch/branches/james/src/mod/dotnet/Info/Properties/AssemblyInfo.cs (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/bin/
freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/
freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.dll (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.pdb (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.dll (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.pdb (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/obj/
freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/
freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/Info.dll (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/Refactor/
freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/ResolveAssemblyReference.cache (contents, props changed)
freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/TempPE/
freeswitch/branches/james/src/mod/dotnet/Info/obj/Info.csproj.FileList.txt (contents, props changed)
Modified:
freeswitch/branches/james/src/dotnet/Common.cs
freeswitch/branches/james/src/dotnet/Core.cs
freeswitch/branches/james/src/dotnet/Makefile
freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs
freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs
freeswitch/branches/james/src/dotnet/Module.cs
freeswitch/branches/james/src/dotnet/Modules/Api.cs
freeswitch/branches/james/src/dotnet/Modules/Application.cs
freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs
freeswitch/branches/james/src/dotnet/Switch/Channel.cs
freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs
freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs
freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs
freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs
freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs
freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs
freeswitch/branches/james/src/dotnet/Types/Channel.cs
freeswitch/branches/james/src/dotnet/Types/CoreSession.cs
freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs
freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c
Log:
Codey Codey.
Modified: freeswitch/branches/james/src/dotnet/Common.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Common.cs (original)
+++ freeswitch/branches/james/src/dotnet/Common.cs Sat Aug 12 00:43:19 2006
@@ -30,6 +30,7 @@
*
*/
using System;
+using System.Reflection;
namespace Freeswitch
{
@@ -40,6 +41,17 @@
Console.WriteLine("DUMP-{0}:", label);
DumpHex(pointer, length);
+ }
+
+ public static void DumpProperties(string label, object dumpObject)
+ {
+ Type type = dumpObject.GetType();
+ PropertyInfo[] properties = type.GetProperties();
+
+ foreach (PropertyInfo p in properties)
+ {
+ Console.WriteLine("%%% - {0}: {1}:{2}", label, p.Name, p.GetValue(dumpObject, null));
+ }
}
public static void DumpHex(IntPtr pointer, int length)
Modified: freeswitch/branches/james/src/dotnet/Core.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Core.cs (original)
+++ freeswitch/branches/james/src/dotnet/Core.cs Sat Aug 12 00:43:19 2006
@@ -48,13 +48,11 @@
*/
public class Core
{
- private static readonly Core instance = new Core();
-
[DllImport("__Internal")]
public static extern void switch_console_printf(SwitchTextChannel channel, string file, string func, int line, string fmt, string msg);
/* Constructor */
- public Core()
+/* public Core()
{
if (instance == null)
{
@@ -68,7 +66,7 @@
// switch_loadable_module_register(module);
}
}
-
+*/
public enum SwitchTextChannel
{
SwitchChannelIdConsole,
@@ -77,13 +75,13 @@
}
/* Instance property to get singleton instance of FreeSwitch */
- public static Core Instance
+/* public static Core Instance
{
get { return instance; }
}
-
- public void Application(IntPtr session, IntPtr data)
- {
- }
+ */
+// public void Application(IntPtr session, IntPtr data)
+// {
+// }
}
}
Added: freeswitch/branches/james/src/dotnet/FreeSwitchDotNet.csproj
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/dotnet/FreeSwitchDotNet.csproj Sat Aug 12 00:43:19 2006
@@ -0,0 +1,126 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{251CAABC-16C3-4593-A491-603B908094E0}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Freeswitch</RootNamespace>
+ <AssemblyName>Freeswitch</AssemblyName>
+ <StartupObject>
+ </StartupObject>
+ <SignAssembly>true</SignAssembly>
+ <AssemblyOriginatorKeyFile>public.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Deployment" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Common.cs" />
+ <Compile Include="Core.cs" />
+ <Compile Include="Ivr.cs" />
+ <Compile Include="Marshaling\BufferMarshaler.cs" />
+ <Compile Include="Marshaling\CallerExtensionMarshaler.cs" />
+ <Compile Include="Marshaling\CallerProfileMarshaler.cs" />
+ <Compile Include="Marshaling\ChannelMarshaler.cs" />
+ <Compile Include="Marshaling\ChannelTimetableMarshaler.cs" />
+ <Compile Include="Marshaling\StreamHandleMarshaler.cs" />
+ <Compile Include="Marshaling\CoreSessionMarshaler.cs" />
+ <Compile Include="Marshaling\EventMarshaler.cs" />
+ <Compile Include="Marshaling\MemoryPoolMarshaler.cs" />
+ <Compile Include="Marshaling\Types\BufferMarshal.cs" />
+ <Compile Include="Marshaling\Types\CallerExtensionMarshal.cs" />
+ <Compile Include="Marshaling\Types\CallerProfileMarshal.cs" />
+ <Compile Include="Marshaling\FileHandleMarshaler.cs" />
+ <Compile Include="Marshaling\Types\ChannelFlagMarshal.cs" />
+ <Compile Include="Marshaling\Types\ChannelMarshal.cs" />
+ <Compile Include="Marshaling\Types\ChannelStateMarshal.cs" />
+ <Compile Include="Marshaling\Types\ChannelTimetableMarshal.cs" />
+ <Compile Include="Marshaling\Types\ApplicationInterfaceMarshal.cs" />
+ <Compile Include="Marshaling\Types\ApiInterfaceMarshal.cs" />
+ <Compile Include="Marshaling\Types\CodecImplementationMarshal.cs" />
+ <Compile Include="Marshaling\Types\CodecInterfaceMarshal.cs" />
+ <Compile Include="Marshaling\Types\CodecMarshal.cs" />
+ <Compile Include="Marshaling\Types\CodecTypeMarshal.cs" />
+ <Compile Include="Marshaling\Types\IMarshaledObject.cs" />
+ <Compile Include="Marshaling\Types\TypesMarshal.cs" />
+ <Compile Include="Marshaling\Types\FileHandleMarshal.cs" />
+ <Compile Include="Marshaling\Types\LoadableModuleInterfaceMarshal.cs" />
+ <Compile Include="Marshaling\Types\LoadableModuleMarshal.cs" />
+ <Compile Include="Marshaling\Types\CoreSessionMarshal.cs" />
+ <Compile Include="Marshaling\Types\EventMarshal.cs" />
+ <Compile Include="Marshaling\Types\FrameMarshal.cs" />
+ <Compile Include="Marshaling\Types\IOEventHooksMarshal.cs" />
+ <Compile Include="Module.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Switch\CallerProfile.cs" />
+ <Compile Include="Switch\Channel.cs" />
+ <Compile Include="Switch\Console.cs" />
+ <Compile Include="Switch\StreamHandle.cs" />
+ <Compile Include="Switch\CoreSession.cs" />
+ <Compile Include="Switch\Ivr.cs" />
+ <Compile Include="Switch\LoadableModule.cs" />
+ <Compile Include="Modules\Api.cs" />
+ <Compile Include="Types\ApiFunction.cs" />
+ <Compile Include="Types\ApplicationInterface.cs" />
+ <Compile Include="Types\Buffer.cs" />
+ <Compile Include="Types\CallerExtension.cs" />
+ <Compile Include="Types\CallerProfile.cs" />
+ <Compile Include="Types\Channel.cs" />
+ <Compile Include="Types\ChannelFlag.cs" />
+ <Compile Include="Types\ChannelState.cs" />
+ <Compile Include="Types\ChannelTimetable.cs" />
+ <Compile Include="Modules\Application.cs" />
+ <Compile Include="Types\ApplicationFunction.cs" />
+ <Compile Include="Types\CallCause.cs" />
+ <Compile Include="Types\ModuleInterfaces.cs" />
+ <Compile Include="Types\StreamHandle.cs" />
+ <Compile Include="Types\Module.cs" />
+ <Compile Include="Types\DtmfCallbackFunction.cs" />
+ <Compile Include="Types\FileHandle.cs" />
+ <Compile Include="Types\MemoryPool.cs" />
+ <Compile Include="Types\LoadableModule.cs" />
+ <Compile Include="Types\LoadableModuleInterface.cs" />
+ <Compile Include="Types\TextChannel.cs" />
+ <Compile Include="Types\CoreSession.cs" />
+ <Compile Include="Types\Event.cs" />
+ <Compile Include="Types\Status.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="Makefile" />
+ <None Include="public.snk" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Modified: freeswitch/branches/james/src/dotnet/Makefile
==============================================================================
--- freeswitch/branches/james/src/dotnet/Makefile (original)
+++ freeswitch/branches/james/src/dotnet/Makefile Sat Aug 12 00:43:19 2006
@@ -13,13 +13,17 @@
Marshaling/Types/ChannelMarshal.cs \
Marshaling/Types/ChannelStateMarshal.cs \
Marshaling/Types/ChannelTimetableMarshal.cs \
+ Marshaling/Types/CodecImplementationMarshal.cs \
+ Marshaling/Types/CodecInterfaceMarshal.cs \
+ Marshaling/Types/CodecMarshal.cs \
+ Marshaling/Types/CodecTypeMarshal.cs \
Marshaling/Types/CoreSessionMarshal.cs \
Marshaling/Types/EventMarshal.cs \
Marshaling/Types/FileHandleMarshal.cs \
Marshaling/Types/FrameMarshal.cs \
Marshaling/Types/IOEventHooksMarshal.cs \
- Marshaling/Types/LoadableModuleMarshal.cs \
Marshaling/Types/LoadableModuleInterfaceMarshal.cs \
+ Marshaling/Types/LoadableModuleMarshal.cs \
Marshaling/Types/TypesMarshal.cs \
Marshaling/BufferMarshaler.cs \
Marshaling/CallerExtensionMarshaler.cs \
@@ -30,6 +34,7 @@
Marshaling/EventMarshaler.cs \
Marshaling/FileHandleMarshaler.cs \
Marshaling/MemoryPoolMarshaler.cs \
+ Marshaling/StreamHandleMarshaler.cs \
Modules/Api.cs \
Modules/Application.cs \
Switch/CallerProfile.cs \
@@ -38,8 +43,10 @@
Switch/CoreSession.cs \
Switch/Ivr.cs \
Switch/LoadableModule.cs \
+ Switch/StreamHandle.cs \
Types/ApiFunction.cs \
Types/ApplicationFunction.cs \
+ Types/ApplicationInterface.cs \
Types/Buffer.cs \
Types/CallCause.cs \
Types/CallerExtension.cs \
@@ -52,9 +59,13 @@
Types/DtmfCallbackFunction.cs \
Types/Event.cs \
Types/FileHandle.cs \
+ Types/LoadableModule.cs \
Types/LoadableModuleInterface.cs \
Types/MemoryPool.cs \
+ Types/Module.cs \
Types/Status.cs \
+ Types/StreamHandle.cs \
+ Types/TextChannel.cs \
Common.cs \
Core.cs \
Ivr.cs \
@@ -64,4 +75,4 @@
rm -fr *.dll
install:
- cp -f $(MODNAME).dll $(PREFIX)/mod/mono
+ cp -f Freeswitch.dll /usr/local/freeswitch/lib/
Added: freeswitch/branches/james/src/dotnet/Marshaling/StreamHandleMarshaler.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/dotnet/Marshaling/StreamHandleMarshaler.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,81 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * StreamHandleMarshaler.cs --
+ *
+ */
+using System;
+using System.Collections;
+using Freeswitch.Marshaling.Types;
+using Freeswitch.Types;
+using System.Runtime.InteropServices;
+
+namespace Freeswitch.Marshaling
+{
+ class StreamHandleMarshaler : ICustomMarshaler
+ {
+ private static StreamHandleMarshaler Instance = new StreamHandleMarshaler();
+
+ public static ICustomMarshaler GetInstance(string s)
+ {
+ return Instance;
+ }
+
+ public void CleanUpManagedData(object o)
+ {
+ }
+
+ public void CleanUpNativeData(IntPtr pNativeData)
+ {
+ }
+
+ public int GetNativeDataSize()
+ {
+ return IntPtr.Size;
+ }
+
+ public IntPtr MarshalManagedToNative(object obj)
+ {
+ StreamHandle streamHandleObj = (StreamHandle)obj;
+
+ return streamHandleObj.marshaledObject.Handle;
+ }
+
+ public object MarshalNativeToManaged(IntPtr streamHandlePtr)
+ {
+ StreamHandleMarshal streamHandleMarshal = new StreamHandleMarshal();
+ StreamHandle streamHandleObj = new StreamHandle();
+
+ Marshal.PtrToStructure(streamHandlePtr, streamHandleMarshal);
+
+ streamHandleObj.marshaledObject = new HandleRef(streamHandleMarshal, streamHandlePtr);
+
+ return streamHandleObj;
+ }
+ }
+}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/ApiInterfaceMarshal.cs Sat Aug 12 00:43:19 2006
@@ -35,14 +35,14 @@
namespace Freeswitch.Marshaling.Types
{
- internal delegate Status ApiFunctionMarshal(IntPtr text_in, IntPtr text_out, uint outlen);
-
[StructLayout(LayoutKind.Sequential)]
internal class ApiInterfaceMarshal
{
- internal IntPtr interface_name;
- internal IntPtr desc;
- internal ApiFunctionMarshal function;
- internal IntPtr next;
+ //[MarshalAs(UnmanagedType.LPStr)]
+ internal IntPtr interface_name;
+ //[MarshalAs(UnmanagedType.LPStr)]
+ internal IntPtr desc;
+ internal ApiFunction function;
+ internal IntPtr next;
}
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/ApplicationInterfaceMarshal.cs Sat Aug 12 00:43:19 2006
@@ -32,24 +32,21 @@
using System;
using System.Runtime.InteropServices;
using Freeswitch.Types;
-using Freeswitch.Marshaling;
namespace Freeswitch.Marshaling.Types
{
- internal delegate void
- ApplicationFunctionMarshal(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
- CoreSession session,
- IntPtr data);
-
[StructLayout(LayoutKind.Sequential)]
internal class ApplicationInterfaceMarshal
{
- internal IntPtr interface_name;
- internal ApplicationFunctionMarshal application_function;
- internal IntPtr long_desc;
- internal IntPtr short_desc;
- internal IntPtr syntax;
- internal IntPtr next;
+ // [MarshalAs(UnmanagedType.LPStr)]
+ internal IntPtr interface_name;
+ internal ApplicationFunction application_function;
+ // [MarshalAs(UnmanagedType.LPStr)]
+ internal IntPtr long_desc;
+ //[MarshalAs(UnmanagedType.LPStr)]
+ internal IntPtr short_desc;
+ //[MarshalAs(UnmanagedType.LPStr)]
+ internal IntPtr syntax;
+ internal IntPtr next;
}
-}
+}
\ No newline at end of file
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/BufferMarshal.cs Sat Aug 12 00:43:19 2006
@@ -37,8 +37,10 @@
[StructLayout(LayoutKind.Sequential)]
internal class BufferMarshal
{
+ [MarshalAs(UnmanagedType.LPStr)]
internal string data;
internal int used;
internal int datalen;
+ internal UInt32 id;
}
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerExtensionMarshal.cs Sat Aug 12 00:43:19 2006
@@ -37,8 +37,8 @@
[StructLayout(LayoutKind.Sequential)]
internal class CallerExtensionMarshal
{
- internal string extension_name;
- internal string extension_number;
+ internal IntPtr extension_name;
+ internal IntPtr extension_number;
internal IntPtr current_application;
internal IntPtr last_application;
internal IntPtr applications;
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CallerProfileMarshal.cs Sat Aug 12 00:43:19 2006
@@ -37,16 +37,32 @@
[StructLayout(LayoutKind.Sequential)]
internal class CallerProfileMarshal
{
- internal IntPtr dialplan;
- internal IntPtr caller_id_name;
- internal IntPtr caller_id_number;
- internal IntPtr network_addr;
- internal IntPtr ani;
- internal IntPtr ani2;
- internal IntPtr rdnis;
- internal IntPtr destination_number;
- internal IntPtr source;
- internal IntPtr chan_name;
- internal IntPtr uuid;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string username;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string dialplan;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string caller_id_name;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string caller_id_number;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string network_addr;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string ani;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string ani2;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string rdnis;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string destination_number;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string source;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string chan_name;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string uuid;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string context;
+ internal IntPtr next;
}
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/ChannelMarshal.cs Sat Aug 12 00:43:19 2006
@@ -31,32 +31,36 @@
*/
using System;
using System.Runtime.InteropServices;
+using Freeswitch.Types;
namespace Freeswitch.Marshaling.Types
{
[StructLayout(LayoutKind.Sequential)]
internal class ChannelMarshal
{
- internal IntPtr name;
- internal IntPtr dtmf_buffer;
- internal IntPtr dtmf_mutex;
- internal IntPtr session;
- internal ChannelStateMarshal state;
- internal ChannelFlagMarshal flags;
- internal IntPtr caller_profile;
- internal IntPtr originator_caller_profile;
- internal IntPtr originatee_caller_profile;
- internal IntPtr caller_extension;
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 120)]
- internal byte[] state_handlers;
- internal int state_handler_index;
- internal IntPtr variables;
- internal ChannelTimetableMarshal times;
- internal IntPtr private_info;
- internal int freq;
- internal int bits;
- internal int channels;
- internal int ms;
- internal int kbps;
+ internal IntPtr name;
+ internal IntPtr dtmf_buffer;
+ internal IntPtr dtmf_mutex;
+ internal IntPtr flag_mutex;
+ internal IntPtr profile_mutex;
+ internal IntPtr session;
+ internal ChannelState state;
+ internal UInt32 flags;
+ internal IntPtr caller_profile;
+ internal IntPtr originator_caller_profile;
+ internal IntPtr originatee_caller_profile;
+ internal IntPtr caller_extension;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=120)]
+ internal byte[] state_handlers;
+ internal int state_handler_index;
+ internal IntPtr variables;
+ internal IntPtr times;
+ internal IntPtr private_info;
+ internal IntPtr hangup_cause;
+ internal int freq;
+ internal int bits;
+ internal int channels;
+ internal int ms;
+ internal int kbps;
}
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CodecInterfaceMarshal.cs Sat Aug 12 00:43:19 2006
@@ -35,4 +35,29 @@
namespace Freeswitch.Marshaling.Types
{
+ [StructLayout(LayoutKind.Sequential)]
+ internal class CodecInterfaceMarshal
+ {
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string interface_name;
+ /*
+ internal CodecImplementation application_function;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string long_desc;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string short_desc;
+ [MarshalAs(UnmanagedType.LPStr)]
+ internal string syntax;
+ internal IntPtr next;
}
+
+
+struct switch_codec_interface {
+ ! the name of the interface
+ const char *interface_name;
+ ! a list of codec implementations related to the codec
+ const switch_codec_implementation_t *implementations;
+ const struct switch_codec_interface *next;
+};*/
+ }
+}
\ No newline at end of file
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/CoreSessionMarshal.cs Sat Aug 12 00:43:19 2006
@@ -35,11 +35,12 @@
namespace Freeswitch.Marshaling.Types
{
- [StructLayout(LayoutKind.Sequential)]
+ [StructLayout(LayoutKind.Sequential, Pack=1)]
internal class CoreSessionMarshal
{
- internal uint id;
- internal IntPtr name;
+ internal UInt32 id;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=80)]
+ internal byte[] name;
internal int thread_running;
internal IntPtr pool;
internal IntPtr channel;
@@ -51,24 +52,29 @@
internal IntPtr raw_write_buffer;
internal FrameMarshal raw_write_frame;
internal FrameMarshal enc_write_frame;
- /*
-switch_frame raw_write_frame
-switch_frame enc_write_frame
-unsigned char * raw_write_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE]
-unsigned char * enc_write_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE]
-switch_buffer * raw_read_buffer
-switch_frame raw_read_frame
-switch_frame enc_read_frame
-unsigned char * raw_read_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE]
-unsigned char * enc_read_buf [SWITCH_RECCOMMENDED_BUFFER_SIZE]
-switch_audio_resampler * read_resampler
-switch_audio_resampler * write_resampler
-switch_mutex_t * mutex
-switch_thread_cond_t * cond
-void * streams [SWITCH_MAX_STREAMS]
-int stream_count
-char uuid_str [SWITCH_UUID_FORMATTED_LENGTH+1]
-void * private_info */
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)]
+ internal byte[] raw_write_buf;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)]
+ internal byte[] enc_write_buf;
+ internal IntPtr raw_read_buffer;
+ internal FrameMarshal raw_read_frame;
+ internal FrameMarshal enc_read_frame;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)]
+ internal byte[] raw_read_buf;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=2048)]
+ internal byte[] enc_read_buf;
+ internal IntPtr read_resampler;
+ internal IntPtr write_resampler;
+ internal IntPtr mutex;
+ internal IntPtr cond;
+ internal IntPtr rwlock;
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=128)]
+ internal IntPtr[] streams;
+ internal int stream_count;
+ /* 36 + 1 char string, but need to grab 40 bytes */
+ [MarshalAs(UnmanagedType.ByValArray, SizeConst=40)]
+ internal byte[] uuid_str;
+ internal IntPtr private_info;
+ internal IntPtr event_queue;
}
-
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/FrameMarshal.cs Sat Aug 12 00:43:19 2006
@@ -31,6 +31,7 @@
*/
using System;
using System.Runtime.InteropServices;
+using Freeswitch.Types;
namespace Freeswitch.Marshaling.Types
{
@@ -38,10 +39,16 @@
internal class FrameMarshal
{
internal IntPtr codec;
+ internal IntPtr source;
+ internal IntPtr packet;
+ internal UInt32 packetlen;
internal IntPtr data;
- internal int datalen;
- internal int buflen;
- internal int samples;
- internal int rate;
+ internal UInt32 datalen;
+ internal UInt32 buflen;
+ internal UInt32 samples;
+ internal UInt32 rate;
+ internal byte payload;
+ internal UInt32 timestamp;
+ internal byte flags;
}
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/IOEventHooksMarshal.cs Sat Aug 12 00:43:19 2006
@@ -40,6 +40,7 @@
internal IntPtr outgoing_channel;
internal IntPtr answer_channel;
internal IntPtr receive_message;
+ internal IntPtr receive_event;
internal IntPtr read_frame;
internal IntPtr write_frame;
internal IntPtr kill_channel;
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleInterfaceMarshal.cs Sat Aug 12 00:43:19 2006
@@ -31,6 +31,7 @@
*/
using System;
using System.Runtime.InteropServices;
+using Freeswitch.Types;
namespace Freeswitch.Marshaling.Types
{
@@ -48,4 +49,17 @@
internal IntPtr speech_interface;
internal IntPtr directory_interface;
}
+
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal class StreamHandleMarshal
+ {
+ internal IntPtr write_function;
+ internal IntPtr data;
+ internal IntPtr end;
+ internal int data_size;
+ internal int data_len;
+ internal IntPtr _event;
+ }
+
}
Modified: freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs (original)
+++ freeswitch/branches/james/src/dotnet/Marshaling/Types/LoadableModuleMarshal.cs Sat Aug 12 00:43:19 2006
@@ -35,26 +35,20 @@
namespace Freeswitch.Marshaling.Types
{
- public delegate Status ModuleLoadMarshal(ref IntPtr loadable_module_interface, string blah);
- public delegate Status ModuleReloadMarshal();
- public delegate bool ModulePauseMarshal();
- public delegate bool ModuleResumeMarshal();
- public delegate bool ModuleStatusMarshal();
- public delegate Status ModuleRuntimeMarshal();
- public delegate bool ModuleShutdownMarshal();
+
[StructLayout(LayoutKind.Sequential)]
public class LoadableModuleMarshal
{
- public IntPtr filename;
- public IntPtr module_interface;
- public IntPtr lib;
- public ModuleLoadMarshal module_load;
- public ModuleReloadMarshal module_reload;
- public ModulePauseMarshal module_pause;
- public ModuleResumeMarshal module_resume;
- public ModuleStatusMarshal module_status;
- public ModuleRuntimeMarshal module_runtime;
- public ModuleShutdownMarshal module_shutdown;
+ public IntPtr filename;
+ public IntPtr module_interface;
+ public IntPtr lib;
+ public ModuleLoad module_load;
+ public ModuleReload module_reload;
+ public ModulePause module_pause;
+ public ModuleResume module_resume;
+ public ModuleStatus module_status;
+ public ModuleRuntime module_runtime;
+ public ModuleShutdown module_shutdown;
}
}
Modified: freeswitch/branches/james/src/dotnet/Module.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Module.cs (original)
+++ freeswitch/branches/james/src/dotnet/Module.cs Sat Aug 12 00:43:19 2006
@@ -31,6 +31,7 @@
*/
using System;
using System.Collections;
+using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using Freeswitch;
@@ -42,32 +43,38 @@
{
public class Module
{
+
+
+ ModuleLoad load;
+
private LoadableModuleInterfaceMarshal module_interface = new LoadableModuleInterfaceMarshal();
private ArrayList apiInterfaces = new ArrayList();
private ArrayList applicationInterfaces = new ArrayList();
- protected ModuleLoad moduleLoad;
+ //protected ModuleLoad moduleLoad;
private string name;
-
- public string Name
- {
- set { name = value; }
- get { return name; }
- }
+ private string filename = Assembly.GetCallingAssembly().GetName().Name;
+ private LoadableModuleMarshal module = new LoadableModuleMarshal();
public Module()
{
- Console.WriteLine("Running module .ctor");
+ Console.WriteLine("Running module .blehctor");
+
+ load = new ModuleLoad(Load);
}
+ /// <summary>
+ /// Implementation of ModuleLoad Delegate
+ /// </summary>
+ /// <param name="module"></param>
+ /// <param name="name"></param>
+ /// <returns></returns>
public Status Load(ref IntPtr module, string name)
{
- if (moduleLoad != null)
- moduleLoad();
-
module = Marshal.AllocHGlobal(Marshal.SizeOf(module_interface));
- module_interface.module_name = Marshal.StringToHGlobalAnsi(Name);
+ module_interface.module_name = Marshal.StringToHGlobalAnsi(filename);
+ /* For each API interface */
if (apiInterfaces.Count > 0)
{
foreach (Api api in apiInterfaces)
@@ -75,11 +82,9 @@
ApiInterfaceMarshal apiInterfaceMarshal = new ApiInterfaceMarshal();
IntPtr apiInterfacePtr = Marshal.AllocHGlobal(Marshal.SizeOf(apiInterfaceMarshal));
- Console.WriteLine(api.Name);
-
apiInterfaceMarshal.interface_name = Marshal.StringToHGlobalAnsi(api.Name);
apiInterfaceMarshal.desc = Marshal.StringToHGlobalAnsi(api.Description);
- apiInterfaceMarshal.function = new ApiFunctionMarshal(api.ApiFunctionWrapper);
+ apiInterfaceMarshal.function = new ApiFunction(api.ApiFunction);
api.handle = new HandleRef(apiInterfaceMarshal, apiInterfacePtr);
@@ -89,26 +94,25 @@
Api apiIndex = (Api) apiInterfaces[0];
module_interface.api_interface = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ApiInterfaceMarshal)));
Marshal.StructureToPtr(apiIndex.handle.Wrapper, module_interface.api_interface, true);
-
- /* APPLICATIONS */
+ }
+ /* For each Application interface */
+ if (applicationInterfaces.Count > 0)
+ {
foreach (Application application in applicationInterfaces)
{
ApplicationInterfaceMarshal applicationInterfaceMarshal = new ApplicationInterfaceMarshal();
IntPtr applicationInterfacePtr = Marshal.AllocHGlobal(Marshal.SizeOf(applicationInterfaceMarshal));
- Console.WriteLine("APPLICATION: {0}", application.Name);
-
applicationInterfaceMarshal.interface_name = Marshal.StringToHGlobalAnsi(application.Name);
applicationInterfaceMarshal.syntax = Marshal.StringToHGlobalAnsi(application.Syntax);
applicationInterfaceMarshal.long_desc = Marshal.StringToHGlobalAnsi(application.LongDescription);
applicationInterfaceMarshal.short_desc = Marshal.StringToHGlobalAnsi(application.ShortDescription);
- applicationInterfaceMarshal.application_function = new ApplicationFunctionMarshal(application.ApplicationFunctionWrapper);
+ applicationInterfaceMarshal.application_function = new ApplicationFunction(application.ApplicationFunction);
application.handle = new HandleRef(applicationInterfaceMarshal, applicationInterfacePtr);
Marshal.StructureToPtr(applicationInterfaceMarshal, application.handle.Handle, true);
-
}
Application applicationIndex = (Application)applicationInterfaces[0];
@@ -133,13 +137,12 @@
public void Register()
{
- LoadableModuleMarshal module = new LoadableModuleMarshal();
-
- module.filename = Marshal.StringToHGlobalAnsi(Name);
-
- module.module_load = new ModuleLoadMarshal(Load);
+ module.module_load = new ModuleLoad(Load);
- Switch.switch_loadable_module_build_dynamic("filename", module.module_load, module.module_runtime, module.module_shutdown);
+ Switch.switch_loadable_module_build_dynamic(filename,
+ module.module_load,
+ module.module_runtime,
+ module.module_shutdown);
}
Modified: freeswitch/branches/james/src/dotnet/Modules/Api.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Modules/Api.cs (original)
+++ freeswitch/branches/james/src/dotnet/Modules/Api.cs Sat Aug 12 00:43:19 2006
@@ -61,21 +61,5 @@
set { apiFunction = value; }
get { return apiFunction; }
}
-
- public Status ApiFunctionWrapper(IntPtr text_in, IntPtr text_out, uint outlen)
- {
- Encoding ansiEncoding = Encoding.GetEncoding(1252);
- string command = Marshal.PtrToStringAnsi(text_in);
- int outputLength = (int)outlen;
-
- string output = ApiFunction(command);
-
- if (output.Length < outputLength)
- outputLength = output.Length;
-
- Marshal.Copy(ansiEncoding.GetBytes(output.ToString()), 0, text_out, outputLength);
-
- return Status.Success;
- }
}
}
\ No newline at end of file
Modified: freeswitch/branches/james/src/dotnet/Modules/Application.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Modules/Application.cs (original)
+++ freeswitch/branches/james/src/dotnet/Modules/Application.cs Sat Aug 12 00:43:19 2006
@@ -77,12 +77,5 @@
set { applicationFunction = value; }
get { return applicationFunction; }
}
-
- public void ApplicationFunctionWrapper(CoreSession session, IntPtr data)
- {
- string applicationData = Marshal.PtrToStringAnsi(data);
-
- ApplicationFunction(session, applicationData);
- }
}
}
\ No newline at end of file
Modified: freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs (original)
+++ freeswitch/branches/james/src/dotnet/Switch/CallerProfile.cs Sat Aug 12 00:43:19 2006
@@ -34,18 +34,41 @@
using System.Runtime.InteropServices;
using Freeswitch.Types;
using Freeswitch.Marshaling;
+using Freeswitch.Marshaling.Types;
namespace Freeswitch
{
public partial class Switch
{
+ /*
+ * TODO: Figure out how to stop mono from trying to free the returned string.
+ */
[DllImport("freeswitch")]
- [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))]
+ //[return: MarshalAs(UnmanagedType.LPStr)]
public extern static
+ IntPtr switch_caller_get_field_by_name(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
+ CallerProfile caller_profile,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string name);
+ /*
+ [DllImport("freeswitch")]
+ [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
+ public extern static
+ CallerProfile switch_caller_profile_clone(
+ [MarshalAs
+ switch_core_session_t *session, switch_caller_profile_t *tocopy)
+ */
+
+ [DllImport("freeswitch")]
+ [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
+ public extern static
CallerProfile switch_caller_profile_new(
- [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(MemoryPoolMarshaler))]
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(MemoryPoolMarshaler))]
MemoryPool pool,
[MarshalAs(UnmanagedType.LPStr)]
+ string username,
+ [MarshalAs(UnmanagedType.LPStr)]
string dialplan,
[MarshalAs(UnmanagedType.LPStr)]
string callerIdName,
@@ -61,6 +84,8 @@
string rdnis,
[MarshalAs(UnmanagedType.LPStr)]
string source,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string context,
[MarshalAs(UnmanagedType.LPStr)]
string destinationNumber);
}
Modified: freeswitch/branches/james/src/dotnet/Switch/Channel.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Switch/Channel.cs (original)
+++ freeswitch/branches/james/src/dotnet/Switch/Channel.cs Sat Aug 12 00:43:19 2006
@@ -40,42 +40,56 @@
public partial class Switch
{
[DllImport("freeswitch")]
- extern public static
+ public extern static
ChannelState switch_channel_set_state(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
Channel channel,
ChannelState channelState);
[DllImport("freeswitch")]
- extern public static
+ public extern static
ChannelState switch_channel_get_state(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
Channel channel);
[DllImport("freeswitch")]
- extern public static
+ public extern static
Status switch_channel_answer(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
Channel channel);
[DllImport("freeswitch")]
- extern public static
+ public extern static
Status switch_channel_hangup(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
Channel channel);
[DllImport("freeswitch")]
[return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerExtensionMarshaler))]
- extern public static
+ public extern static
CallerExtension switch_channel_get_caller_extension(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
Channel channel);
[DllImport("freeswitch")]
- [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
+ [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))]
public extern static
CallerProfile switch_channel_get_caller_profile(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))]
+ Channel channel);
+
+ [DllImport("freeswitch")]
+ [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(CallerProfileMarshaler))]
+ public extern static
+ CallerProfile switch_channel_get_originator_caller_profile(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(ChannelMarshaler))]
+ Channel channel);
+
+ [DllImport("freeswitch")]
+ [return: MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CallerProfileMarshaler))]
+ public extern static
+ CallerProfile switch_channel_get_originatee_caller_profile(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ChannelMarshaler))]
Channel channel);
[DllImport("freeswitch")]
Modified: freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs (original)
+++ freeswitch/branches/james/src/dotnet/Switch/LoadableModule.cs Sat Aug 12 00:43:19 2006
@@ -61,8 +61,11 @@
Status
switch_loadable_module_build_dynamic(
string filename,
- ModuleLoadMarshal switch_module_load,
- ModuleRuntimeMarshal switch_module_runtime,
- ModuleShutdownMarshal switch_module_shutdown);
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ ModuleLoad switch_module_load,
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ ModuleRuntime switch_module_runtime,
+ [MarshalAs(UnmanagedType.FunctionPtr)]
+ ModuleShutdown switch_module_shutdown);
}
}
Added: freeswitch/branches/james/src/dotnet/Switch/StreamHandle.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/dotnet/Switch/StreamHandle.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,61 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * LoadableModule.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using Freeswitch.Types;
+using Freeswitch.Marshaling.Types;
+
+namespace Freeswitch
+{
+ /*
+ * SWITCH_DECLARE(switch_status_t) switch_loadable_module_load_module(char *dir, char *fname)
+ * SWITCH_DECLARE(switch_status_t) switch_loadable_module_build_dynamic(char *filename,
+ * SWITCH_DECLARE(switch_status_t) switch_loadable_module_init()
+ * SWITCH_DECLARE(void) switch_loadable_module_shutdown(void)
+ * SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoint_interface(char *name)
+ * SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(char *name)
+ * SWITCH_DECLARE(switch_dialplan_interface_t *) switch_loadable_module_get_dialplan_interface(char *name)
+ * SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_interface(char *name)
+ * SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(char *name)
+ * SWITCH_DECLARE(switch_api_interface_t *) switch_loadable_module_get_api_interface(char *name)
+ * SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interface(char *name)
+ * SWITCH_DECLARE(switch_speech_interface_t *) switch_loadable_module_get_speech_interface(char *name)
+ * SWITCH_DECLARE(switch_directory_interface_t *) switch_loadable_module_get_directory_interface(char *name)
+ * SWITCH_DECLARE(int) switch_loadable_module_get_codecs(switch_memory_pool_t *pool, switch_codec_interface_t **array,
+ * SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(switch_codec_interface_t **array,
+ * SWITCH_DECLARE(switch_status_t) switch_api_execute(char *cmd, char *arg, char *retbuf, switch_size_t len)
+ */
+ public partial class Switch
+ {
+
+ }
+}
Modified: freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/ApiFunction.cs Sat Aug 12 00:43:19 2006
@@ -28,10 +28,4 @@
*
* ApiFunction.cs --
*
- */
-using System;
-
-namespace Freeswitch.Types
-{
- public delegate string ApiFunction(string command);
-}
+ */
\ No newline at end of file
Modified: freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/ApplicationFunction.cs Sat Aug 12 00:43:19 2006
@@ -33,5 +33,5 @@
namespace Freeswitch.Types
{
- public delegate void ApplicationFunction(CoreSession coreSession, string data);
+
}
Modified: freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/ApplicationInterface.cs Sat Aug 12 00:43:19 2006
@@ -36,6 +36,7 @@
namespace Freeswitch.Types
{
+ /*
public class ApplicationInterface
{
private string interface_name;
@@ -45,4 +46,5 @@
private string syntax;
//const struct switch_application_interface *next;
}
+ * */
}
Modified: freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/CallerExtension.cs Sat Aug 12 00:43:19 2006
@@ -31,6 +31,7 @@
*/
using System;
using System.Runtime.InteropServices;
+using Freeswitch.Marshaling.Types;
namespace Freeswitch.Types
{
@@ -40,12 +41,22 @@
public string ExtensionName
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ CallerExtensionMarshal callerExtension = (CallerExtensionMarshal)marshaledObject.Wrapper;
+
+ return Marshal.PtrToStringAnsi(callerExtension.extension_name);
+ }
}
public string ExtensionNumber
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ CallerExtensionMarshal callerExtension = (CallerExtensionMarshal)marshaledObject.Wrapper;
+
+ return Marshal.PtrToStringAnsi(callerExtension.extension_number);
+ }
}
}
}
Modified: freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/CallerProfile.cs Sat Aug 12 00:43:19 2006
@@ -39,11 +39,8 @@
{
internal HandleRef marshaledObject;
- public CallerProfile()
- {
- }
-
- public CallerProfile(CoreSession session,
+ public static CallerProfile New(MemoryPool pool,
+ string username,
string dialplan,
string callerIdName,
string callerIdNumber,
@@ -52,105 +49,91 @@
string ani2,
string rdnis,
string source,
+ string context,
string destinationNumber)
{
- MemoryPool pool = session.Pool;
+ return Switch.switch_caller_profile_new(pool, username, dialplan, callerIdName, callerIdNumber, networkAddress, ani, ani2, rdnis, source, context, destinationNumber);
+ }
+
+ public string GetFieldByName(string field)
+ {
+ IntPtr ptr;
- CallerProfile profile = Switch.switch_caller_profile_new(pool, dialplan, callerIdName, callerIdNumber, networkAddress, ani, ani2, rdnis, source, destinationNumber);
+ ptr = Switch.switch_caller_get_field_by_name(this, field);
- marshaledObject = profile.marshaledObject;
+ if (ptr != IntPtr.Zero)
+ return Marshal.PtrToStringAnsi(ptr);
+ else
+ return "";
}
-
+
+ /*
+ * Properties
+ */
public string Dialplan
{
- set { throw new NotImplementedException(); }
- get
- {
- CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper;
-
- return Marshal.PtrToStringAnsi(profile.dialplan);
- }
+ get { return GetFieldByName("dialplan"); }
}
public string CallerIdName
{
- set
- {
- throw new NotImplementedException();
- }
- get
- {
- CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper;
-
- return Marshal.PtrToStringAnsi(profile.caller_id_name);
- }
+ get { return GetFieldByName("caller_id_name"); }
}
public string CallerIdNumber
{
- set
- {
- throw new NotImplementedException();
- }
- get
- {
- CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper;
-
- return Marshal.PtrToStringAnsi(profile.caller_id_number);
- }
+ get { return GetFieldByName("caller_id_number"); }
}
public string NetworkAddress
{
- set { throw new NotImplementedException(); }
- get
- {
- CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper;
-
- return Marshal.PtrToStringAnsi(profile.network_addr);
- }
+ get { return GetFieldByName("network_addr"); }
}
public string Ani
{
- set { throw new NotImplementedException(); }
- get { throw new NotImplementedException(); }
+ get { return GetFieldByName("ani"); }
}
public string Ani2
{
- set { throw new NotImplementedException(); }
- get { throw new NotImplementedException(); }
+ get { return GetFieldByName("ani2"); }
}
public string Rdnis
{
- set { throw new NotImplementedException(); }
- get
- {
- CallerProfileMarshal profile = (CallerProfileMarshal)marshaledObject.Wrapper;
+ get { return GetFieldByName("rdnis"); }
+ }
- return Marshal.PtrToStringAnsi(profile.rdnis);
- }
+ public string Source
+ {
+ get { return GetFieldByName("source"); }
}
+ public string Context
+ {
+ get { return GetFieldByName("context"); }
+ }
+
public string DestinationNumber
{
- set { throw new NotImplementedException(); }
- get { throw new NotImplementedException(); }
+ get { return GetFieldByName("destination_number"); }
}
public string ChannelName
{
- set { throw new NotImplementedException(); }
- get { throw new NotImplementedException(); }
+ get { return GetFieldByName("chan_name"); }
}
public string Uuid
{
- set { throw new NotImplementedException(); }
- get { throw new NotImplementedException(); }
+ get{ return GetFieldByName("uuid"); }
+ }
+
+ public string Username
+ {
+ get { return GetFieldByName("username"); }
}
}
}
Modified: freeswitch/branches/james/src/dotnet/Types/Channel.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/Channel.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/Channel.cs Sat Aug 12 00:43:19 2006
@@ -35,6 +35,31 @@
namespace Freeswitch.Types
{
+ /*
+ * char *name;
+ switch_buffer_t *dtmf_buffer;
+ switch_mutex_t *dtmf_mutex;
+ switch_mutex_t *flag_mutex;
+ switch_mutex_t *profile_mutex;
+ switch_core_session_t *session;
+ switch_channel_state_t state;
+ uint32_t flags;
+ switch_caller_profile_t *caller_profile;
+ switch_caller_profile_t *originator_caller_profile;
+ switch_caller_profile_t *originatee_caller_profile;
+ switch_caller_extension_t *caller_extension;
+ const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
+ int state_handler_index;
+ switch_hash_t *variables;
+ switch_channel_timetable_t *times;
+ void *private_info;
+ switch_call_cause_t hangup_cause;
+ int freq;
+ int bits;
+ int channels;
+ int ms;
+ int kbps;
+ */
public class Channel
{
internal HandleRef marshaledObject;
@@ -43,7 +68,7 @@
{
get
{
- ChannelMarshal channel = (ChannelMarshal)marshaledObject.Wrapper;
+ ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper;
return Marshal.PtrToStringAnsi(channel.name);
}
@@ -51,7 +76,12 @@
public Buffer DtmfBuffer
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ Console.WriteLine("Buffer");
+ return new Buffer();
+ //throw new NotImplementedException();
+ }
}
public ChannelState State
@@ -81,7 +111,12 @@
public ChannelFlag Flags
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ Console.WriteLine("ChannelFlag");
+ return new ChannelFlag();
+ //throw new NotImplementedException();
+ }
}
public CallerProfile CallerProfile
@@ -94,48 +129,82 @@
public CallerProfile OriginatorCallerProfile
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ return Switch.switch_channel_get_originator_caller_profile(this);
+ }
}
public CallerProfile OriginateeCallerProfile
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ return Switch.switch_channel_get_originatee_caller_profile(this);
+ }
}
public CallerExtension CallerExtension
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ return Switch.switch_channel_get_caller_extension(this);
+ }
}
public ChannelTimetable Times
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ Console.WriteLine("Channel Timetable");
+ return new ChannelTimetable();
+ // throw new NotImplementedException();
+ }
}
public int Freq
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper;
+
+ return channel.freq;
+ }
}
public int Bits
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper;
+
+ return channel.bits;
+ }
}
public int Channels
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper;
+
+ return channel.channels;
+ }
}
public int Ms
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper;
+
+ return channel.ms;
+ }
}
public int Kbps
{
get {
- ChannelMarshal channel = (ChannelMarshal)marshaledObject.Wrapper;
+ ChannelMarshal channel = (ChannelMarshal) marshaledObject.Wrapper;
return channel.kbps;
}
Modified: freeswitch/branches/james/src/dotnet/Types/CoreSession.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/CoreSession.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/CoreSession.cs Sat Aug 12 00:43:19 2006
@@ -37,25 +37,95 @@
namespace Freeswitch.Types
{
+ /*
+ * uint32_t id;
+ char name[80];
+ int thread_running;
+ switch_memory_pool_t *pool;
+ switch_channel_t *channel;
+ switch_thread_t *thread;
+ const switch_endpoint_interface_t *endpoint_interface;
+ switch_io_event_hooks_t event_hooks;
+ switch_codec_t *read_codec;
+ switch_codec_t *write_codec;
+
+ switch_buffer_t *raw_write_buffer;
+ switch_frame_t raw_write_frame;
+ switch_frame_t enc_write_frame;
+ uint8_t raw_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
+ uint8_t enc_write_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
+
+ switch_buffer_t *raw_read_buffer;
+ switch_frame_t raw_read_frame;
+ switch_frame_t enc_read_frame;
+ uint8_t raw_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
+ uint8_t enc_read_buf[SWITCH_RECCOMMENDED_BUFFER_SIZE];
+
+
+ switch_audio_resampler_t *read_resampler;
+ switch_audio_resampler_t *write_resampler;
+
+ switch_mutex_t *mutex;
+ switch_thread_cond_t *cond;
+
+ switch_thread_rwlock_t *rwlock;
+
+ void *streams[SWITCH_MAX_STREAMS];
+ int stream_count;
+
+ char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
+ void *private_info;
+ switch_queue_t *event_queue;
+ */
public class CoreSession
{
public HandleRef marshaledObject;
- public ulong Id
+ /*
+ * Properties
+ */
+ public UInt32 Id
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper;
+
+ return coreSessionMarshal.id;
+ }
}
public string Name
{
- get { throw new NotImplementedException(); }
+ get
+ {
+ CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal) marshaledObject.Wrapper;
+
+ return Encoding.ASCII.GetString(coreSessionMarshal.name);
+ }
}
- public int IsThreadRunning
+ public bool IsThreadRunning
{
- get { throw new NotImplementedException(); ; }
+ get
+ {
+ CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper;
+
+ if (coreSessionMarshal.thread_running <= 0)
+ return false;
+ else
+ return true;
+ }
}
+ public MemoryPool Pool
+ {
+ get
+ {
+ return Switch.switch_core_session_get_pool(this);
+ }
+ }
+
+
public Channel Channel
{
get
@@ -64,13 +134,16 @@
}
}
- public MemoryPool Pool
+ public string Uuid
{
get
{
- return Switch.switch_core_session_get_pool(this);
+ CoreSessionMarshal coreSessionMarshal = (CoreSessionMarshal)marshaledObject.Wrapper;
+
+ return Encoding.ASCII.GetString(coreSessionMarshal.uuid_str);
}
}
+
public CoreSession OutgoingChannel(string endpointName, CallerProfile callerProfile)
{
Modified: freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs
==============================================================================
--- freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs (original)
+++ freeswitch/branches/james/src/dotnet/Types/LoadableModuleInterface.cs Sat Aug 12 00:43:19 2006
@@ -33,10 +33,17 @@
using System.Collections;
using System.Runtime.InteropServices;
using System.Text;
+using Freeswitch.Marshaling;
namespace Freeswitch.Types
{
- public delegate void ModuleLoad();
+ public delegate Status WriteFunction(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StreamHandleMarshaler))]
+ StreamHandle streamHandle,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string fmt);
+
+ //public delegate void ModuleLoad();
public class LoadableModuleInterface
{
Added: freeswitch/branches/james/src/dotnet/Types/Module.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/dotnet/Types/Module.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,59 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * Module.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using Freeswitch.Marshaling;
+
+namespace Freeswitch.Types
+{
+ public delegate Status ModuleReload();
+ public delegate bool ModulePause();
+ public delegate bool ModuleResume();
+ public delegate bool ModuleStatus();
+ public delegate Status ModuleRuntime();
+ public delegate bool ModuleShutdown();
+ public delegate Status ModuleLoad(ref IntPtr module, string name);
+
+ public delegate void
+ ApplicationFunction(
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoreSessionMarshaler))]
+ CoreSession session,
+ [MarshalAs(UnmanagedType.LPStr)]
+ string data);
+
+ public delegate Status
+ ApiFunction(
+ [MarshalAs(UnmanagedType.LPStr)]
+ string command,
+ [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(StreamHandleMarshaler))]
+ StreamHandle streamHandle);
+}
Added: freeswitch/branches/james/src/dotnet/Types/ModuleInterfaces.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/dotnet/Types/ModuleInterfaces.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,69 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * ApplicationInterface.cs --
+ *
+ */
+using System;
+using System.Collections;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Freeswitch.Types
+{
+ /*
+ public class ApplicationInterface
+ {
+ private string interface_name;
+ private ApplicationFunction application_function;
+ private string long_desc;
+ private string short_desc;
+ private string syntax;
+ //const struct switch_application_interface *next;
+
+ public string InterfaceName
+ {
+ get { return interface_name; }
+ }
+
+ public ApplicationFunction ApplicationFunction
+ {
+ get { return application_function; }
+ }
+
+ public string LongDesc
+ {
+ get { return long_desc; }
+ }
+
+ public string ShortDesc
+ {
+ get { return short_desc; }
+ }
+ }*/
+}
Added: freeswitch/branches/james/src/dotnet/Types/StreamHandle.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/dotnet/Types/StreamHandle.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,59 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2006, James Martelletti <james(a)nerdc0re.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * James Martelletti <james(a)nerdc0re.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * James Martelletti <james(a)nerdc0re.com>
+ *
+ *
+ * StreamHandle.cs --
+ *
+ */
+using System;
+using System.Runtime.InteropServices;
+using Freeswitch.Marshaling.Types;
+
+namespace Freeswitch.Types
+{
+ public class StreamHandle
+ {
+ internal HandleRef marshaledObject;
+ internal WriteFunction writeFunction;
+ //internal WriteFunctions; //switch_stream_handle_write_function_t write_function;
+ /*
+ * internal
+ void *data;
+ void *end;
+ switch_size_t data_size;
+ switch_size_t data_len;
+ switch_event_t *event;
+ */
+ public void Write(string data)
+ {
+ StreamHandleMarshal streamHandleMarshal = (StreamHandleMarshal) marshaledObject.Wrapper;
+ WriteFunction writeFunction = (WriteFunction) Marshal.GetDelegateForFunctionPointer(streamHandleMarshal.write_function, typeof(WriteFunction));
+
+ writeFunction(this, data);
+ }
+ }
+}
Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/mod/dotnet/Info/Info.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,124 @@
+using System;
+using System.Text;
+using Freeswitch;
+using Freeswitch.Modules;
+using Freeswitch.Types;
+
+namespace Info
+{
+ public class Info : Module
+ {
+ public Info()
+ {
+ Console.WriteLine("Running INFO ctor");
+
+ AddApiInterface(new InfoApi());
+ AddApplicationInterface(new InfoApplication());
+
+ Register();
+ }
+
+ }
+
+ public class InfoApplication : Application
+ {
+ public InfoApplication()
+ {
+ Name = "dotnetbridge";
+ Syntax = "record /file/name";
+ ShortDescription = "short description";
+ LongDescription = "long description, long description, long description";
+ ApplicationFunction = new ApplicationFunction(BridgeApplicationFunction);
+ }
+
+ public Status OnDtmf(CoreSession session, string dtmf)
+ {
+
+ Console.WriteLine("Digits: {0}", dtmf);
+
+ return Status.Success;
+ }
+
+ public void BridgeApplicationFunction(CoreSession coreSession, string data)
+ {
+ Console.WriteLine("%%% Processing new call");
+ Console.WriteLine("%%% Data: {0}", data);
+ Common.DumpProperties("coreSession", coreSession);
+ Common.DumpProperties("coreSession.Channel", coreSession.Channel);
+
+ Common.DumpProperties("coreSession.Channel.CallerExtension", coreSession.Channel.CallerExtension);
+ Common.DumpProperties("coreSession.Channel.CallerProfile", coreSession.Channel.CallerProfile);
+ //Console.WriteLine("%%% Name: {0}", coreSession.Name);
+ //Console.WriteLine("%%% Name: {0}", coreSession.Name);
+ //Console.WriteLine("%%% Name: {0}", coreSession.Name);
+ //Console.WriteLine("%%% Name: {0}", coreSession.Name);
+
+
+ CoreSession peerSession;
+ Channel callerChannel = coreSession.Channel;
+
+ CallerProfile callerProfile;
+ CallerProfile callerCallerProfile = callerChannel.CallerProfile;
+
+ string chanType = "exosip";
+ string chanData = "666(a)10.0.0.60";
+ uint timelimit = 60;
+
+ Console.WriteLine(callerCallerProfile.Dialplan);
+ Console.WriteLine(callerCallerProfile.CallerIdName);
+ Console.WriteLine(callerCallerProfile.CallerIdNumber);
+ Console.WriteLine(callerCallerProfile.NetworkAddress);
+
+ try
+ {
+ callerProfile = CallerProfile.New(coreSession.Pool,
+ callerCallerProfile.Username,
+ callerCallerProfile.Dialplan,
+ callerCallerProfile.CallerIdName,
+ callerCallerProfile.CallerIdNumber,
+ callerCallerProfile.NetworkAddress,
+ "ani",
+ "ani2",
+ callerCallerProfile.Rdnis,
+ callerCallerProfile.Source,
+ callerCallerProfile.Context,
+ chanData);
+
+ Console.WriteLine(callerProfile.Dialplan);
+ Console.WriteLine(callerProfile.CallerIdName);
+ Console.WriteLine(callerProfile.CallerIdNumber);
+ Console.WriteLine(callerProfile.NetworkAddress);
+
+ peerSession = coreSession.OutgoingChannel(chanType, callerProfile);
+
+ Console.WriteLine("Peer Channel Name: " + peerSession.Channel.Name);
+
+ }
+ catch (Exception e)
+ {
+ callerChannel.Hangup();
+ return;
+ }
+
+ Ivr.MultiThreadedBridge(coreSession, peerSession, timelimit);
+
+ }
+ }
+
+ public class InfoApi : Api
+ {
+ public InfoApi()
+ {
+ Name = "info";
+ Description = "blah blah blah";
+ ApiFunction = new ApiFunction(InfoApiFunction);
+ }
+
+ public Status InfoApiFunction(string command, StreamHandle streamHandle)
+ {
+ streamHandle.Write("It is " + DateTime.Now.ToLongTimeString());
+
+ return Status.Success;
+ }
+ }
+}
Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.csproj
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/mod/dotnet/Info/Info.csproj Sat Aug 12 00:43:19 2006
@@ -0,0 +1,53 @@
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.50727</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{B8A7E58B-2480-4A56-B39B-5FF9698A7124}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Info</RootNamespace>
+ <AssemblyName>Info</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Info.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\..\dotnet\FreeSwitchDotNet.csproj">
+ <Project>{251CAABC-16C3-4593-A491-603B908094E0}</Project>
+ <Name>FreeSwitch</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
\ No newline at end of file
Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.dll
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/Info.suo
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/Makefile
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/mod/dotnet/Info/Makefile Sat Aug 12 00:43:19 2006
@@ -0,0 +1,10 @@
+all: Info.so
+
+Info.so:
+ gmcs -t:library -r:../../../dotnet/Freeswitch.dll -out:Info.dll Properties/AssemblyInfo.cs Info.cs
+
+clean:
+ rm -fr *.dll
+
+install:
+ cp -f Info.dll /usr/local/freeswitch/mod/mono
Added: freeswitch/branches/james/src/mod/dotnet/Info/Properties/AssemblyInfo.cs
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/mod/dotnet/Info/Properties/AssemblyInfo.cs Sat Aug 12 00:43:19 2006
@@ -0,0 +1,35 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Info")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Info")]
+[assembly: AssemblyCopyright("Copyright © 2006")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("92e4523b-8d54-4152-bb7b-fedb39ea4a5a")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.dll
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Freeswitch.pdb
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.dll
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/bin/Debug/Info.pdb
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/Info.dll
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/obj/Debug/ResolveAssemblyReference.cache
==============================================================================
Binary file. No diff available.
Added: freeswitch/branches/james/src/mod/dotnet/Info/obj/Info.csproj.FileList.txt
==============================================================================
--- (empty file)
+++ freeswitch/branches/james/src/mod/dotnet/Info/obj/Info.csproj.FileList.txt Sat Aug 12 00:43:19 2006
@@ -0,0 +1,7 @@
+obj\Debug\ResolveAssemblyReference.cache
+bin\Debug\Info.dll
+bin\Debug\Info.pdb
+bin\Debug\FreeSwitch.dll
+bin\Debug\FreeSwitch.pdb
+obj\Debug\Info.dll
+obj\Debug\Info.pdb
Modified: freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c
==============================================================================
--- freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c (original)
+++ freeswitch/branches/james/src/mod/languages/mod_mono/mod_mono.c Sat Aug 12 00:43:19 2006
@@ -42,37 +42,10 @@
#define SWITCH_MONO_MODULES "/usr/local/freeswitch/mod/mono"
#define SWITCH_MONO_ASSEMBLY "Freeswitch.dll"
-/*
-typedef switch_status (*switch_module_load_t) (switch_loadable_module_interface **, char *);
-typedef switch_status (*switch_module_reload_t) (void);
-typedef switch_status (*switch_module_pause_t) (void);
-typedef switch_status (*switch_module_resume_t) (void);
-typedef switch_status (*switch_module_status_t) (void);
-typedef switch_status (*switch_module_runtime_t) (void);
-typedef switch_status (*switch_module_shutdown_t) (void);
-*/
-
-SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
-switch_status_t mod_mono_check_api(MonoImage *image);
-switch_status_t mod_mono_load_managed();
switch_status_t mod_mono_load_plugins();
-//SWITCH_MOD_DECLARE(switch_status_t) mod_mono_api_function(char *in, char *out, size_t outlen);
void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg);
-SWITCH_DECLARE(void) event_handler(switch_event_t *event);
MonoClass* find_assembly_class(MonoImage *image);
-static void mod_mono_application_function(switch_core_session_t *session, char *data);
-/*
-const char *mod_mono_public_key = "\x00\x24\x00\x00\x04\x80\x00\x00\x94\x00\x00\x00\x06\x02\x00\x00"
- "\x00\x24\x00\x00\x52\x53\x41\x31\x00\x04\x00\x00\x11\x00\x00\x00"
- "\x25\x45\x19\xB7\xFF\xB9\x3A\x67\xDD\x9E\x39\x0D\x29\xEF\x31\xAD"
- "\x30\x77\xE3\x01\xAF\x28\x2C\xAC\x7A\x09\x34\xDF\x39\x4C\x9A\x26"
- "\xF8\x5A\x84\xF8\x88\x53\x00\x5A\x94\xC9\x65\x82\x2A\xF3\x40\x4B"
- "\x0F\x82\xA1\xB9\x61\x52\xFE\x23\x2E\xAC\xE9\x71\x97\xC4\xFE\xA7"
- "\x11\x17\xCE\x69\x05\xB1\xB7\xD0\xE2\xAE\x8A\xAF\x96\x1A\x58\x91"
- "\x84\x1D\x7C\x2F\x26\x6E\x31\x84\x38\xD8\xC8\xD5\xE9\xE5\x4A\xC0"
- "\x0F\x6B\x4A\x57\x4F\xA2\xFC\x13\x7A\x8E\xB6\x3A\xA4\xC1\xE5\xC2"
- "\xAD\x17\xA5\xFF\xBC\xE1\x35\x4F\x7F\x83\x48\x2A\x2E\x15\x83\xB3";
-*/
+
static const char modname[] = "mod_mono";
switch_memory_pool_t *mono_pool;
@@ -94,18 +67,9 @@
MonoClass *class;
MonoObject *object;
} mono_plugin;
-static const switch_application_interface_t mono_application_interface = {
- /*.interface_name */ "mod_mono",
- /*.application_function */ mod_mono_application_function
-};
static switch_loadable_module_interface_t mono_module_interface = {
/*.module_name */ modname,
- /*.endpoint_interface */ NULL,
- /*.timer_interface */ NULL,
- /*.dialplan_interface */ NULL,
- /*.codec_interface */ NULL,
- /*.application_interface */ &mono_application_interface,
};
void mono_switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, char *msg)
@@ -113,47 +77,7 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
}
-static void mod_mono_application_function(switch_core_session_t *session, char *data)
-{
- MonoObject *exception;
- MonoString *string;
- void *params[2];
-
- mono_thread_attach(globals.domain);
-
- params[0] = &session;
- params[1] = &data;
- string = (MonoString *)mono_runtime_invoke(globals.application, globals.object, params, &exception);
-
- if (exception)
- mono_print_unhandled_exception(exception);
-}
/*
-SWITCH_MOD_DECLARE(switch_status_t) mod_mono_api_function(char *in, char *out, size_t outlen)
-{
- MonoObject *exception;
- MonoString *string;
- void *params[3];
-
- mono_thread_attach(globals.domain);
-
- params[0] = ∈
- params[1] = &out;
- params[2] = &outlen;
- string = (MonoString *)mono_runtime_invoke(globals.api, globals.object, params, &exception);
-
- if (exception)
- {
- mono_print_unhandled_exception(exception);
- return SWITCH_STATUS_FALSE;
- }
-
- switch_copy_string(out, mono_string_to_utf8(string), outlen);
-
- return SWITCH_STATUS_SUCCESS;
-}
-*/
-/*
* Load mod_mono module and initialise domain
*
* This function will initialise the memory pool and plugin hash for this module,
@@ -184,12 +108,6 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Initialised mono runtime.\n");
-
- /* Load our core assembly */
- if (mod_mono_load_managed() != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Error loading our core assembly.\n");
- return SWITCH_STATUS_FALSE;
- }
/* Load our plugins */
if (mod_mono_load_plugins() != SWITCH_STATUS_SUCCESS) {
@@ -197,9 +115,6 @@
return SWITCH_STATUS_FALSE;
}
- /* Start our core assembly */
- //mono_runtime_object_init(globals.object);
-
for (plugin = switch_hash_first(mono_pool, mono_plugins); plugin; plugin = switch_hash_next(plugin)) {
mono_plugin *p = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*p));
apr_ssize_t *key_length = NULL;
@@ -233,86 +148,6 @@
/*
* This function will load the managed portion of mod_mono.
*/
-switch_status_t mod_mono_load_managed()
-{
-// MonoAssembly *assembly;
-// MonoImage *image;
-// MonoMethod *method;
-// gpointer iter = NULL;
-// int len;
-// char *file;
-
- /* Construct the file path and name for FreeSwitch.dll */
-// len = strlen(SWITCH_MONO_MODULES) + strlen(SWITCH_MONO_ASSEMBLY) + 2;
-// file = (char *)switch_core_alloc(mono_pool, len);
-// snprintf(file, len, "%s/%s", SWITCH_MONO_MODULES, SWITCH_MONO_ASSEMBLY);
-
- /* Attempt to open FreeSwitch.dll */
-// assembly = mono_domain_assembly_open(globals.domain, file);
-
-// if (!assembly) {
-// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not locate managed library (Freeswitch.dll)\n");
-// return SWITCH_STATUS_FALSE;
-// }
-
- /* Get the image for our core assembly */
-// image = mono_assembly_get_image(assembly);
-
- /* Check that the assembly is our core */
-// if (mod_mono_check_api(image) != SWITCH_STATUS_SUCCESS)
-// {
-// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Freeswitch.dll is an invalid assembly.\n");
-// return SWITCH_STATUS_FALSE;
-// }
-
-// globals.assembly = assembly;
-// globals.image = image;
-
-// globals.class = mono_class_from_name(globals.image, "Freeswitch", "Core");
-// if (!globals.class)
-// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not create object from class.\n");
-
-// globals.object = mono_object_new(globals.domain, globals.class);
-// mono_runtime_object_init(globals.object);
-
-// while ((method = mono_class_get_methods(globals.class, &iter))) {
-// if (!strcmp(mono_method_get_name(method), "Event")) {
-// globals.event = method;
-
-// if (switch_event_bind((char *) modname, SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
-// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Could not bind events.\n");
-// return SWITCH_STATUS_FALSE;
-// }
-// }
-// if (!strcmp(mono_method_get_name(method), "Api")) {
-// globals.api = method;
-// }
-// if (!strcmp(mono_method_get_name(method), "Application")) {
-// globals.application = method;
-// }
-// }
- return SWITCH_STATUS_SUCCESS;
-}
-
-/*
-SWITCH_DECLARE(void) event_handler(switch_event_t *event)
-{
- MonoObject *exception;
- void *params[1];
-
- mono_thread_attach(globals.domain);
-
- params[0] = &event;
- mono_runtime_invoke(globals.event, globals.object, params, &exception);
-*/
- /* Catch any exceptions */
-/* if (exception)
- mono_print_unhandled_exception(exception);
-}
-*/
-/*
- * This function will load the managed portion of mod_mono.
- */
switch_status_t mod_mono_load_plugins()
{
char *file;
@@ -336,10 +171,9 @@
/* Read the modules directory */
while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS)
- {
+ {
assembly = (MonoAssembly *)switch_core_alloc(mono_pool, sizeof(assembly));
image = (MonoImage *)switch_core_alloc(mono_pool, sizeof(image));
- //*image = NULL;
const char *fname = finfo.fname;
if (finfo.filetype != APR_REG)
@@ -368,52 +202,24 @@
/* Get the image from assembly */
image = mono_assembly_get_image(assembly);
+
+ plugin = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*plugin));
- /* Check that the laoded assembly is not our core assembly */
- //if (mod_mono_check_api(image) == SWITCH_STATUS_SUCCESS)
- // continue;
- //else {
- plugin = (mono_plugin *)switch_core_alloc(mono_pool, sizeof(*plugin));
+ plugin->assembly = assembly;
+ plugin->class = find_assembly_class(mono_assembly_get_image(plugin->assembly));
- plugin->assembly = assembly;
-
- plugin->class = find_assembly_class(mono_assembly_get_image(plugin->assembly));
- if (!plugin->class) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No plugin class ;(\n");
- }
+ if (!plugin->class)
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No plugin class\n");
- plugin->object = mono_object_new(globals.domain, plugin->class);
- //mono_runtime_object_init(plugin->object);
+ plugin->object = mono_object_new(globals.domain, plugin->class);
- switch_core_hash_insert(mono_plugins, (char *)mono_image_get_name(mono_assembly_get_image(assembly)), plugin);
+ switch_core_hash_insert(mono_plugins, (char *) mono_image_get_name(mono_assembly_get_image(assembly)), plugin);
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loaded %s [0x%x]I - A:0x%x, C:0x%x, O:0x%x\n",
- // (char *)mono_image_get_name(mono_assembly_get_image(assembly)),
- // plugin, plugin->assembly, plugin->class, plugin->object);
- plugin = NULL;
- //}
+ plugin = NULL;
}
return SWITCH_STATUS_SUCCESS;
}
-/*
- * This function will retrieve the public key from the assembly and check
- * it against the public key defined in this file to ensure that we are
- * loading the correct assembly.
- */
-/*
-switch_status_t mod_mono_check_api(MonoImage *image)
-{
- unsigned int size = 0;
- const char *public_key = mono_image_get_public_key(image, &size);
-
- if (size > 0)
- if (memcmp(public_key, mod_mono_public_key, size) == 0)
- return SWITCH_STATUS_SUCCESS;
-
- return SWITCH_STATUS_FALSE;
-}
-*/
MonoClass* find_assembly_class(MonoImage *image)
{
MonoClass *class, *parent_class = NULL;
1
0
[Freeswitch-branches] [commit] r2265 - freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip
by Freeswitch SVN 11 Aug '06
by Freeswitch SVN 11 Aug '06
11 Aug '06
Author: bennylp
Date: Fri Aug 11 17:19:49 2006
New Revision: 2265
Modified:
freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
Log:
Handle codec nego failure more gracefully
Modified: freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c Fri Aug 11 17:19:49 2006
@@ -1045,6 +1045,25 @@
status = pjsip_inv_answer( tech_pvt->sip_invite, 183, NULL, NULL, &txdata );
pjsip_tx_data_dec_ref(txdata);
+ /* Check that media has been negotiated successfully */
+ if (switch_channel_get_state( channel ) >= CS_HANGUP) {
+ /* Media negotiation failed */
+ status = pjsip_inv_answer(tech_pvt->sip_invite, PJSIP_SC_NOT_ACCEPTABLE, NULL, NULL, &txdata);
+ if (status == PJ_SUCCESS) {
+ status = pjsip_inv_send_msg(tech_pvt->sip_invite, txdata);
+ if (status != PJ_SUCCESS)
+ pjsip_tx_data_dec_ref(txdata);
+ }
+
+ if (status != PJ_SUCCESS) {
+ pjsip_inv_terminate( tech_pvt->sip_invite, PJSIP_SC_NOT_ACCEPTABLE, PJ_FALSE );
+ }
+
+ switch_core_session_destroy( &session );
+ pjsip_dlg_dec_lock(dialog);
+ goto on_return;
+ }
+
/* Send 180 Ring */
status = pjsip_inv_answer( tech_pvt->sip_invite, 180, NULL, NULL, &txdata );
if( status != PJ_SUCCESS ) {
@@ -1059,6 +1078,7 @@
pjsip_inv_terminate( tech_pvt->sip_invite, 500, PJ_FALSE );
switch_core_session_destroy( &session );
+ pjsip_dlg_dec_lock(dialog);
goto on_return;
}
add_server_header(txdata);
@@ -1066,6 +1086,7 @@
if( status != PJ_SUCCESS ) {
perror_(tech_pvt->sip_invite->dlg->obj_name, "pjsip_inv_send_msg error", status);
switch_core_session_destroy( &session );
+ pjsip_dlg_dec_lock(dialog);
goto on_return;
}
@@ -2010,11 +2031,24 @@
+/* PJSIP worker thread */
+static int pjsip_worker_thread(void *arg)
+{
+ while ( globals.running > 0 ) {
+ pj_time_val timeout = { 1, 0 };
+ TRACE_((THIS_FILE, "ENTER pjsip_endpt_handle_events"));
+ pjsip_endpt_handle_events( globals.sip_endpt, &timeout );
+ TRACE_((THIS_FILE, "LEAVE pjsip_endpt_handle_events"));
+ }
+ return 0;
+}
-
SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void)
{
+ enum { WORKER_COUNT=0 };
+ pj_thread_t *worker_threads[16];
+ int i;
switch_hash_index_t *p_entry;
pj_status_t status;
@@ -2180,8 +2214,18 @@
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Monitor thread running\n" );
- /* main loop */
globals.running = 1;
+
+ /* Create PJSIP from worker threads */
+ for (i=0; i<WORKER_COUNT; ++i) {
+ status = pj_thread_create(pjsip_pool, "sip%p", &pjsip_worker_thread, NULL, 0, 0, &worker_threads[i]);
+ if (status != PJ_SUCCESS) {
+ perror_(THIS_FILE, "Unable to create thread!", status);
+ return SWITCH_STATUS_TERM;
+ }
+ }
+
+ /* Another worker */
while ( globals.running > 0 ) {
pj_time_val timeout = { 1, 0 };
TRACE_((THIS_FILE, "ENTER pjsip_endpt_handle_events"));
@@ -2189,6 +2233,12 @@
TRACE_((THIS_FILE, "LEAVE pjsip_endpt_handle_events"));
}
globals.running = 0;
+
+ /* Wait for all worker threads to quit */
+ for (i=0; i<WORKER_COUNT; ++i) {
+ status = pj_thread_join(worker_threads[i]);
+ }
+
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Monitor thread exiting\n" );
1
0
[Freeswitch-branches] [commit] r2264 - freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip
by Freeswitch SVN 11 Aug '06
by Freeswitch SVN 11 Aug '06
11 Aug '06
Author: anthm
Date: Fri Aug 11 16:10:29 2006
New Revision: 2264
Modified:
freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
Log:
add more config options to control debug and rtp-ip
Modified: freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c Fri Aug 11 16:10:29 2006
@@ -74,10 +74,11 @@
pj_sockaddr_in sip_addr;
char *sip_ip;
+ char *rtp_ip;
int sip_port;
/* */
- char name[128];
+ char *name;
char local_addr[128];
char *dialplan;
char *codec_string;
@@ -89,6 +90,7 @@
int flags;
switch_hash_t *call_hash;
+ switch_memory_pool_t *pool;
};
typedef enum {
@@ -1603,7 +1605,7 @@
media->desc.port_count = 1;
media->desc.transport = pj_str( "RTP/AVP" );
- strncpy( tech_pvt->local_sdp_audio_addr, profile->local_addr,
+ strncpy( tech_pvt->local_sdp_audio_addr, profile->rtp_ip,
sizeof(tech_pvt->local_sdp_audio_addr) );
/* codec rtpmap list */
@@ -1768,33 +1770,52 @@
static switch_status_t config_pjsip( void )
{
char *cfgname = MOD_PJSIP_CFG;
- switch_xml_t config, xml, xmlprofile, param;
+ switch_xml_t config, xml, xmlprofile, settings, param;
switch_status_t result = SWITCH_STATUS_SUCCESS;
+
if( !( xml = switch_xml_open_cfg( cfgname, &config, NULL ) )) {
switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open config %s\n", cfgname );
return SWITCH_STATUS_TERM;
}
+
+ if ((settings = switch_xml_child( config, "settings" ))) {
+ for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ char *var = (char *) switch_xml_attr_soft(param, "name");
+ char *val = (char *) switch_xml_attr_soft(param, "value");
+
+ if (!strcasecmp(var, "debug")) {
+ pj_log_set_level(atoi(val));
+ }
+ }
+ }
+
for( xmlprofile = switch_xml_child( config, "profile" ); xmlprofile; xmlprofile = xmlprofile->next )
{
struct pjsip_profile *profile;
char *profile_name = (char *) switch_xml_attr_soft( xmlprofile, "name" );
+ switch_memory_pool_t *pool = NULL;
if( !profile_name ) {
profile_name = "noname";
}
+
+ if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
+ result = SWITCH_STATUS_TERM;
+ goto out;
+ }
- if( !(profile = switch_core_alloc( module_pool, sizeof(struct pjsip_profile))) ) {
- switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Failed to allocate new profile %s\n", profile_name );
- result = SWITCH_STATUS_TERM;
+ if( !(profile = switch_core_alloc( pool, sizeof(struct pjsip_profile))) ) {
+ switch_log_printf( SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to allocate new profile %s\n", profile_name );
+ result = SWITCH_STATUS_TERM;
goto out;
}
- memset( profile, 0, sizeof( struct pjsip_profile ) );
+
+ profile->pool = pool;
+ profile->name = switch_core_strdup(pool, profile_name);
- switch_copy_string( profile->name, profile_name, sizeof( profile->name ) );
-
profile->sip_addr.sin_family = PJ_AF_INET;
profile->sip_addr.sin_port = pj_htons( DEFAULT_PORT );
@@ -1806,7 +1827,9 @@
if ( !strcmp( var, "max-calls" ) ) {
profile->max_calls = atoi( val );
}
- else if ( !strcmp( var, "ip" ) ) {
+ else if ( !strcmp( var, "rtp-ip" ) ) {
+ profile->rtp_ip = switch_core_strdup(profile->pool, val);
+ } else if ( !strcmp( var, "ip" ) ) {
pj_str_t tmp;
if( !pj_inet_aton( pj_cstr( &tmp, val ), &profile->sip_addr.sin_addr ) ) {
@@ -2003,7 +2026,7 @@
}
pj_log_set_log_func(log_func);
- pj_log_set_level(4);
+ pj_log_set_level(0);
/* next: pjlib_util */
status = pjlib_util_init();
1
0
[Freeswitch-branches] [commit] r2262 - freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip
by Freeswitch SVN 11 Aug '06
by Freeswitch SVN 11 Aug '06
11 Aug '06
Author: bennylp
Date: Fri Aug 11 14:49:23 2006
New Revision: 2262
Modified:
freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
Log:
Fixed destination number unset in mod_pjsip
Modified: freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c
==============================================================================
--- freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c (original)
+++ freeswitch/branches/bennylp/src/mod/endpoints/mod_pjsip/mod_pjsip.c Fri Aug 11 14:49:23 2006
@@ -963,8 +963,9 @@
if (PJSIP_URI_SCHEME_IS_SIP(rxdata->msg_info.to->uri)) {
pjsip_sip_uri *sip_uri;
- sip_uri = pjsip_uri_get_uri(rxdata->msg_info.from->uri);
+ sip_uri = pjsip_uri_get_uri(rxdata->msg_info.to->uri);
pj_strdup_with_null( dialog->pool, &destination, &sip_uri->user);
+ PJ_LOG(3,(dialog->obj_name, "Destination set to %s", destination.ptr));
} else {
destination = pj_str("unknown");
}
@@ -994,7 +995,8 @@
/* Send 100 Trying */
status = pjsip_inv_initial_answer( tech_pvt->sip_invite, rxdata, 100, NULL, NULL, &txdata );
if( status != PJ_SUCCESS ) {
- perror_(tech_pvt->sip_invite->dlg->obj_name, "Error in pjsip_inv_initial_answer", status);
+ perror_(tech_pvt->sip_invite->dlg->obj_name,
+ "Error in pjsip_inv_initial_answer", status);
pjsip_dlg_respond(dialog, rxdata, 500, NULL, NULL, NULL);
pjsip_inv_terminate(tech_pvt->sip_invite, 500, PJ_FALSE);
1
0