Commit f1ed0194 by xiongziliang

合并#106

parent d6e60e09
...@@ -61,7 +61,8 @@ void MediaSink::addTrack(const Track::Ptr &track_in) { ...@@ -61,7 +61,8 @@ void MediaSink::addTrack(const Track::Ptr &track_in) {
} }
void MediaSink::resetTracks() { void MediaSink::resetTracks() {
_anyTrackUnReady = true; lock_guard<recursive_mutex> lck(_mtx);
_anyTrackUnReady = false;
_allTrackReady = false; _allTrackReady = false;
_track_map.clear(); _track_map.clear();
_trackReadyCallback.clear(); _trackReadyCallback.clear();
......
...@@ -85,13 +85,10 @@ void HlsMaker::inputData(void *data, uint32_t len, uint32_t timestamp) { ...@@ -85,13 +85,10 @@ void HlsMaker::inputData(void *data, uint32_t len, uint32_t timestamp) {
if (data && len) { if (data && len) {
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();
} }
} }
...@@ -112,12 +109,6 @@ void HlsMaker::delOldFile() { ...@@ -112,12 +109,6 @@ 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();
......
...@@ -92,7 +92,6 @@ protected: ...@@ -92,7 +92,6 @@ 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;
......
...@@ -48,22 +48,22 @@ public: ...@@ -48,22 +48,22 @@ public:
virtual ~MediaRecorder(); virtual ~MediaRecorder();
/** /**
* 输入frame * 输入frame
* @param frame * @param frame
*/ */
void inputFrame(const Frame::Ptr &frame) override; void inputFrame(const Frame::Ptr &frame) override;
/** /**
* 添加track,内部会调用Track的clone方法 * 添加track,内部会调用Track的clone方法
* 只会克隆sps pps这些信息 ,而不会克隆Delegate相关关系 * 只会克隆sps pps这些信息 ,而不会克隆Delegate相关关系
* @param track * @param track
*/ */
void addTrack(const Track::Ptr & track) override; void addTrack(const Track::Ptr &track) override;
/** /**
* 重置track * 重置track
*/ */
void resetTracks() override; void resetTracks() override;
private: private:
#if defined(ENABLE_HLS) #if defined(ENABLE_HLS)
std::shared_ptr<HlsRecorder> _hlsRecorder; std::shared_ptr<HlsRecorder> _hlsRecorder;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论