Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
314a2a1e
提交
314a2a1e
authored
1月 27, 2011
作者:
Brian West
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3004
上级
48c02b7c
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
50 行增加
和
39 行删除
+50
-39
mod_spandsp_fax.c
src/mod/applications/mod_spandsp/mod_spandsp_fax.c
+50
-39
没有找到文件。
src/mod/applications/mod_spandsp/mod_spandsp_fax.c
浏览文件 @
314a2a1e
...
@@ -40,6 +40,9 @@
...
@@ -40,6 +40,9 @@
#define MAX_FEC_ENTRIES 4
#define MAX_FEC_ENTRIES 4
#define MAX_FEC_SPAN 4
#define MAX_FEC_SPAN 4
#define SPANDSP_EVENT_TXFAXRESULT "spandsp::txfaxresult"
#define SPANDSP_EVENT_RXFAXRESULT "spandsp::rxfaxresult"
/*****************************************************************************
/*****************************************************************************
OUR DEFINES AND STRUCTS
OUR DEFINES AND STRUCTS
*****************************************************************************/
*****************************************************************************/
...
@@ -305,7 +308,14 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
...
@@ -305,7 +308,14 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_core_session_t
*
session
;
switch_core_session_t
*
session
;
switch_channel_t
*
channel
;
switch_channel_t
*
channel
;
pvt_t
*
pvt
;
pvt_t
*
pvt
;
char
*
tmp
;
char
*
fax_document_transferred_pages
=
NULL
;
char
*
fax_document_total_pages
=
NULL
;
char
*
fax_image_resolution
=
NULL
;
char
*
fax_image_size
=
NULL
;
char
*
fax_bad_rows
=
NULL
;
char
*
fax_transfer_rate
=
NULL
;
char
*
fax_result_code
=
NULL
;
switch_event_t
*
event
;
pvt
=
(
pvt_t
*
)
user_data
;
pvt
=
(
pvt_t
*
)
user_data
;
switch_assert
(
pvt
);
switch_assert
(
pvt
);
...
@@ -353,13 +363,12 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
...
@@ -353,13 +363,12 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"==============================================================================
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"==============================================================================
\n
"
);
/*
/*
Set our channel variables
Set our channel variables
, variables are also used in event
*/
*/
tmp
=
switch_mprintf
(
"%i"
,
result
);
fax_result_code
=
switch_core_session_sprintf
(
session
,
"%i"
,
result
);
if
(
tmp
)
{
if
(
fax_result_code
)
{
switch_channel_set_variable
(
channel
,
"fax_result_code"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_result_code"
,
fax_result_code
);
switch_safe_free
(
tmp
);
}
}
switch_channel_set_variable
(
channel
,
"fax_result_text"
,
t30_completion_code_to_str
(
result
));
switch_channel_set_variable
(
channel
,
"fax_result_text"
,
t30_completion_code_to_str
(
result
));
...
@@ -368,49 +377,56 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
...
@@ -368,49 +377,56 @@ static void phase_e_handler(t30_state_t *s, void *user_data, int result)
switch_channel_set_variable
(
channel
,
"fax_local_station_id"
,
local_ident
);
switch_channel_set_variable
(
channel
,
"fax_local_station_id"
,
local_ident
);
switch_channel_set_variable
(
channel
,
"fax_remote_station_id"
,
far_ident
);
switch_channel_set_variable
(
channel
,
"fax_remote_station_id"
,
far_ident
);
tmp
=
switch_mprintf
(
"%i"
,
pvt
->
app_mode
==
FUNCTION_TX
?
t
.
pages_tx
:
t
.
pages_rx
);
fax_document_transferred_pages
=
switch_core_session_sprintf
(
session
,
"%i"
,
pvt
->
app_mode
==
FUNCTION_TX
?
t
.
pages_tx
:
t
.
pages_rx
);
if
(
tmp
)
{
if
(
fax_document_transferred_pages
)
{
switch_channel_set_variable
(
channel
,
"fax_document_transferred_pages"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_document_transferred_pages"
,
fax_document_transferred_pages
);
switch_safe_free
(
tmp
);
}
}
tmp
=
switch_mprintf
(
"%i"
,
t
.
pages_in_file
);
fax_document_total_pages
=
switch_core_session_sprintf
(
session
,
"%i"
,
t
.
pages_in_file
);
if
(
tmp
)
{
if
(
fax_document_total_pages
)
{
switch_channel_set_variable
(
channel
,
"fax_document_total_pages"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_document_total_pages"
,
fax_document_total_pages
);
switch_safe_free
(
tmp
);
}
}
tmp
=
switch_mprintf
(
"%ix%i"
,
t
.
x_resolution
,
t
.
y_resolution
);
fax_image_resolution
=
switch_core_session_sprintf
(
session
,
"%ix%i"
,
t
.
x_resolution
,
t
.
y_resolution
);
if
(
tmp
)
{
if
(
fax_image_resolution
)
{
switch_channel_set_variable
(
channel
,
"fax_image_resolution"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_image_resolution"
,
fax_image_resolution
);
switch_safe_free
(
tmp
);
}
}
tmp
=
switch_mprintf
(
"%d"
,
t
.
image_size
);
fax_image_size
=
switch_core_session_sprintf
(
session
,
"%d"
,
t
.
image_size
);
if
(
tmp
)
{
if
(
fax_image_size
)
{
switch_channel_set_variable
(
channel
,
"fax_image_size"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_image_size"
,
fax_image_size
);
switch_safe_free
(
tmp
);
}
}
tmp
=
switch_mprintf
(
"%d"
,
t
.
bad_rows
);
fax_bad_rows
=
switch_core_session_sprintf
(
session
,
"%d"
,
t
.
bad_rows
);
if
(
tmp
)
{
if
(
fax_bad_rows
)
{
switch_channel_set_variable
(
channel
,
"fax_bad_rows"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_bad_rows"
,
fax_bad_rows
);
switch_safe_free
(
tmp
);
}
}
tmp
=
switch_mprintf
(
"%i"
,
t
.
bit_rate
);
fax_transfer_rate
=
switch_core_session_sprintf
(
session
,
"%i"
,
t
.
bit_rate
);
if
(
tmp
)
{
if
(
fax_transfer_rate
)
{
switch_channel_set_variable
(
channel
,
"fax_transfer_rate"
,
tmp
);
switch_channel_set_variable
(
channel
,
"fax_transfer_rate"
,
fax_transfer_rate
);
switch_safe_free
(
tmp
);
}
}
/* switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); */
/* switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); */
pvt
->
done
=
1
;
pvt
->
done
=
1
;
/*
/* Fire event */
TODO Fire events
*/
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
pvt
->
app_mode
==
FUNCTION_TX
?
SPANDSP_EVENT_TXFAXRESULT
:
SPANDSP_EVENT_RXFAXRESULT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-document-transferred-pages"
,
fax_document_transferred_pages
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-document-total-pages"
,
fax_document_total_pages
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-image-resolution"
,
fax_image_resolution
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-image-size"
,
fax_image_size
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-bad-rows"
,
fax_bad_rows
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-transfer-rate"
,
fax_transfer_rate
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-result-code"
,
fax_result_code
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-result-text"
,
t30_completion_code_to_str
(
result
));
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-ecm-used"
,
(
t
.
error_correcting_mode
)
?
"on"
:
"off"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-local-station-id"
,
local_ident
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"fax-remote-station-id"
,
far_ident
);
switch_core_session_queue_private_event
(
session
,
&
event
,
SWITCH_FALSE
);
}
}
}
static
int
t38_tx_packet_handler
(
t38_core_state_t
*
s
,
void
*
user_data
,
const
uint8_t
*
buf
,
int
len
,
int
count
)
static
int
t38_tx_packet_handler
(
t38_core_state_t
*
s
,
void
*
user_data
,
const
uint8_t
*
buf
,
int
len
,
int
count
)
...
@@ -1026,7 +1042,6 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
...
@@ -1026,7 +1042,6 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Fax TX filename not set.
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Fax TX filename not set.
\n
"
);
goto
done
;
goto
done
;
}
else
if
(
pvt
->
app_mode
==
FUNCTION_RX
)
{
}
else
if
(
pvt
->
app_mode
==
FUNCTION_RX
)
{
char
*
fname
;
const
char
*
prefix
;
const
char
*
prefix
;
switch_time_t
time
;
switch_time_t
time
;
...
@@ -1036,11 +1051,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
...
@@ -1036,11 +1051,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
prefix
=
globals
.
prepend_string
;
prefix
=
globals
.
prepend_string
;
}
}
fname
=
switch_mprintf
(
"%s/%s-%ld-%ld.tif"
,
globals
.
spool
,
prefix
,
globals
.
total_sessions
,
time
);
if
(
!
(
pvt
->
filename
=
switch_core_session_sprintf
(
session
,
"%s/%s-%ld-%ld.tif"
,
globals
.
spool
,
prefix
,
globals
.
total_sessions
,
time
)))
{
if
(
fname
)
{
pvt
->
filename
=
switch_core_session_strdup
(
session
,
fname
);
switch_safe_free
(
fname
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Cannot automatically set fax RX destination file
\n
"
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Cannot automatically set fax RX destination file
\n
"
);
goto
done
;
goto
done
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论