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
|
@ -209,7 +209,8 @@ Supported operating systems and hardware:
|
|||
* 2013-10-17, Created.<br/>
|
||||
|
||||
## History
|
||||
* v1.0, 2014-07-19, fix [#121](https://github.com/winlinvip/simple-rtmp-server/issues/121), srs_info detail log compile failed. 0.9.168.
|
||||
* v1.0, 2014-07-26, fix [#124](https://github.com/winlinvip/simple-rtmp-server/issues/124), gop cache support disable video in publishing. 0.9.171.
|
||||
* v1.0, 2014-07-23, fix [#121](https://github.com/winlinvip/simple-rtmp-server/issues/121), srs_info detail log compile failed. 0.9.168.
|
||||
* v1.0, 2014-07-19, fix [#119](https://github.com/winlinvip/simple-rtmp-server/issues/119), use iformat and oformat for ffmpeg transcode. 0.9.163.
|
||||
* <strong>v1.0, 2014-07-13, [1.0 mainline6(0.9.160)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline8) released. 50029 lines.</strong>
|
||||
* v1.0, 2014-07-13, refine the bandwidth check/test, add as/js library, use srs-librtmp for linux tool. 0.9.159
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -213,6 +213,19 @@ private:
|
|||
*/
|
||||
int cached_video_count;
|
||||
/**
|
||||
* when user disabled video when publishing, and gop cache enalbed,
|
||||
* we will cache the audio/video for we already got video, but we never
|
||||
* know when to clear the gop cache, for there is no video in future,
|
||||
* so we must guess whether user disabled the video.
|
||||
* when we got some audios after laster video, for instance, 600 audio packets,
|
||||
* about 3s(26ms per packet) 115 audio packets, clear gop cache.
|
||||
*
|
||||
* @remark, it is ok for performance, for when we clear the gop cache,
|
||||
* gop cache is disabled for pure audio stream.
|
||||
* @see: https://github.com/winlinvip/simple-rtmp-server/issues/124
|
||||
*/
|
||||
int audio_count_after_last_video;
|
||||
/**
|
||||
* cached gop.
|
||||
*/
|
||||
std::vector<SrsSharedPtrMessage*> gop_cache;
|
||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// current release version
|
||||
#define VERSION_MAJOR "0"
|
||||
#define VERSION_MINOR "9"
|
||||
#define VERSION_REVISION "170"
|
||||
#define VERSION_REVISION "171"
|
||||
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
|
||||
// server info.
|
||||
#define RTMP_SIG_SRS_KEY "SRS"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue