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
2015-08-14 14:35:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a0a89a8ca617e4db349e74ea6252bb3746f17599
a0a89a8c
1 parent
b79d830e
use reduce_sequence_header for stream control.
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
56 行增加
和
14 行删除
README.md
trunk/conf/full.conf
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_source.cpp
README.md
查看文件 @
a0a89a8
...
...
@@ -342,6 +342,7 @@ Remark:
## History
*
v2.0, 2015-08-14, use reduce_sequence_header for stream control.
*
v2.0, 2015-08-14, use send_min_interval for stream control. 2.0.183
*
v2.0, 2015-08-12, enable the SRS_PERF_TCP_NODELAY and add config tcp_nodelay. 2.0.182
*
v2.0, 2015-08-11, for
[
#442
](
https://github.com/simple-rtmp-server/srs/issues/442
)
support kickoff connected client. 2.0.181
...
...
trunk/conf/full.conf
查看文件 @
a0a89a8
...
...
@@ -876,7 +876,12 @@ vhost stream.control.com {
# @remark 0 to disable the minimal interval.
# @remark >0 to make the srs to send message one by one.
# default: 0
send_min_interval
10
;
send_min_interval
10
;
# whether reduce the sequence header,
# for some client which cannot got duplicated sequence header,
# while the sequence header is not changed yet.
# default: off
reduce_sequence_header
on
;
}
# the vhost for antisuck.
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
a0a89a8
...
...
@@ -1761,7 +1761,8 @@ int SrsConfig::check_config()
&&
n
!=
"time_jitter"
&&
n
!=
"mix_correct"
&&
n
!=
"atc"
&&
n
!=
"atc_auto"
&&
n
!=
"debug_srs_upnode"
&&
n
!=
"mr"
&&
n
!=
"mw_latency"
&&
n
!=
"min_latency"
&&
n
!=
"tcp_nodelay"
&&
n
!=
"send_min_interval"
&&
n
!=
"mr"
&&
n
!=
"mw_latency"
&&
n
!=
"min_latency"
&&
n
!=
"tcp_nodelay"
&&
n
!=
"send_min_interval"
&&
n
!=
"reduce_sequence_header"
&&
n
!=
"security"
&&
n
!=
"http_remux"
&&
n
!=
"http"
&&
n
!=
"http_static"
&&
n
!=
"hds"
...
...
@@ -2534,6 +2535,23 @@ int SrsConfig::get_send_min_interval(string vhost)
return
::
atoi
(
conf
->
arg0
().
c_str
());
}
bool
SrsConfig
::
get_reduce_sequence_header
(
string
vhost
)
{
static
bool
DEFAULT
=
false
;
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
return
DEFAULT
;
}
conf
=
conf
->
get
(
"reduce_sequence_header"
);
if
(
!
conf
||
conf
->
arg0
().
empty
())
{
return
DEFAULT
;
}
return
SRS_CONF_PERFER_FALSE
(
conf
->
arg0
());
}
int
SrsConfig
::
get_global_chunk_size
()
{
SrsConfDirective
*
conf
=
root
->
get
(
"chunk_size"
);
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
a0a89a8
...
...
@@ -530,6 +530,10 @@ public:
* the minimal send interval in ms.
*/
virtual
int
get_send_min_interval
(
std
::
string
vhost
);
/**
* whether reduce the sequence header.
*/
virtual
bool
get_reduce_sequence_header
(
std
::
string
vhost
);
private
:
/**
* get the global chunk size.
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
a0a89a8
...
...
@@ -1535,6 +1535,8 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
int
ret
=
ERROR_SUCCESS
;
srs_info
(
"Audio dts=%"
PRId64
", size=%d"
,
msg
->
timestamp
,
msg
->
size
);
bool
is_aac_sequence_header
=
SrsFlvCodec
::
audio_is_sequence_header
(
msg
->
payload
,
msg
->
size
);
bool
is_sequence_header
=
is_aac_sequence_header
;
#ifdef SRS_AUTO_HLS
if
((
ret
=
hls
->
on_audio
(
msg
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -1589,11 +1591,16 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
#endif
// copy to all consumer
int
nb_consumers
=
(
int
)
consumers
.
size
();
if
(
nb_consumers
>
0
)
{
SrsConsumer
**
pconsumer
=
consumers
.
data
();
for
(
int
i
=
0
;
i
<
nb_consumers
;
i
++
)
{
SrsConsumer
*
consumer
=
pconsumer
[
i
];
bool
drop_for_reduce
=
false
;
if
(
is_sequence_header
&&
cache_sh_audio
&&
_srs_config
->
get_reduce_sequence_header
(
_req
->
vhost
))
{
if
(
cache_sh_audio
->
size
==
msg
->
size
)
{
drop_for_reduce
=
srs_bytes_equals
(
cache_sh_audio
->
payload
,
msg
->
payload
,
msg
->
size
);
srs_warn
(
"drop for reduce sh audio, size=%d"
,
msg
->
size
);
}
}
if
(
!
drop_for_reduce
)
{
for
(
int
i
=
0
;
i
<
(
int
)
consumers
.
size
();
i
++
)
{
SrsConsumer
*
consumer
=
consumers
.
at
(
i
);
if
((
ret
=
consumer
->
enqueue
(
msg
,
atc
,
jitter_algorithm
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"dispatch the audio failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -1617,7 +1624,6 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg)
// cache the sequence header of aac, or first packet of mp3.
// for example, the mp3 is used for hls to write the "right" audio codec.
// TODO: FIXME: to refine the stream info system.
bool
is_aac_sequence_header
=
SrsFlvCodec
::
audio_is_sequence_header
(
msg
->
payload
,
msg
->
size
);
if
(
is_aac_sequence_header
||
!
cache_sh_audio
)
{
srs_freep
(
cache_sh_audio
);
cache_sh_audio
=
msg
->
copy
();
...
...
@@ -1740,6 +1746,8 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
srs_info
(
"Video dts=%"
PRId64
", size=%d"
,
msg
->
timestamp
,
msg
->
size
);
bool
is_sequence_header
=
SrsFlvCodec
::
video_is_sequence_header
(
msg
->
payload
,
msg
->
size
);
#ifdef SRS_AUTO_HLS
if
((
ret
=
hls
->
on_video
(
msg
))
!=
ERROR_SUCCESS
)
{
// apply the error strategy for hls.
...
...
@@ -1793,7 +1801,14 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
#endif
// copy to all consumer
if
(
true
)
{
bool
drop_for_reduce
=
false
;
if
(
is_sequence_header
&&
cache_sh_video
&&
_srs_config
->
get_reduce_sequence_header
(
_req
->
vhost
))
{
if
(
cache_sh_video
->
size
==
msg
->
size
)
{
drop_for_reduce
=
srs_bytes_equals
(
cache_sh_video
->
payload
,
msg
->
payload
,
msg
->
size
);
srs_warn
(
"drop for reduce sh video, size=%d"
,
msg
->
size
);
}
}
if
(
!
drop_for_reduce
)
{
for
(
int
i
=
0
;
i
<
(
int
)
consumers
.
size
();
i
++
)
{
SrsConsumer
*
consumer
=
consumers
.
at
(
i
);
if
((
ret
=
consumer
->
enqueue
(
msg
,
atc
,
jitter_algorithm
))
!=
ERROR_SUCCESS
)
{
...
...
@@ -1818,7 +1833,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg)
// cache the sequence header if h264
// donot cache the sequence header to gop_cache, return here.
if
(
SrsFlvCodec
::
video_is_sequence_header
(
msg
->
payload
,
msg
->
size
)
)
{
if
(
is_sequence_header
)
{
srs_freep
(
cache_sh_video
);
cache_sh_video
=
msg
->
copy
();
...
...
@@ -2062,13 +2077,12 @@ void SrsSource::on_unpublish()
hds
->
on_unpublish
();
#endif
// only clear the gop cache metadata,
// donot clear the sequence header, for it maybe not changed.
gop_cache
->
clear
();
srs_freep
(
cache_metadata
);
srs_freep
(
cache_sh_video
);
srs_freep
(
cache_sh_audio
);
srs_info
(
"clear cache/metadata
/sequence-headers
when unpublish."
);
srs_info
(
"clear cache/metadata when unpublish."
);
srs_trace
(
"cleanup when unpublish"
);
_can_publish
=
true
;
...
...
请
注册
或
登录
后发表评论