Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b4845b9f
提交
b4845b9f
authored
12月 26, 2005
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ok gsm works
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@206
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
ad455930
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
169 行增加
和
136 行删除
+169
-136
switch_caller.h
src/include/switch_caller.h
+1
-1
switch_channel.h
src/include/switch_channel.h
+2
-0
switch_module_interfaces.h
src/include/switch_module_interfaces.h
+15
-18
mod_codec_gsm.c
src/mod/codec/mod_codec_gsm/mod_codec_gsm.c
+29
-19
mod_bridgecall.c
src/mod/mod_bridgecall/mod_bridgecall.c
+1
-1
mod_exosip.c
src/mod/mod_exosip/mod_exosip.c
+3
-12
mod_iaxchan.c
src/mod/mod_iaxchan/mod_iaxchan.c
+5
-17
mod_playback.c
src/mod/mod_playback/mod_playback.c
+17
-6
mod_portaudio.c
src/mod/mod_portaudio/mod_portaudio.c
+1
-12
mod_woomerachan.c
src/mod/mod_woomerachan/mod_woomerachan.c
+3
-11
switch_caller.c
src/switch_caller.c
+31
-22
switch_channel.c
src/switch_channel.c
+22
-3
switch_core.c
src/switch_core.c
+25
-0
switch_utils.c
src/switch_utils.c
+14
-14
没有找到文件。
src/include/switch_caller.h
浏览文件 @
b4845b9f
...
...
@@ -92,7 +92,7 @@ extern "C" {
SWITCH_DECLARE
(
switch_caller_profile
*
)
switch_caller_profile_clone
(
switch_core_session
*
session
,
switch_caller_profile
*
tocopy
);
SWITCH_DECLARE
(
void
)
switch_caller_profile_event_set_data
(
switch_caller_profile
*
caller_profile
,
switch_event
*
event
);
SWITCH_DECLARE
(
void
)
switch_caller_profile_event_set_data
(
switch_caller_profile
*
caller_profile
,
char
*
prefix
,
switch_event
*
event
);
#ifdef __cplusplus
...
...
src/include/switch_channel.h
浏览文件 @
b4845b9f
...
...
@@ -53,6 +53,8 @@ SWITCH_DECLARE(void) switch_channel_set_caller_profile(switch_channel *channel,
SWITCH_DECLARE
(
switch_caller_profile
*
)
switch_channel_get_caller_profile
(
switch_channel
*
channel
);
SWITCH_DECLARE
(
void
)
switch_channel_set_originator_caller_profile
(
switch_channel
*
channel
,
switch_caller_profile
*
caller_profile
);
SWITCH_DECLARE
(
switch_caller_profile
*
)
switch_channel_get_originator_caller_profile
(
switch_channel
*
channel
);
SWITCH_DECLARE
(
void
)
switch_channel_set_originatee_caller_profile
(
switch_channel
*
channel
,
switch_caller_profile
*
caller_profile
);
SWITCH_DECLARE
(
switch_caller_profile
*
)
switch_channel_get_originatee_caller_profile
(
switch_channel
*
channel
);
SWITCH_DECLARE
(
char
*
)
switch_channel_get_variable
(
switch_channel
*
channel
,
char
*
varname
);
SWITCH_DECLARE
(
switch_status
)
switch_channel_set_variable
(
switch_channel
*
channel
,
char
*
varname
,
char
*
value
);
SWITCH_DECLARE
(
void
)
switch_channel_set_caller_extension
(
switch_channel
*
channel
,
switch_caller_extension
*
caller_extension
);
...
...
src/include/switch_module_interfaces.h
浏览文件 @
b4845b9f
...
...
@@ -176,30 +176,27 @@ struct switch_codec_settings {
float
pp_dereverb_level
;
};
struct
switch_file_handle
{
const
struct
switch_file_interface
*
file_interface
;
const
struct
switch_file_implementation
*
implementation
;
switch_file_t
*
fd
;
unsigned
int
sample_count
;
switch_codec_flag
flags
;
switch_memory_pool
*
memory_pool
;
void
*
private
;
};
struct
switch_file_implementation
{
const
struct
switch_file_implementation
*
next
;
int
codec_iananum
;
};
struct
switch_codec
{
const
struct
switch_codec_interface
*
codec_interface
;
const
struct
switch_codec_implementation
*
implementation
;
struct
switch_codec_settings
codec_settings
;
switch_codec_flag
flags
;
switch_memory_pool
*
memory_pool
;
switch_frame
raw_write_frame
;
unsigned
char
*
raw_write_frame_data
;
switch_buffer
*
raw_write_buffer
;
switch_frame
enc_write_frame
;
unsigned
char
*
enc_write_frame_data
;
switch_buffer
*
enc_write_buffer
;
switch_frame
raw_read_frame
;
unsigned
char
*
raw_read_frame_data
;
switch_buffer
*
raw_read_buffer
;
switch_frame
enc_read_frame
;
unsigned
char
*
enc_read_frame_data
;
switch_buffer
*
enc_read_buffer
;
void
*
private
;
};
...
...
src/mod/codec/mod_codec_gsm/mod_codec_gsm.c
浏览文件 @
b4845b9f
...
...
@@ -34,10 +34,14 @@
static
const
char
modname
[]
=
"mod_codec_gsm"
;
struct
gsm_context
{
gsm
encoder
;
gsm
decoder
;
};
static
switch_status
switch_gsm_init
(
switch_codec
*
codec
,
switch_codec_flag
flags
,
const
struct
switch_codec_settings
*
codec_settings
)
{
gsm
context
;
struct
gsm_context
*
context
;
int
encoding
,
decoding
;
encoding
=
(
flags
&
SWITCH_CODEC_FLAG_ENCODE
);
...
...
@@ -46,18 +50,26 @@ static switch_status switch_gsm_init(switch_codec *codec, switch_codec_flag flag
if
(
!
(
encoding
||
decoding
))
{
return
SWITCH_STATUS_FALSE
;
}
else
{
context
=
gsm_create
();
}
context
=
switch_core_alloc
(
codec
->
memory_pool
,
sizeof
(
*
context
));
if
(
encoding
)
context
->
encoder
=
gsm_create
();
if
(
decoding
)
context
->
decoder
=
gsm_create
();
}
codec
->
private
=
context
;
codec
->
private
=
context
;
return
SWITCH_STATUS_SUCCESS
;
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status
switch_gsm_destroy
(
switch_codec
*
codec
)
{
gsm_destroy
((
gsm
)
codec
->
private
);
struct
gsm_context
*
context
=
codec
->
private
;
int
encoding
=
(
codec
->
flags
&
SWITCH_CODEC_FLAG_ENCODE
);
int
decoding
=
(
codec
->
flags
&
SWITCH_CODEC_FLAG_DECODE
);
if
(
encoding
)
gsm_destroy
(
context
->
encoder
);
if
(
decoding
)
gsm_destroy
(
context
->
decoder
);
codec
->
private
=
NULL
;
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -71,24 +83,23 @@ static switch_status switch_gsm_encode(switch_codec *codec,
size_t
*
encoded_data_len
,
unsigned
int
*
flag
)
{
gsm
context
=
codec
->
private
;
struct
gsm_context
*
context
=
codec
->
private
;
int
cbret
=
0
;
if
(
!
context
)
{
return
SWITCH_STATUS_FALSE
;
}
if
(
decoded_data_len
%
16
0
==
0
)
{
if
(
decoded_data_len
%
32
0
==
0
)
{
unsigned
int
new_len
=
0
;
gsm_signal
*
ddp
=
decoded_data
;
gsm_byte
*
edp
=
encoded_data
;
int
x
;
int
loops
=
(
int
)
decoded_data_len
/
160
;
int
loops
=
(
int
)
decoded_data_len
/
320
;
for
(
x
=
0
;
x
<
loops
&&
new_len
<
*
encoded_data_len
;
x
++
)
{
gsm_encode
(
context
,
ddp
,
edp
);
edp
+=
10
;
ddp
+=
8
0
;
new_len
+=
10
;
gsm_encode
(
context
->
encoder
,
ddp
,
edp
);
edp
+=
33
;
ddp
+=
16
0
;
new_len
+=
33
;
}
if
(
new_len
<=
*
encoded_data_len
)
{
*
encoded_data_len
=
new_len
;
...
...
@@ -124,9 +135,9 @@ static switch_status switch_gsm_decode(switch_codec *codec,
int
x
;
unsigned
int
new_len
=
0
;
for
(
x
=
0
;
x
<
loops
&&
new_len
<
*
decoded_data_len
;
x
++
)
{
gsm_decode
(
&
context
,
ddp
,
e
dp
);
ddp
+=
8
0
;
edp
+=
10
;
gsm_decode
(
context
->
decoder
,
edp
,
d
dp
);
ddp
+=
16
0
;
edp
+=
33
;
new_len
+=
320
;
}
if
(
new_len
<=
*
decoded_data_len
)
{
...
...
@@ -139,7 +150,6 @@ static switch_status switch_gsm_decode(switch_codec *codec,
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"yo this frame is an odd size [%d]
\n
"
,
encoded_data_len
);
}
return
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -154,7 +164,7 @@ static const switch_codec_implementation gsm_8k_implementation = {
/*.encoded_bytes_per_frame*/
33
,
/*.number_of_channels*/
1
,
/*.pref_frames_per_packet*/
1
,
/*.max_frames_per_packet*/
7
,
/*.max_frames_per_packet*/
1
,
/*.init*/
switch_gsm_init
,
/*.encode*/
switch_gsm_encode
,
/*.decode*/
switch_gsm_decode
,
...
...
src/mod/mod_bridgecall/mod_bridgecall.c
浏览文件 @
b4845b9f
...
...
@@ -190,7 +190,6 @@ static void audio_bridge_function(switch_core_session *session, char *data)
time_t
start
;
peer_channel
=
switch_core_session_get_channel
(
peer_session
);
memset
(
&
other_audio_thread
,
0
,
sizeof
(
other_audio_thread
));
memset
(
&
this_audio_thread
,
0
,
sizeof
(
this_audio_thread
));
other_audio_thread
.
objs
[
0
]
=
session
;
...
...
@@ -226,6 +225,7 @@ static void audio_bridge_function(switch_core_session *session, char *data)
if
(
switch_channel_test_flag
(
peer_channel
,
CF_ANSWERED
))
{
switch_channel_answer
(
caller_channel
);
switch_core_session_launch_thread
(
session
,
audio_bridge_thread
,
(
void
*
)
&
other_audio_thread
);
audio_bridge_thread
(
NULL
,
(
void
*
)
&
this_audio_thread
);
switch_channel_hangup
(
peer_channel
);
...
...
src/mod/mod_exosip/mod_exosip.c
浏览文件 @
b4845b9f
...
...
@@ -367,8 +367,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
{
if
((
*
new_session
=
switch_core_session_request
(
&
exosip_endpoint_interface
,
NULL
)))
{
struct
private_object
*
tech_pvt
;
switch_channel
*
channel
,
*
orig_channel
;
switch_caller_profile
*
caller_profile
,
*
originator_caller_profile
=
NULL
;
switch_channel
*
channel
;
if
((
tech_pvt
=
(
struct
private_object
*
)
switch_core_session_alloc
(
*
new_session
,
sizeof
(
struct
private_object
))))
{
memset
(
tech_pvt
,
0
,
sizeof
(
*
tech_pvt
));
...
...
@@ -384,6 +383,8 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
if
(
outbound_profile
)
{
char
name
[
128
];
switch_caller_profile
*
caller_profile
;
caller_profile
=
switch_caller_profile_clone
(
*
new_session
,
outbound_profile
);
switch_channel_set_caller_profile
(
channel
,
caller_profile
);
tech_pvt
->
caller_profile
=
caller_profile
;
...
...
@@ -394,16 +395,6 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
switch_core_session_destroy
(
new_session
);
return
SWITCH_STATUS_GENERR
;
}
/* (session == NULL) means it was originated from the core not from another channel */
if
(
session
&&
(
orig_channel
=
switch_core_session_get_channel
(
session
)))
{
switch_caller_profile
*
cloned_profile
;
if
((
originator_caller_profile
=
switch_channel_get_caller_profile
(
orig_channel
)))
{
cloned_profile
=
switch_caller_profile_clone
(
*
new_session
,
originator_caller_profile
);
switch_channel_set_originator_caller_profile
(
channel
,
cloned_profile
);
}
}
switch_channel_set_flag
(
channel
,
CF_OUTBOUND
);
switch_set_flag
(
tech_pvt
,
TFLAG_OUTBOUND
);
...
...
src/mod/mod_iaxchan/mod_iaxchan.c
浏览文件 @
b4845b9f
...
...
@@ -477,7 +477,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
if
((
*
new_session
=
switch_core_session_request
(
&
channel_endpoint_interface
,
NULL
)))
{
struct
private_object
*
tech_pvt
;
switch_channel
*
channel
,
*
orig_channel
;
switch_caller_profile
*
caller_profile
,
*
originator_caller_profile
=
NULL
;
switch_caller_profile
*
caller_profile
;
unsigned
int
req
=
0
,
cap
=
0
;
if
((
tech_pvt
=
(
struct
private_object
*
)
switch_core_session_alloc
(
*
new_session
,
sizeof
(
struct
private_object
))))
{
...
...
@@ -523,17 +523,6 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
caller_profile
->
destination_number
,
NULL
,
0
,
req
,
cap
);
/* (session == NULL) means it was originated from the core not from another channel */
if
(
session
&&
(
orig_channel
=
switch_core_session_get_channel
(
session
)))
{
switch_caller_profile
*
cloned_profile
;
if
((
originator_caller_profile
=
switch_channel_get_caller_profile
(
orig_channel
)))
{
cloned_profile
=
switch_caller_profile_clone
(
*
new_session
,
originator_caller_profile
);
switch_channel_set_originator_caller_profile
(
channel
,
cloned_profile
);
}
}
switch_channel_set_flag
(
channel
,
CF_OUTBOUND
);
switch_set_flag
(
tech_pvt
,
TFLAG_OUTBOUND
);
switch_channel_set_state
(
channel
,
CS_INIT
);
...
...
@@ -904,8 +893,10 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
}
}
break
;
case
IAX_EVENT_BUSY
:
case
IAX_EVENT_HANGUP
:
case
IAX_EVENT_REJECT
:
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"Rejected call.
\n
"
);
case
IAX_EVENT_BUSY
:
case
IAX_EVENT_HANGUP
:
if
(
tech_pvt
)
{
switch_channel
*
channel
;
...
...
@@ -941,9 +932,6 @@ SWITCH_MOD_DECLARE(switch_status) switch_module_runtime(void)
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"Call transfer occurred.
\n
"
);
//session[0] = iaxevent->session;
break
;
case
IAX_EVENT_REJECT
:
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"Rejected call.
\n
"
);
break
;
case
IAX_EVENT_DTMF
:
if
(
tech_pvt
)
{
switch_channel
*
channel
;
...
...
src/mod/mod_playback/mod_playback.c
浏览文件 @
b4845b9f
...
...
@@ -44,17 +44,27 @@ void playback_function(switch_core_session *session, char *data)
switch_file_t
*
fd
;
char
buf
[
960
];
char
dtmf
[
128
];
char
*
ext
;
int
interval
=
0
,
samples
=
0
;
size_t
len
=
0
,
ilen
=
0
;
switch_frame
write_frame
;
switch_timer
timer
;
switch_core_thread_session
thread_session
;
switch_codec
codec
;
char
*
codec_name
;
int
x
;
channel
=
switch_core_session_get_channel
(
session
);
assert
(
channel
!=
NULL
);
if
(
!
(
ext
=
strrchr
(
data
,
'.'
)))
{
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"Invalid Format
\n
"
);
return
;
}
ext
++
;
switch_channel_answer
(
channel
);
write_frame
.
data
=
buf
;
...
...
@@ -65,19 +75,20 @@ void playback_function(switch_core_session *session, char *data)
switch_channel_hangup
(
channel
);
return
;
}
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"OPEN FILE %s
\n
"
,
data
);
interval
=
20
;
len
=
320
;
samples
=
160
;
codec_name
=
"L16"
;
#if 0
interval = 30;
len = 480;
samples = 240;
interval = 20;
len = 33;
samples = 160;
codec_name = "gsm";
#endif
write_frame
.
samples
=
samples
;
...
...
@@ -91,7 +102,7 @@ void playback_function(switch_core_session *session, char *data)
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"setup timer success %d bytes per %d ms!
\n
"
,
len
,
interval
);
if
(
switch_core_codec_init
(
&
codec
,
"L16"
,
8000
,
interval
,
SWITCH_CODEC_FLAG_ENCODE
|
SWITCH_CODEC_FLAG_DECODE
,
NULL
)
==
SWITCH_STATUS_SUCCESS
)
{
if
(
switch_core_codec_init
(
&
codec
,
codec_name
,
8000
,
interval
,
SWITCH_CODEC_FLAG_ENCODE
|
SWITCH_CODEC_FLAG_DECODE
,
NULL
)
==
SWITCH_STATUS_SUCCESS
)
{
switch_console_printf
(
SWITCH_CHANNEL_CONSOLE
,
"Raw Codec Activated
\n
"
);
write_frame
.
codec
=
&
codec
;
}
else
{
...
...
src/mod/mod_portaudio/mod_portaudio.c
浏览文件 @
b4845b9f
...
...
@@ -297,7 +297,7 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
if
((
*
new_session
=
switch_core_session_request
(
&
channel_endpoint_interface
,
NULL
)))
{
struct
private_object
*
tech_pvt
;
switch_channel
*
channel
,
*
orig_channel
;
switch_caller_profile
*
caller_profile
,
*
originator_caller_profile
=
NULL
;
switch_caller_profile
*
caller_profile
;
if
((
tech_pvt
=
(
struct
private_object
*
)
switch_core_session_alloc
(
*
new_session
,
sizeof
(
struct
private_object
))))
{
memset
(
tech_pvt
,
0
,
sizeof
(
*
tech_pvt
));
...
...
@@ -323,17 +323,6 @@ static switch_status channel_outgoing_channel(switch_core_session *session, swit
return
SWITCH_STATUS_GENERR
;
}
/* (session == NULL) means it was originated from the core not from another channel */
if
(
session
&&
(
orig_channel
=
switch_core_session_get_channel
(
session
)))
{
switch_caller_profile
*
cloned_profile
;
if
((
originator_caller_profile
=
switch_channel_get_caller_profile
(
orig_channel
)))
{
cloned_profile
=
switch_caller_profile_clone
(
*
new_session
,
originator_caller_profile
);
switch_channel_set_originator_caller_profile
(
channel
,
cloned_profile
);
}
}
switch_channel_set_flag
(
channel
,
CF_OUTBOUND
);
switch_set_flag
(
tech_pvt
,
TFLAG_OUTBOUND
);
switch_channel_set_state
(
channel
,
CS_INIT
);
...
...
src/mod/mod_woomerachan/mod_woomerachan.c
浏览文件 @
b4845b9f
...
...
@@ -348,8 +348,8 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
if
((
*
new_session
=
switch_core_session_request
(
&
woomerachan_endpoint_interface
,
NULL
)))
{
struct
private_object
*
tech_pvt
;
switch_channel
*
channel
,
*
orig_channel
;
switch_caller_profile
*
caller_profile
,
*
originator_caller_profile
=
NULL
;
if
((
tech_pvt
=
(
struct
private_object
*
)
switch_core_session_alloc
(
*
new_session
,
sizeof
(
struct
private_object
))))
{
memset
(
tech_pvt
,
0
,
sizeof
(
*
tech_pvt
));
tech_pvt
->
profile
=
&
default_profile
;
...
...
@@ -364,6 +364,8 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
if
(
outbound_profile
)
{
char
name
[
128
];
switch_caller_profile
*
caller_profile
;
caller_profile
=
switch_caller_profile_clone
(
*
new_session
,
outbound_profile
);
switch_channel_set_caller_profile
(
channel
,
caller_profile
);
tech_pvt
->
caller_profile
=
caller_profile
;
...
...
@@ -375,16 +377,6 @@ static switch_status woomerachan_outgoing_channel(switch_core_session *session,
return
SWITCH_STATUS_GENERR
;
}
/* (session == NULL) means it was originated from the core not from another channel */
if
(
session
&&
(
orig_channel
=
switch_core_session_get_channel
(
session
)))
{
switch_caller_profile
*
cloned_profile
;
if
((
originator_caller_profile
=
switch_channel_get_caller_profile
(
orig_channel
)))
{
cloned_profile
=
switch_caller_profile_clone
(
*
new_session
,
originator_caller_profile
);
switch_channel_set_originator_caller_profile
(
channel
,
cloned_profile
);
}
}
switch_channel_set_flag
(
channel
,
CF_OUTBOUND
);
switch_set_flag
(
tech_pvt
,
TFLAG_OUTBOUND
);
switch_channel_set_state
(
channel
,
CS_INIT
);
...
...
src/switch_caller.c
浏览文件 @
b4845b9f
...
...
@@ -75,30 +75,39 @@ SWITCH_DECLARE(switch_caller_profile *) switch_caller_profile_clone(switch_core_
return
profile
;
}
SWITCH_DECLARE
(
void
)
switch_caller_profile_event_set_data
(
switch_caller_profile
*
caller_profile
,
switch_event
*
event
)
SWITCH_DECLARE
(
void
)
switch_caller_profile_event_set_data
(
switch_caller_profile
*
caller_profile
,
char
*
prefix
,
switch_event
*
event
)
{
if
(
caller_profile
->
dialplan
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Dialplan"
,
caller_profile
->
dialplan
);
}
if
(
caller_profile
->
caller_id_name
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Caller-ID-Name"
,
caller_profile
->
caller_id_name
);
}
if
(
caller_profile
->
caller_id_number
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Caller-ID-Number"
,
caller_profile
->
caller_id_number
);
}
if
(
caller_profile
->
network_addr
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Network-Addr"
,
caller_profile
->
network_addr
);
}
if
(
caller_profile
->
ani
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-ANI"
,
caller_profile
->
ani
);
}
if
(
caller_profile
->
ani2
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-ANI2"
,
caller_profile
->
ani2
);
}
if
(
caller_profile
->
destination_number
)
{
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Destination-Number"
,
caller_profile
->
destination_number
);
}
char
header_name
[
1024
];
if
(
caller_profile
->
dialplan
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-Dialplan"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
dialplan
);
}
if
(
caller_profile
->
caller_id_name
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-Caller-ID-Name"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
caller_id_name
);
}
if
(
caller_profile
->
caller_id_number
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-Caller-ID-Number"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
caller_id_number
);
}
if
(
caller_profile
->
network_addr
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-Network-Addr"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
network_addr
);
}
if
(
caller_profile
->
ani
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-ANI"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
ani
);
}
if
(
caller_profile
->
ani2
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-ANI2"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
ani2
);
}
if
(
caller_profile
->
destination_number
)
{
snprintf
(
header_name
,
sizeof
(
header_name
),
"%s-Destination-Number"
,
prefix
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
header_name
,
caller_profile
->
destination_number
);
}
}
...
...
src/switch_channel.c
浏览文件 @
b4845b9f
...
...
@@ -41,6 +41,7 @@ struct switch_channel {
switch_channel_flag
flags
;
switch_caller_profile
*
caller_profile
;
switch_caller_profile
*
originator_caller_profile
;
switch_caller_profile
*
originatee_caller_profile
;
switch_caller_extension
*
caller_extension
;
const
struct
switch_event_handler_table
*
event_handlers
;
switch_hash
*
variables
;
...
...
@@ -397,13 +398,14 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
SWITCH_DECLARE
(
void
)
switch_channel_event_set_data
(
switch_channel
*
channel
,
switch_event
*
event
)
{
switch_caller_profile
*
caller_profile
,
*
originator_caller_profile
;
switch_caller_profile
*
caller_profile
,
*
originator_caller_profile
,
*
originatee_caller_profile
;
switch_hash_index_t
*
hi
;
void
*
val
;
const
void
*
var
;
caller_profile
=
switch_channel_get_caller_profile
(
channel
);
originator_caller_profile
=
switch_channel_get_originator_caller_profile
(
channel
);
originatee_caller_profile
=
switch_channel_get_originatee_caller_profile
(
channel
);
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-State"
,
(
char
*
)
switch_channel_state_name
(
channel
->
state
));
switch_event_add_header
(
event
,
SWITCH_STACK_BOTTOM
,
"Channel-Name"
,
switch_channel_get_name
(
channel
));
...
...
@@ -412,12 +414,17 @@ SWITCH_DECLARE(void) switch_channel_event_set_data(switch_channel *channel, swit
/* Index Caller's Profile */
if
(
caller_profile
)
{
switch_caller_profile_event_set_data
(
caller_profile
,
event
);
switch_caller_profile_event_set_data
(
caller_profile
,
"Caller"
,
event
);
}
/* Index Originator's Profile */
if
(
originator_caller_profile
)
{
switch_caller_profile_event_set_data
(
originator_caller_profile
,
event
);
switch_caller_profile_event_set_data
(
originator_caller_profile
,
"Originator"
,
event
);
}
/* Index Originatee's Profile */
if
(
originatee_caller_profile
)
{
switch_caller_profile_event_set_data
(
originatee_caller_profile
,
"Originatee"
,
event
);
}
/* Index Variables */
...
...
@@ -452,12 +459,24 @@ SWITCH_DECLARE(void) switch_channel_set_originator_caller_profile(switch_channel
channel
->
originator_caller_profile
=
caller_profile
;
}
SWITCH_DECLARE
(
void
)
switch_channel_set_originatee_caller_profile
(
switch_channel
*
channel
,
switch_caller_profile
*
caller_profile
)
{
assert
(
channel
!=
NULL
);
channel
->
originatee_caller_profile
=
caller_profile
;
}
SWITCH_DECLARE
(
switch_caller_profile
*
)
switch_channel_get_originator_caller_profile
(
switch_channel
*
channel
)
{
assert
(
channel
!=
NULL
);
return
channel
->
originator_caller_profile
;
}
SWITCH_DECLARE
(
switch_caller_profile
*
)
switch_channel_get_originatee_caller_profile
(
switch_channel
*
channel
)
{
assert
(
channel
!=
NULL
);
return
channel
->
originatee_caller_profile
;
}
SWITCH_DECLARE
(
void
)
switch_channel_set_event_handlers
(
switch_channel
*
channel
,
const
struct
switch_event_handler_table
*
event_handlers
)
{
assert
(
channel
!=
NULL
);
...
...
src/switch_core.c
浏览文件 @
b4845b9f
...
...
@@ -521,6 +521,31 @@ SWITCH_DECLARE(switch_status) switch_core_session_outgoing_channel(switch_core_s
}
}
if
(
*
new_session
)
{
switch_caller_profile
*
profile
=
NULL
,
*
peer_profile
=
NULL
,
*
cloned_profile
=
NULL
;
switch_channel
*
channel
=
NULL
,
*
peer_channel
=
NULL
;
if
((
channel
=
switch_core_session_get_channel
(
session
)))
{
profile
=
switch_channel_get_caller_profile
(
channel
);
}
if
((
peer_channel
=
switch_core_session_get_channel
(
*
new_session
)))
{
peer_profile
=
switch_channel_get_caller_profile
(
peer_channel
);
}
if
(
channel
&&
peer_channel
)
{
if
(
profile
)
{
if
((
cloned_profile
=
switch_caller_profile_clone
(
*
new_session
,
profile
)))
{
switch_channel_set_originator_caller_profile
(
peer_channel
,
cloned_profile
);
}
}
if
(
peer_profile
)
{
if
((
cloned_profile
=
switch_caller_profile_clone
(
session
,
peer_profile
)))
{
switch_channel_set_originatee_caller_profile
(
channel
,
cloned_profile
);
}
}
}
}
return
status
;
}
...
...
src/switch_utils.c
浏览文件 @
b4845b9f
...
...
@@ -31,20 +31,20 @@
*/
#include <switch_utils.h>
SWITCH_DECLARE
(
char
*
)
switch_cut_path
(
char
*
in
)
{
char
*
p
,
*
ret
=
in
;
char
delims
[]
=
"/
\\
"
;
char
*
i
;
for
(
i
=
delims
;
*
i
;
i
++
)
{
p
=
in
;
while
((
p
=
strchr
(
p
,
*
i
)))
{
ret
=
++
p
;
}
}
return
ret
;
}
SWITCH_DECLARE
(
char
*
)
switch_cut_path
(
char
*
in
)
{
char
*
p
,
*
ret
=
in
;
char
delims
[]
=
"/
\\
"
;
char
*
i
;
for
(
i
=
delims
;
*
i
;
i
++
)
{
p
=
in
;
while
((
p
=
strchr
(
p
,
*
i
)))
{
ret
=
++
p
;
}
}
return
ret
;
}
SWITCH_DECLARE
(
void
)
switch_swap_linear
(
int16_t
*
buf
,
int
len
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论