mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
提高http-ts直播性能:#961
This commit is contained in:
parent
c393cc7c0e
commit
9f9b3a5a64
@ -110,6 +110,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
|
||||
_is_idr_fast_packet = have_idr;
|
||||
mpeg_ts_write(_context, track_info.track_id, have_idr ? 0x0001 : 0,
|
||||
pts_out * 90LL, dts_out * 90LL, buffer->data(), buffer->size());
|
||||
flushCache();
|
||||
});
|
||||
break;
|
||||
}
|
||||
@ -129,6 +130,7 @@ void TsMuxer::inputFrame(const Frame::Ptr &frame) {
|
||||
}
|
||||
mpeg_ts_write(_context, track_info.track_id, frame->keyFrame() ? 0x0001 : 0,
|
||||
pts_out * 90LL, dts_out * 90LL, frame->data(), frame->size());
|
||||
flushCache();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -154,8 +156,7 @@ void TsMuxer::init() {
|
||||
},
|
||||
[](void *param, const void *packet, size_t bytes) {
|
||||
TsMuxer *muxer = (TsMuxer *) param;
|
||||
muxer->onTs(packet, bytes, muxer->_timestamp, muxer->_is_idr_fast_packet);
|
||||
muxer->_is_idr_fast_packet = false;
|
||||
muxer->onTs_l(packet, bytes);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@ -164,6 +165,16 @@ void TsMuxer::init() {
|
||||
}
|
||||
}
|
||||
|
||||
void TsMuxer::onTs_l(const void *packet, size_t bytes) {
|
||||
_cache.append((char *) packet, bytes);
|
||||
}
|
||||
|
||||
void TsMuxer::flushCache() {
|
||||
onTs(_cache.data(), _cache.size(), _timestamp, _is_idr_fast_packet);
|
||||
_cache.clear();
|
||||
_is_idr_fast_packet = false;
|
||||
}
|
||||
|
||||
void TsMuxer::uninit() {
|
||||
if (_context) {
|
||||
mpeg_ts_destroy(_context);
|
||||
|
@ -57,6 +57,8 @@ private:
|
||||
void uninit();
|
||||
//音视频时间戳同步用
|
||||
void stampSync();
|
||||
void onTs_l(const void *packet, size_t bytes);
|
||||
void flushCache();
|
||||
|
||||
private:
|
||||
bool _have_video = false;
|
||||
@ -70,6 +72,7 @@ private:
|
||||
};
|
||||
unordered_map<int, track_info> _codec_to_trackid;
|
||||
FrameMerger _frame_merger{FrameMerger::h264_prefix};
|
||||
BufferLikeString _cache;
|
||||
};
|
||||
|
||||
}//namespace mediakit
|
||||
|
Loading…
Reference in New Issue
Block a user