winlin

refine the overflow algorithm, prevent smaller piece.

... ... @@ -542,6 +542,11 @@ bool SrsHlsMuxer::is_segment_overflow()
{
srs_assert(current);
// to prevent very small segment.
if (current->duration < 2 * SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) {
return false;
}
// use N% deviation, to smoother.
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
... ... @@ -560,6 +565,11 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow()
// @see https://github.com/winlinvip/simple-rtmp-server/issues/151#issuecomment-83553950
srs_assert(current);
// to prevent very small segment.
if (current->duration < 2 * SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) {
return false;
}
// use N% deviation, to smoother.
double deviation = hls_ts_floor? SRS_HLS_FLOOR_REAP_PERCENT * deviation_ts * hls_fragment : 0.0;
srs_info("hls: dur=%.2f, tar=%.2f, dev=%.2fms/%dp, frag=%.2f",
... ...
... ... @@ -871,9 +871,10 @@ int SrsIngestSrsOutput::parse_message_queue()
SrsTsMessage* first_ts_msg = queue.begin()->second;
SrsTsContext* context = first_ts_msg->channel->context;
bool cpa = context->is_pure_audio();
int nb_videos = 0;
if (!context->is_pure_audio()) {
if (!cpa) {
std::multimap<int64_t, SrsTsMessage*>::iterator it;
for (it = queue.begin(); it != queue.end(); ++it) {
SrsTsMessage* msg = it->second;
... ... @@ -892,7 +893,8 @@ int SrsIngestSrsOutput::parse_message_queue()
}
// parse messages util the last video.
while ((nb_videos > 1 || context->is_pure_audio()) && queue.size() > 0) {
while ((cpa && queue.size() > 1) || nb_videos > 1) {
srs_assert(!queue.empty());
std::multimap<int64_t, SrsTsMessage*>::iterator it = queue.begin();
SrsTsMessage* msg = it->second;
... ...