Freeswitch-svn
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
- 12151 discussions
[commit] r11663 - in freeswitch/trunk: libs/esl scripts src/mod/applications/mod_conference
by FreeSWITCH SVN 06 Feb '09
by FreeSWITCH SVN 06 Feb '09
06 Feb '09
Author: anthm
Date: Fri Feb 6 10:03:56 2009
New Revision: 11663
Log:
fix regression in previous fix for MODAPP-209
Modified:
freeswitch/trunk/libs/esl/testclient.c
freeswitch/trunk/scripts/freeswitch-gcore
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Modified: freeswitch/trunk/libs/esl/testclient.c
==============================================================================
--- freeswitch/trunk/libs/esl/testclient.c (original)
+++ freeswitch/trunk/libs/esl/testclient.c Fri Feb 6 10:03:56 2009
@@ -9,7 +9,21 @@
esl_connect(&handle, "localhost", 8021, "ClueCon");
- esl_send_recv(&handle, "api status\n\n");
+ esl_send_recv(&handle, "api conference 3100 play /root/sr8k.raw 1\n\n");
+
+ esl_send_recv(&handle, "api uuid_transfer aa1cedb1-5abc-4154-b068-9a0d1be6a7b6 3101\n\n");
+
+ esl_send_recv(&handle, "api conference 3101 play /root/sr8k.raw 2\n\n");
+
+ esl_send_recv(&handle, "api uuid_transfer aa1cedb1-5abc-4154-b068-9a0d1be6a7b6 3102\n\n");
+
+ esl_send_recv(&handle, "api conference 3102 play /root/sr8k.raw 3\n\n");
+
+ esl_send_recv(&handle, "api uuid_transfer aa1cedb1-5abc-4154-b068-9a0d1be6a7b6 3103\n\n");
+
+ esl_send_recv(&handle, "api conference 3103 play /root/sr8k.raw 4\n\n");
+
+ esl_send_recv(&handle, "api uuid_transfer aa1cedb1-5abc-4154-b068-9a0d1be6a7b6 3104\n\n");
esl_disconnect(&handle);
Modified: freeswitch/trunk/scripts/freeswitch-gcore
==============================================================================
--- freeswitch/trunk/scripts/freeswitch-gcore (original)
+++ freeswitch/trunk/scripts/freeswitch-gcore Fri Feb 6 10:03:56 2009
@@ -9,4 +9,4 @@
--eval-command='thread apply all bt' \
--eval-command='thread apply all bt full' \
--eval-command='quit'
-rm /usr/local/freeswitch/log/freeswitch.gcore.$fspid
+#rm /usr/local/freeswitch/log/freeswitch.gcore.$fspid
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Fri Feb 6 10:03:56 2009
@@ -2181,6 +2181,7 @@
switch_mutex_init(&member->control_mutex, SWITCH_MUTEX_NESTED, rec->pool);
+ switch_mutex_init(&member->flag_mutex, SWITCH_MUTEX_NESTED, rec->pool);
switch_mutex_init(&member->audio_in_mutex, SWITCH_MUTEX_NESTED, rec->pool);
switch_mutex_init(&member->audio_out_mutex, SWITCH_MUTEX_NESTED, rec->pool);
1
0
06 Feb '09
Author: mrene
Date: Thu Feb 5 21:03:50 2009
New Revision: 11662
Log:
MDXMLINT-46 Add purpose=gateways and profile=[name] so xml_curl requests make sense
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu Feb 5 21:03:50 2009
@@ -1629,6 +1629,12 @@
status = SWITCH_STATUS_SUCCESS;
if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
+ switch_event_t *xml_params;
+ switch_event_create(&xml_params, SWITCH_EVENT_REQUEST_PARAMS);
+ switch_assert(xml_params);
+ switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "purpose", "gateways");
+ switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "profile", profile->name);
+
for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
switch_xml_t droot, x_domain_tag;
const char *dname = switch_xml_attr_soft(domain_tag, "name");
@@ -1638,19 +1644,21 @@
if (!switch_strlen_zero(dname)) {
if (!strcasecmp(dname, "all")) {
switch_xml_t xml_root, x_domains;
- if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, NULL) == SWITCH_STATUS_SUCCESS) {
+ if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params) == SWITCH_STATUS_SUCCESS) {
for (x_domain_tag = switch_xml_child(x_domains, "domain"); x_domain_tag; x_domain_tag = x_domain_tag->next) {
dname = switch_xml_attr_soft(x_domain_tag, "name");
parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
}
switch_xml_free(xml_root);
}
- } else if (switch_xml_locate_domain(dname, NULL, &droot, &x_domain_tag) == SWITCH_STATUS_SUCCESS) {
+ } else if (switch_xml_locate_domain(dname, xml_params, &droot, &x_domain_tag) == SWITCH_STATUS_SUCCESS) {
parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
switch_xml_free(droot);
}
}
}
+
+ switch_event_destroy(&xml_params);
}
if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) {
@@ -2310,6 +2318,12 @@
}
if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
+ switch_event_t *xml_params;
+ switch_event_create(&xml_params, SWITCH_EVENT_REQUEST_PARAMS);
+ switch_assert(xml_params);
+ switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "purpose", "gateways");
+ switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "profile", profile->name);
+
for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
switch_xml_t droot, x_domain_tag;
const char *dname = switch_xml_attr_soft(domain_tag, "name");
@@ -2319,19 +2333,21 @@
if (!switch_strlen_zero(dname)) {
if (!strcasecmp(dname, "all")) {
switch_xml_t xml_root, x_domains;
- if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, NULL) == SWITCH_STATUS_SUCCESS) {
+ if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params) == SWITCH_STATUS_SUCCESS) {
for (x_domain_tag = switch_xml_child(x_domains, "domain"); x_domain_tag; x_domain_tag = x_domain_tag->next) {
dname = switch_xml_attr_soft(x_domain_tag, "name");
parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
}
switch_xml_free(xml_root);
}
- } else if (switch_xml_locate_domain(dname, NULL, &droot, &x_domain_tag) == SWITCH_STATUS_SUCCESS) {
+ } else if (switch_xml_locate_domain(dname, xml_params, &droot, &x_domain_tag) == SWITCH_STATUS_SUCCESS) {
parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
switch_xml_free(droot);
}
}
}
+
+ switch_event_destroy(&xml_params);
}
if ((aliases_tag = switch_xml_child(xprofile, "aliases"))) {
1
0
05 Feb '09
Author: anthm
Date: Thu Feb 5 16:43:46 2009
New Revision: 11661
Log:
MODAPP-209
Modified:
freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c Thu Feb 5 16:43:46 2009
@@ -288,6 +288,7 @@
uint32_t flags;
uint32_t score;
switch_mutex_t *flag_mutex;
+ switch_mutex_t *control_mutex;
switch_mutex_t *audio_in_mutex;
switch_mutex_t *audio_out_mutex;
switch_codec_t *orig_read_codec;
@@ -448,8 +449,8 @@
if (member == NULL || other_member == NULL || member->relationships == NULL)
return NULL;
- switch_mutex_lock(member->flag_mutex);
- switch_mutex_lock(other_member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
+ switch_mutex_lock(other_member->control_mutex);
for (rel = member->relationships; rel; rel = rel->next) {
if (rel->id == other_member->id) {
@@ -462,8 +463,8 @@
}
}
- switch_mutex_unlock(other_member->flag_mutex);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(other_member->control_mutex);
+ switch_mutex_unlock(member->control_mutex);
return rel ? rel : global;
}
@@ -527,10 +528,10 @@
rel->id = id;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
rel->next = member->relationships;
member->relationships = rel;
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
return rel;
}
@@ -544,7 +545,7 @@
if (member == NULL || id == 0)
return status;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
for (rel = member->relationships; rel; rel = rel->next) {
if (rel->id == id) {
/* we just forget about rel here cos it was allocated by the member's pool
@@ -558,7 +559,7 @@
}
last = rel;
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
return status;
}
@@ -578,7 +579,7 @@
switch_mutex_lock(conference->mutex);
switch_mutex_lock(member->audio_in_mutex);
switch_mutex_lock(member->audio_out_mutex);
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
switch_mutex_lock(conference->member_mutex);
switch_clear_flag(conference, CFLAG_DESTRUCT);
@@ -587,7 +588,7 @@
member->energy_level = conference->energy_level;
member->verbose_events = conference->verbose_events;
conference->members = member;
- switch_set_flag(member, MFLAG_INTREE);
+ switch_set_flag_locked(member, MFLAG_INTREE);
switch_mutex_unlock(conference->member_mutex);
if (!switch_test_flag(member, MFLAG_NOCHANNEL)) {
@@ -658,7 +659,7 @@
}
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_mutex_unlock(member->audio_out_mutex);
switch_mutex_unlock(member->audio_in_mutex);
@@ -674,15 +675,24 @@
switch_status_t status = SWITCH_STATUS_FALSE;
conference_member_t *imember, *last = NULL;
switch_event_t *event;
+ conference_file_node_t *member_fnode;
+ switch_speech_handle_t *member_sh;
switch_assert(conference != NULL);
switch_assert(member != NULL);
+ switch_mutex_lock(member->control_mutex);
+ member_fnode = member->fnode;
+ member_sh = member->sh;
+ member->fnode = NULL;
+ member->sh = NULL;
+ switch_mutex_unlock(member->control_mutex);
+
switch_mutex_lock(conference->mutex);
switch_mutex_lock(conference->member_mutex);
switch_mutex_lock(member->audio_in_mutex);
switch_mutex_lock(member->audio_out_mutex);
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
switch_clear_flag(member, MFLAG_INTREE);
for (imember = conference->members; imember; imember = imember->next) {
@@ -698,11 +708,11 @@
}
/* Close Unused Handles */
- if (member->fnode) {
+ if (member_fnode) {
conference_file_node_t *fnode, *cur;
switch_memory_pool_t *pool;
- fnode = member->fnode;
+ fnode = member_fnode;
while (fnode) {
cur = fnode;
fnode = fnode->next;
@@ -716,10 +726,9 @@
}
}
- if (member->sh) {
+ if (member_sh) {
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
switch_core_speech_close(&member->lsh, &flags);
- member->sh = NULL;
}
if (switch_test_flag(member, MFLAG_ENDCONF)) {
@@ -775,7 +784,7 @@
}
}
switch_mutex_unlock(conference->member_mutex);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_mutex_unlock(member->audio_out_mutex);
switch_mutex_unlock(member->audio_in_mutex);
switch_mutex_unlock(conference->mutex);
@@ -1298,7 +1307,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->energy_level += 200;
if (member->energy_level > 3000) {
member->energy_level = 3000;
@@ -1311,7 +1320,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0);
@@ -1325,7 +1334,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->energy_level = member->conference->energy_level;
if (test_eflag(member->conference, EFLAG_ENERGY_LEVEL) &&
@@ -1335,7 +1344,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0);
@@ -1349,7 +1358,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->energy_level -= 100;
if (member->energy_level < 0) {
member->energy_level = 0;
@@ -1362,7 +1371,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->energy_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Energy level %d", member->energy_level);
conference_member_say(member, msg, 0);
@@ -1376,7 +1385,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_out_level++;
switch_normalize_volume(member->volume_out_level);
@@ -1387,7 +1396,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0);
@@ -1401,7 +1410,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_out_level = 0;
if (test_eflag(member->conference, EFLAG_VOLUME_LEVEL) &&
@@ -1411,7 +1420,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0);
@@ -1425,7 +1434,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_out_level--;
switch_normalize_volume(member->volume_out_level);
@@ -1436,7 +1445,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_out_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Volume level %d", member->volume_out_level);
conference_member_say(member, msg, 0);
@@ -1450,7 +1459,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_in_level++;
switch_normalize_volume(member->volume_in_level);
@@ -1461,7 +1470,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0);
@@ -1475,7 +1484,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_in_level = 0;
if (test_eflag(member->conference, EFLAG_GAIN_LEVEL) &&
@@ -1485,7 +1494,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0);
@@ -1499,7 +1508,7 @@
if (member == NULL)
return;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_in_level--;
switch_normalize_volume(member->volume_in_level);
@@ -1510,7 +1519,7 @@
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "New-Level", "%d", member->volume_in_level);
switch_event_fire(&event);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
switch_snprintf(msg, sizeof(msg), "Gain level %d", member->volume_in_level);
conference_member_say(member, msg, 0);
@@ -1893,7 +1902,7 @@
goto top;
}
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
if (switch_core_session_dequeue_event(member->session, &event) == SWITCH_STATUS_SUCCESS) {
if (event->event_id == SWITCH_EVENT_MESSAGE) {
@@ -2086,7 +2095,7 @@
switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
if (switch_core_session_private_event_count(member->session)) {
@@ -2171,7 +2180,7 @@
member->mux_frame = switch_core_alloc(member->pool, member->frame_size);
- switch_mutex_init(&member->flag_mutex, SWITCH_MUTEX_NESTED, rec->pool);
+ switch_mutex_init(&member->control_mutex, SWITCH_MUTEX_NESTED, rec->pool);
switch_mutex_init(&member->audio_in_mutex, SWITCH_MUTEX_NESTED, rec->pool);
switch_mutex_init(&member->audio_out_mutex, SWITCH_MUTEX_NESTED, rec->pool);
@@ -2330,7 +2339,7 @@
if (member == NULL)
return count;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
if (stop == FILE_STOP_ALL) {
for (nptr = member->fnode; nptr; nptr = nptr->next) {
@@ -2344,7 +2353,7 @@
}
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
return count;
}
@@ -2526,14 +2535,14 @@
fnode->pool = pool;
/* Queue the node */
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Queueing file '%s' for play\n", file);
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
if (nptr) {
nptr->next = fnode;
} else {
member->fnode = fnode;
}
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
status = SWITCH_STATUS_SUCCESS;
done:
@@ -2591,7 +2600,7 @@
}
/* Queue the node */
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
for (nptr = member->fnode; nptr && nptr->next; nptr = nptr->next);
if (nptr) {
@@ -2617,7 +2626,7 @@
}
switch_core_speech_feed_tts(fnode->sh, text, &flags);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
status = SWITCH_STATUS_SUCCESS;
@@ -2918,11 +2927,11 @@
if (member == NULL)
return SWITCH_STATUS_GENERR;
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
switch_clear_flag(member, MFLAG_RUNNING);
- switch_set_flag(member, MFLAG_KICKED);
+ switch_set_flag_locked(member, MFLAG_KICKED);
switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
if (stream != NULL) {
stream->write_function(stream, "OK kicked %u\n", member->id);
}
@@ -2952,10 +2961,10 @@
return SWITCH_STATUS_GENERR;
}
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
switch_core_session_kill_channel(member->session, SWITCH_SIG_BREAK);
switch_core_session_send_dtmf_string(member->session, (char *) data);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
if (stream != NULL) {
stream->write_function(stream, "OK sent %s to %u\n", (char *) data, member->id);
@@ -2980,9 +2989,9 @@
return SWITCH_STATUS_GENERR;
if (data) {
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->energy_level = atoi((char *) data);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
}
if (stream != NULL) {
stream->write_function(stream, "Energy %u = %d\n", member->id, member->energy_level);
@@ -3006,10 +3015,10 @@
return SWITCH_STATUS_GENERR;
if (data) {
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_in_level = atoi((char *) data);
switch_normalize_volume(member->volume_in_level);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
}
if (stream != NULL) {
stream->write_function(stream, "Volume IN %u = %d\n", member->id, member->volume_in_level);
@@ -3033,10 +3042,10 @@
return SWITCH_STATUS_GENERR;
if (data) {
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
member->volume_out_level = atoi((char *) data);
switch_normalize_volume(member->volume_out_level);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
}
if (stream != NULL) {
stream->write_function(stream, "Volume OUT %u = %d\n", member->id, member->volume_out_level);
@@ -3684,7 +3693,7 @@
}
/* move the member from the old conference to the new one */
- switch_mutex_lock(member->flag_mutex);
+ switch_mutex_lock(member->control_mutex);
conference_del_member(conference, member);
conference_add_member(new_conference, member);
@@ -3693,12 +3702,12 @@
switch_clear_flag_locked(member, MFLAG_RUNNING);
} else {
switch_channel_set_flag(channel, CF_SERVICE);
- switch_set_flag(member, MFLAG_RESTART);
+ switch_set_flag_locked(member, MFLAG_RESTART);
}
}
switch_mutex_unlock(new_conference->mutex);
- switch_mutex_unlock(member->flag_mutex);
+ switch_mutex_unlock(member->control_mutex);
stream->write_function(stream, "OK Member '%d' sent to conference %s.\n", member->id, argv[2]);
@@ -4820,6 +4829,7 @@
/* Prepare MUTEXS */
member.id = next_member_id();
switch_mutex_init(&member.flag_mutex, SWITCH_MUTEX_NESTED, member.pool);
+ switch_mutex_init(&member.control_mutex, SWITCH_MUTEX_NESTED, member.pool);
switch_mutex_init(&member.audio_in_mutex, SWITCH_MUTEX_NESTED, member.pool);
switch_mutex_init(&member.audio_out_mutex, SWITCH_MUTEX_NESTED, member.pool);
1
0
[commit] r11660 - freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket
by FreeSWITCH SVN 05 Feb '09
by FreeSWITCH SVN 05 Feb '09
05 Feb '09
Author: mikej
Date: Thu Feb 5 14:13:35 2009
New Revision: 11660
Log:
mod_spidermonkey_socket: fix gc blocking (MODLANG-97)
Modified:
freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey_socket/mod_spidermonkey_socket.c Thu Feb 5 14:13:35 2009
@@ -37,6 +37,7 @@
char *read_buffer;
switch_size_t buffer_size;
int state;
+ jsrefcount saveDepth;
};
typedef struct js_socket_obj js_socket_obj_t;
@@ -72,10 +73,13 @@
return;
if (socket->socket != 0) {
+ socket->saveDepth = JS_SuspendRequest(cx);
switch_socket_shutdown(socket->socket, SWITCH_SHUTDOWN_READWRITE);
switch_socket_close(socket->socket);
switch_core_destroy_memory_pool(&socket->pool);
+ JS_ResumeRequest(cx, socket->saveDepth);
}
+
}
static JSBool socket_connect(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
@@ -101,7 +105,9 @@
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Connecting to: %s:%d.\n", host, port);
+ socket->saveDepth = JS_SuspendRequest(cx);
ret = switch_socket_connect(socket->socket, addr);
+ JS_ResumeRequest(cx, socket->saveDepth);
if (ret != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "switch_socket_connect failed: %d.\n", ret);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -122,9 +128,12 @@
}
if (argc == 1) {
+ switch_status_t ret;
char *buffer = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
switch_size_t len = strlen(buffer);
- switch_status_t ret = switch_socket_send(socket->socket, buffer, &len);
+ socket->saveDepth = JS_SuspendRequest(cx);
+ ret = switch_socket_send(socket->socket, buffer, &len);
+ JS_ResumeRequest(cx, socket->saveDepth);
if (ret != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "switch_socket_send failed: %d.\n", ret);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -156,7 +165,9 @@
socket->buffer_size = bytes_to_read + 1;
}
+ socket->saveDepth = JS_SuspendRequest(cx);
ret = switch_socket_recv(socket->socket, socket->read_buffer, &len);
+ JS_ResumeRequest(cx, socket->saveDepth);
if (ret != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "switch_socket_send failed: %d.\n", ret);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -192,6 +203,7 @@
if (socket->read_buffer == 0)
socket->read_buffer = switch_core_alloc(socket->pool, socket->buffer_size);
+ socket->saveDepth = JS_SuspendRequest(cx);
while (can_run == TRUE) {
ret = switch_socket_recv(socket->socket, tempbuf, &len);
if (ret != SWITCH_STATUS_SUCCESS)
@@ -215,6 +227,8 @@
++total_length;
}
}
+ JS_ResumeRequest(cx, socket->saveDepth);
+
if (ret != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "socket receive failed: %d.\n", ret);
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
@@ -235,9 +249,11 @@
return JS_FALSE;
}
+ socket->saveDepth = JS_SuspendRequest(cx);
switch_socket_shutdown(socket->socket, SWITCH_SHUTDOWN_READWRITE);
switch_socket_close(socket->socket);
socket->socket = NULL;
+ JS_ResumeRequest(cx, socket->saveDepth);
return JS_TRUE;
}
1
0
05 Feb '09
Author: brian
Date: Thu Feb 5 14:10:08 2009
New Revision: 11659
Log:
MODFORM-22
Modified:
freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c (original)
+++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c Thu Feb 5 14:10:08 2009
@@ -139,6 +139,9 @@
context->sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_ALAW;
context->sfinfo.channels = 1;
context->sfinfo.samplerate = 8000;
+ } else if (!strcmp(ext, "adpcm")) {
+ context->sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM;
+ context->sfinfo.samplerate = 8000;
}
if ((mode & SFM_WRITE) && sf_format_check(&context->sfinfo) == 0) {
@@ -305,7 +308,7 @@
char buffer[128];
int format, major_count, subtype_count, m, s;
int len, x, skip;
- char *extras[] = { "r8", "r16", "r24", "r32", "gsm", "ul", "al", NULL };
+ char *extras[] = { "r8", "r16", "r24", "r32", "gsm", "ul", "al", "adpcm", NULL };
int exlen = (sizeof(extras) / sizeof(extras[0]));
buffer[0] = 0;
1
0
[commit] r11658 - in freeswitch/trunk/src: . include mod/applications/mod_dptools
by FreeSWITCH SVN 05 Feb '09
by FreeSWITCH SVN 05 Feb '09
05 Feb '09
Author: anthm
Date: Thu Feb 5 13:53:13 2009
New Revision: 11658
Log:
sound_test app
Modified:
freeswitch/trunk/src/include/switch_ivr.h
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/switch_ivr.c
Modified: freeswitch/trunk/src/include/switch_ivr.h
==============================================================================
--- freeswitch/trunk/src/include/switch_ivr.h (original)
+++ freeswitch/trunk/src/include/switch_ivr.h Thu Feb 5 13:53:13 2009
@@ -794,6 +794,7 @@
SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name);
SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data);
+ SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session);
/** @} */
SWITCH_END_EXTERN_C
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu Feb 5 13:53:13 2009
@@ -912,6 +912,11 @@
}
}
+SWITCH_STANDARD_APP(sound_test_function)
+{
+ switch_ivr_sound_test(session);
+}
+
SWITCH_STANDARD_APP(event_function)
{
switch_event_t *event;
@@ -2581,6 +2586,7 @@
SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA);
+ SWITCH_ADD_APP(app_interface, "sound_test", "Analyze Audio", "Analyze Audio", sound_test_function, "", SAF_NONE);
SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>",
SAF_SUPPORT_NOMEDIA);
SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA);
Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c (original)
+++ freeswitch/trunk/src/switch_ivr.c Thu Feb 5 13:53:13 2009
@@ -38,6 +38,91 @@
#include <switch_ivr.h>
#include "stfu.h"
+SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session)
+{
+
+ switch_codec_implementation_t imp = {0};
+ switch_codec_t codec = { 0 };
+ int16_t peak = 0;
+ int16_t *data;
+ switch_frame_t *read_frame = NULL;
+ int i;
+ switch_channel_t *channel = switch_core_session_get_channel(session);
+ switch_status_t status = SWITCH_STATUS_SUCCESS;
+ int64_t global_total = 0, global_sum = 0, period_sum = 0;
+ int period_total = 0;
+ int period_avg = 0, global_avg = 0;
+ int avg = 0;
+ int period_len;
+
+ switch_core_session_get_read_impl(session, &imp);
+
+ period_len = imp.actual_samples_per_second / imp.samples_per_packet;
+
+ if (switch_core_codec_init(&codec,
+ "L16",
+ NULL,
+ imp.samples_per_second,
+ imp.microseconds_per_packet / 1000,
+ imp.number_of_channels,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
+ imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
+ return SWITCH_STATUS_FALSE;
+ }
+
+ while(switch_channel_ready(channel)) {
+ status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
+
+ if (!SWITCH_READ_ACCEPTABLE(status)) {
+ break;
+ }
+
+ if (switch_test_flag(read_frame, SFF_CNG) || !read_frame->samples) {
+ continue;
+ }
+
+
+ data = (int16_t *) read_frame->data;
+ peak = 0;
+ avg = 0;
+ for (i = 0; i < read_frame->samples; i++) {
+ const int16_t s = abs(data[i]);
+ if (s > peak) {
+ peak = s;
+ }
+ avg += s;
+ }
+
+ avg /= read_frame->samples;
+
+ period_sum += peak;
+ global_sum += peak;
+
+ global_total++;
+ period_total++;
+
+ period_avg = period_sum / period_total;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
+ "\npacket_avg=%d packet_peak=%d period_avg=%d global_avg=%d\n\n", avg, peak, period_avg, global_avg);
+
+ if (period_total >= period_len) {
+ global_avg = global_sum / global_total;
+ period_total = 0;
+ period_sum = 0;
+ }
+
+ }
+
+
+ switch_core_codec_destroy(&codec);
+
+ return SWITCH_STATUS_SUCCESS;
+
+}
+
SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
1
0
Author: nicholas
Date: Thu Feb 5 11:29:11 2009
New Revision: 11657
Log:
fixed an configure error in rules
Modified:
freeswitch/trunk/debian/rules
Modified: freeswitch/trunk/debian/rules
==============================================================================
--- freeswitch/trunk/debian/rules (original)
+++ freeswitch/trunk/debian/rules Thu Feb 5 11:29:11 2009
@@ -61,7 +61,7 @@
touch modules.conf
echo $(MODULES)
for i in $(MODULES); do echo $$i >> modules.conf; done
- ./configure --prefix=/opt/freeswitch --with-modinstdir=/usr/lib/freeswitch/modules --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) ${FEATURES}
+ ./configure --prefix=/opt/freeswitch --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) ${FEATURES}
configure:
if test ! -f Makefile.in ; then \
1
0
05 Feb '09
Author: anthm
Date: Thu Feb 5 11:14:12 2009
New Revision: 11656
Log:
tweak sofia profile shutdown
Modified:
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
freeswitch/trunk/src/switch_core_session.c
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c Thu Feb 5 11:14:12 2009
@@ -692,7 +692,7 @@
int use_100rel = !sofia_test_pflag(profile, PFLAG_DISABLE_100REL);
int use_timer = !sofia_test_pflag(profile, PFLAG_DISABLE_TIMER);
const char *supported = NULL;
- int sanity = 4;
+ int sanity;
switch_mutex_lock(mod_sofia_globals.mutex);
mod_sofia_globals.threads++;
@@ -831,9 +831,15 @@
sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
switch_core_session_hupall_matching_var("sofia_profile_name", profile->name, SWITCH_CAUSE_MANAGER_REQUEST);
+ sanity = 10;
while (profile->inuse) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Waiting for %d session(s)\n", profile->inuse);
su_root_step(profile->s_root, 1000);
+ if (!--sanity) {
+ break;
+ } else if (sanity == 5) {
+ switch_core_session_hupall_matching_var("sofia_profile_name", profile->name, SWITCH_CAUSE_MANAGER_REQUEST);
+ }
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock %s\n", profile->name);
@@ -841,6 +847,8 @@
sofia_reg_unregister(profile);
nua_shutdown(profile->nua);
su_root_run(profile->s_root);
+ nua_shutdown(profile->nua);
+ su_root_run(profile->s_root);
sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n");
@@ -848,16 +856,18 @@
while (sofia_test_pflag(profile, PFLAG_WORKER_RUNNING)) {
switch_yield(100000);
}
-
+
+ sanity = 4;
while (profile->inuse) {
+ switch_core_session_hupall_matching_var("sofia_profile_name", profile->name, SWITCH_CAUSE_MANAGER_REQUEST);
switch_yield(5000000);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Waiting for %d session(s)\n", profile->inuse);
- if (!sanity--) {
+ if (!--sanity) {
break;
}
}
nua_destroy(profile->nua);
-
+
switch_mutex_lock(profile->ireg_mutex);
switch_mutex_unlock(profile->ireg_mutex);
Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c (original)
+++ freeswitch/trunk/src/switch_core_session.c Thu Feb 5 11:14:12 2009
@@ -142,8 +142,8 @@
switch_mutex_unlock(runtime.throttle_mutex);
while (session_manager.session_count > 0) {
- switch_yield(100000);
- if (++loops == 100) {
+ switch_yield(1000000);
+ if (++loops == 30) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Giving up with %d session%s remaining\n",
session_manager.session_count, session_manager.session_count == 1 ? "" : "s");
break;
1
0
Author: mikej
Date: Thu Feb 5 10:21:18 2009
New Revision: 11655
Log:
fix gcc 4.3.2 build warnings
Modified:
freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c
freeswitch/trunk/libs/spandsp/src/vector_float.c
Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c (original)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_lpc.c Thu Feb 5 10:21:18 2009
@@ -135,7 +135,7 @@
/*- End of function --------------------------------------------------------*/
#if defined(__GNUC__) && defined(SPANDSP_USE_MMX)
-void gsm0610_vec_vsraw(const int16_t *p, int n, int bits)
+static void gsm0610_vec_vsraw(const int16_t *p, int n, int bits)
{
static const int64_t ones = 0x0001000100010001LL;
Modified: freeswitch/trunk/libs/spandsp/src/vector_float.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/vector_float.c (original)
+++ freeswitch/trunk/libs/spandsp/src/vector_float.c Thu Feb 5 10:21:18 2009
@@ -132,13 +132,14 @@
SPAN_DECLARE(void) vec_negatef(float z[], const float x[], int n)
{
int i;
- static const uint32_t mask = 0x80000000;
+ static const uint32_t mask = 0x80000000;
+ static const float *fmask = (float *)&mask;
__m128 n1;
__m128 n2;
if ((i = n & ~3))
{
- n2 = _mm_set1_ps(*((float *) &mask));
+ n2 = _mm_set1_ps(*fmask);
for (i -= 4; i >= 0; i -= 4)
{
n1 = _mm_loadu_ps(x + i);
1
0
[commit] r11654 - in freeswitch/trunk/libs/spandsp: . src src/msvc src/spandsp src/spandsp/private
by FreeSWITCH SVN 05 Feb '09
by FreeSWITCH SVN 05 Feb '09
05 Feb '09
Author: mikej
Date: Thu Feb 5 09:54:02 2009
New Revision: 11654
Log:
update to snapshot spandsp-20090205
Modified:
freeswitch/trunk/libs/spandsp/ (props changed)
freeswitch/trunk/libs/spandsp/src/async.c
freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj
freeswitch/trunk/libs/spandsp/src/msvc/vc8proj.head
freeswitch/trunk/libs/spandsp/src/silence_gen.c
freeswitch/trunk/libs/spandsp/src/spandsp/async.h
freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h
freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h
freeswitch/trunk/libs/spandsp/src/spandsp/private/t4.h
freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h
freeswitch/trunk/libs/spandsp/src/spandsp/silence_gen.h
freeswitch/trunk/libs/spandsp/src/spandsp/t30.h
freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h
freeswitch/trunk/libs/spandsp/src/spandsp/t4.h
freeswitch/trunk/libs/spandsp/src/spandsp/v42.h
freeswitch/trunk/libs/spandsp/src/spandsp/version.h
freeswitch/trunk/libs/spandsp/src/t30.c
freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c
freeswitch/trunk/libs/spandsp/src/t4.c
freeswitch/trunk/libs/spandsp/src/v42.c
Modified: freeswitch/trunk/libs/spandsp/src/async.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/async.c (original)
+++ freeswitch/trunk/libs/spandsp/src/async.c Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: async.c,v 1.16 2009/02/03 16:28:39 steveu Exp $
+ * $Id: async.c,v 1.17 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj (original)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.vcproj Thu Feb 5 09:54:02 2009
@@ -8,37 +8,22 @@
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
- <Platforms>
- <Platform
+ <Platforms>
+ <Platform
Name="Win32"
/>
- </Platforms>
- <ToolFiles>
- </ToolFiles>
- <Configurations>
- <Configuration
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)Debug"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
+ <Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;.\generated"
@@ -52,16 +37,7 @@
CompileAs="1"
DisableSpecificWarnings="4127"
/>
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
+ <Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
@@ -71,29 +47,8 @@
ImportLibrary="./Debug\spandsp.lib"
TargetMachine="1"
/>
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- <Configuration
+ </Configuration>
+ <Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)Release"
IntermediateDirectory="$(ConfigurationName)"
@@ -101,22 +56,7 @@
CharacterSet="1"
WholeProgramOptimization="1"
>
- <Tool
- Name="VCPreBuildEventTool"
- />
- <Tool
- Name="VCCustomBuildTool"
- />
- <Tool
- Name="VCXMLDataGeneratorTool"
- />
- <Tool
- Name="VCWebServiceProxyGeneratorTool"
- />
- <Tool
- Name="VCMIDLTool"
- />
- <Tool
+ <Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=".;.\spandsp;.\msvc;..\..\tiff-3.8.2\libtiff;.\generated"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBSPANDSP_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;HAVE_CONFIG_H"
@@ -126,16 +66,7 @@
DebugInformationFormat="3"
DisableSpecificWarnings="4127"
/>
- <Tool
- Name="VCManagedResourceCompilerTool"
- />
- <Tool
- Name="VCResourceCompilerTool"
- />
- <Tool
- Name="VCPreLinkEventTool"
- />
- <Tool
+ <Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
@@ -147,33 +78,12 @@
ImportLibrary="./Release\spandsp.lib"
TargetMachine="1"
/>
- <Tool
- Name="VCALinkTool"
- />
- <Tool
- Name="VCManifestTool"
- />
- <Tool
- Name="VCXDCMakeTool"
- />
- <Tool
- Name="VCBscMakeTool"
- />
- <Tool
- Name="VCFxCopTool"
- />
- <Tool
- Name="VCAppVerifierTool"
- />
- <Tool
- Name="VCPostBuildEventTool"
- />
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
Modified: freeswitch/trunk/libs/spandsp/src/msvc/vc8proj.head
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/msvc/vc8proj.head (original)
+++ freeswitch/trunk/libs/spandsp/src/msvc/vc8proj.head Thu Feb 5 09:54:02 2009
@@ -87,4 +87,4 @@
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
- >
\ No newline at end of file
+ >
Modified: freeswitch/trunk/libs/spandsp/src/silence_gen.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/silence_gen.c (original)
+++ freeswitch/trunk/libs/spandsp/src/silence_gen.c Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: silence_gen.c,v 1.18 2009/02/03 16:28:40 steveu Exp $
+ * $Id: silence_gen.c,v 1.19 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/async.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/async.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/async.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: async.h,v 1.21 2009/02/03 16:28:40 steveu Exp $
+ * $Id: async.h,v 1.22 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/complex_vector_float.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: complex_vector_float.h,v 1.12 2009/01/31 08:48:11 steveu Exp $
+ * $Id: complex_vector_float.h,v 1.13 2009/02/04 13:18:53 steveu Exp $
*/
#if !defined(_SPANDSP_COMPLEX_VECTOR_FLOAT_H_)
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/fast_convert.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: fast_convert.h,v 1.1 2009/02/03 16:28:41 steveu Exp $
+ * $Id: fast_convert.h,v 1.2 2009/02/05 12:21:36 steveu Exp $
*/
#if !defined(_SPANDSP_FAST_CONVERT_H_)
@@ -90,7 +90,6 @@
* These replacement functions (pulled from the Public Domain MinGW
* math.h header) replace the native versions.
*/
-#if 0
static __inline__ long int lrint(double x)
{
long int retval;
@@ -119,8 +118,8 @@
);
return retval;
}
-#endif
+ /* The fastest way to convert is the equivalent of lrint() */
static __inline__ long int lfastrint(double x)
{
long int retval;
@@ -149,7 +148,7 @@
);
return retval;
}
-#elif defined(HAVE_LRINT) && defined(HAVE_LRINTF)
+#elif defined(__GNUC__)
#if defined(__i386__)
/* These routines are guaranteed fast on an i386 machine. Using the built in
@@ -235,6 +234,7 @@
* Win32 doesn't seem to have the lrint() and lrintf() functions.
* Therefore implement inline versions of these functions here.
*/
+
__inline long int lrint(double x)
{
long int i;
@@ -269,7 +269,7 @@
__inline double rint(double dbl)
{
- __asm
+ _asm
{
fld dbl
frndint
@@ -300,7 +300,7 @@
return i;
}
#elif defined(WIN64) || defined(_WIN64)
- /* Win64 machines will do best with a simple assignment. */
+ /* x86_64 machines will do best with a simple assignment. */
__inline long int lfastrint(double x)
{
@@ -377,12 +377,21 @@
the accuracy issues related to changing the rounding scheme are of little concern
to us. */
-#if 0
#if !defined(__sgi)
#warning "No usable lrint() and lrintf() functions available."
#warning "Replacing these functions with a simple C cast."
#endif
-#endif
+
+ static __inline__ long int lrint(double x)
+ {
+ return (long int) (x);
+ }
+
+ static __inline__ long int lrintf(float x)
+ {
+ return (long int) (x);
+ }
+
static __inline__ long int lfastrint(double x)
{
return (long int) (x);
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/t4.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t4.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t4.h Thu Feb 5 09:54:02 2009
@@ -22,25 +22,29 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t4.h,v 1.1 2008/10/13 13:14:01 steveu Exp $
+ * $Id: t4.h,v 1.2 2009/02/05 12:21:36 steveu Exp $
*/
#if !defined(_SPANDSP_PRIVATE_T4_H_)
#define _SPANDSP_PRIVATE_T4_H_
/*!
- T.4 FAX compression/decompression descriptor. This defines the working state
- for a single instance of a T.4 FAX compression or decompression channel.
+ TIFF specific state information to go with T.4 compression or decompression handling.
*/
-struct t4_state_s
+typedef struct
{
- /*! \brief The same structure is used for T.4 transmit and receive. This variable
- records which mode is in progress. */
- int rx;
- /* "Background" information about the FAX, which can be stored in a TIFF file. */
- /*! \brief The vendor of the machine which produced the TIFF file. */
+ /*! \brief The libtiff context for the current TIFF file */
+ TIFF *tiff_file;
+
+ /*! \brief The compression type for output to the TIFF file. */
+ int output_compression;
+ /*! \brief The TIFF G3 FAX options. */
+ int output_t4_options;
+
+ /* "Background" information about the FAX, which can be stored in the image file. */
+ /*! \brief The vendor of the machine which produced the file. */
const char *vendor;
- /*! \brief The model of machine which produced the TIFF file. */
+ /*! \brief The model of machine which produced the file. */
const char *model;
/*! \brief The local ident string. */
const char *local_ident;
@@ -50,9 +54,17 @@
const char *sub_address;
/*! \brief The FAX DCS information, as an ASCII string. */
const char *dcs;
- /*! \brief The text which will be used in FAX page header. No text results
- in no header line. */
- const char *header_info;
+} t4_tiff_state_t;
+
+/*!
+ T.4 FAX compression/decompression descriptor. This defines the working state
+ for a single instance of a T.4 FAX compression or decompression channel.
+*/
+struct t4_state_s
+{
+ /*! \brief The same structure is used for T.4 transmit and receive. This variable
+ records which mode is in progress. */
+ int rx;
/*! \brief The type of compression used between the FAX machines. */
int line_encoding;
@@ -60,11 +72,6 @@
for hardware FAX machines. */
int min_bits_per_row;
- /*! \brief The compression type for output to the TIFF file. */
- int output_compression;
- /*! \brief The TIFF G3 FAX options. */
- int output_t4_options;
-
/*! \brief Callback function to read a row of pixels from the image source. */
t4_row_read_handler_t row_read_handler;
/*! \brief Opaque pointer passed to row_read_handler. */
@@ -88,8 +95,6 @@
/*! \brief A point to the image buffer. */
uint8_t *image_buffer;
- /*! \brief The libtiff context for the current TIFF file */
- TIFF *tiff_file;
/*! \brief The current file name. */
const char *file;
/*! \brief The first page to transfer. -1 to start at the beginning of the file. */
@@ -99,7 +104,7 @@
/*! \brief The number of pages transferred to date. */
int pages_transferred;
- /*! \brief The number of pages in the current TIFF file. */
+ /*! \brief The number of pages in the current image file. */
int pages_in_file;
/*! \brief Column-to-column (X) resolution in pixels per metre. */
int x_resolution;
@@ -193,8 +198,15 @@
/*! \brief The maximum bits in any row of the current page. For monitoring only. */
int max_row_bits;
+ /*! \brief The text which will be used in FAX page header. No text results
+ in no header line. */
+ const char *header_info;
+
/*! \brief Error and flow logging control */
logging_state_t logging;
+
+ /*! \brief All TIFF file specific state information for the T.4 context. */
+ t4_tiff_state_t tiff;
};
#endif
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/saturated.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: saturated.h,v 1.3 2009/02/03 17:25:53 steveu Exp $
+ * $Id: saturated.h,v 1.4 2009/02/05 12:21:36 steveu Exp $
*/
/*! \file */
@@ -75,7 +75,6 @@
return INT16_MAX;
if (famp < (float) INT16_MIN)
return INT16_MIN;
- //return (int16_t) lfastrintf(famp);
return (int16_t) lrintf(famp);
}
/*- End of function --------------------------------------------------------*/
@@ -86,11 +85,33 @@
return INT16_MAX;
if (damp < (double) INT16_MIN)
return INT16_MIN;
- //return (int16_t) lfastrint(damp);
return (int16_t) lrint(damp);
}
/*- End of function --------------------------------------------------------*/
+/* Saturate to a 16 bit integer, using the fastest float to int conversion */
+static __inline__ int16_t ffastsaturatef(float famp)
+{
+ if (famp > (float) INT16_MAX)
+ return INT16_MAX;
+ if (famp < (float) INT16_MIN)
+ return INT16_MIN;
+ return (int16_t) lfastrintf(famp);
+}
+/*- End of function --------------------------------------------------------*/
+
+/* Saturate to a 16 bit integer, using the fastest double to int conversion */
+static __inline__ int16_t ffastsaturate(double damp)
+{
+ if (damp > (double) INT16_MAX)
+ return INT16_MAX;
+ if (damp < (double) INT16_MIN)
+ return INT16_MIN;
+ return (int16_t) lfastrint(damp);
+}
+/*- End of function --------------------------------------------------------*/
+
+/* Saturate to a 16 bit integer, using the closest float to int conversion */
static __inline__ float ffsaturatef(float famp)
{
if (famp > (float) INT16_MAX)
@@ -101,6 +122,7 @@
}
/*- End of function --------------------------------------------------------*/
+/* Saturate to a 16 bit integer, using the closest double to int conversion */
static __inline__ double ffsaturate(double famp)
{
if (famp > (double) INT16_MAX)
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/silence_gen.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/silence_gen.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/silence_gen.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: silence_gen.h,v 1.14 2009/02/03 16:28:41 steveu Exp $
+ * $Id: silence_gen.h,v 1.15 2009/02/04 13:18:53 steveu Exp $
*/
#if !defined(_SPANDSP_SILENCE_GEN_H_)
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/t30.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/t30.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t30.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t30.h,v 1.122 2009/02/03 16:28:41 steveu Exp $
+ * $Id: t30.h,v 1.123 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h Thu Feb 5 09:54:02 2009
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t38_non_ecm_buffer.h,v 1.5 2009/02/03 16:28:41 steveu Exp $
+ * $Id: t38_non_ecm_buffer.h,v 1.6 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/t4.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/t4.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t4.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t4.h,v 1.55 2009/02/03 16:28:41 steveu Exp $
+ * $Id: t4.h,v 1.56 2009/02/05 12:21:36 steveu Exp $
*/
/*! \file */
@@ -249,7 +249,7 @@
started with t4_rx_init.
\param s The T.4 receive context.
\return 0 for success, otherwise -1. */
-SPAN_DECLARE(int) t4_rx_delete(t4_state_t *s);
+SPAN_DECLARE(int) t4_rx_free(t4_state_t *s);
/*! \brief End reception of a document. Tidy up and close the file.
This should be used to end T.4 reception started with
@@ -379,7 +379,7 @@
started with t4_tx_init.
\param s The T.4 context.
\return 0 for success, otherwise -1. */
-SPAN_DECLARE(int) t4_tx_delete(t4_state_t *s);
+SPAN_DECLARE(int) t4_tx_free(t4_state_t *s);
/*! \brief End the transmission of a document. Tidy up and close the file.
This should be used to end T.4 transmission started with t4_tx_init.
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v42.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/v42.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v42.h Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v42.h,v 1.28 2009/02/03 16:28:41 steveu Exp $
+ * $Id: v42.h,v 1.29 2009/02/04 13:18:53 steveu Exp $
*/
/*! \page v42_page V.42 modem error correction
Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h (original)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h Thu Feb 5 09:54:02 2009
@@ -30,8 +30,8 @@
/* The date and time of the version are in UTC form. */
-#define SPANDSP_RELEASE_DATE 20090203
-#define SPANDSP_RELEASE_TIME 172817
+#define SPANDSP_RELEASE_DATE 20090205
+#define SPANDSP_RELEASE_TIME 122416
#endif
/*- End of file ------------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/t30.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/t30.c (original)
+++ freeswitch/trunk/libs/spandsp/src/t30.c Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t30.c,v 1.283 2009/02/03 16:28:40 steveu Exp $
+ * $Id: t30.c,v 1.284 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c (original)
+++ freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c Thu Feb 5 09:54:02 2009
@@ -23,7 +23,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t38_non_ecm_buffer.c,v 1.6 2009/02/03 16:28:40 steveu Exp $
+ * $Id: t38_non_ecm_buffer.c,v 1.7 2009/02/04 13:18:53 steveu Exp $
*/
/*! \file */
Modified: freeswitch/trunk/libs/spandsp/src/t4.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/t4.c (original)
+++ freeswitch/trunk/libs/spandsp/src/t4.c Thu Feb 5 09:54:02 2009
@@ -24,7 +24,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: t4.c,v 1.121 2009/02/03 16:28:40 steveu Exp $
+ * $Id: t4.c,v 1.123 2009/02/05 12:21:36 steveu Exp $
*/
/*
@@ -117,6 +117,8 @@
#include "faxfont.h"
+static int encode_row(t4_state_t *s);
+
#if defined(T4_STATE_DEBUGGING)
static void STATE_TRACE(const char *format, ...)
{
@@ -156,66 +158,68 @@
uint16_t resunit;
float x_resolution;
float y_resolution;
+ t4_tiff_state_t *t;
+ t = &s->tiff;
/* Prepare the directory entry fully before writing the image, or libtiff complains */
- TIFFSetField(s->tiff_file, TIFFTAG_COMPRESSION, s->output_compression);
- if (s->output_compression == COMPRESSION_CCITT_T4)
+ TIFFSetField(t->tiff_file, TIFFTAG_COMPRESSION, t->output_compression);
+ if (t->output_compression == COMPRESSION_CCITT_T4)
{
- TIFFSetField(s->tiff_file, TIFFTAG_T4OPTIONS, s->output_t4_options);
- TIFFSetField(s->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
+ TIFFSetField(t->tiff_file, TIFFTAG_T4OPTIONS, t->output_t4_options);
+ TIFFSetField(t->tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
}
- TIFFSetField(s->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width);
- TIFFSetField(s->tiff_file, TIFFTAG_BITSPERSAMPLE, 1);
- TIFFSetField(s->tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
- TIFFSetField(s->tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1);
- if (s->output_compression == COMPRESSION_CCITT_T4
+ TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width);
+ TIFFSetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, 1);
+ TIFFSetField(t->tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+ TIFFSetField(t->tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1);
+ if (t->output_compression == COMPRESSION_CCITT_T4
||
- s->output_compression == COMPRESSION_CCITT_T6)
+ t->output_compression == COMPRESSION_CCITT_T6)
{
- TIFFSetField(s->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L);
+ TIFFSetField(t->tiff_file, TIFFTAG_ROWSPERSTRIP, -1L);
}
else
{
- TIFFSetField(s->tiff_file,
+ TIFFSetField(t->tiff_file,
TIFFTAG_ROWSPERSTRIP,
- TIFFDefaultStripSize(s->tiff_file, 0));
+ TIFFDefaultStripSize(t->tiff_file, 0));
}
- TIFFSetField(s->tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
- TIFFSetField(s->tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
- TIFFSetField(s->tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB);
+ TIFFSetField(t->tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+ TIFFSetField(t->tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
+ TIFFSetField(t->tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB);
x_resolution = s->x_resolution/100.0f;
y_resolution = s->y_resolution/100.0f;
/* Metric seems the sane thing to use in the 21st century, but a lot of lousy software
gets FAX resolutions wrong, and more get it wrong using metric than using inches. */
#if 0
- TIFFSetField(s->tiff_file, TIFFTAG_XRESOLUTION, x_resolution);
- TIFFSetField(s->tiff_file, TIFFTAG_YRESOLUTION, y_resolution);
+ TIFFSetField(t->tiff_file, TIFFTAG_XRESOLUTION, x_resolution);
+ TIFFSetField(t->tiff_file, TIFFTAG_YRESOLUTION, y_resolution);
resunit = RESUNIT_CENTIMETER;
- TIFFSetField(s->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit);
+ TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit);
#else
- TIFFSetField(s->tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*CM_PER_INCH + 0.5f));
- TIFFSetField(s->tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*CM_PER_INCH + 0.5f));
+ TIFFSetField(t->tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*CM_PER_INCH + 0.5f));
+ TIFFSetField(t->tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*CM_PER_INCH + 0.5f));
resunit = RESUNIT_INCH;
- TIFFSetField(s->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit);
+ TIFFSetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit);
#endif
/* TODO: add the version of spandsp */
- TIFFSetField(s->tiff_file, TIFFTAG_SOFTWARE, "spandsp");
+ TIFFSetField(t->tiff_file, TIFFTAG_SOFTWARE, "spandsp");
if (gethostname(buf, sizeof(buf)) == 0)
- TIFFSetField(s->tiff_file, TIFFTAG_HOSTCOMPUTER, buf);
+ TIFFSetField(t->tiff_file, TIFFTAG_HOSTCOMPUTER, buf);
#if defined(TIFFTAG_FAXDCS)
- if (s->dcs)
- TIFFSetField(s->tiff_file, TIFFTAG_FAXDCS, s->dcs);
+ if (t->dcs)
+ TIFFSetField(t->tiff_file, TIFFTAG_FAXDCS, t->dcs);
#endif
- if (s->sub_address)
- TIFFSetField(s->tiff_file, TIFFTAG_FAXSUBADDRESS, s->sub_address);
- if (s->far_ident)
- TIFFSetField(s->tiff_file, TIFFTAG_IMAGEDESCRIPTION, s->far_ident);
- if (s->vendor)
- TIFFSetField(s->tiff_file, TIFFTAG_MAKE, s->vendor);
- if (s->model)
- TIFFSetField(s->tiff_file, TIFFTAG_MODEL, s->model);
+ if (t->sub_address)
+ TIFFSetField(t->tiff_file, TIFFTAG_FAXSUBADDRESS, t->sub_address);
+ if (t->far_ident)
+ TIFFSetField(t->tiff_file, TIFFTAG_IMAGEDESCRIPTION, t->far_ident);
+ if (t->vendor)
+ TIFFSetField(t->tiff_file, TIFFTAG_MAKE, t->vendor);
+ if (t->model)
+ TIFFSetField(t->tiff_file, TIFFTAG_MODEL, t->model);
time(&now);
tm = localtime(&now);
@@ -227,43 +231,33 @@
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
- TIFFSetField(s->tiff_file, TIFFTAG_DATETIME, buf);
- TIFFSetField(s->tiff_file, TIFFTAG_FAXRECVTIME, now - s->page_start_time);
+ TIFFSetField(t->tiff_file, TIFFTAG_DATETIME, buf);
+ TIFFSetField(t->tiff_file, TIFFTAG_FAXRECVTIME, now - s->page_start_time);
- TIFFSetField(s->tiff_file, TIFFTAG_IMAGELENGTH, s->image_length);
+ TIFFSetField(t->tiff_file, TIFFTAG_IMAGELENGTH, s->image_length);
/* Set the total pages to 1. For any one page document we will get this
right. For multi-page documents we will need to come back and fill in
the right answer when we know it. */
- TIFFSetField(s->tiff_file, TIFFTAG_PAGENUMBER, s->pages_transferred++, 1);
+ TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, s->pages_transferred++, 1);
s->pages_in_file = s->pages_transferred;
- if (s->output_compression == COMPRESSION_CCITT_T4)
+ if (t->output_compression == COMPRESSION_CCITT_T4)
{
if (s->bad_rows)
{
- TIFFSetField(s->tiff_file, TIFFTAG_BADFAXLINES, s->bad_rows);
- TIFFSetField(s->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED);
- TIFFSetField(s->tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s->longest_bad_row_run);
+ TIFFSetField(t->tiff_file, TIFFTAG_BADFAXLINES, s->bad_rows);
+ TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED);
+ TIFFSetField(t->tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s->longest_bad_row_run);
}
else
{
- TIFFSetField(s->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN);
+ TIFFSetField(t->tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN);
}
}
- TIFFSetField(s->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width);
+ TIFFSetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, s->image_width);
return 0;
}
/*- End of function --------------------------------------------------------*/
-static void update_row_bit_info(t4_state_t *s)
-{
- if (s->row_bits > s->max_row_bits)
- s->max_row_bits = s->row_bits;
- if (s->row_bits < s->min_row_bits)
- s->min_row_bits = s->row_bits;
- s->row_bits = 0;
-}
-/*- End of function --------------------------------------------------------*/
-
static int test_resolution(int res_unit, float actual, float expected)
{
if (res_unit == RESUNIT_INCH)
@@ -310,24 +304,26 @@
float x_resolution;
float y_resolution;
int i;
+ t4_tiff_state_t *t;
+ t = &s->tiff;
parm = 0;
- TIFFGetField(s->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm);
+ TIFFGetField(t->tiff_file, TIFFTAG_BITSPERSAMPLE, &parm);
if (parm != 1)
return -1;
parm = 0;
- TIFFGetField(s->tiff_file, TIFFTAG_IMAGEWIDTH, &parm);
+ TIFFGetField(t->tiff_file, TIFFTAG_IMAGEWIDTH, &parm);
s->image_width = parm;
s->bytes_per_row = (s->image_width + 7)/8;
parm = 0;
- TIFFGetField(s->tiff_file, TIFFTAG_IMAGELENGTH, &parm);
+ TIFFGetField(t->tiff_file, TIFFTAG_IMAGELENGTH, &parm);
s->image_length = parm;
x_resolution = 0.0f;
- TIFFGetField(s->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution);
+ TIFFGetField(t->tiff_file, TIFFTAG_XRESOLUTION, &x_resolution);
y_resolution = 0.0f;
- TIFFGetField(s->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution);
+ TIFFGetField(t->tiff_file, TIFFTAG_YRESOLUTION, &y_resolution);
res_unit = RESUNIT_INCH;
- TIFFGetField(s->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit);
+ TIFFGetField(t->tiff_file, TIFFTAG_RESOLUTIONUNIT, &res_unit);
/* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the
precise value. The other value should be exact. */
@@ -360,16 +356,37 @@
static int open_tiff_input_file(t4_state_t *s, const char *file)
{
- if ((s->tiff_file = TIFFOpen(file, "r")) == NULL)
+ if ((s->tiff.tiff_file = TIFFOpen(file, "r")) == NULL)
return -1;
return 0;
}
/*- End of function --------------------------------------------------------*/
+static int read_tiff_image(t4_state_t *s)
+{
+ int row;
+ int image_length;
+
+ image_length = 0;
+ TIFFGetField(s->tiff.tiff_file, TIFFTAG_IMAGELENGTH, &image_length);
+ for (row = 0; row < image_length; row++)
+ {
+ if (TIFFReadScanline(s->tiff.tiff_file, s->row_buf, row, 0) <= 0)
+ {
+ span_log(&s->logging, SPAN_LOG_WARNING, "%s: Read error at row %d.\n", s->file, row);
+ break;
+ }
+ if (encode_row(s))
+ return -1;
+ }
+ return image_length;
+}
+/*- End of function --------------------------------------------------------*/
+
static int close_tiff_input_file(t4_state_t *s)
{
- TIFFClose(s->tiff_file);
- s->tiff_file = NULL;
+ TIFFClose(s->tiff.tiff_file);
+ s->tiff.tiff_file = NULL;
if (s->file)
free((char *) s->file);
s->file = NULL;
@@ -379,16 +396,30 @@
static int open_tiff_output_file(t4_state_t *s, const char *file)
{
- if ((s->tiff_file = TIFFOpen(file, "w")) == NULL)
+ if ((s->tiff.tiff_file = TIFFOpen(file, "w")) == NULL)
return -1;
return 0;
}
/*- End of function --------------------------------------------------------*/
+static void write_tiff_image(t4_state_t *s)
+{
+ /* Set up the TIFF directory info... */
+ set_tiff_directory_info(s);
+ /* ..and then write the image... */
+ if (TIFFWriteEncodedStrip(s->tiff.tiff_file, 0, s->image_buffer, s->image_length*s->bytes_per_row) < 0)
+ span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", s->file);
+ /* ...then the directory entry, and libtiff is happy. */
+ TIFFWriteDirectory(s->tiff.tiff_file);
+}
+/*- End of function --------------------------------------------------------*/
+
static int close_tiff_output_file(t4_state_t *s)
{
int i;
+ t4_tiff_state_t *t;
+ t = &s->tiff;
/* Perform any operations needed to tidy up a written TIFF file before
closure. */
if (s->pages_transferred > 1)
@@ -398,13 +429,13 @@
need to set the correct total page count associated with each page. */
for (i = 0; i < s->pages_transferred; i++)
{
- TIFFSetDirectory(s->tiff_file, (tdir_t) i);
- TIFFSetField(s->tiff_file, TIFFTAG_PAGENUMBER, i, s->pages_transferred);
- TIFFWriteDirectory(s->tiff_file);
+ TIFFSetDirectory(t->tiff_file, (tdir_t) i);
+ TIFFSetField(t->tiff_file, TIFFTAG_PAGENUMBER, i, s->pages_transferred);
+ TIFFWriteDirectory(t->tiff_file);
}
}
- TIFFClose(s->tiff_file);
- s->tiff_file = NULL;
+ TIFFClose(t->tiff_file);
+ t->tiff_file = NULL;
if (s->file)
{
/* Try not to leave a file behind, if we didn't receive any pages to
@@ -418,6 +449,16 @@
}
/*- End of function --------------------------------------------------------*/
+static void update_row_bit_info(t4_state_t *s)
+{
+ if (s->row_bits > s->max_row_bits)
+ s->max_row_bits = s->row_bits;
+ if (s->row_bits < s->min_row_bits)
+ s->min_row_bits = s->row_bits;
+ s->row_bits = 0;
+}
+/*- End of function --------------------------------------------------------*/
+
#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || defined(__powerpc__)
static __inline__ int run_length(unsigned int bits)
{
@@ -780,13 +821,7 @@
}
else
{
- /* Set up the TIFF directory info... */
- set_tiff_directory_info(s);
- /* ..and then write the image... */
- if (TIFFWriteEncodedStrip(s->tiff_file, 0, s->image_buffer, s->image_length*s->bytes_per_row) < 0)
- span_log(&s->logging, SPAN_LOG_WARNING, "%s: Error writing TIFF strip.\n", s->file);
- /* ...then the directory entry, and libtiff is happy. */
- TIFFWriteDirectory(s->tiff_file);
+ write_tiff_image(s);
}
s->rx_bits = 0;
s->rx_skip_bits = 0;
@@ -801,7 +836,8 @@
static __inline__ void drop_rx_bits(t4_state_t *s, int bits)
{
/* Only remove one bit right now. The rest need to be removed step by step,
- checking for a misaligned EOL along the way. */
+ checking for a misaligned EOL along the way. This is time consuming, but
+ if we don't do it a single bit error can severely damage an image. */
s->row_bits += bits;
s->rx_skip_bits += (bits - 1);
s->rx_bits--;
@@ -1162,6 +1198,11 @@
SPAN_DECLARE(t4_state_t *) t4_rx_init(t4_state_t *s, const char *file, int output_encoding)
{
+ if (s == NULL)
+ {
+ if ((s = (t4_state_t *) malloc(sizeof(*s))) == NULL)
+ return NULL;
+ }
memset(s, 0, sizeof(*s));
span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&s->logging, "T.4");
@@ -1179,16 +1220,16 @@
switch (output_encoding)
{
case T4_COMPRESSION_ITU_T4_1D:
- s->output_compression = COMPRESSION_CCITT_T4;
- s->output_t4_options = GROUP3OPT_FILLBITS;
+ s->tiff.output_compression = COMPRESSION_CCITT_T4;
+ s->tiff.output_t4_options = GROUP3OPT_FILLBITS;
break;
case T4_COMPRESSION_ITU_T4_2D:
- s->output_compression = COMPRESSION_CCITT_T4;
- s->output_t4_options = GROUP3OPT_FILLBITS | GROUP3OPT_2DENCODING;
+ s->tiff.output_compression = COMPRESSION_CCITT_T4;
+ s->tiff.output_t4_options = GROUP3OPT_FILLBITS | GROUP3OPT_2DENCODING;
break;
case T4_COMPRESSION_ITU_T6:
- s->output_compression = COMPRESSION_CCITT_T6;
- s->output_t4_options = 0;
+ s->tiff.output_compression = COMPRESSION_CCITT_T6;
+ s->tiff.output_t4_options = 0;
break;
}
@@ -1220,7 +1261,7 @@
uint32_t *bufptr;
span_log(&s->logging, SPAN_LOG_FLOW, "Start rx page - compression %d\n", s->line_encoding);
- if (s->tiff_file == NULL)
+ if (s->tiff.tiff_file == NULL)
return -1;
/* Calculate the scanline/tile width. */
@@ -1286,23 +1327,22 @@
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t4_rx_delete(t4_state_t *s)
+SPAN_DECLARE(int) t4_rx_end(t4_state_t *s)
{
- if (t4_rx_end(s))
+ if (!s->rx)
return -1;
+ if (s->tiff.tiff_file)
+ close_tiff_output_file(s);
free_buffers(s);
- free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t4_rx_end(t4_state_t *s)
+SPAN_DECLARE(int) t4_rx_free(t4_state_t *s)
{
- if (!s->rx)
+ if (t4_rx_end(s))
return -1;
- if (s->tiff_file)
- close_tiff_output_file(s);
- free_buffers(s);
+ free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -1333,31 +1373,31 @@
SPAN_DECLARE(void) t4_rx_set_dcs(t4_state_t *s, const char *dcs)
{
- s->dcs = (dcs && dcs[0]) ? dcs : NULL;
+ s->tiff.dcs = (dcs && dcs[0]) ? dcs : NULL;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) t4_rx_set_sub_address(t4_state_t *s, const char *sub_address)
{
- s->sub_address = (sub_address && sub_address[0]) ? sub_address : NULL;
+ s->tiff.sub_address = (sub_address && sub_address[0]) ? sub_address : NULL;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) t4_rx_set_far_ident(t4_state_t *s, const char *ident)
{
- s->far_ident = (ident && ident[0]) ? ident : NULL;
+ s->tiff.far_ident = (ident && ident[0]) ? ident : NULL;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) t4_rx_set_vendor(t4_state_t *s, const char *vendor)
{
- s->vendor = vendor;
+ s->tiff.vendor = vendor;
}
/*- End of function --------------------------------------------------------*/
SPAN_DECLARE(void) t4_rx_set_model(t4_state_t *s, const char *model)
{
- s->model = model;
+ s->tiff.model = model;
}
/*- End of function --------------------------------------------------------*/
@@ -1721,6 +1761,11 @@
{
int run_space;
+ if (s == NULL)
+ {
+ if ((s = (t4_state_t *) malloc(sizeof(*s))) == NULL)
+ return NULL;
+ }
memset(s, 0, sizeof(*s));
span_log_init(&s->logging, SPAN_LOG_NONE, NULL);
span_log_set_protocol(&s->logging, "T.4");
@@ -1801,7 +1846,7 @@
tm.tm_hour,
tm.tm_min,
s->header_info,
- s->local_ident,
+ s->tiff.local_ident,
s->pages_transferred + 1);
}
/*- End of function --------------------------------------------------------*/
@@ -1813,9 +1858,9 @@
int repeats;
int pattern;
int row_bufptr;
- int parm;
int run_space;
int len;
+ int this_image_width;
char *t;
char header[132 + 1];
uint8_t *bufptr8;
@@ -1824,23 +1869,26 @@
span_log(&s->logging, SPAN_LOG_FLOW, "Start tx page %d\n", s->pages_transferred);
if (s->pages_transferred > s->stop_page)
return -1;
- if (s->tiff_file == NULL)
- return -1;
- if (!TIFFSetDirectory(s->tiff_file, (tdir_t) s->pages_transferred))
+ if (s->tiff.tiff_file == NULL)
return -1;
+ this_image_width = 0;
+ if (s->row_read_handler == NULL)
+ {
+ if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->pages_transferred))
+ return -1;
+ TIFFGetField(s->tiff.tiff_file, TIFFTAG_IMAGEWIDTH, &this_image_width);
+ }
s->image_size = 0;
s->tx_bitstream = 0;
s->tx_bits = 0;
s->row_is_2d = (s->line_encoding == T4_COMPRESSION_ITU_T6);
s->rows_to_next_1d_row = s->max_rows_to_next_1d_row - 1;
- /* Allow for pages being of different width */
- parm = 0;
- TIFFGetField(s->tiff_file, TIFFTAG_IMAGEWIDTH, &parm);
- run_space = (parm + 4)*sizeof(uint32_t);
- if (parm != s->image_width)
+ /* Allow for pages being of different width. */
+ run_space = (this_image_width + 4)*sizeof(uint32_t);
+ if (this_image_width != s->image_width)
{
- s->image_width = parm;
+ s->image_width = this_image_width;
s->bytes_per_row = (s->image_width + 7)/8;
if ((bufptr = (uint32_t *) realloc(s->cur_runs, run_space)) == NULL)
@@ -1928,18 +1976,8 @@
}
else
{
- s->image_length = 0;
- TIFFGetField(s->tiff_file, TIFFTAG_IMAGELENGTH, &s->image_length);
- for (row = 0; row < s->image_length; row++)
- {
- if (TIFFReadScanline(s->tiff_file, s->row_buf, row, 0) <= 0)
- {
- span_log(&s->logging, SPAN_LOG_WARNING, "%s: Read error at row %d.\n", s->file, row);
- break;
- }
- if (encode_row(s))
- return -1;
- }
+ if ((s->image_length = read_tiff_image(s)) < 0)
+ return -1;
}
if (s->line_encoding == T4_COMPRESSION_ITU_T6)
{
@@ -1970,7 +2008,7 @@
span_log(&s->logging, SPAN_LOG_FLOW, "Checking for the existance of page %d\n", s->pages_transferred + 1);
if (s->pages_transferred >= s->stop_page)
return -1;
- if (s->tiff_file == NULL)
+ if (s->tiff.tiff_file == NULL)
return -1;
if (s->pages_in_file >= 0)
{
@@ -1979,8 +2017,11 @@
}
else
{
- if (!TIFFSetDirectory(s->tiff_file, (tdir_t) s->pages_transferred + 1))
- return -1;
+ if (s->row_read_handler == NULL)
+ {
+ if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->pages_transferred + 1))
+ return -1;
+ }
}
return 0;
}
@@ -2048,23 +2089,22 @@
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t4_tx_delete(t4_state_t *s)
+SPAN_DECLARE(int) t4_tx_end(t4_state_t *s)
{
- if (t4_tx_end(s))
+ if (s->rx)
return -1;
+ if (s->tiff.tiff_file)
+ close_tiff_input_file(s);
free_buffers(s);
- free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
-SPAN_DECLARE(int) t4_tx_end(t4_state_t *s)
+SPAN_DECLARE(int) t4_tx_free(t4_state_t *s)
{
- if (s->rx)
+ if (t4_tx_end(s))
return -1;
- if (s->tiff_file)
- close_tiff_input_file(s);
- free_buffers(s);
+ free(s);
return 0;
}
/*- End of function --------------------------------------------------------*/
@@ -2085,7 +2125,7 @@
SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident)
{
- s->local_ident = (ident && ident[0]) ? ident : NULL;
+ s->tiff.local_ident = (ident && ident[0]) ? ident : NULL;
}
/*- End of function --------------------------------------------------------*/
@@ -2121,12 +2161,15 @@
trusted? Some files say 0. Actually searching for the last page is
more reliable. */
max = 0;
- while (TIFFSetDirectory(s->tiff_file, (tdir_t) max))
- max++;
+ if (s->row_write_handler == NULL)
+ {
+ while (TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) max))
+ max++;
+ /* Back to the previous page */
+ if (!TIFFSetDirectory(s->tiff.tiff_file, (tdir_t) s->pages_transferred))
+ return -1;
+ }
s->pages_in_file = max;
- /* Back to the previous page */
- if (!TIFFSetDirectory(s->tiff_file, (tdir_t) s->pages_transferred))
- return -1;
return max;
}
/*- End of function --------------------------------------------------------*/
Modified: freeswitch/trunk/libs/spandsp/src/v42.c
==============================================================================
--- freeswitch/trunk/libs/spandsp/src/v42.c (original)
+++ freeswitch/trunk/libs/spandsp/src/v42.c Thu Feb 5 09:54:02 2009
@@ -22,7 +22,7 @@
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * $Id: v42.c,v 1.48 2009/02/03 16:28:40 steveu Exp $
+ * $Id: v42.c,v 1.49 2009/02/04 13:18:53 steveu Exp $
*/
/* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
1
0