mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-16 13:05:59 +08:00
AI automatically translates all comments in the code into English (#3917)
This commit is contained in:
@@ -15,20 +15,26 @@
|
||||
#include "Util/List.h"
|
||||
|
||||
namespace mediakit {
|
||||
/// 缓存刷新策略类
|
||||
// / 缓存刷新策略类 [AUTO-TRANSLATED:bd941d15]
|
||||
// / Cache refresh strategy class
|
||||
class FlushPolicy {
|
||||
public:
|
||||
bool isFlushAble(bool is_video, bool is_key, uint64_t new_stamp, size_t cache_size);
|
||||
|
||||
private:
|
||||
// 音视频的最后时间戳
|
||||
// 音视频的最后时间戳 [AUTO-TRANSLATED:957d18ed]
|
||||
// Last timestamp of audio and video
|
||||
uint64_t _last_stamp[2] = { 0, 0 };
|
||||
};
|
||||
|
||||
/// 合并写缓存模板
|
||||
/// \tparam packet 包类型
|
||||
/// \tparam policy 刷新缓存策略
|
||||
/// \tparam packet_list 包缓存类型
|
||||
// / 合并写缓存模板 [AUTO-TRANSLATED:25cde944]
|
||||
// / Merge write cache template
|
||||
// / \tparam packet 包类型 [AUTO-TRANSLATED:43085d9b]
|
||||
// / \tparam packet Packet type
|
||||
// / \tparam policy 刷新缓存策略 [AUTO-TRANSLATED:c5ac29a7]
|
||||
// / \tparam policy Refresh cache strategy
|
||||
// / \tparam packet_list 包缓存类型 [AUTO-TRANSLATED:a434e7fe]
|
||||
// / \tparam packet_list Packet cache type
|
||||
template<typename packet, typename policy = FlushPolicy, typename packet_list = toolkit::List<std::shared_ptr<packet> > >
|
||||
class PacketCache {
|
||||
public:
|
||||
@@ -42,7 +48,8 @@ public:
|
||||
flush();
|
||||
}
|
||||
|
||||
//追加数据到最后
|
||||
// 追加数据到最后 [AUTO-TRANSLATED:e24ccfb6]
|
||||
// Append data to the end
|
||||
_cache->emplace_back(std::move(pkt));
|
||||
if (key_pos) {
|
||||
_key_pos = key_pos;
|
||||
@@ -70,10 +77,14 @@ public:
|
||||
|
||||
private:
|
||||
bool flushImmediatelyWhenCloseMerge() {
|
||||
// 一般的协议关闭合并写时,立即刷新缓存,这样可以减少一帧的延时,但是rtp例外
|
||||
// 因为rtp的包很小,一个RtpPacket包中也不是完整的一帧图像,所以在关闭合并写时,
|
||||
// 还是有必要缓冲一帧的rtp(也就是时间戳相同的rtp)再输出,这样虽然会增加一帧的延时
|
||||
// 但是却对性能提升很大,这样做还是比较划算的
|
||||
// 一般的协议关闭合并写时,立即刷新缓存,这样可以减少一帧的延时,但是rtp例外 [AUTO-TRANSLATED:54eba701]
|
||||
// Generally, when the protocol closes the merge write, the cache is refreshed immediately, which can reduce the delay of one frame, but RTP is an exception.
|
||||
// 因为rtp的包很小,一个RtpPacket包中也不是完整的一帧图像,所以在关闭合并写时, [AUTO-TRANSLATED:b219082d]
|
||||
// Because the RTP packet is very small, and a RtpPacket does not contain a complete frame of image, so when closing the merge write,
|
||||
// 还是有必要缓冲一帧的rtp(也就是时间戳相同的rtp)再输出,这样虽然会增加一帧的延时 [AUTO-TRANSLATED:27c7ee8b]
|
||||
// It is still necessary to buffer one frame of RTP (that is, RTP with the same timestamp) before outputting. Although this will increase the delay of one frame,
|
||||
// 但是却对性能提升很大,这样做还是比较划算的 [AUTO-TRANSLATED:80eab719]
|
||||
// But it greatly improves performance, so it is still worthwhile to do so.
|
||||
|
||||
GET_CONFIG(int, mergeWriteMS, General::kMergeWriteMS);
|
||||
GET_CONFIG(int, rtspLowLatency, Rtsp::kLowLatency);
|
||||
|
||||
Reference in New Issue
Block a user