Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d5e48302
提交
d5e48302
authored
4月 07, 2015
作者:
Anthony Minessale
提交者:
Michael Jerris
5月 28, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7501: improve linked list algorithm in a few places to help performance
上级
8e417c45
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
128 行增加
和
34 行删除
+128
-34
switch_vidderbuffer.h
src/include/switch_vidderbuffer.h
+1
-0
switch_rtp.c
src/switch_rtp.c
+2
-3
switch_utils.c
src/switch_utils.c
+36
-6
switch_vidderbuffer.c
src/switch_vidderbuffer.c
+89
-25
没有找到文件。
src/include/switch_vidderbuffer.h
浏览文件 @
d5e48302
...
@@ -45,6 +45,7 @@ SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb);
...
@@ -45,6 +45,7 @@ SWITCH_DECLARE(void) switch_vb_reset(switch_vb_t *vb);
SWITCH_DECLARE
(
void
)
switch_vb_debug_level
(
switch_vb_t
*
vb
,
uint8_t
level
);
SWITCH_DECLARE
(
void
)
switch_vb_debug_level
(
switch_vb_t
*
vb
,
uint8_t
level
);
SWITCH_DECLARE
(
int
)
switch_vb_frame_count
(
switch_vb_t
*
vb
);
SWITCH_DECLARE
(
int
)
switch_vb_frame_count
(
switch_vb_t
*
vb
);
SWITCH_DECLARE
(
int
)
switch_vb_poll
(
switch_vb_t
*
vb
);
SWITCH_DECLARE
(
int
)
switch_vb_poll
(
switch_vb_t
*
vb
);
SWITCH_DECLARE
(
switch_status_t
)
switch_vb_push_packet
(
switch_vb_t
*
vb
,
switch_rtp_packet_t
*
packet
,
switch_size_t
len
);
SWITCH_DECLARE
(
switch_status_t
)
switch_vb_put_packet
(
switch_vb_t
*
vb
,
switch_rtp_packet_t
*
packet
,
switch_size_t
len
);
SWITCH_DECLARE
(
switch_status_t
)
switch_vb_put_packet
(
switch_vb_t
*
vb
,
switch_rtp_packet_t
*
packet
,
switch_size_t
len
);
SWITCH_DECLARE
(
switch_status_t
)
switch_vb_get_packet
(
switch_vb_t
*
vb
,
switch_rtp_packet_t
*
packet
,
switch_size_t
*
len
);
SWITCH_DECLARE
(
switch_status_t
)
switch_vb_get_packet
(
switch_vb_t
*
vb
,
switch_rtp_packet_t
*
packet
,
switch_size_t
*
len
);
SWITCH_DECLARE
(
uint32_t
)
switch_vb_pop_nack
(
switch_vb_t
*
vb
);
SWITCH_DECLARE
(
uint32_t
)
switch_vb_pop_nack
(
switch_vb_t
*
vb
);
...
...
src/switch_rtp.c
浏览文件 @
d5e48302
...
@@ -7018,11 +7018,10 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
...
@@ -7018,11 +7018,10 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
if
(
rtp_session
->
flags
[
SWITCH_RTP_FLAG_NACK
])
{
if
(
rtp_session
->
flags
[
SWITCH_RTP_FLAG_NACK
])
{
if
(
!
rtp_session
->
vbw
)
{
if
(
!
rtp_session
->
vbw
)
{
switch_vb_create
(
&
rtp_session
->
vbw
,
500
,
500
,
rtp_session
->
pool
);
switch_vb_create
(
&
rtp_session
->
vbw
,
150
,
150
,
rtp_session
->
pool
);
switch_vb_set_flag
(
rtp_session
->
vbw
,
SVB_QUEUE_ONLY
);
//switch_vb_debug_level(rtp_session->vbw, 10);
//switch_vb_debug_level(rtp_session->vbw, 10);
}
}
switch_vb_pu
t
_packet
(
rtp_session
->
vbw
,
(
switch_rtp_packet_t
*
)
send_msg
,
bytes
);
switch_vb_pu
sh
_packet
(
rtp_session
->
vbw
,
(
switch_rtp_packet_t
*
)
send_msg
,
bytes
);
}
}
#ifdef RTP_WRITE_PLOSS
#ifdef RTP_WRITE_PLOSS
...
...
src/switch_utils.c
浏览文件 @
d5e48302
...
@@ -96,6 +96,7 @@ SWITCH_DECLARE(switch_status_t) switch_frame_alloc(switch_frame_t **frame, switc
...
@@ -96,6 +96,7 @@ SWITCH_DECLARE(switch_status_t) switch_frame_alloc(switch_frame_t **frame, switc
typedef
struct
switch_frame_node_s
{
typedef
struct
switch_frame_node_s
{
switch_frame_t
*
frame
;
switch_frame_t
*
frame
;
int
inuse
;
int
inuse
;
struct
switch_frame_node_s
*
prev
;
struct
switch_frame_node_s
*
next
;
struct
switch_frame_node_s
*
next
;
}
switch_frame_node_t
;
}
switch_frame_node_t
;
...
@@ -103,19 +104,37 @@ struct switch_frame_buffer_s {
...
@@ -103,19 +104,37 @@ struct switch_frame_buffer_s {
switch_frame_node_t
*
head
;
switch_frame_node_t
*
head
;
switch_memory_pool_t
*
pool
;
switch_memory_pool_t
*
pool
;
switch_mutex_t
*
mutex
;
switch_mutex_t
*
mutex
;
uint32_t
total
;
};
};
static
switch_frame_t
*
find_free_frame
(
switch_frame_buffer_t
*
fb
,
switch_frame_t
*
orig
)
static
switch_frame_t
*
find_free_frame
(
switch_frame_buffer_t
*
fb
,
switch_frame_t
*
orig
)
{
{
switch_frame_node_t
*
np
;
switch_frame_node_t
*
np
;
int
x
=
0
;
switch_mutex_lock
(
fb
->
mutex
);
switch_mutex_lock
(
fb
->
mutex
);
for
(
np
=
fb
->
head
;
np
;
np
=
np
->
next
)
{
for
(
np
=
fb
->
head
;
np
;
np
=
np
->
next
)
{
x
++
;
if
(
!
np
->
inuse
&&
((
orig
->
packet
&&
np
->
frame
->
packet
)
||
(
!
orig
->
packet
&&
!
np
->
frame
->
packet
)))
{
if
(
!
np
->
inuse
&&
((
orig
->
packet
&&
np
->
frame
->
packet
)
||
(
!
orig
->
packet
&&
!
np
->
frame
->
packet
)))
{
if
(
np
==
fb
->
head
)
{
fb
->
head
=
np
->
next
;
}
else
if
(
np
->
prev
)
{
np
->
prev
->
next
=
np
->
next
;
}
if
(
np
->
next
)
{
np
->
next
->
prev
=
np
->
prev
;
}
fb
->
total
--
;
np
->
prev
=
np
->
next
=
NULL
;
break
;
break
;
}
}
}
}
if
(
!
np
)
{
if
(
!
np
)
{
np
=
switch_core_alloc
(
fb
->
pool
,
sizeof
(
*
np
));
np
=
switch_core_alloc
(
fb
->
pool
,
sizeof
(
*
np
));
np
->
frame
=
switch_core_alloc
(
fb
->
pool
,
sizeof
(
*
np
->
frame
));
np
->
frame
=
switch_core_alloc
(
fb
->
pool
,
sizeof
(
*
np
->
frame
));
...
@@ -126,11 +145,8 @@ static switch_frame_t *find_free_frame(switch_frame_buffer_t *fb, switch_frame_t
...
@@ -126,11 +145,8 @@ static switch_frame_t *find_free_frame(switch_frame_buffer_t *fb, switch_frame_t
np
->
frame
->
data
=
switch_core_alloc
(
fb
->
pool
,
SWITCH_RTP_MAX_BUF_LEN
);
np
->
frame
->
data
=
switch_core_alloc
(
fb
->
pool
,
SWITCH_RTP_MAX_BUF_LEN
);
np
->
frame
->
buflen
=
SWITCH_RTP_MAX_BUF_LEN
;
np
->
frame
->
buflen
=
SWITCH_RTP_MAX_BUF_LEN
;
}
}
np
->
next
=
fb
->
head
;
fb
->
head
=
np
;
}
}
np
->
frame
->
samples
=
orig
->
samples
;
np
->
frame
->
samples
=
orig
->
samples
;
np
->
frame
->
rate
=
orig
->
rate
;
np
->
frame
->
rate
=
orig
->
rate
;
np
->
frame
->
channels
=
orig
->
channels
;
np
->
frame
->
channels
=
orig
->
channels
;
...
@@ -177,10 +193,24 @@ SWITCH_DECLARE(switch_status_t) switch_frame_buffer_free(switch_frame_buffer_t *
...
@@ -177,10 +193,24 @@ SWITCH_DECLARE(switch_status_t) switch_frame_buffer_free(switch_frame_buffer_t *
old_frame
=
*
frameP
;
old_frame
=
*
frameP
;
*
frameP
=
NULL
;
*
frameP
=
NULL
;
node
=
(
switch_frame_node_t
*
)
old_frame
->
extra_data
;
node
=
(
switch_frame_node_t
*
)
old_frame
->
extra_data
;
node
->
inuse
=
0
;
node
->
inuse
=
0
;
switch_img_free
(
&
node
->
frame
->
img
);
switch_img_free
(
&
node
->
frame
->
img
);
fb
->
total
++
;
if
(
fb
->
head
)
{
fb
->
head
->
prev
=
node
;
}
node
->
next
=
fb
->
head
;
node
->
prev
=
NULL
;
fb
->
head
=
node
;
switch_assert
(
node
->
next
!=
node
);
switch_assert
(
node
->
prev
!=
node
);
switch_mutex_unlock
(
fb
->
mutex
);
switch_mutex_unlock
(
fb
->
mutex
);
...
...
src/switch_vidderbuffer.c
浏览文件 @
d5e48302
...
@@ -44,6 +44,7 @@ typedef struct switch_vb_node_s {
...
@@ -44,6 +44,7 @@ typedef struct switch_vb_node_s {
switch_rtp_packet_t
packet
;
switch_rtp_packet_t
packet
;
uint32_t
len
;
uint32_t
len
;
uint8_t
visible
;
uint8_t
visible
;
struct
switch_vb_node_s
*
prev
;
struct
switch_vb_node_s
*
next
;
struct
switch_vb_node_s
*
next
;
}
switch_vb_node_t
;
}
switch_vb_node_t
;
...
@@ -67,6 +68,7 @@ struct switch_vb_s {
...
@@ -67,6 +68,7 @@ struct switch_vb_s {
switch_inthash_t
*
missing_seq_hash
;
switch_inthash_t
*
missing_seq_hash
;
switch_inthash_t
*
node_hash
;
switch_inthash_t
*
node_hash
;
switch_mutex_t
*
mutex
;
switch_mutex_t
*
mutex
;
switch_mutex_t
*
list_mutex
;
switch_memory_pool_t
*
pool
;
switch_memory_pool_t
*
pool
;
int
free_pool
;
int
free_pool
;
switch_vb_flag_t
flags
;
switch_vb_flag_t
flags
;
...
@@ -74,25 +76,26 @@ struct switch_vb_s {
...
@@ -74,25 +76,26 @@ struct switch_vb_s {
static
inline
switch_vb_node_t
*
new_node
(
switch_vb_t
*
vb
)
static
inline
switch_vb_node_t
*
new_node
(
switch_vb_t
*
vb
)
{
{
switch_vb_node_t
*
np
,
*
last
=
NULL
;
switch_vb_node_t
*
np
;
switch_mutex_lock
(
vb
->
list_mutex
);
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
if
(
!
np
->
visible
)
{
if
(
!
np
->
visible
)
{
break
;
break
;
}
}
last
=
np
;
}
}
if
(
!
np
)
{
if
(
!
np
)
{
np
=
switch_core_alloc
(
vb
->
pool
,
sizeof
(
*
np
));
np
=
switch_core_alloc
(
vb
->
pool
,
sizeof
(
*
np
));
if
(
last
)
{
np
->
next
=
vb
->
node_list
;
last
->
next
=
np
;
if
(
np
->
next
)
{
}
else
{
np
->
next
->
prev
=
np
;
vb
->
node_list
=
np
;
}
}
vb
->
node_list
=
np
;
}
}
switch_assert
(
np
);
switch_assert
(
np
);
...
@@ -101,41 +104,89 @@ static inline switch_vb_node_t *new_node(switch_vb_t *vb)
...
@@ -101,41 +104,89 @@ static inline switch_vb_node_t *new_node(switch_vb_t *vb)
vb
->
visible_nodes
++
;
vb
->
visible_nodes
++
;
np
->
parent
=
vb
;
np
->
parent
=
vb
;
switch_mutex_unlock
(
vb
->
list_mutex
);
return
np
;
return
np
;
}
}
#if 0
static
inline
void
push_to_top
(
switch_vb_t
*
vb
,
switch_vb_node_t
*
node
)
static inline switch_vb_node_t *find_seq(switch_vb_t *vb, uint16_t seq)
{
{
switch_vb_node_t *np;
if
(
node
==
vb
->
node_list
)
{
for (np = vb->node_list; np; np = np->next) {
vb
->
node_list
=
node
->
next
;
if (!np->visible) continue;
}
else
if
(
node
->
prev
)
{
node
->
prev
->
next
=
node
->
next
;
}
if (ntohs(np->packet.header.seq) == ntohs(seq)) {
if
(
node
->
next
)
{
return np;
node
->
next
->
prev
=
node
->
prev
;
}
}
}
return NULL;
node
->
next
=
vb
->
node_list
;
node
->
prev
=
NULL
;
if
(
node
->
next
)
{
node
->
next
->
prev
=
node
;
}
vb
->
node_list
=
node
;
switch_assert
(
node
->
next
!=
node
);
switch_assert
(
node
->
prev
!=
node
);
}
}
#endif
static
inline
void
hide_node
(
switch_vb_node_t
*
node
)
static
inline
void
hide_node
(
switch_vb_node_t
*
node
,
switch_bool_t
pop
)
{
{
switch_vb_t
*
vb
=
node
->
parent
;
switch_mutex_lock
(
vb
->
list_mutex
);
if
(
node
->
visible
)
{
if
(
node
->
visible
)
{
node
->
visible
=
0
;
node
->
visible
=
0
;
node
->
parent
->
visible_nodes
--
;
vb
->
visible_nodes
--
;
if
(
pop
)
{
push_to_top
(
vb
,
node
);
}
}
switch_core_inthash_delete
(
vb
->
node_hash
,
node
->
packet
.
header
.
seq
);
switch_mutex_unlock
(
vb
->
list_mutex
);
}
static
inline
void
sort_free_nodes
(
switch_vb_t
*
vb
)
{
switch_vb_node_t
*
np
,
*
this_np
;
int
start
=
0
;
switch_mutex_lock
(
vb
->
list_mutex
);
np
=
vb
->
node_list
;
while
(
np
)
{
this_np
=
np
;
np
=
np
->
next
;
if
(
this_np
->
visible
)
{
start
++
;
}
if
(
start
&&
!
this_np
->
visible
)
{
push_to_top
(
vb
,
this_np
);
}
}
}
switch_core_inthash_delete
(
node
->
parent
->
node_hash
,
node
->
packet
.
header
.
seq
);
switch_mutex_unlock
(
vb
->
list_mutex
);
}
}
static
inline
void
hide_nodes
(
switch_vb_t
*
vb
)
static
inline
void
hide_nodes
(
switch_vb_t
*
vb
)
{
{
switch_vb_node_t
*
np
;
switch_vb_node_t
*
np
;
switch_mutex_lock
(
vb
->
list_mutex
);
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
hide_node
(
np
);
hide_node
(
np
,
SWITCH_FALSE
);
}
}
switch_mutex_unlock
(
vb
->
list_mutex
);
}
}
static
inline
void
drop_ts
(
switch_vb_t
*
vb
,
uint32_t
ts
)
static
inline
void
drop_ts
(
switch_vb_t
*
vb
,
uint32_t
ts
)
...
@@ -143,15 +194,22 @@ static inline void drop_ts(switch_vb_t *vb, uint32_t ts)
...
@@ -143,15 +194,22 @@ static inline void drop_ts(switch_vb_t *vb, uint32_t ts)
switch_vb_node_t
*
np
;
switch_vb_node_t
*
np
;
int
x
=
0
;
int
x
=
0
;
switch_mutex_lock
(
vb
->
list_mutex
);
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
if
(
!
np
->
visible
)
continue
;
if
(
!
np
->
visible
)
continue
;
if
(
ts
==
np
->
packet
.
header
.
ts
)
{
if
(
ts
==
np
->
packet
.
header
.
ts
)
{
hide_node
(
np
);
hide_node
(
np
,
SWITCH_FALSE
);
x
++
;
x
++
;
}
}
}
}
if
(
x
)
{
sort_free_nodes
(
vb
);
}
switch_mutex_unlock
(
vb
->
list_mutex
);
if
(
x
)
vb
->
complete_frames
--
;
if
(
x
)
vb
->
complete_frames
--
;
}
}
...
@@ -159,6 +217,7 @@ static inline uint32_t vb_find_lowest_ts(switch_vb_t *vb)
...
@@ -159,6 +217,7 @@ static inline uint32_t vb_find_lowest_ts(switch_vb_t *vb)
{
{
switch_vb_node_t
*
np
,
*
lowest
=
NULL
;
switch_vb_node_t
*
np
,
*
lowest
=
NULL
;
switch_mutex_lock
(
vb
->
list_mutex
);
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
if
(
!
np
->
visible
)
continue
;
if
(
!
np
->
visible
)
continue
;
...
@@ -166,6 +225,7 @@ static inline uint32_t vb_find_lowest_ts(switch_vb_t *vb)
...
@@ -166,6 +225,7 @@ static inline uint32_t vb_find_lowest_ts(switch_vb_t *vb)
lowest
=
np
;
lowest
=
np
;
}
}
}
}
switch_mutex_unlock
(
vb
->
list_mutex
);
return
lowest
?
lowest
->
packet
.
header
.
ts
:
0
;
return
lowest
?
lowest
->
packet
.
header
.
ts
:
0
;
}
}
...
@@ -239,6 +299,7 @@ static inline switch_vb_node_t *vb_find_lowest_seq(switch_vb_t *vb)
...
@@ -239,6 +299,7 @@ static inline switch_vb_node_t *vb_find_lowest_seq(switch_vb_t *vb)
{
{
switch_vb_node_t
*
np
,
*
lowest
=
NULL
;
switch_vb_node_t
*
np
,
*
lowest
=
NULL
;
switch_mutex_lock
(
vb
->
list_mutex
);
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
for
(
np
=
vb
->
node_list
;
np
;
np
=
np
->
next
)
{
if
(
!
np
->
visible
)
continue
;
if
(
!
np
->
visible
)
continue
;
...
@@ -246,6 +307,7 @@ static inline switch_vb_node_t *vb_find_lowest_seq(switch_vb_t *vb)
...
@@ -246,6 +307,7 @@ static inline switch_vb_node_t *vb_find_lowest_seq(switch_vb_t *vb)
lowest
=
np
;
lowest
=
np
;
}
}
}
}
switch_mutex_unlock
(
vb
->
list_mutex
);
return
lowest
;
return
lowest
;
}
}
...
@@ -294,7 +356,9 @@ static inline switch_status_t vb_next_packet(switch_vb_t *vb, switch_vb_node_t *
...
@@ -294,7 +356,9 @@ static inline switch_status_t vb_next_packet(switch_vb_t *vb, switch_vb_node_t *
static
inline
void
free_nodes
(
switch_vb_t
*
vb
)
static
inline
void
free_nodes
(
switch_vb_t
*
vb
)
{
{
switch_mutex_lock
(
vb
->
list_mutex
);
vb
->
node_list
=
NULL
;
vb
->
node_list
=
NULL
;
switch_mutex_unlock
(
vb
->
list_mutex
);
}
}
SWITCH_DECLARE
(
void
)
switch_vb_set_flag
(
switch_vb_t
*
vb
,
switch_vb_flag_t
flag
)
SWITCH_DECLARE
(
void
)
switch_vb_set_flag
(
switch_vb_t
*
vb
,
switch_vb_flag_t
flag
)
...
@@ -370,7 +434,7 @@ SWITCH_DECLARE(switch_status_t) switch_vb_create(switch_vb_t **vbp, uint32_t min
...
@@ -370,7 +434,7 @@ SWITCH_DECLARE(switch_status_t) switch_vb_create(switch_vb_t **vbp, uint32_t min
switch_core_inthash_init
(
&
vb
->
missing_seq_hash
);
switch_core_inthash_init
(
&
vb
->
missing_seq_hash
);
switch_core_inthash_init
(
&
vb
->
node_hash
);
switch_core_inthash_init
(
&
vb
->
node_hash
);
switch_mutex_init
(
&
vb
->
mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
vb
->
mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
switch_mutex_init
(
&
vb
->
list_mutex
,
SWITCH_MUTEX_NESTED
,
pool
);
*
vbp
=
vb
;
*
vbp
=
vb
;
...
@@ -569,7 +633,7 @@ SWITCH_DECLARE(switch_status_t) switch_vb_get_packet(switch_vb_t *vb, switch_rtp
...
@@ -569,7 +633,7 @@ SWITCH_DECLARE(switch_status_t) switch_vb_get_packet(switch_vb_t *vb, switch_rtp
*
packet
=
node
->
packet
;
*
packet
=
node
->
packet
;
*
len
=
node
->
len
;
*
len
=
node
->
len
;
memcpy
(
packet
->
body
,
node
->
packet
.
body
,
node
->
len
);
memcpy
(
packet
->
body
,
node
->
packet
.
body
,
node
->
len
);
hide_node
(
node
);
hide_node
(
node
,
SWITCH_TRUE
);
vb_debug
(
vb
,
1
,
"GET packet ts:%u seq:%u %s
\n
"
,
ntohl
(
packet
->
header
.
ts
),
ntohs
(
packet
->
header
.
seq
),
packet
->
header
.
m
?
" <MARK>"
:
""
);
vb_debug
(
vb
,
1
,
"GET packet ts:%u seq:%u %s
\n
"
,
ntohl
(
packet
->
header
.
ts
),
ntohs
(
packet
->
header
.
seq
),
packet
->
header
.
m
?
" <MARK>"
:
""
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论