mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #124, gop cache support disable video in publishing. 0.9.171.
This commit is contained in:
parent
50cd1d2360
commit
b17c736f3f
4 changed files with 34 additions and 2 deletions
|
@ -46,6 +46,10 @@ using namespace std;
|
|||
#define CONST_MAX_JITTER_MS 500
|
||||
#define DEFAULT_FRAME_TIME_MS 40
|
||||
|
||||
// for 26ms per audio packet,
|
||||
// 115 packets is 3s.
|
||||
#define __SRS_PURE_AUDIO_GUESS_COUNT 115
|
||||
|
||||
int _srs_time_jitter_string2int(std::string time_jitter)
|
||||
{
|
||||
if (time_jitter == "full") {
|
||||
|
@ -351,6 +355,7 @@ SrsGopCache::SrsGopCache()
|
|||
{
|
||||
cached_video_count = 0;
|
||||
enable_gop_cache = true;
|
||||
audio_count_after_last_video = 0;
|
||||
}
|
||||
|
||||
SrsGopCache::~SrsGopCache()
|
||||
|
@ -383,6 +388,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;
|
||||
}
|
||||
|
||||
// no acceptable video or pure audio, disable the cache.
|
||||
|
@ -391,6 +397,18 @@ int SrsGopCache::cache(SrsSharedPtrMessage* msg)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// ok, gop cache enabled, and got an audio.
|
||||
if (msg->header.is_audio()) {
|
||||
audio_count_after_last_video++;
|
||||
}
|
||||
|
||||
// clear gop cache when pure audio count overflow
|
||||
if (audio_count_after_last_video > __SRS_PURE_AUDIO_GUESS_COUNT) {
|
||||
srs_warn("clear gop cache for guess pure audio overflow");
|
||||
clear();
|
||||
return ret;
|
||||
}
|
||||
|
||||
// clear gop cache when got key frame
|
||||
if (msg->header.is_video() && SrsFlvCodec::video_is_keyframe(msg->payload, msg->size)) {
|
||||
srs_info("clear gop cache when got keyframe. vcount=%d, count=%d",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue