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
2014-10-08 14:28:09 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
13b092704d87254ca2d6d04a27b8ec3b5819d219
13b09270
1 parent
f33f91c8
refine code for bug #151, refine the source functions, add comments.
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
27 行增加
和
11 行删除
trunk/src/app/srs_app_source.cpp
trunk/src/app/srs_app_source.hpp
trunk/src/app/srs_app_source.cpp
查看文件 @
13b0927
...
...
@@ -363,7 +363,7 @@ SrsGopCache::SrsGopCache()
{
cached_video_count
=
0
;
enable_gop_cache
=
true
;
audio_
count_after_last_video
=
0
;
audio_
after_last_video_count
=
0
;
}
SrsGopCache
::~
SrsGopCache
()
...
...
@@ -396,7 +396,7 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg)
// got video, update the video count if acceptable
if
(
msg
->
header
.
is_video
())
{
cached_video_count
++
;
audio_
count_after_last_video
=
0
;
audio_
after_last_video_count
=
0
;
}
// no acceptable video or pure audio, disable the cache.
...
...
@@ -407,11 +407,11 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg)
// ok, gop cache enabled, and got an audio.
if
(
msg
->
header
.
is_audio
())
{
audio_
count_after_last_video
++
;
audio_
after_last_video_count
++
;
}
// clear gop cache when pure audio count overflow
if
(
audio_
count_after_last_video
>
__SRS_PURE_AUDIO_GUESS_COUNT
)
{
if
(
audio_
after_last_video_count
>
__SRS_PURE_AUDIO_GUESS_COUNT
)
{
srs_warn
(
"clear gop cache for guess pure audio overflow"
);
clear
();
return
ret
;
...
...
@@ -444,6 +444,7 @@ void SrsGopCache::clear()
gop_cache
.
clear
();
cached_video_count
=
0
;
audio_after_last_video_count
=
0
;
}
int
SrsGopCache
::
dump
(
SrsConsumer
*
consumer
,
bool
atc
,
int
tba
,
int
tbv
,
SrsRtmpJitterAlgorithm
jitter_algorithm
)
...
...
@@ -469,7 +470,7 @@ bool SrsGopCache::empty()
return
gop_cache
.
empty
();
}
int64_t
SrsGopCache
::
get_
start_time
()
int64_t
SrsGopCache
::
start_time
()
{
if
(
empty
())
{
return
0
;
...
...
@@ -1457,13 +1458,13 @@ void SrsSource::on_unpublish()
// if atc, update the sequence header to gop cache time.
if
(
atc
&&
!
gop_cache
->
empty
())
{
if
(
cache_metadata
)
{
cache_metadata
->
header
.
timestamp
=
gop_cache
->
get_
start_time
();
cache_metadata
->
header
.
timestamp
=
gop_cache
->
start_time
();
}
if
(
cache_sh_video
)
{
cache_sh_video
->
header
.
timestamp
=
gop_cache
->
get_
start_time
();
cache_sh_video
->
header
.
timestamp
=
gop_cache
->
start_time
();
}
if
(
cache_sh_audio
)
{
cache_sh_audio
->
header
.
timestamp
=
gop_cache
->
get_
start_time
();
cache_sh_audio
->
header
.
timestamp
=
gop_cache
->
start_time
();
}
}
...
...
trunk/src/app/srs_app_source.hpp
查看文件 @
13b0927
...
...
@@ -224,7 +224,7 @@ private:
* gop cache is disabled for pure audio stream.
* @see: https://github.com/winlinvip/simple-rtmp-server/issues/124
*/
int
audio_
count_after_last_video
;
int
audio_
after_last_video_count
;
/**
* cached gop.
*/
...
...
@@ -233,6 +233,9 @@ public:
SrsGopCache
();
virtual
~
SrsGopCache
();
public
:
/**
* to enable or disable the gop cache.
*/
virtual
void
set
(
bool
enabled
);
/**
* only for h264 codec
...
...
@@ -240,14 +243,26 @@ public:
* 2. clear gop when got keyframe.
*/
virtual
int
cache
(
SrsSharedPtrMessage
*
msg
);
/**
* clear the gop cache.
*/
virtual
void
clear
();
virtual
int
dump
(
SrsConsumer
*
consumer
,
bool
atc
,
int
tba
,
int
tbv
,
SrsRtmpJitterAlgorithm
jitter_algorithm
);
/**
* dump the cached gop to consumer.
*/
virtual
int
dump
(
SrsConsumer
*
consumer
,
bool
atc
,
int
tba
,
int
tbv
,
SrsRtmpJitterAlgorithm
jitter_algorithm
);
/**
* used for atc to get the time of gop cache,
* the atc will adjust the sequence header timestamp to gop cache.
*/
virtual
bool
empty
();
virtual
int64_t
get_start_time
();
/**
* get the start time of gop cache, in ms.
* @return 0 if no packets.
*/
virtual
int64_t
start_time
();
};
/**
...
...
请
注册
或
登录
后发表评论