正在显示
1 个修改的文件
包含
25 行增加
和
0 行删除
| @@ -814,6 +814,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -814,6 +814,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 814 | if (currentSeg->is_sequence_header) { | 814 | if (currentSeg->is_sequence_header) { |
| 815 | if( m3u8_total_endlist_saved ){ | 815 | if( m3u8_total_endlist_saved ){ |
| 816 | erase_last_endlist = true; | 816 | erase_last_endlist = true; |
| 817 | + m3u8_total_endlist_saved = false; | ||
| 817 | } | 818 | } |
| 818 | if (currentSeg->sequence_no != 0) { | 819 | if (currentSeg->sequence_no != 0) { |
| 819 | // #EXT-X-DISCONTINUITY\n | 820 | // #EXT-X-DISCONTINUITY\n |
| @@ -833,6 +834,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -833,6 +834,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 833 | ss << currentSeg->uri << SRS_CONSTS_LF; | 834 | ss << currentSeg->uri << SRS_CONSTS_LF; |
| 834 | srs_verbose("write m3u8 segment uri success."); | 835 | srs_verbose("write m3u8 segment uri success."); |
| 835 | 836 | ||
| 837 | + srs_trace("---log_desc:%s",log_desc.c_str()); | ||
| 836 | if(log_desc == "unpublish"){ | 838 | if(log_desc == "unpublish"){ |
| 837 | ss << "#EXT-X-ENDLIST" << SRS_CONSTS_LF; | 839 | ss << "#EXT-X-ENDLIST" << SRS_CONSTS_LF; |
| 838 | m3u8_total_endlist_saved = true; | 840 | m3u8_total_endlist_saved = true; |
| @@ -886,6 +888,29 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -886,6 +888,29 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 886 | // reuse current segment index. | 888 | // reuse current segment index. |
| 887 | _sequence_no--; | 889 | _sequence_no--; |
| 888 | 890 | ||
| 891 | + //write #EXT-X-ENDLIST" when unpublish and drop segment | ||
| 892 | + if(save_m3u8_total && !m3u8_total_endlist_saved && log_desc == "unpublish" ){ | ||
| 893 | + SrsFileWriter total_m3u8_writer; | ||
| 894 | + ret = total_m3u8_writer.open_write(total_m3u8); | ||
| 895 | + if (ret != ERROR_SUCCESS) { | ||
| 896 | + srs_error( | ||
| 897 | + "open total file %s error when drop segment:%s reap ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64, | ||
| 898 | + total_m3u8.c_str(), log_desc.c_str(), | ||
| 899 | + current->sequence_no, current->uri.c_str(), | ||
| 900 | + current->duration, current->segment_start_dts); | ||
| 901 | + return ret; | ||
| 902 | + } | ||
| 903 | + std::stringstream ss; | ||
| 904 | + ss << "#EXT-X-ENDLIST" << SRS_CONSTS_LF; | ||
| 905 | + m3u8_total_endlist_saved = true; | ||
| 906 | + std::string m3u8 = ss.str(); | ||
| 907 | + if ((ret = total_m3u8_writer.write((char*) m3u8.c_str(), | ||
| 908 | + (int) m3u8.length(), NULL)) != ERROR_SUCCESS) { | ||
| 909 | + srs_error("write m3u8 failed. ret=%d", ret); | ||
| 910 | + return ret; | ||
| 911 | + } | ||
| 912 | + } | ||
| 913 | + | ||
| 889 | srs_trace("%s drop ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64"", | 914 | srs_trace("%s drop ts segment, sequence_no=%d, uri=%s, duration=%.2f, start=%"PRId64"", |
| 890 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, | 915 | log_desc.c_str(), current->sequence_no, current->uri.c_str(), current->duration, |
| 891 | current->segment_start_dts); | 916 | current->segment_start_dts); |
-
请 注册 或 登录 后发表评论