From 5979752fa1fb750c48d335483184cbedb8c55444 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 29 Apr 2019 11:26:14 +0800 Subject: [PATCH] =?UTF-8?q?hls=E5=88=87=E7=89=87=E4=BB=A5=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=97=B6=E9=97=B4=E6=88=B3=E4=B8=BA=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MediaFile/HlsMaker.cpp | 6 +++--- src/MediaFile/HlsMaker.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/MediaFile/HlsMaker.cpp b/src/MediaFile/HlsMaker.cpp index 883252ca..a9b6f045 100644 --- a/src/MediaFile/HlsMaker.cpp +++ b/src/MediaFile/HlsMaker.cpp @@ -86,10 +86,10 @@ void HlsMaker::delOldFile() { } } -void HlsMaker::addNewFile(uint32_t timestamp) { - int stampInc = timestamp - _stamp_last; +void HlsMaker::addNewFile(uint32_t) { + int stampInc = _ticker.elapsedTime(); if (stampInc >= _seg_duration * 1000) { - _stamp_last = timestamp; + _ticker.resetTime(); auto file_name = onOpenFile(_file_index); if (_file_index++ > 0) { _seg_dur_list.push_back(std::make_tuple(stampInc, _last_file_name)); diff --git a/src/MediaFile/HlsMaker.h b/src/MediaFile/HlsMaker.h index a82d9eae..3c772e28 100644 --- a/src/MediaFile/HlsMaker.h +++ b/src/MediaFile/HlsMaker.h @@ -86,11 +86,10 @@ private: void addNewFile(uint32_t timestamp); void makeIndexFile(bool eof = false); private: - string _file_prefix; float _seg_duration = 0; uint32_t _seg_number = 0; uint64_t _file_index = 0; - uint32_t _stamp_last = 0; + Ticker _ticker; string _last_file_name; std::deque > _seg_dur_list; };