Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
fef3711e
提交
fef3711e
authored
5月 15, 2018
作者:
Anthony Minessale
提交者:
Muteesa Fred
7月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11164: [freeswitch-core] Improve audio JB in bad conditions #resolve
上级
3e5938a5
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
66 行增加
和
30 行删除
+66
-30
switch_jitterbuffer.c
src/switch_jitterbuffer.c
+55
-29
switch_rtp.c
src/switch_rtp.c
+11
-1
没有找到文件。
src/switch_jitterbuffer.c
浏览文件 @
fef3711e
...
...
@@ -200,6 +200,8 @@ switch_jb_node_t *sort_nodes(switch_jb_node_t *list, int (*cmp)(const void *, co
}
}
static
inline
void
thin_frames
(
switch_jb_t
*
jb
,
int
freq
,
int
max
);
static
inline
switch_jb_node_t
*
new_node
(
switch_jb_t
*
jb
)
{
...
...
@@ -214,7 +216,7 @@ static inline switch_jb_node_t *new_node(switch_jb_t *jb)
}
if
(
!
np
)
{
int
mult
=
2
5
;
int
mult
=
2
;
if
(
jb
->
type
!=
SJB_VIDEO
)
{
mult
=
2
;
...
...
@@ -223,14 +225,14 @@ static inline switch_jb_node_t *new_node(switch_jb_t *jb)
mult
=
jb
->
max_packet_len
;
}
}
if
(
jb
->
allocated_nodes
>
jb
->
max_frame_len
*
mult
)
{
jb_debug
(
jb
,
2
,
"ALLOCATED FRAMES TOO HIGH! %d
\n
"
,
jb
->
allocated_nodes
);
switch_jb_reset
(
jb
);
switch_mutex_unlock
(
jb
->
list_mutex
);
return
NULL
;
}
np
=
switch_core_alloc
(
jb
->
pool
,
sizeof
(
*
np
));
jb
->
allocated_nodes
++
;
np
->
next
=
jb
->
node_list
;
...
...
@@ -391,24 +393,25 @@ static inline uint32_t jb_find_lowest_ts(switch_jb_t *jb)
static
inline
void
thin_frames
(
switch_jb_t
*
jb
,
int
freq
,
int
max
)
{
switch_jb_node_t
*
node
;
switch_jb_node_t
*
node
,
*
this_node
;
int
i
=
-
1
;
int
dropped
=
0
;
switch_mutex_lock
(
jb
->
list_mutex
);
node
=
jb
->
node_list
;
for
(
node
=
jb
->
node_list
;
node
&&
jb
->
complete_frames
>
jb
->
max_frame_len
&&
dropped
<
max
;
node
=
node
->
next
)
{
if
(
node
->
visible
)
{
while
(
node
&&
dropped
<=
max
)
{
this_node
=
node
;
node
=
node
->
next
;
if
(
this_node
->
visible
)
{
i
++
;
}
else
{
continue
;
}
if
((
i
%
freq
)
==
0
)
{
drop_ts
(
jb
,
node
->
packet
.
header
.
ts
);
node
=
jb
->
node_list
;
drop_ts
(
jb
,
this_node
->
packet
.
header
.
ts
);
dropped
++
;
}
}
...
...
@@ -418,7 +421,6 @@ static inline void thin_frames(switch_jb_t *jb, int freq, int max)
}
#if 0
static inline switch_jb_node_t *jb_find_highest_node(switch_jb_t *jb)
{
...
...
@@ -437,6 +439,7 @@ static inline switch_jb_node_t *jb_find_highest_node(switch_jb_t *jb)
return highest ? highest : NULL;
}
static inline uint32_t jb_find_highest_ts(switch_jb_t *jb)
{
switch_jb_node_t *highest = jb_find_highest_node(jb);
...
...
@@ -444,6 +447,17 @@ static inline uint32_t jb_find_highest_ts(switch_jb_t *jb)
return highest ? highest->packet.header.ts : 0;
}
static inline void drop_newest_frame(switch_jb_t *jb)
{
uint32_t ts = jb_find_highest_ts(jb);
drop_ts(jb, ts);
jb_debug(jb, 1, "Dropping highest frame ts:%u\n", ntohl(ts));
}
static inline switch_jb_node_t *jb_find_penultimate_node(switch_jb_t *jb)
{
switch_jb_node_t *np, *highest = NULL, *second_highest = NULL;
...
...
@@ -572,15 +586,9 @@ static inline void drop_oldest_frame(switch_jb_t *jb)
jb_debug
(
jb
,
1
,
"Dropping oldest frame ts:%u
\n
"
,
ntohl
(
ts
));
}
#if 0
static inline void drop_newest_frame(switch_jb_t *jb)
{
uint32_t ts = jb_find_highest_ts(jb);
drop_ts(jb, ts);
jb_debug(jb, 1, "Dropping highest frame ts:%u\n", ntohl(ts));
}
#if 0
static inline void drop_second_newest_frame(switch_jb_t *jb)
{
switch_jb_node_t *second_newest = jb_find_penultimate_node(jb);
...
...
@@ -1241,6 +1249,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_put_packet(switch_jb_t *jb, switch_rtp
}
}
add_node
(
jb
,
packet
,
len
);
if
(
switch_test_flag
(
jb
,
SJB_QUEUE_ONLY
)
&&
jb
->
complete_frames
>
jb
->
max_frame_len
)
{
...
...
@@ -1283,7 +1292,8 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
switch_jb_node_t
*
node
=
NULL
;
switch_status_t
status
;
int
plc
=
0
;
int
too_big
=
0
;
switch_mutex_lock
(
jb
->
mutex
);
if
(
jb
->
complete_frames
==
0
)
{
...
...
@@ -1350,10 +1360,10 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
jb
->
period_miss_pct
=
((
double
)
jb
->
period_miss_count
/
jb
->
period_count
)
*
100
;
if
(
jb
->
period_miss_pct
>
60
.
0
f
)
{
jb_debug
(
jb
,
2
,
"Miss percent %02f too high, resetting buffer.
\n
"
,
jb
->
period_miss_pct
);
switch_jb_reset
(
jb
);
}
//
if (jb->period_miss_pct > 60.0f) {
//
jb_debug(jb, 2, "Miss percent %02f too high, resetting buffer.\n", jb->period_miss_pct);
//
switch_jb_reset(jb);
//
}
if
((
status
=
jb_next_packet
(
jb
,
&
node
))
==
SWITCH_STATUS_SUCCESS
)
{
jb_debug
(
jb
,
2
,
"Found next frame cur ts: %u seq: %u
\n
"
,
htonl
(
node
->
packet
.
header
.
ts
),
htons
(
node
->
packet
.
header
.
seq
));
...
...
@@ -1397,7 +1407,7 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
case
SWITCH_STATUS_NOTFOUND
:
default
:
if
(
jb
->
consec_miss_count
>
jb
->
frame_len
)
{
switch_jb_reset
(
jb
);
//
switch_jb_reset(jb);
jb_frame_inc
(
jb
,
1
);
jb_debug
(
jb
,
2
,
"%s"
,
"Too many frames not found, RESIZE
\n
"
);
switch_goto_status
(
SWITCH_STATUS_RESTART
,
end
);
...
...
@@ -1445,15 +1455,31 @@ SWITCH_DECLARE(switch_status_t) switch_jb_get_packet(switch_jb_t *jb, switch_rtp
switch_mutex_unlock
(
jb
->
mutex
);
if
(
jb
->
complete_frames
>
jb
->
max_frame_len
)
{
thin_frames
(
jb
,
8
,
25
);
if
(
jb
->
type
==
SJB_VIDEO
)
{
too_big
=
jb
->
max_frame_len
*
15
;
}
else
{
too_big
=
(
int
)(
jb
->
max_frame_len
*
1
.
5
);
}
if
(
jb
->
complete_frames
>
jb
->
max_frame_len
*
2
)
{
jb_debug
(
jb
,
2
,
"JB TOO BIG (%d), RESET
\n
"
,
jb
->
complete_frames
);
switch_jb_reset
(
jb
);
if
(
jb
->
visible_nodes
>
too_big
)
{
//if (jb->complete_frames > jb->max_frame_len) {
//int b4 = jb->visible_nodes;
//thin_frames(jb, 2, jb->max_frame_len / 2);
//jb_debug(jb, 2, "JB TOO BIG (%d/%d), DROP SOME\n", b4, jb->visible_nodes);
//switch_jb_reset(jb);
}
//if (jb->complete_frames > jb->max_frame_len * 2) {
// jb_debug(jb, 2, "JB TOO BIG (%d), RESET\n", jb->complete_frames);
// switch_jb_reset(jb);
//}
if
(
jb
->
visible_nodes
>
too_big
&&
status
==
SWITCH_STATUS_SUCCESS
)
{
//if (jb->frame_len >= jb->max_frame_len && status == SWITCH_STATUS_SUCCESS) {
//if (jb->allocated_nodes > jb->max_frame_len) {
status
=
SWITCH_STATUS_TIMEOUT
;
}
return
status
;
}
...
...
src/switch_rtp.c
浏览文件 @
fef3711e
...
...
@@ -477,6 +477,7 @@ struct switch_rtp {
uint8_t
punts
;
uint8_t
clean
;
uint32_t
last_max_vb_frames
;
int
skip_timer
;
#ifdef ENABLE_ZRTP
zrtp_session_t
*
zrtp_session
;
zrtp_profile_t
*
zrtp_profile
;
...
...
@@ -6296,8 +6297,12 @@ static switch_status_t read_rtp_packet(switch_rtp_t *rtp_session, switch_size_t
case
SWITCH_STATUS_BREAK
:
break
;
case
SWITCH_STATUS_SUCCESS
:
case
SWITCH_STATUS_TIMEOUT
:
default
:
{
if
(
status
==
SWITCH_STATUS_TIMEOUT
)
{
rtp_session
->
skip_timer
=
1
;
}
rtp_session
->
stats
.
inbound
.
jb_packet_count
++
;
status
=
SWITCH_STATUS_SUCCESS
;
rtp_session
->
last_rtp_hdr
=
rtp_session
->
recv_msg
.
header
;
...
...
@@ -7098,7 +7103,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if
(
slept
)
{
switch_cond_next
();
}
else
{
switch_core_timer_next
(
&
rtp_session
->
timer
);
if
(
rtp_session
->
skip_timer
)
{
rtp_session
->
skip_timer
=
0
;
switch_cond_next
();
}
else
{
switch_core_timer_next
(
&
rtp_session
->
timer
);
}
slept
++
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论