Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
48554d1a
提交
48554d1a
authored
12月 22, 2012
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compiles
上级
22d838b4
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
793 行增加
和
634 行删除
+793
-634
switch_core_media.h
src/include/switch_core_media.h
+16
-2
switch_types.h
src/include/switch_types.h
+1
-0
mod_sofia.h
src/mod/endpoints/mod_sofia/mod_sofia.h
+13
-4
sofia.c
src/mod/endpoints/mod_sofia/sofia.c
+45
-59
sofia_glue.c
src/mod/endpoints/mod_sofia/sofia_glue.c
+114
-206
sofia_media.c
src/mod/endpoints/mod_sofia/sofia_media.c
+11
-312
switch_core_media.c
src/switch_core_media.c
+593
-51
没有找到文件。
src/include/switch_core_media.h
浏览文件 @
48554d1a
...
...
@@ -89,7 +89,7 @@ typedef struct switch_core_media_params_s {
uint32_t
rtp_hold_timeout_sec
;
uint32_t
dtmf_delay
;
uint32_t
codec_flags
;
int
reinvite
;
switch_core_media_NDLB_t
ndlb
;
switch_rtp_bug_flag_t
auto_rtp_bugs
;
...
...
@@ -127,10 +127,16 @@ typedef struct switch_core_media_params_s {
char
*
extsipip
;
char
*
local_network
;
char
*
sipip
;
char
*
sdp_username
;
switch_mutex_t
*
mutex
;
switch_payload_t
te
;
//x:tp
switch_payload_t
recv_te
;
//x:tp
char
*
adv_sdp_audio_ip
;
}
switch_core_media_params_t
;
...
...
@@ -188,6 +194,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_write_frame(switch_core_sessio
SWITCH_DECLARE
(
int
)
switch_core_media_check_nat
(
switch_media_handle_t
*
smh
,
const
char
*
network_ip
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_choose_port
(
switch_core_session_t
*
session
,
switch_media_type_t
type
,
int
force
);
SWITCH_DECLARE
(
void
)
switch_core_media_check_dtmf_type
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
void
)
switch_core_media_absorb_sdp
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_proxy_remote_addr
(
switch_core_session_t
*
session
,
const
char
*
sdp_str
);
SWITCH_DECLARE
(
void
)
switch_core_media_deactivate_rtp
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_activate_rtp
(
switch_core_session_t
*
session
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_ext_address_lookup
(
switch_core_session_t
*
session
,
char
**
ip
,
switch_port_t
*
port
,
const
char
*
sourceip
);
SWITCH_DECLARE
(
switch_status_t
)
switch_core_media_process_t38_passthru
(
switch_core_session_t
*
session
,
switch_core_session_t
*
other_session
,
switch_t38_options_t
*
t38_options
);
SWITCH_END_EXTERN_C
#endif
...
...
src/include/switch_types.h
浏览文件 @
48554d1a
...
...
@@ -1292,6 +1292,7 @@ typedef enum {
CF_PASS_RFC2833
,
CF_T38_PASSTHRU
,
CF_DROP_DTMF
,
CF_REINVITE
,
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
/* IF YOU ADD NEW ONES CHECK IF THEY SHOULD PERSIST OR ZERO THEM IN switch_core_session.c switch_core_session_request_xml() */
CF_FLAG_MAX
...
...
src/mod/endpoints/mod_sofia/mod_sofia.h
浏览文件 @
48554d1a
...
...
@@ -195,6 +195,7 @@ typedef enum {
typedef
enum
{
PFLAG_AUTH_CALLS
,
PFLAG_AUTH_MESSAGES
,
PFLAG_PASS_RFC2833
,
PFLAG_BLIND_REG
,
PFLAG_AUTH_ALL
,
PFLAG_FULL_ID
,
...
...
@@ -286,7 +287,6 @@ typedef enum {
TFLAG_EARLY_MEDIA
,
TFLAG_3PCC
,
TFLAG_READY
,
TFLAG_REINVITE
,
TFLAG_REFER
,
TFLAG_NOHUP
,
TFLAG_NOSDP_REINVITE
,
...
...
@@ -523,8 +523,15 @@ struct sofia_profile {
char
*
shutdown_type
;
char
*
extrtpip
;
char
*
rtpip
[
MAX_RTPIP
];
char
*
jb_msec
;
switch_payload_t
te
;
//x:tp
switch_payload_t
recv_te
;
//x:tp
uint32_t
rtpip_index
;
uint32_t
rtpip_next
;
char
*
rtcp_audio_interval_msec
;
char
*
rtcp_video_interval_msec
;
char
*
sdp_username
;
char
*
sipip
;
char
*
extsipip
;
char
*
url
;
...
...
@@ -573,7 +580,7 @@ struct sofia_profile {
switch_core_media_flag_t
media_flags
[
SCMF_MAX
];
unsigned
int
mflags
;
unsigned
int
ndlb
;
unsigned
int
mdlb
;
unsigned
int
m
n
dlb
;
uint32_t
max_calls
;
uint32_t
nonce_ttl
;
nua_t
*
nua
;
...
...
@@ -907,8 +914,6 @@ void launch_sofia_profile_thread(sofia_profile_t *profile);
switch_status_t
sofia_presence_chat_send
(
switch_event_t
*
message_event
);
void
sofia_media_tech_absorb_sdp
(
private_object_t
*
tech_pvt
);
/*
* \brief Sets the "ep_codec_string" channel variable, parsing r_sdp and taing codec_string in consideration
* \param channel Current channel
...
...
@@ -1152,6 +1157,10 @@ void sofia_glue_fire_events(sofia_profile_t *profile);
void
sofia_event_fire
(
sofia_profile_t
*
profile
,
switch_event_t
**
event
);
void
sofia_queue_message
(
sofia_dispatch_event_t
*
de
);
void
sofia_media_set_sdp_codec_string
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
);
int
sofia_glue_check_nat
(
sofia_profile_t
*
profile
,
const
char
*
network_ip
);
switch_status_t
sofia_glue_ext_address_lookup
(
sofia_profile_t
*
profile
,
char
**
ip
,
switch_port_t
*
port
,
const
char
*
sourceip
,
switch_memory_pool_t
*
pool
);
/* For Emacs:
* Local Variables:
...
...
src/mod/endpoints/mod_sofia/sofia.c
浏览文件 @
48554d1a
差异被折叠。
点击展开。
src/mod/endpoints/mod_sofia/sofia_glue.c
浏览文件 @
48554d1a
差异被折叠。
点击展开。
src/mod/endpoints/mod_sofia/sofia_media.c
浏览文件 @
48554d1a
...
...
@@ -34,45 +34,6 @@
void
sofia_media_tech_absorb_sdp
(
private_object_t
*
tech_pvt
)
{
const
char
*
sdp_str
;
if
((
sdp_str
=
switch_channel_get_variable
(
tech_pvt
->
channel
,
SWITCH_B_SDP_VARIABLE
)))
{
sdp_parser_t
*
parser
;
sdp_session_t
*
sdp
;
sdp_media_t
*
m
;
sdp_connection_t
*
connection
;
if
((
parser
=
sdp_parse
(
NULL
,
sdp_str
,
(
int
)
strlen
(
sdp_str
),
0
)))
{
if
((
sdp
=
sdp_session
(
parser
)))
{
for
(
m
=
sdp
->
sdp_media
;
m
;
m
=
m
->
m_next
)
{
if
(
m
->
m_type
!=
sdp_media_audio
||
!
m
->
m_port
)
{
continue
;
}
connection
=
sdp
->
sdp_connection
;
if
(
m
->
m_connections
)
{
connection
=
m
->
m_connections
;
}
if
(
connection
)
{
tech_pvt
->
proxy_sdp_audio_ip
=
switch_core_session_strdup
(
tech_pvt
->
session
,
connection
->
c_address
);
}
tech_pvt
->
proxy_sdp_audio_port
=
(
switch_port_t
)
m
->
m_port
;
if
(
tech_pvt
->
proxy_sdp_audio_ip
&&
tech_pvt
->
proxy_sdp_audio_port
)
{
break
;
}
}
}
sdp_parser_free
(
parser
);
}
sofia_media_tech_set_local_sdp
(
tech_pvt
,
sdp_str
,
SWITCH_TRUE
);
}
}
void
sofia_media_proxy_codec
(
switch_core_session_t
*
session
,
const
char
*
r_sdp
)
{
sdp_media_t
*
m
;
...
...
@@ -141,7 +102,7 @@ uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_
uint8_t
t
,
p
=
0
;
private_object_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
if
((
t
=
switch_core_media_negotiate_sdp
(
session
,
r_sdp
,
&
p
,
s
ofia_test_flag
(
tech_pvt
,
TFLAG
_REINVITE
),
if
((
t
=
switch_core_media_negotiate_sdp
(
session
,
r_sdp
,
&
p
,
s
witch_channel_test_flag
(
tech_pvt
->
channel
,
CF
_REINVITE
),
tech_pvt
->
profile
->
codec_flags
,
tech_pvt
->
profile
->
te
)))
{
sofia_set_flag_locked
(
tech_pvt
,
TFLAG_SDP
);
}
...
...
@@ -155,16 +116,18 @@ uint8_t sofia_media_negotiate_sdp(switch_core_session_t *session, const char *r_
switch_status_t
sofia_media_activate_rtp
(
private_object_t
*
tech_pvt
)
{
int
ok
;
switch_status_t
status
;
switch_mutex_lock
(
tech_pvt
->
sofia_mutex
);
status
=
switch_core_media_activate_rtp
(
tech_pvt
->
session
);
switch_mutex_unlock
(
tech_pvt
->
sofia_mutex
);
if
(
ok
)
{
if
(
status
==
SWITCH_STATUS_SUCCESS
)
{
sofia_set_flag
(
tech_pvt
,
TFLAG_RTP
);
sofia_set_flag
(
tech_pvt
,
TFLAG_IO
);
}
return
status
;
}
...
...
@@ -511,279 +474,15 @@ void sofia_media_tech_prepare_codecs(private_object_t *tech_pvt)
}
void
sofia_media_
tech_patch_sd
p
(
private_object_t
*
tech_pvt
)
void
sofia_media_
deactivate_rt
p
(
private_object_t
*
tech_pvt
)
{
switch_size_t
len
;
char
*
p
,
*
q
,
*
pe
,
*
qe
;
int
has_video
=
0
,
has_audio
=
0
,
has_ip
=
0
;
char
port_buf
[
25
]
=
""
;
char
vport_buf
[
25
]
=
""
;
char
*
new_sdp
;
int
bad
=
0
;
if
(
zstr
(
tech_pvt
->
local_sdp_str
))
{
return
;
}
len
=
strlen
(
tech_pvt
->
local_sdp_str
)
*
2
;
if
(
switch_channel_test_flag
(
tech_pvt
->
channel
,
CF_ANSWERED
)
&&
(
switch_stristr
(
"sendonly"
,
tech_pvt
->
local_sdp_str
)
||
switch_stristr
(
"0.0.0.0"
,
tech_pvt
->
local_sdp_str
)))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_DEBUG
,
"Skip patch on hold SDP
\n
"
);
return
;
}
if
(
zstr
(
tech_pvt
->
adv_sdp_audio_ip
)
||
!
tech_pvt
->
adv_sdp_audio_port
)
{
if
(
sofia_glue_tech_choose_port
(
tech_pvt
,
1
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_ERROR
,
"%s I/O Error
\n
"
,
switch_channel_get_name
(
tech_pvt
->
channel
));
return
;
}
tech_pvt
->
iananame
=
switch_core_session_strdup
(
tech_pvt
->
session
,
"PROXY"
);
tech_pvt
->
rm_rate
=
8000
;
tech_pvt
->
codec_ms
=
20
;
}
new_sdp
=
switch_core_session_alloc
(
tech_pvt
->
session
,
len
);
switch_snprintf
(
port_buf
,
sizeof
(
port_buf
),
"%u"
,
tech_pvt
->
adv_sdp_audio_port
);
p
=
tech_pvt
->
local_sdp_str
;
q
=
new_sdp
;
pe
=
p
+
strlen
(
p
);
qe
=
q
+
len
-
1
;
while
(
p
&&
*
p
)
{
if
(
p
>=
pe
)
{
bad
=
1
;
goto
end
;
}
if
(
q
>=
qe
)
{
bad
=
2
;
goto
end
;
}
if
(
tech_pvt
->
adv_sdp_audio_ip
&&
!
strncmp
(
"c=IN IP"
,
p
,
7
))
{
strncpy
(
q
,
p
,
7
);
p
+=
7
;
q
+=
7
;
strncpy
(
q
,
strchr
(
tech_pvt
->
adv_sdp_audio_ip
,
':'
)
?
"6 "
:
"4 "
,
2
);
p
+=
2
;
q
+=
2
;
strncpy
(
q
,
tech_pvt
->
adv_sdp_audio_ip
,
strlen
(
tech_pvt
->
adv_sdp_audio_ip
));
q
+=
strlen
(
tech_pvt
->
adv_sdp_audio_ip
);
while
(
p
&&
*
p
&&
((
*
p
>=
'0'
&&
*
p
<=
'9'
)
||
*
p
==
'.'
||
*
p
==
':'
||
(
*
p
>=
'A'
&&
*
p
<=
'F'
)
||
(
*
p
>=
'a'
&&
*
p
<=
'f'
)))
{
if
(
p
>=
pe
)
{
bad
=
3
;
goto
end
;
}
p
++
;
}
has_ip
++
;
}
else
if
(
!
strncmp
(
"o="
,
p
,
2
))
{
char
*
oe
=
strchr
(
p
,
'\n'
);
switch_size_t
len
;
if
(
oe
)
{
const
char
*
family
=
"IP4"
;
char
o_line
[
1024
]
=
""
;
if
(
oe
>=
pe
)
{
bad
=
5
;
goto
end
;
}
len
=
(
oe
-
p
);
p
+=
len
;
family
=
strchr
(
tech_pvt
->
profile
->
sipip
,
':'
)
?
"IP6"
:
"IP4"
;
if
(
!
tech_pvt
->
owner_id
)
{
tech_pvt
->
owner_id
=
(
uint32_t
)
switch_epoch_time_now
(
NULL
)
*
31821U
+
13849U
;
}
if
(
!
tech_pvt
->
session_id
)
{
tech_pvt
->
session_id
=
tech_pvt
->
owner_id
;
}
tech_pvt
->
session_id
++
;
snprintf
(
o_line
,
sizeof
(
o_line
),
"o=%s %010u %010u IN %s %s
\n
"
,
tech_pvt
->
profile
->
username
,
tech_pvt
->
owner_id
,
tech_pvt
->
session_id
,
family
,
tech_pvt
->
profile
->
sipip
);
strncpy
(
q
,
o_line
,
strlen
(
o_line
));
q
+=
strlen
(
o_line
)
-
1
;
}
}
else
if
(
!
strncmp
(
"s="
,
p
,
2
))
{
char
*
se
=
strchr
(
p
,
'\n'
);
switch_size_t
len
;
if
(
se
)
{
char
s_line
[
1024
]
=
""
;
if
(
se
>=
pe
)
{
bad
=
5
;
goto
end
;
}
len
=
(
se
-
p
);
p
+=
len
;
snprintf
(
s_line
,
sizeof
(
s_line
),
"s=%s
\n
"
,
tech_pvt
->
profile
->
username
);
strncpy
(
q
,
s_line
,
strlen
(
s_line
));
q
+=
strlen
(
s_line
)
-
1
;
}
}
else
if
((
!
strncmp
(
"m=audio "
,
p
,
8
)
&&
*
(
p
+
8
)
!=
'0'
)
||
(
!
strncmp
(
"m=image "
,
p
,
8
)
&&
*
(
p
+
8
)
!=
'0'
))
{
strncpy
(
q
,
p
,
8
);
p
+=
8
;
if
(
p
>=
pe
)
{
bad
=
4
;
goto
end
;
}
q
+=
8
;
if
(
q
>=
qe
)
{
bad
=
5
;
goto
end
;
}
strncpy
(
q
,
port_buf
,
strlen
(
port_buf
));
q
+=
strlen
(
port_buf
);
if
(
q
>=
qe
)
{
bad
=
6
;
goto
end
;
}
while
(
p
&&
*
p
&&
(
*
p
>=
'0'
&&
*
p
<=
'9'
))
{
if
(
p
>=
pe
)
{
bad
=
7
;
goto
end
;
}
p
++
;
}
has_audio
++
;
}
else
if
(
!
strncmp
(
"m=video "
,
p
,
8
)
&&
*
(
p
+
8
)
!=
'0'
)
{
if
(
!
has_video
)
{
sofia_glue_tech_choose_video_port
(
tech_pvt
,
1
);
tech_pvt
->
video_rm_encoding
=
"PROXY-VID"
;
tech_pvt
->
video_rm_rate
=
90000
;
tech_pvt
->
video_codec_ms
=
0
;
switch_snprintf
(
vport_buf
,
sizeof
(
vport_buf
),
"%u"
,
tech_pvt
->
adv_sdp_video_port
);
if
(
switch_channel_media_ready
(
tech_pvt
->
channel
)
&&
!
switch_rtp_ready
(
tech_pvt
->
video_rtp_session
))
{
switch_channel_set_flag
(
tech_pvt
->
channel
,
CF_VIDEO_POSSIBLE
);
sofia_set_flag
(
tech_pvt
,
TFLAG_REINVITE
);
sofia_media_activate_rtp
(
tech_pvt
);
}
}
strncpy
(
q
,
p
,
8
);
p
+=
8
;
if
(
p
>=
pe
)
{
bad
=
8
;
goto
end
;
}
q
+=
8
;
if
(
q
>=
qe
)
{
bad
=
9
;
goto
end
;
}
strncpy
(
q
,
vport_buf
,
strlen
(
vport_buf
));
q
+=
strlen
(
vport_buf
);
if
(
q
>=
qe
)
{
bad
=
10
;
goto
end
;
}
while
(
p
&&
*
p
&&
(
*
p
>=
'0'
&&
*
p
<=
'9'
))
{
if
(
p
>=
pe
)
{
bad
=
11
;
goto
end
;
}
p
++
;
}
has_video
++
;
}
while
(
p
&&
*
p
&&
*
p
!=
'\n'
)
{
if
(
p
>=
pe
)
{
bad
=
12
;
goto
end
;
}
if
(
q
>=
qe
)
{
bad
=
13
;
goto
end
;
}
*
q
++
=
*
p
++
;
}
if
(
p
>=
pe
)
{
bad
=
14
;
goto
end
;
}
if
(
q
>=
qe
)
{
bad
=
15
;
goto
end
;
}
*
q
++
=
*
p
++
;
}
end:
if
(
bad
)
{
return
;
int
loops
=
0
;
while
(
loops
<
10
&&
(
sofia_test_flag
(
tech_pvt
,
TFLAG_READING
)
||
sofia_test_flag
(
tech_pvt
,
TFLAG_WRITING
)))
{
switch_yield
(
10000
);
loops
++
;
}
if
(
switch_channel_down
(
tech_pvt
->
channel
)
||
sofia_test_flag
(
tech_pvt
,
TFLAG_BYE
))
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_DEBUG
,
"%s too late.
\n
"
,
switch_channel_get_name
(
tech_pvt
->
channel
));
return
;
}
if
(
!
has_ip
&&
!
has_audio
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_DEBUG
,
"%s SDP has no audio in it.
\n
%s
\n
"
,
switch_channel_get_name
(
tech_pvt
->
channel
),
tech_pvt
->
local_sdp_str
);
return
;
}
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
tech_pvt
->
session
),
SWITCH_LOG_DEBUG
,
"%s Patched SDP
\n
---
\n
%s
\n
+++
\n
%s
\n
"
,
switch_channel_get_name
(
tech_pvt
->
channel
),
tech_pvt
->
local_sdp_str
,
new_sdp
);
sofia_media_tech_set_local_sdp
(
tech_pvt
,
new_sdp
,
SWITCH_FALSE
);
switch_core_media_deactivate_rtp
(
tech_pvt
->
session
);
}
...
...
src/switch_core_media.c
浏览文件 @
48554d1a
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论