Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
6c135e15
提交
6c135e15
authored
6月 03, 2015
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7602 FS-7499 FS-7587 #comment another refactoring pass on candidate parsing and ipv4/6 parsing
上级
fc075a75
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
172 行增加
和
199 行删除
+172
-199
switch_rtp.h
src/include/switch_rtp.h
+1
-1
mod_verto.c
src/mod/endpoints/mod_verto/mod_verto.c
+31
-16
switch_apr.c
src/switch_apr.c
+6
-2
switch_core.c
src/switch_core.c
+14
-0
switch_core_media.c
src/switch_core_media.c
+98
-161
switch_rtp.c
src/switch_rtp.c
+22
-19
没有找到文件。
src/include/switch_rtp.h
浏览文件 @
6c135e15
...
@@ -103,7 +103,7 @@ typedef struct icand_s {
...
@@ -103,7 +103,7 @@ typedef struct icand_s {
typedef
struct
ice_s
{
typedef
struct
ice_s
{
icand_t
cands
[
MAX_CAND
][
2
];
icand_t
cands
[
MAX_CAND
][
2
];
int
cand_idx
;
int
cand_idx
[
2
]
;
int
chosen
[
2
];
int
chosen
[
2
];
int
is_chosen
[
2
];
int
is_chosen
[
2
];
char
*
ufrag
;
char
*
ufrag
;
...
...
src/mod/endpoints/mod_verto/mod_verto.c
浏览文件 @
6c135e15
...
@@ -143,7 +143,7 @@ static void verto_deinit_ssl(verto_profile_t *profile)
...
@@ -143,7 +143,7 @@ static void verto_deinit_ssl(verto_profile_t *profile)
static
void
close_file
(
ws_socket_t
*
sock
)
static
void
close_file
(
ws_socket_t
*
sock
)
{
{
if
(
*
sock
>
-
1
)
{
if
(
*
sock
!=
ws_sock_invalid
)
{
#ifndef WIN32
#ifndef WIN32
close
(
*
sock
);
close
(
*
sock
);
#else
#else
...
@@ -155,7 +155,7 @@ static void close_file(ws_socket_t *sock)
...
@@ -155,7 +155,7 @@ static void close_file(ws_socket_t *sock)
static
void
close_socket
(
ws_socket_t
*
sock
)
static
void
close_socket
(
ws_socket_t
*
sock
)
{
{
if
(
*
sock
>
-
1
)
{
if
(
*
sock
!=
ws_sock_invalid
)
{
shutdown
(
*
sock
,
2
);
shutdown
(
*
sock
,
2
);
close_file
(
sock
);
close_file
(
sock
);
}
}
...
@@ -1914,7 +1914,7 @@ static void *SWITCH_THREAD_FUNC client_thread(switch_thread_t *thread, void *obj
...
@@ -1914,7 +1914,7 @@ static void *SWITCH_THREAD_FUNC client_thread(switch_thread_t *thread, void *obj
switch_event_destroy
(
&
jsock
->
vars
);
switch_event_destroy
(
&
jsock
->
vars
);
switch_event_destroy
(
&
jsock
->
user_vars
);
switch_event_destroy
(
&
jsock
->
user_vars
);
if
(
jsock
->
client_socket
>
-
1
)
{
if
(
jsock
->
client_socket
!=
ws_sock_invalid
)
{
close_socket
(
&
jsock
->
client_socket
);
close_socket
(
&
jsock
->
client_socket
);
}
}
...
@@ -3655,7 +3655,7 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js
...
@@ -3655,7 +3655,7 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js
jevent
=
cJSON_Duplicate
(
params
,
1
);
jevent
=
cJSON_Duplicate
(
params
,
1
);
switch_event_channel_broadcast
(
event_channel
,
&
jevent
,
modname
,
globals
.
event_channel_id
);
switch_event_channel_broadcast
(
event_channel
,
&
jevent
,
modname
,
globals
.
event_channel_id
);
if
(
jsock
->
profile
->
mcast_pub
.
sock
>
-
1
)
{
if
(
jsock
->
profile
->
mcast_pub
.
sock
!=
ws_sock_invalid
)
{
if
((
json_text
=
cJSON_PrintUnformatted
(
params
)))
{
if
((
json_text
=
cJSON_PrintUnformatted
(
params
)))
{
if
(
mcast_socket_send
(
&
jsock
->
profile
->
mcast_pub
,
json_text
,
strlen
(
json_text
)
+
1
)
<
0
)
{
if
(
mcast_socket_send
(
&
jsock
->
profile
->
mcast_pub
,
json_text
,
strlen
(
json_text
)
+
1
)
<
0
)
{
...
@@ -3894,7 +3894,7 @@ static int start_jsock(verto_profile_t *profile, ws_socket_t sock, int family)
...
@@ -3894,7 +3894,7 @@ static int start_jsock(verto_profile_t *profile, ws_socket_t sock, int family)
error:
error:
if
(
jsock
)
{
if
(
jsock
)
{
if
(
jsock
->
client_socket
>
-
1
)
{
if
(
jsock
->
client_socket
!=
ws_sock_invalid
)
{
close_socket
(
&
jsock
->
client_socket
);
close_socket
(
&
jsock
->
client_socket
);
}
}
...
@@ -3965,7 +3965,13 @@ static ws_socket_t prepare_socket(ips_t *ips)
...
@@ -3965,7 +3965,13 @@ static ws_socket_t prepare_socket(ips_t *ips)
static
void
handle_mcast_sub
(
verto_profile_t
*
profile
)
static
void
handle_mcast_sub
(
verto_profile_t
*
profile
)
{
{
int
bytes
=
mcast_socket_recv
(
&
profile
->
mcast_sub
,
NULL
,
0
,
0
);
int
bytes
;
if
(
profile
->
mcast_sub
.
sock
==
ws_sock_invalid
)
{
return
;
}
bytes
=
mcast_socket_recv
(
&
profile
->
mcast_sub
,
NULL
,
0
,
0
);
if
(
bytes
>
0
)
{
if
(
bytes
>
0
)
{
cJSON
*
json
;
cJSON
*
json
;
...
@@ -4100,27 +4106,36 @@ static int runtime(verto_profile_t *profile)
...
@@ -4100,27 +4106,36 @@ static int runtime(verto_profile_t *profile)
{
{
int
i
;
int
i
;
int
r
=
0
;
int
r
=
0
;
int
listeners
=
0
;
for
(
i
=
0
;
i
<
profile
->
i
;
i
++
)
{
for
(
i
=
0
;
i
<
profile
->
i
;
i
++
)
{
//if ((profile->server_socket[i] = prepare_socket(profile->ip[i].local_ip_addr, profile->ip[i].local_port)) < 0) {
//if ((profile->server_socket[i] = prepare_socket(profile->ip[i].local_ip_addr, profile->ip[i].local_port)) < 0) {
if
((
profile
->
server_socket
[
i
]
=
prepare_socket
(
&
profile
->
ip
[
i
]))
<
0
)
{
if
((
profile
->
server_socket
[
i
]
=
prepare_socket
(
&
profile
->
ip
[
i
]))
!=
ws_sock_invalid
)
{
die
(
"Client Socket Error!
\n
"
)
;
listeners
++
;
}
}
}
}
if
(
!
listeners
)
{
die
(
"Client Socket Error! No Listeners!
\n
"
);
}
if
(
profile
->
mcast_ip
)
{
if
(
profile
->
mcast_ip
)
{
int
ok
=
1
;
if
(
mcast_socket_create
(
profile
->
mcast_ip
,
profile
->
mcast_port
,
&
profile
->
mcast_sub
,
MCAST_RECV
|
MCAST_TTL_HOST
)
<
0
)
{
if
(
mcast_socket_create
(
profile
->
mcast_ip
,
profile
->
mcast_port
,
&
profile
->
mcast_sub
,
MCAST_RECV
|
MCAST_TTL_HOST
)
<
0
)
{
r
=
-
1
;
ok
++
;
die
(
"mcast recv socket create
\n
"
);
}
}
if
(
mcast_socket_create
(
profile
->
mcast_ip
,
profile
->
mcast_port
+
1
,
&
profile
->
mcast_pub
,
MCAST_SEND
|
MCAST_TTL_HOST
)
>
0
)
{
if
(
ok
&&
mcast_socket_create
(
profile
->
mcast_ip
,
profile
->
mcast_port
+
1
,
&
profile
->
mcast_pub
,
MCAST_SEND
|
MCAST_TTL_HOST
)
>
0
)
{
mcast_socket_close
(
&
profile
->
mcast_sub
);
mcast_socket_close
(
&
profile
->
mcast_sub
);
r
=
-
1
;
ok
=
0
;
die
(
"mcast send socket create
\n
"
);
}
}
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"MCAST Bound to %s:%d/%d
\n
"
,
profile
->
mcast_ip
,
profile
->
mcast_port
,
profile
->
mcast_port
+
1
);
if
(
ok
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"MCAST Bound to %s:%d/%d
\n
"
,
profile
->
mcast_ip
,
profile
->
mcast_port
,
profile
->
mcast_port
+
1
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"MCAST Disabled
\n
"
);
}
}
}
...
@@ -4132,11 +4147,11 @@ static int runtime(verto_profile_t *profile)
...
@@ -4132,11 +4147,11 @@ static int runtime(verto_profile_t *profile)
error:
error:
if
(
profile
->
mcast_sub
.
sock
>
-
1
)
{
if
(
profile
->
mcast_sub
.
sock
!=
ws_sock_invalid
)
{
mcast_socket_close
(
&
profile
->
mcast_sub
);
mcast_socket_close
(
&
profile
->
mcast_sub
);
}
}
if
(
profile
->
mcast_pub
.
sock
>
-
1
)
{
if
(
profile
->
mcast_pub
.
sock
!=
ws_sock_invalid
)
{
mcast_socket_close
(
&
profile
->
mcast_pub
);
mcast_socket_close
(
&
profile
->
mcast_pub
);
}
}
...
...
src/switch_apr.c
浏览文件 @
6c135e15
...
@@ -864,11 +864,15 @@ SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switc
...
@@ -864,11 +864,15 @@ SWITCH_DECLARE(const char *) switch_get_addr(char *buf, switch_size_t len, switc
return
SWITCH_BLANK_STRING
;
return
SWITCH_BLANK_STRING
;
}
}
memset
(
buf
,
0
,
len
);
if
(
in
->
family
==
AF_INET
)
{
if
(
in
->
family
==
AF_INET
)
{
return
get_addr
(
buf
,
len
,
(
struct
sockaddr
*
)
&
in
->
sa
,
in
->
salen
);
get_addr
(
buf
,
len
,
(
struct
sockaddr
*
)
&
in
->
sa
,
in
->
salen
);
return
buf
;
}
}
return
get_addr6
(
buf
,
len
,
(
struct
sockaddr_in6
*
)
&
in
->
sa
,
in
->
salen
);
get_addr6
(
buf
,
len
,
(
struct
sockaddr_in6
*
)
&
in
->
sa
,
in
->
salen
);
return
buf
;
}
}
SWITCH_DECLARE
(
uint16_t
)
switch_sockaddr_get_port
(
switch_sockaddr_t
*
sa
)
SWITCH_DECLARE
(
uint16_t
)
switch_sockaddr_get_port
(
switch_sockaddr_t
*
sa
)
...
...
src/switch_core.c
浏览文件 @
6c135e15
...
@@ -1420,6 +1420,20 @@ SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload)
...
@@ -1420,6 +1420,20 @@ SWITCH_DECLARE(void) switch_load_network_lists(switch_bool_t reload)
switch_core_hash_insert
(
IP_LIST
.
hash
,
tmp_name
,
rfc_list
);
switch_core_hash_insert
(
IP_LIST
.
hash
,
tmp_name
,
rfc_list
);
tmp_name
=
"any_v6.auto"
;
switch_network_list_create
(
&
rfc_list
,
tmp_name
,
SWITCH_TRUE
,
IP_LIST
.
pool
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Created ip list %s default (allow)
\n
"
,
tmp_name
);
switch_network_list_add_cidr
(
rfc_list
,
"0.0.0.0/0"
,
SWITCH_FALSE
);
switch_core_hash_insert
(
IP_LIST
.
hash
,
tmp_name
,
rfc_list
);
tmp_name
=
"any_v4.auto"
;
switch_network_list_create
(
&
rfc_list
,
tmp_name
,
SWITCH_TRUE
,
IP_LIST
.
pool
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Created ip list %s default (allow)
\n
"
,
tmp_name
);
switch_network_list_add_cidr
(
rfc_list
,
"::/0"
,
SWITCH_FALSE
);
switch_core_hash_insert
(
IP_LIST
.
hash
,
tmp_name
,
rfc_list
);
tmp_name
=
"nat.auto"
;
tmp_name
=
"nat.auto"
;
switch_network_list_create
(
&
rfc_list
,
tmp_name
,
SWITCH_FALSE
,
IP_LIST
.
pool
);
switch_network_list_create
(
&
rfc_list
,
tmp_name
,
SWITCH_FALSE
,
IP_LIST
.
pool
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Created ip list %s default (deny)
\n
"
,
tmp_name
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_NOTICE
,
"Created ip list %s default (deny)
\n
"
,
tmp_name
);
...
...
src/switch_core_media.c
浏览文件 @
6c135e15
差异被折叠。
点击展开。
src/switch_rtp.c
浏览文件 @
6c135e15
...
@@ -1038,7 +1038,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
...
@@ -1038,7 +1038,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
if
(
!
icep
[
j
]
||
!
icep
[
j
]
->
ice_params
)
{
if
(
!
icep
[
j
]
||
!
icep
[
j
]
->
ice_params
)
{
continue
;
continue
;
}
}
for
(
i
=
0
;
i
<
icep
[
j
]
->
ice_params
->
cand_idx
;
i
++
)
{
for
(
i
=
0
;
i
<
icep
[
j
]
->
ice_params
->
cand_idx
[
icep
[
j
]
->
proto
]
;
i
++
)
{
if
(
icep
[
j
]
->
ice_params
&&
icep
[
j
]
->
ice_params
->
cands
[
i
][
icep
[
j
]
->
proto
].
priority
==
*
pri
)
{
if
(
icep
[
j
]
->
ice_params
&&
icep
[
j
]
->
ice_params
->
cands
[
i
][
icep
[
j
]
->
proto
].
priority
==
*
pri
)
{
if
(
j
==
IPR_RTP
)
{
if
(
j
==
IPR_RTP
)
{
icep
[
j
]
->
ice_params
->
chosen
[
j
]
=
i
;
icep
[
j
]
->
ice_params
->
chosen
[
j
]
=
i
;
...
@@ -1191,7 +1191,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
...
@@ -1191,7 +1191,7 @@ static void handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, void *d
for
(
i
=
0
;
i
<=
ice
->
ice_params
->
cand_idx
;
i
++
)
{
for
(
i
=
0
;
i
<=
ice
->
ice_params
->
cand_idx
[
ice
->
proto
]
;
i
++
)
{
if
(
ice
->
ice_params
->
cands
[
i
][
ice
->
proto
].
con_port
==
port
)
{
if
(
ice
->
ice_params
->
cands
[
i
][
ice
->
proto
].
con_port
==
port
)
{
if
(
!
strcmp
(
ice
->
ice_params
->
cands
[
i
][
ice
->
proto
].
con_addr
,
host
)
&&
if
(
!
strcmp
(
ice
->
ice_params
->
cands
[
i
][
ice
->
proto
].
con_addr
,
host
)
&&
!
strcmp
(
ice
->
ice_params
->
cands
[
i
][
ice
->
proto
].
cand_type
,
"relay"
))
{
!
strcmp
(
ice
->
ice_params
->
cands
[
i
][
ice
->
proto
].
cand_type
,
"relay"
))
{
...
@@ -2404,7 +2404,7 @@ static switch_status_t enable_remote_rtcp_socket(switch_rtp_t *rtp_session, cons
...
@@ -2404,7 +2404,7 @@ static switch_status_t enable_remote_rtcp_socket(switch_rtp_t *rtp_session, cons
host
=
switch_get_addr
(
bufa
,
sizeof
(
bufa
),
rtp_session
->
rtcp_remote_addr
);
host
=
switch_get_addr
(
bufa
,
sizeof
(
bufa
),
rtp_session
->
rtcp_remote_addr
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
rtp_session
->
session
),
SWITCH_LOG_DEBUG
,
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
rtp_session
->
session
),
SWITCH_LOG_DEBUG
,
"Setting RTCP remote addr to %s:%d
\n
"
,
host
,
rtp_session
->
remote_rtcp_port
);
"Setting RTCP remote addr to %s:%d
%d
\n
"
,
host
,
rtp_session
->
remote_rtcp_port
,
rtp_session
->
rtcp_remote_addr
->
family
);
}
}
if
(
rtp_session
->
rtcp_sock_input
&&
switch_sockaddr_get_family
(
rtp_session
->
rtcp_remote_addr
)
==
if
(
rtp_session
->
rtcp_sock_input
&&
switch_sockaddr_get_family
(
rtp_session
->
rtcp_remote_addr
)
==
...
@@ -2846,25 +2846,26 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
...
@@ -2846,25 +2846,26 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_
}
}
if
(
rtp_session
->
flags
[
SWITCH_RTP_FLAG_ENABLE_RTCP
]
&&
!
rtp_session
->
flags
[
SWITCH_RTP_FLAG_RTCP_MUX
])
{
if
(
rtp_session
->
flags
[
SWITCH_RTP_FLAG_ENABLE_RTCP
])
{
if
(
remote_rtcp_port
)
{
if
(
rtp_session
->
flags
[
SWITCH_RTP_FLAG_RTCP_MUX
])
{
rtp_session
->
remote_rtcp_port
=
remote_rtcp_port
;
rtp_session
->
rtcp_remote_addr
=
rtp_session
->
remote_addr
;
rtp_session
->
rtcp_sock_output
=
rtp_session
->
sock_output
;
}
else
{
}
else
{
rtp_session
->
remote_rtcp_port
=
rtp_session
->
eff_remote_port
+
1
;
if
(
remote_rtcp_port
)
{
}
rtp_session
->
remote_rtcp_port
=
remote_rtcp_port
;
status
=
enable_remote_rtcp_socket
(
rtp_session
,
err
);
}
else
{
rtp_session
->
remote_rtcp_port
=
rtp_session
->
eff_remote_port
+
1
;
if
(
rtp_session
->
rtcp_dtls
)
{
}
//switch_sockaddr_info_get(&rtp_session->rtcp_dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
status
=
enable_remote_rtcp_socket
(
rtp_session
,
err
);
rtp_session
->
rtcp_dtls
->
remote_addr
=
rtp_session
->
rtcp_remote_addr
;
rtp_session
->
rtcp_dtls
->
sock_output
=
rtp_session
->
rtcp_sock_output
;
if
(
rtp_session
->
rtcp_dtls
)
{
//switch_sockaddr_info_get(&rtp_session->rtcp_dtls->remote_addr, host, SWITCH_UNSPEC, port, 0, rtp_session->pool);
rtp_session
->
rtcp_dtls
->
remote_addr
=
rtp_session
->
rtcp_remote_addr
;
rtp_session
->
rtcp_dtls
->
sock_output
=
rtp_session
->
rtcp_sock_output
;
}
}
}
}
}
if
(
rtp_session
->
flags
[
SWITCH_RTP_FLAG_ENABLE_RTCP
]
&&
rtp_session
->
flags
[
SWITCH_RTP_FLAG_RTCP_MUX
])
{
rtp_session
->
rtcp_remote_addr
=
rtp_session
->
remote_addr
;
}
switch_mutex_unlock
(
rtp_session
->
write_mutex
);
switch_mutex_unlock
(
rtp_session
->
write_mutex
);
return
status
;
return
status
;
...
@@ -4112,8 +4113,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
...
@@ -4112,8 +4113,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_activate_rtcp(switch_rtp_t *rtp_sessi
rtp_session
->
rtcp_sock_output
=
rtp_session
->
sock_output
;
rtp_session
->
rtcp_sock_output
=
rtp_session
->
sock_output
;
rtp_session
->
rtcp_recv_msg_p
=
(
rtcp_msg_t
*
)
&
rtp_session
->
recv_msg
;
rtp_session
->
rtcp_recv_msg_p
=
(
rtcp_msg_t
*
)
&
rtp_session
->
recv_msg
;
return
SWITCH_STATUS_SUCCESS
;
return
enable_remote_rtcp_socket
(
rtp_session
,
&
err
);
//
return enable_remote_rtcp_socket(rtp_session, &err);
}
else
{
}
else
{
rtp_session
->
rtcp_recv_msg_p
=
(
rtcp_msg_t
*
)
&
rtp_session
->
rtcp_recv_msg
;
rtp_session
->
rtcp_recv_msg_p
=
(
rtcp_msg_t
*
)
&
rtp_session
->
rtcp_recv_msg
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论