[Freeswitch-branches] [commit] r11531 - freeswitch/branches/gmaruzz/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Tue Jan 27 17:13:57 PST 2009
Author: gmaruzz
Date: Tue Jan 27 19:13:57 2009
New Revision: 11531
Log:
skypiax: moving switch specific things out of skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Tue Jan 27 19:13:57 2009
@@ -1064,6 +1064,98 @@
return 0;
}
+int start_audio_threads(private_t *tech_pvt) {
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, skypiax_module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr,
+ skypiax_do_tcp_srv_thread, tech_pvt,
+ skypiax_module_pool);
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+
+ switch_threadattr_create(&thd_attr, skypiax_module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr,
+ skypiax_do_tcp_cli_thread, tech_pvt,
+ skypiax_module_pool);
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ skypiax_sleep(100000);
+
+
+ return 0;
+}
+
+int new_inbound_channel(private_t *tech_pvt) {
+ switch_core_session_t *session = NULL;
+ switch_channel_t *channel = NULL;
+
+ if ((session =
+ switch_core_session_request(skypiax_endpoint_interface,
+ NULL)) != 0) {
+ switch_core_session_add_stream(session, NULL);
+ channel = switch_core_session_get_channel(session);
+ skypiax_tech_init(tech_pvt, session);
+
+ if ((tech_pvt->caller_profile =
+ switch_caller_profile_new(switch_core_session_get_pool(session),
+ "skypiax", tech_pvt->dialplan,
+ tech_pvt->callid_name,
+ tech_pvt->callid_number, NULL, NULL,
+ NULL, NULL, "mod_skypiax",
+ tech_pvt->context,
+ tech_pvt->destination)) != 0) {
+ char name[128];
+ //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
+ switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
+ switch_channel_set_name(channel, name);
+ switch_channel_set_caller_profile(channel,
+ tech_pvt->caller_profile);
+ }
+ switch_channel_set_state(channel, CS_INIT);
+ if (switch_core_session_thread_launch(session) !=
+ SWITCH_STATUS_SUCCESS) {
+ ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
+ switch_core_session_destroy(&session);
+ }
+ }
+ switch_channel_mark_answered(channel);
+
+ DEBUGA_SKYPE("Here\n", SKYPIAX_P_LOG);
+
+ return 0;
+}
+int outbound_channel_answered(private_t *tech_pvt) {
+ switch_core_session_t *session = NULL;
+ switch_channel_t *channel = NULL;
+
+
+ if (strlen(tech_pvt->session_uuid_str)) {
+ session = switch_core_session_locate(tech_pvt->session_uuid_str);
+ } else {
+ ERRORA("No session???\n", SKYPIAX_P_LOG);
+ }
+ if (session) {
+ channel = switch_core_session_get_channel(session);
+ } else {
+ ERRORA("No session???\n", SKYPIAX_P_LOG);
+ }
+ if (channel) {
+ switch_channel_mark_answered(channel);
+ //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
+ } else {
+ ERRORA("No channel???\n", SKYPIAX_P_LOG);
+ }
+
+ switch_core_session_rwunlock(session);
+ DEBUGA_SKYPE("HERE!\n", SKYPIAX_P_LOG);
+
+
+ return 0;
+}
+
/* For Emacs:
* Local Variables:
* mode:c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Tue Jan 27 19:13:57 2009
@@ -255,3 +255,6 @@
void * skypiax_do_skypeapi_thread_func(void *obj);
void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj);
int dtmf_received(private_t *tech_pvt, char *value);
+int start_audio_threads(private_t *tech_pvt);
+int new_inbound_channel(private_t *tech_pvt);
+int outbound_channel_answered(private_t *tech_pvt);
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Tue Jan 27 19:13:57 2009
@@ -1350,27 +1350,9 @@
}
if (!strcasecmp(prop, "DTMF")) {
- //switch_core_session_t *session = NULL;
- //switch_channel_t *channel = NULL;
DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
- /*
- session = switch_core_session_locate(tech_pvt->session_uuid_str);
- channel = switch_core_session_get_channel(session);
-
- if (channel) {
- switch_dtmf_t dtmf =
- { (char) value[0], switch_core_default_dtmf_duration(0) };
- DEBUGA_SKYPE("%c DTMF %s\n", SKYPIAX_P_LOG, dtmf.digit,
- switch_channel_get_name(channel));
- switch_mutex_lock(tech_pvt->flag_mutex);
- switch_channel_queue_dtmf(channel, &dtmf);
- switch_set_flag(tech_pvt, TFLAG_DTMF);
- switch_mutex_unlock(tech_pvt->flag_mutex);
- }
- switch_core_session_rwunlock(session);
- */
dtmf_received(tech_pvt, value);
}
@@ -1525,6 +1507,7 @@
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "INPROGRESS")) {
+ char msg_to_skype[1024];
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_UP;
@@ -1535,26 +1518,8 @@
DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
SKYPIAX_P_LOG, id);
- if (1) { //FIXME //CICOPET
- char msg_to_skype[1024];
- switch_threadattr_t *thd_attr = NULL;
+ start_audio_threads(tech_pvt);
- switch_threadattr_create(&thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr,
- skypiax_do_tcp_srv_thread, tech_pvt,
- skypiax_module_pool);
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
- switch_threadattr_create(&thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr,
- skypiax_do_tcp_cli_thread, tech_pvt,
- skypiax_module_pool);
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- skypiax_sleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
tech_pvt->tcp_srv_port);
skypiax_skype_write(tech_pvt, msg_to_skype);
@@ -1563,86 +1528,19 @@
tech_pvt->tcp_cli_port);
skypiax_skype_write(tech_pvt, msg_to_skype);
skypiax_sleep(100000);
- }
-
+
tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
- //FIXME switch_core_session_t **new_session;
-
- //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
-
- if (!strlen(tech_pvt->session_uuid_str)) { //CICOPET
- switch_core_session_t *session = NULL;
- //private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
+ if (!strlen(tech_pvt->session_uuid_str)) {
DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
- if ((session =
- switch_core_session_request(skypiax_endpoint_interface,
- NULL)) != 0) {
- switch_core_session_add_stream(session, NULL);
- channel = switch_core_session_get_channel(session);
- skypiax_tech_init(tech_pvt, session);
-#if 0
- if ((tech_pvt =
- (private_t *) switch_core_session_alloc(session,
- sizeof(private_t))) !=
- 0) {
- channel = switch_core_session_get_channel(session);
- skypiax_tech_init(tech_pvt, session);
- } else {
- ERRORA("Hey where is my memory pool?\n", SKYPIAX_P_LOG);
- switch_core_session_destroy(&session);
- break;
- }
-#endif
-
- if ((tech_pvt->caller_profile =
- switch_caller_profile_new(switch_core_session_get_pool(session),
- "skypiax", tech_pvt->dialplan,
- tech_pvt->callid_name,
- tech_pvt->callid_number, NULL, NULL,
- NULL, NULL, "mod_skypiax",
- tech_pvt->context,
- tech_pvt->destination)) != 0) {
- char name[128];
- //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
- switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
- switch_channel_set_name(channel, name);
- switch_channel_set_caller_profile(channel,
- tech_pvt->caller_profile);
- }
- switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(session) !=
- SWITCH_STATUS_SUCCESS) {
- ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
- switch_core_session_destroy(&session);
- }
- }
- switch_channel_mark_answered(channel);
- } else { //CICOPET
- switch_core_session_t *session = NULL;
- switch_channel_t *channel = NULL;
+ new_inbound_channel(tech_pvt);
+ } else {
- if (strlen(tech_pvt->session_uuid_str)) {
- session = switch_core_session_locate(tech_pvt->session_uuid_str);
- } else {
- ERRORA("No session???\n", SKYPIAX_P_LOG);
- }
- if (session) {
- channel = switch_core_session_get_channel(session);
- } else {
- ERRORA("No session???\n", SKYPIAX_P_LOG);
- }
- if (channel) {
- switch_channel_mark_answered(channel);
- //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
- } else {
- ERRORA("No channel???\n", SKYPIAX_P_LOG);
- }
+ DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
- switch_core_session_rwunlock(session);
+ outbound_channel_answered(tech_pvt);
}
} else {
More information about the Freeswitch-branches
mailing list