修复回复hls生成的bug

This commit is contained in:
xiongziliang 2019-10-11 19:01:34 +08:00
parent f1ed019437
commit 7f203ce9b7
2 changed files with 12 additions and 3 deletions

View File

@ -86,9 +86,11 @@ void HlsMaker::inputData(void *data, uint32_t len, uint32_t timestamp) {
addNewFile(timestamp); addNewFile(timestamp);
onWriteFile((char *) data, len); onWriteFile((char *) data, len);
} else { } else {
//调用resetTracks触发这个时候生成直播hls被中断 _noData = true;
//我们记录为点播,等待下次拉流再恢复为直播。 _stampInc = _ticker.elapsedTime();
makeIndexFile(true); _seg_dur_list.push_back(std::make_tuple(_stampInc, _last_file_name));
delOldFile();
makeIndexFile();
} }
} }
@ -109,6 +111,12 @@ void HlsMaker::delOldFile() {
} }
void HlsMaker::addNewFile(uint32_t) { void HlsMaker::addNewFile(uint32_t) {
//上次分片数据中断结束,重置时间避免中途的等待
if (_noData) {
_ticker.resetTime();
_last_file_name = onOpenFile(_file_index++);
_noData = false;
}
_stampInc = _ticker.elapsedTime(); _stampInc = _ticker.elapsedTime();
if (_file_index == 0 || _stampInc >= _seg_duration * 1000) { if (_file_index == 0 || _stampInc >= _seg_duration * 1000) {
_ticker.resetTime(); _ticker.resetTime();

View File

@ -92,6 +92,7 @@ protected:
protected: protected:
uint32_t _seg_number = 0; uint32_t _seg_number = 0;
private: private:
bool _noData = false;
int _stampInc = 0; int _stampInc = 0;
float _seg_duration = 0; float _seg_duration = 0;
uint64_t _file_index = 0; uint64_t _file_index = 0;