Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2013-12-15 19:11:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c47f07c69a60936b2648df2eb3cf29b7f89cfd51
c47f07c6
1 parent
b4093bfb
refine the consumer, use srs message queue to shrink message when overflow.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
18 行增加
和
6 行删除
trunk/conf/srs.conf
trunk/src/core/srs_core_config.cpp
trunk/src/core/srs_core_source.cpp
trunk/conf/srs.conf
查看文件 @
c47f07c
...
...
@@ -93,7 +93,7 @@ vhost __defaultVhost__ {
vhost
dev
{
enabled
on
;
gop_cache
on
;
queue_length
3
0
;
queue_length
1
0
;
#forward 127.0.0.1:19350;
hls
{
enabled
off
;
...
...
trunk/src/core/srs_core_config.cpp
查看文件 @
c47f07c
...
...
@@ -1303,7 +1303,7 @@ double SrsConfig::get_queue_length(string vhost)
}
conf
=
conf
->
get
(
"queue_length"
);
if
(
conf
||
conf
->
arg0
().
empty
())
{
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
SRS_CONF_DEFAULT_QUEUE_LENGTH
;
}
...
...
trunk/src/core/srs_core_source.cpp
查看文件 @
c47f07c
...
...
@@ -171,6 +171,10 @@ int SrsMessageQueue::get_packets(int max_count, SrsSharedPtrMessage**& pmsgs, in
}
else
{
count
=
srs_min
(
max_count
,
(
int
)
msgs
.
size
());
}
if
(
count
<=
0
)
{
return
ret
;
}
pmsgs
=
new
SrsSharedPtrMessage
*
[
count
];
...
...
@@ -178,6 +182,9 @@ int SrsMessageQueue::get_packets(int max_count, SrsSharedPtrMessage**& pmsgs, in
pmsgs
[
i
]
=
msgs
[
i
];
}
SrsSharedPtrMessage
*
last
=
msgs
[
count
-
1
];
av_start_time
=
last
->
header
.
timestamp
;
if
(
count
==
(
int
)
msgs
.
size
())
{
msgs
.
clear
();
}
else
{
...
...
@@ -217,15 +224,15 @@ void SrsMessageQueue::shrink()
return
;
}
srs_trace
(
"shrink the cache queue, size=%d, removed=%d, max=%.2f"
,
(
int
)
msgs
.
size
(),
iframe_index
,
queue_size_ms
/
1000.0
);
// remove the first gop from the front
for
(
int
i
=
0
;
i
<
iframe_index
;
i
++
)
{
SrsSharedPtrMessage
*
msg
=
msgs
[
i
];
srs_freep
(
msg
);
}
msgs
.
erase
(
msgs
.
begin
(),
msgs
.
begin
()
+
iframe_index
);
srs_trace
(
"shrink the cache queue, "
"size=%d, removed=%d"
,
(
int
)
msgs
.
size
(),
iframe_index
);
}
void
SrsMessageQueue
::
clear
()
...
...
@@ -893,9 +900,12 @@ void SrsSource::on_unpublish()
{
int
ret
=
ERROR_SUCCESS
;
double
queue_size
=
config
->
get_queue_length
(
req
->
vhost
);
consumer
=
new
SrsConsumer
(
this
);
consumer
->
set_queue_size
(
config
->
get_queue_length
(
req
->
vhost
));
consumers
.
push_back
(
consumer
);
consumer
->
set_queue_size
(
queue_size
);
if
(
cache_metadata
&&
(
ret
=
consumer
->
enqueue
(
cache_metadata
->
copy
(),
sample_rate
,
frame_rate
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"dispatch metadata failed. ret=%d"
,
ret
);
...
...
@@ -919,6 +929,8 @@ void SrsSource::on_unpublish()
return
ret
;
}
srs_trace
(
"create consumer, queue_size=%.2f, tba=%d, tbv=%d"
,
queue_size
,
sample_rate
,
frame_rate
);
return
ret
;
}
...
...
请
注册
或
登录
后发表评论