正在显示
1 个修改的文件
包含
11 行增加
和
3 行删除
@@ -697,7 +697,9 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -697,7 +697,9 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
697 | srs_assert(it == segments.end()); | 697 | srs_assert(it == segments.end()); |
698 | 698 | ||
699 | // valid, add to segments if segment duration is ok | 699 | // valid, add to segments if segment duration is ok |
700 | - if (current->duration * 1000 >= SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS) { | 700 | + // when too small, it maybe not enough data to play. |
701 | + // when too large, it maybe timestamp corrupt. | ||
702 | + if (current->duration * 1000 >= SRS_AUTO_HLS_SEGMENT_MIN_DURATION_MS && (int)current->duration <= max_td) { | ||
701 | segments.push_back(current); | 703 | segments.push_back(current); |
702 | 704 | ||
703 | // use async to call the http hooks, for it will cause thread switch. | 705 | // use async to call the http hooks, for it will cause thread switch. |
@@ -748,7 +750,6 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -748,7 +750,6 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
748 | // rename from tmp to real path | 750 | // rename from tmp to real path |
749 | std::string tmp_file = current->full_path + ".tmp"; | 751 | std::string tmp_file = current->full_path + ".tmp"; |
750 | if (should_write_file) { | 752 | if (should_write_file) { |
751 | - unlink(tmp_file.c_str()); | ||
752 | if (unlink(tmp_file.c_str()) < 0) { | 753 | if (unlink(tmp_file.c_str()) < 0) { |
753 | srs_warn("ignore unlink path failed, file=%s.", tmp_file.c_str()); | 754 | srs_warn("ignore unlink path failed, file=%s.", tmp_file.c_str()); |
754 | } | 755 | } |
@@ -815,6 +816,11 @@ int SrsHlsMuxer::refresh_m3u8() | @@ -815,6 +816,11 @@ int SrsHlsMuxer::refresh_m3u8() | ||
815 | { | 816 | { |
816 | int ret = ERROR_SUCCESS; | 817 | int ret = ERROR_SUCCESS; |
817 | 818 | ||
819 | + // no segments, also no m3u8, return. | ||
820 | + if (segments.size() == 0) { | ||
821 | + return ret; | ||
822 | + } | ||
823 | + | ||
818 | std::string temp_m3u8 = m3u8 + ".temp"; | 824 | std::string temp_m3u8 = m3u8 + ".temp"; |
819 | if ((ret = _refresh_m3u8(temp_m3u8)) == ERROR_SUCCESS) { | 825 | if ((ret = _refresh_m3u8(temp_m3u8)) == ERROR_SUCCESS) { |
820 | if (should_write_file && rename(temp_m3u8.c_str(), m3u8.c_str()) < 0) { | 826 | if (should_write_file && rename(temp_m3u8.c_str(), m3u8.c_str()) < 0) { |
@@ -824,7 +830,9 @@ int SrsHlsMuxer::refresh_m3u8() | @@ -824,7 +830,9 @@ int SrsHlsMuxer::refresh_m3u8() | ||
824 | } | 830 | } |
825 | 831 | ||
826 | // remove the temp file. | 832 | // remove the temp file. |
827 | - unlink(temp_m3u8.c_str()); | 833 | + if (unlink(temp_m3u8.c_str()) < 0) { |
834 | + srs_warn("ignore remove m3u8 failed, %s", temp_m3u8.c_str()); | ||
835 | + } | ||
828 | 836 | ||
829 | return ret; | 837 | return ret; |
830 | } | 838 | } |
-
请 注册 或 登录 后发表评论