Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d820fe08
提交
d820fe08
authored
9月 19, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix small valet parking issue
上级
8df1872f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
63 行增加
和
45 行删除
+63
-45
mod_valet_parking.c
src/mod/applications/mod_valet_parking/mod_valet_parking.c
+63
-45
没有找到文件。
src/mod/applications/mod_valet_parking/mod_valet_parking.c
浏览文件 @
d820fe08
...
@@ -39,6 +39,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
...
@@ -39,6 +39,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
SWITCH_MODULE_DEFINITION
(
mod_valet_parking
,
mod_valet_parking_load
,
NULL
,
NULL
);
SWITCH_MODULE_DEFINITION
(
mod_valet_parking
,
mod_valet_parking_load
,
NULL
,
NULL
);
typedef
struct
{
typedef
struct
{
char
ext
[
256
];
char
uuid
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
char
uuid
[
SWITCH_UUID_FORMATTED_LENGTH
+
1
];
time_t
timeout
;
time_t
timeout
;
}
valet_token_t
;
}
valet_token_t
;
...
@@ -104,7 +105,7 @@ static void check_timeouts(void)
...
@@ -104,7 +105,7 @@ static void check_timeouts(void)
now
=
switch_epoch_time_now
(
NULL
);
now
=
switch_epoch_time_now
(
NULL
);
switch_mutex_lock
(
globals
.
mutex
);
switch_mutex_lock
(
globals
.
mutex
);
if
(
now
-
globals
.
last_timeout_check
>
30
)
{
if
(
now
-
globals
.
last_timeout_check
<
30
)
{
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
return
;
return
;
}
}
...
@@ -144,10 +145,10 @@ static void check_timeouts(void)
...
@@ -144,10 +145,10 @@ static void check_timeouts(void)
}
}
static
int
next_id
(
valet_lot_t
*
lot
,
int
min
,
int
max
,
int
in
)
static
valet_token_t
*
next_id
(
switch_core_session_t
*
session
,
valet_lot_t
*
lot
,
int
min
,
int
max
,
int
in
)
{
{
int
i
,
r
=
0
;
int
i
,
r
=
0
;
char
buf
[
128
]
=
""
;
char
buf
[
256
]
=
""
;
valet_token_t
*
token
;
valet_token_t
*
token
;
if
(
!
min
)
{
if
(
!
min
)
{
...
@@ -164,9 +165,20 @@ static int next_id(valet_lot_t *lot, int min, int max, int in)
...
@@ -164,9 +165,20 @@ static int next_id(valet_lot_t *lot, int min, int max, int in)
break
;
break
;
}
}
}
}
token
=
NULL
;
if
(
r
)
{
switch_snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
r
);
switch_zmalloc
(
token
,
sizeof
(
*
token
));
switch_set_string
(
token
->
uuid
,
switch_core_session_get_uuid
(
session
));
switch_set_string
(
token
->
ext
,
buf
);
switch_core_hash_insert
(
lot
->
hash
,
buf
,
token
);
}
switch_mutex_unlock
(
globals
.
mutex
);
switch_mutex_unlock
(
globals
.
mutex
);
return
r
;
return
token
;
}
}
...
@@ -182,6 +194,9 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -182,6 +194,9 @@ SWITCH_STANDARD_APP(valet_parking_function)
const
char
*
var
;
const
char
*
var
;
valet_token_t
*
token
=
NULL
;
valet_token_t
*
token
=
NULL
;
check_timeouts
();
if
((
var
=
switch_channel_get_variable
(
channel
,
"valet_announce_slot"
)))
{
if
((
var
=
switch_channel_get_variable
(
channel
,
"valet_announce_slot"
)))
{
play_announce
=
switch_true
(
var
);
play_announce
=
switch_true
(
var
);
}
}
...
@@ -206,7 +221,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -206,7 +221,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
const
char
*
io
=
argv
[
2
];
const
char
*
io
=
argv
[
2
];
const
char
*
min
=
argv
[
3
];
const
char
*
min
=
argv
[
3
];
const
char
*
max
=
argv
[
4
];
const
char
*
max
=
argv
[
4
];
int
min_i
,
max_i
,
i
d
,
i
n
=
-
1
;
int
min_i
,
max_i
,
in
=
-
1
;
if
(
argc
<
5
)
{
if
(
argc
<
5
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Usage: %s
\n
"
,
VALET_APP_SYNTAX
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Usage: %s
\n
"
,
VALET_APP_SYNTAX
);
...
@@ -231,13 +246,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -231,13 +246,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
min_i
=
atoi
(
min
);
min_i
=
atoi
(
min
);
max_i
=
atoi
(
max
);
max_i
=
atoi
(
max
);
if
(
!
(
id
=
next_id
(
lot
,
min_i
,
max_i
,
in
)))
{
if
(
!
(
token
=
next_id
(
session
,
lot
,
min_i
,
max_i
,
in
)))
{
switch_ivr_phrase_macro
(
session
,
in
?
"valet_lot_full"
:
"valet_lot_empty"
,
""
,
NULL
,
NULL
);
switch_ivr_phrase_macro
(
session
,
in
?
"valet_lot_full"
:
"valet_lot_empty"
,
""
,
NULL
,
NULL
);
switch_mutex_unlock
(
lot
->
mutex
);
switch_mutex_unlock
(
lot
->
mutex
);
return
;
return
;
}
}
switch_snprintf
(
dtmf_buf
,
sizeof
(
dtmf_buf
),
"%
d"
,
id
);
switch_snprintf
(
dtmf_buf
,
sizeof
(
dtmf_buf
),
"%
s"
,
token
->
ext
);
ext
=
dtmf_buf
;
ext
=
dtmf_buf
;
}
else
if
(
!
strcasecmp
(
ext
,
"ask"
))
{
}
else
if
(
!
strcasecmp
(
ext
,
"ask"
))
{
const
char
*
prompt
=
"ivr/ivr-enter_ext_pound.wav"
;
const
char
*
prompt
=
"ivr/ivr-enter_ext_pound.wav"
;
...
@@ -283,60 +298,63 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -283,60 +298,63 @@ SWITCH_STANDARD_APP(valet_parking_function)
}
}
}
}
switch_mutex_lock
(
lot
->
mutex
);
if
(
!
token
)
{
if
((
token
=
(
valet_token_t
*
)
switch_core_hash_find
(
lot
->
hash
,
ext
)))
{
switch_mutex_lock
(
lot
->
mutex
);
switch_core_session_t
*
b_session
;
if
((
token
=
(
valet_token_t
*
)
switch_core_hash_find
(
lot
->
hash
,
ext
)))
{
switch_core_session_t
*
b_session
;
if
(
token
->
timeout
)
{
if
(
token
->
timeout
)
{
const
char
*
var
=
switch_channel_get_variable
(
channel
,
"valet_ticket"
);
const
char
*
var
=
switch_channel_get_variable
(
channel
,
"valet_ticket"
);
if
(
!
zstr
(
var
))
{
if
(
!
zstr
(
var
))
{
if
(
!
strcmp
(
var
,
token
->
uuid
))
{
if
(
!
strcmp
(
var
,
token
->
uuid
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Valet ticket %s accepted.
\n
"
,
var
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_DEBUG
,
"Valet ticket %s accepted.
\n
"
,
var
);
token
->
timeout
=
0
;
token
->
timeout
=
0
;
switch_channel_set_variable
(
channel
,
"valet_ticket"
,
NULL
);
switch_channel_set_variable
(
channel
,
"valet_ticket"
,
NULL
);
}
else
{
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid token %s
\n
"
,
token
->
uuid
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Invalid token %s
\n
"
,
token
->
uuid
);
switch_channel_hangup
(
channel
,
SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER
);
switch_channel_hangup
(
channel
,
SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER
);
return
;
return
;
}
}
}
}
}
}
if
(
!
zstr
(
token
->
uuid
)
&&
(
b_session
=
switch_core_session_locate
(
token
->
uuid
)))
{
if
(
!
zstr
(
token
->
uuid
)
&&
(
b_session
=
switch_core_session_locate
(
token
->
uuid
)))
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
VALET_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CUSTOM
,
VALET_EVENT
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Valet-Lot-Name"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Valet-Lot-Name"
,
lot_name
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Valet-Extension"
,
ext
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Valet-Extension"
,
ext
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Action"
,
"bridge"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Action"
,
"bridge"
);
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Bridge-To-UUID"
,
switch_core_session_get_uuid
(
session
));
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"Bridge-To-UUID"
,
switch_core_session_get_uuid
(
session
));
switch_channel_event_set_data
(
switch_core_session_get_channel
(
b_session
),
event
);
switch_channel_event_set_data
(
switch_core_session_get_channel
(
b_session
),
event
);
switch_event_fire
(
&
event
);
switch_event_fire
(
&
event
);
switch_core_session_rwunlock
(
b_session
);
switch_core_session_rwunlock
(
b_session
);
token
->
timeout
=
0
;
token
->
timeout
=
0
;
switch_ivr_uuid_bridge
(
switch_core_session_get_uuid
(
session
),
token
->
uuid
);
switch_ivr_uuid_bridge
(
switch_core_session_get_uuid
(
session
),
token
->
uuid
);
switch_mutex_unlock
(
lot
->
mutex
);
switch_mutex_unlock
(
lot
->
mutex
);
return
;
return
;
}
}
}
}
}
}
token
=
NULL
;
token
=
NULL
;
switch_zmalloc
(
token
,
sizeof
(
*
token
));
switch_set_string
(
token
->
uuid
,
switch_core_session_get_uuid
(
session
));
switch_core_hash_insert
(
lot
->
hash
,
ext
,
token
);
}
if
(
!
(
tmp
=
switch_channel_get_variable
(
channel
,
"valet_hold_music"
)))
{
if
(
!
(
tmp
=
switch_channel_get_variable
(
channel
,
"valet_hold_music"
)))
{
tmp
=
switch_channel_get_hold_music
(
channel
);
tmp
=
switch_channel_get_hold_music
(
channel
);
}
}
if
(
tmp
)
if
(
tmp
)
{
music
=
tmp
;
music
=
tmp
;
}
if
(
!
strcasecmp
(
music
,
"silence"
))
{
if
(
!
strcasecmp
(
music
,
"silence"
))
{
music
=
"silence_stream://-1"
;
music
=
"silence_stream://-1"
;
}
}
switch_zmalloc
(
token
,
sizeof
(
*
token
));
switch_set_string
(
token
->
uuid
,
switch_core_session_get_uuid
(
session
));
switch_core_hash_insert
(
lot
->
hash
,
ext
,
token
);
dest
=
switch_core_session_sprintf
(
session
,
"set:valet_ticket=%s,set:valet_hold_music=%s,sleep:1000,valet_park:%s %s"
,
dest
=
switch_core_session_sprintf
(
session
,
"set:valet_ticket=%s,set:valet_hold_music=%s,sleep:1000,valet_park:%s %s"
,
token
->
uuid
,
music
,
lot_name
,
ext
);
token
->
uuid
,
music
,
lot_name
,
ext
);
switch_channel_set_variable
(
channel
,
"inline_destination"
,
dest
);
switch_channel_set_variable
(
channel
,
"inline_destination"
,
dest
);
...
@@ -351,6 +369,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -351,6 +369,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
if
((
b_session
=
switch_core_session_locate
(
uuid
)))
{
if
((
b_session
=
switch_core_session_locate
(
uuid
)))
{
token
->
timeout
=
switch_epoch_time_now
(
NULL
)
+
10
;
token
->
timeout
=
switch_epoch_time_now
(
NULL
)
+
10
;
if
(
play_announce
)
{
if
(
play_announce
)
{
switch_ivr_sleep
(
session
,
1500
,
SWITCH_TRUE
,
NULL
);
switch_ivr_phrase_macro
(
session
,
"valet_announce_ext"
,
tmp
,
NULL
,
NULL
);
switch_ivr_phrase_macro
(
session
,
"valet_announce_ext"
,
tmp
,
NULL
,
NULL
);
}
}
switch_ivr_session_transfer
(
b_session
,
dest
,
"inline"
,
NULL
);
switch_ivr_session_transfer
(
b_session
,
dest
,
"inline"
,
NULL
);
...
@@ -362,6 +381,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -362,6 +381,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
}
}
if
(
play_announce
)
{
if
(
play_announce
)
{
switch_ivr_sleep
(
session
,
1500
,
SWITCH_TRUE
,
NULL
);
switch_ivr_phrase_macro
(
session
,
"valet_announce_ext"
,
tmp
,
NULL
,
NULL
);
switch_ivr_phrase_macro
(
session
,
"valet_announce_ext"
,
tmp
,
NULL
,
NULL
);
}
}
}
}
...
@@ -405,8 +425,6 @@ SWITCH_STANDARD_APP(valet_parking_function)
...
@@ -405,8 +425,6 @@ SWITCH_STANDARD_APP(valet_parking_function)
end
:
end
:
check_timeouts
();
if
(
token
)
{
if
(
token
)
{
token
->
timeout
=
1
;
token
->
timeout
=
1
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论