[Freeswitch-branches] [commit] r10312 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Mon Nov 10 04:43:38 PST 2008
Author: gmaruzz
Date: Mon Nov 10 07:43:38 2008
New Revision: 10312
Log:
skypiax: answers an incoming call, goes to the dialplan extension, but do not read or write audio frames
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Mon Nov 10 07:43:38 2008
@@ -125,21 +125,6 @@
switch_mutex_t *mutex;
} globals;
-struct private_object {
- unsigned int flags;
- switch_codec_t read_codec;
- switch_codec_t write_codec;
- switch_frame_t read_frame;
- unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
- switch_core_session_t *session;
- switch_caller_profile_t *caller_profile;
- switch_mutex_t *mutex;
- switch_mutex_t *flag_mutex;
- //switch_thread_cond_t *cond;
-};
-
-typedef struct private_object private_t;
-
struct skypiax_config {
char span_id[80];
char name[80];
@@ -195,6 +180,23 @@
static skypiax_config_t SKYPIAX_CONFIGS[SKYPIAX_MAX_INTERFACES];
+struct private_object {
+ unsigned int flags;
+ switch_codec_t read_codec;
+ switch_codec_t write_codec;
+ switch_frame_t read_frame;
+ unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_core_session_t *session;
+ switch_caller_profile_t *caller_profile;
+ switch_mutex_t *mutex;
+ switch_mutex_t *flag_mutex;
+ skypiax_config_t *p;
+ //switch_thread_cond_t *cond;
+};
+
+typedef struct private_object private_t;
+
+
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
@@ -270,7 +272,7 @@
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
while (1) {
len = recv(fd, in, sizeof(short) * GG, 0);
- DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
+ //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
if (len > 0) {
a = 0;
for (i = 0; i < len / sizeof(short); i++) {
@@ -362,7 +364,7 @@
while (1) {
got = read(p->audioskypepipe[0], in, (NN / 2) * sizeof(short));
- ERRORA("got %d\n", SKYPIAX_P_LOG, got);
+ //ERRORA("got %d\n", SKYPIAX_P_LOG, got);
if (got > 0) {
a = 0;
@@ -504,9 +506,9 @@
#endif //NOTDEF
#endif /* SKYPE_AUDIO */
-static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
+static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_config_t *p)
{
- struct skypiax_config *p = NULL;
+ //struct skypiax_config *p = NULL;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
tech_pvt->read_frame.data = tech_pvt->databuf;
@@ -515,6 +517,8 @@
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
switch_core_session_set_private(session, tech_pvt);
tech_pvt->session = session;
+ if(p)
+ tech_pvt->p=p;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -575,7 +579,7 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
@@ -727,7 +731,8 @@
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
//switch_frame_t *pframe;
- //FIXME int sent;
+ int sent;
+ struct skypiax_config *p=NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -735,7 +740,11 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
+ p=tech_pvt->p;
+ assert(p != NULL);
+
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
+ ERRORA("CIAPA \n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
#ifdef BIGENDIAN
@@ -744,8 +753,8 @@
}
#endif
- //FIXME sent = write(p->audioskypepipe[1], (short *) frame->data, frame->datalen);
- //FIXME ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
+ sent = write(p->audioskypepipe[1], (short *) frame->data, frame->datalen);
+ ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
return SWITCH_STATUS_SUCCESS;
@@ -756,6 +765,7 @@
{
private_t *tech_pvt;
switch_channel_t *channel = NULL;
+ struct skypiax_config *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -763,6 +773,9 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
+ p=tech_pvt->p;
+
+ ERRORA("ANSWERED! \n", SKYPIAX_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
@@ -772,6 +785,7 @@
{
switch_channel_t *channel;
private_t *tech_pvt;
+ struct skypiax_config *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -779,9 +793,12 @@
tech_pvt = (private_t *) switch_core_session_get_private(session);
assert(tech_pvt != NULL);
+ p=tech_pvt->p;
+
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_ANSWER:
{
+ ERRORA("TO BE ANSWERED! \n", SKYPIAX_P_LOG);
channel_answer_channel(session);
}
break;
@@ -807,7 +824,7 @@
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
channel = switch_core_session_get_channel(*new_session);
- tech_init(tech_pvt, *new_session);
+ tech_init(tech_pvt, *new_session, NULL);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
switch_core_session_destroy(new_session);
@@ -1266,7 +1283,7 @@
if (read_from_pipe[i] == '\0') {
- if (option_debug > 1)
+ if (option_debug > 101)
DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
howmany, i, a, messaggio);
@@ -1371,7 +1388,7 @@
where = strsep(stringp, " ");
- if (option_debug > 1)
+ if (option_debug > 101)
DEBUGA_SKYPE
("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
@@ -1622,40 +1639,59 @@
//FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
-#ifdef NOTDEF
+#ifndef NOTDEF
if (1) {
- switch_core_session_t *session;
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel!\n");
- if ((session = switch_core_session_request(iax_endpoint_interface, NULL)) != 0) {
+ if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) {
switch_core_session_add_stream(session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
channel = switch_core_session_get_channel(session);
- tech_init(tech_pvt, session);
+ tech_init(tech_pvt, session, p);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
switch_core_session_destroy(&session);
break;
}
+ // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0)
+
+#if 1
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
- iaxevent->ies.username,
- globals.dialplan,
- iaxevent->ies.calling_name,
- iaxevent->ies.calling_number,
- iax_get_peer_ip(iaxevent->session),
- iaxevent->ies.calling_ani,
+ "SKYPIAX",
+ "XML",
+ "calling_name",
+ "calling_number",
NULL,
+ "calling_ani",
NULL,
- modname,
- iaxevent->ies.called_context, iaxevent->ies.called_number)) != 0) {
+ NULL,
+ (char *) modname,
+ "default",
+ "5000")) != 0) {
char name[128];
- switch_snprintf(name, sizeof(name), "IAX/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
+ switch_snprintf(name, sizeof(name), "Skypiax/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff);
switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
}
+ WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
+ switch_channel_set_state(channel, CS_INIT);
+ WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
+ if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+ WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
+ switch_core_session_destroy(&session);
+ }
+ WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
+#endif //0
+#if 0
if (iax_set_codec(tech_pvt, iaxevent->session,
&iaxevent->ies.format, &iaxevent->ies.capability, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
iax_reject(iaxevent->session, "Codec Error!");
@@ -1671,6 +1707,7 @@
switch_core_session_destroy(&session);
}
}
+#endif //0
}
}
#endif //NOTDEF
More information about the Freeswitch-branches
mailing list