AI automatically translates all comments in the code into English (#3917)

This commit is contained in:
alex
2024-09-19 14:53:50 +08:00
committed by GitHub
parent 046de691cb
commit 4152dcd409
279 changed files with 10602 additions and 3038 deletions

View File

@@ -55,11 +55,17 @@ typedef enum {
/**
* 字符串转媒体类型转
* String to media type conversion
* [AUTO-TRANSLATED:59850011]
*/
TrackType getTrackType(const std::string &str);
/**
* 媒体类型转字符串
* Media type to string conversion
* [AUTO-TRANSLATED:0456e0e2]
*/
const char* getTrackString(TrackType type);
@@ -67,41 +73,67 @@ const char* getTrackString(TrackType type);
* 根据SDP中描述获取codec_id
* @param str
* @return
* Get codec_id from SDP description
* @param str
* @return
* [AUTO-TRANSLATED:024f2ed1]
*/
CodecId getCodecId(const std::string &str);
/**
* 获取编码器名称
* Get encoder name
* [AUTO-TRANSLATED:0253534b]
*/
const char *getCodecName(CodecId codecId);
/**
* 获取音视频类型
* Get audio/video type
* [AUTO-TRANSLATED:e2f06ac2]
*/
TrackType getTrackType(CodecId codecId);
/**
* 根据codecid获取mov object id
* Get mov object id by codecid
* [AUTO-TRANSLATED:c315b87d]
*/
int getMovIdByCodec(CodecId codecId);
/**
* 根据mov object id获取CodecId
* Get CodecId by mov object id
* [AUTO-TRANSLATED:de2237a1]
*/
CodecId getCodecByMovId(int object_id);
/**
* 根据codecid获取mpeg id
* Get mpeg id by codecid
* [AUTO-TRANSLATED:d365eac7]
*/
int getMpegIdByCodec(CodecId codec);
/**
* 根据mpeg id获取CodecId
* Get CodecId by mpeg id
* [AUTO-TRANSLATED:ca190565]
*/
CodecId getCodecByMpegId(int mpeg_id);
/**
* 编码信息的抽象接口
* Abstract interface for encoding information
* [AUTO-TRANSLATED:c3b14625]
*/
class CodecInfo {
public:
@@ -111,31 +143,49 @@ public:
/**
* 获取编解码器类型
* Get codec type
* [AUTO-TRANSLATED:2dbf103b]
*/
virtual CodecId getCodecId() const = 0;
/**
* 获取编码器名称
* Get encoder name
* [AUTO-TRANSLATED:a92f41f6]
*/
const char *getCodecName() const;
/**
* 获取音视频类型
* Get audio/video type
* [AUTO-TRANSLATED:ff8ba95b]
*/
TrackType getTrackType() const;
/**
* 获取音视频类型描述
* Get audio/video type description
* [AUTO-TRANSLATED:a460e432]
*/
std::string getTrackTypeStr() const;
/**
* 设置track index, 用于支持多track
* Set track index, for multi-track support
* [AUTO-TRANSLATED:da5bdb91]
*/
void setIndex(int index) { _index = index; }
/**
* 获取track index, 用于支持多track
* Get track index, for multi-track support
* [AUTO-TRANSLATED:1e96c587]
*/
int getIndex() const { return _index < 0 ? (int)getTrackType() : _index; }
@@ -145,6 +195,9 @@ private:
/**
* 帧类型的抽象接口
* Abstract interface for frame types
* [AUTO-TRANSLATED:eb166e7e]
*/
class Frame : public toolkit::Buffer, public CodecInfo {
public:
@@ -152,32 +205,51 @@ public:
/**
* 返回解码时间戳,单位毫秒
* Return decoding timestamp, in milliseconds
* [AUTO-TRANSLATED:00072dad]
*/
virtual uint64_t dts() const = 0;
/**
* 返回显示时间戳,单位毫秒
* Return display timestamp, in milliseconds
* [AUTO-TRANSLATED:c7eecb91]
*/
virtual uint64_t pts() const { return dts(); }
/**
* 前缀长度譬如264前缀为0x00 00 00 01,那么前缀长度就是4
* aac前缀则为7个字节
* Prefix length, for example, the 264 prefix is 0x00 00 00 01, so the prefix length is 4
* aac prefix is 7 bytes
* [AUTO-TRANSLATED:6334f58e]
*/
virtual size_t prefixSize() const = 0;
/**
* 返回是否为关键帧
* Return whether it is a key frame
* [AUTO-TRANSLATED:2e52426a]
*/
virtual bool keyFrame() const = 0;
/**
* 是否为配置帧譬如sps pps vps
* Whether it is a configuration frame, such as sps pps vps
* [AUTO-TRANSLATED:595c7ecf]
*/
virtual bool configFrame() const = 0;
/**
* 是否可以缓存
* Whether it can be cached
* [AUTO-TRANSLATED:5c35d3e0]
*/
virtual bool cacheAble() const { return true; }
@@ -185,29 +257,44 @@ public:
* 该帧是否可以丢弃
* SEI/AUD帧可以丢弃
* 默认都不能丢帧
* Whether this frame can be dropped
* SEI/AUD frames can be dropped
* By default, no frames can be dropped
* [AUTO-TRANSLATED:42957087]
*/
virtual bool dropAble() const { return false; }
/**
* 是否为可解码帧
* sps pps等帧不能解码
* Whether it is a decodable frame
* sps pps frames cannot be decoded
* [AUTO-TRANSLATED:52f093c7]
*/
virtual bool decodeAble() const {
if (getTrackType() != TrackVideo) {
//非视频帧都可以解码
// 非视频帧都可以解码 [AUTO-TRANSLATED:24aa4342]
// Non-video frames can be decoded
return true;
}
//默认非sps pps帧都可以解码
// 默认非sps pps帧都可以解码 [AUTO-TRANSLATED:b14d1e34]
// By default, non-sps pps frames can be decoded
return !configFrame();
}
/**
* 返回可缓存的frame
* Return the cacheable frame
* [AUTO-TRANSLATED:88fb9c3e]
*/
static Ptr getCacheAbleFrame(const Ptr &frame);
private:
//对象个数统计
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
// Object count statistics
toolkit::ObjectStatistic<Frame> _statistic;
};
@@ -250,7 +337,8 @@ public:
toolkit::BufferLikeString _buffer;
private:
//对象个数统计
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
// Object count statistics
toolkit::ObjectStatistic<FrameImp> _statistic;
protected:
@@ -258,7 +346,8 @@ protected:
FrameImp() = default;
};
// 包装一个指针成不可缓存的frame
// 包装一个指针成不可缓存的frame [AUTO-TRANSLATED:c3e5d65e]
// Wrap a pointer into a non-cacheable frame
class FrameFromPtr : public Frame {
public:
using Ptr = std::shared_ptr<FrameFromPtr>;
@@ -311,6 +400,12 @@ protected:
* ZLMediaKit会先把这种复合帧split成单个帧然后再处理
* 一个复合帧可以通过无内存拷贝的方式切割成多个子Frame
* 提供该类的目的是切割复合帧时防止内存拷贝,提高性能
* A Frame class can have multiple frames (AAC), and the timestamp will change
* ZLMediaKit will first split this composite frame into single frames and then process it
* A composite frame can be split into multiple sub-Frames without memory copy
* The purpose of providing this class is to prevent memory copy when splitting composite frames, improving performance
* [AUTO-TRANSLATED:4010c0a5]
*/
template <typename Parent>
class FrameInternalBase : public Parent {
@@ -333,6 +428,12 @@ private:
* ZLMediaKit会先把这种复合帧split成单个帧然后再处理
* 一个复合帧可以通过无内存拷贝的方式切割成多个子Frame
* 提供该类的目的是切割复合帧时防止内存拷贝,提高性能
* A Frame class can have multiple frames, they are separated by 0x 00 00 01
* ZLMediaKit will first split this composite frame into single frames and then process it
* A composite frame can be split into multiple sub-Frames without memory copy
* The purpose of providing this class is to prevent memory copy when splitting composite frames, improving performance
* [AUTO-TRANSLATED:ed49148b]
*/
template <typename Parent>
class FrameInternal : public FrameInternalBase<Parent> {
@@ -342,7 +443,8 @@ public:
: FrameInternalBase<Parent>(parent_frame, ptr, size, parent_frame->dts(), parent_frame->pts(), prefix_size) {}
};
// 管理一个指针生命周期并生产一个frame
// 管理一个指针生命周期并生产一个frame [AUTO-TRANSLATED:449d107b]
// Manage the lifetime of a pointer and produce a frame
class FrameAutoDelete : public FrameFromPtr {
public:
template <typename... ARGS>
@@ -353,7 +455,8 @@ public:
bool cacheAble() const override { return true; }
};
// 把一个不可缓存的frame声明为可缓存的
// 把一个不可缓存的frame声明为可缓存的 [AUTO-TRANSLATED:2c8d0659]
// Declare a non-cacheable frame as cacheable
template <typename Parent>
class FrameToCache : public Parent {
public:
@@ -365,7 +468,8 @@ public:
}
};
// 该对象的功能是把一个不可缓存的帧转换成可缓存的帧
// 该对象的功能是把一个不可缓存的帧转换成可缓存的帧 [AUTO-TRANSLATED:5851119b]
// The function of this object is to convert a non-cacheable frame into a cacheable frame
class FrameCacheAble : public FrameFromPtr {
public:
using Ptr = std::shared_ptr<FrameCacheAble>;
@@ -397,6 +501,9 @@ public:
/**
* 可以被缓存
* Can be cached
* [AUTO-TRANSLATED:7f9cec13]
*/
bool cacheAble() const override { return true; }
bool keyFrame() const override { return _key; }
@@ -412,7 +519,8 @@ private:
toolkit::Buffer::Ptr _buffer;
};
//该类实现frame级别的时间戳覆盖
// 该类实现frame级别的时间戳覆盖 [AUTO-TRANSLATED:77c28d0f]
// This class implements frame-level timestamp overwrite
class FrameStamp : public Frame {
public:
using Ptr = std::shared_ptr<FrameStamp>;
@@ -439,6 +547,9 @@ private:
/**
* 该对象可以把Buffer对象转换成可缓存的Frame对象
* This object can convert a Buffer object into a cacheable Frame object
* [AUTO-TRANSLATED:3c5786b8]
*/
template <typename Parent>
class FrameFromBuffer : public Parent {
@@ -450,6 +561,14 @@ public:
* @param pts 显示时间戳
* @param prefix 帧前缀长度
* @param offset buffer有效数据偏移量
* Construct frame
* @param buf Data cache
* @param dts Decode timestamp
* @param pts Display timestamp
* @param prefix Frame prefix length
* @param offset Buffer valid data offset
* [AUTO-TRANSLATED:6afec0f1]
*/
FrameFromBuffer(toolkit::Buffer::Ptr buf, uint64_t dts, uint64_t pts, size_t prefix = 0, size_t offset = 0)
: Parent(buf->data() + offset, buf->size() - offset, dts, pts, prefix) {
@@ -464,6 +583,15 @@ public:
* @param prefix 帧前缀长度
* @param offset buffer有效数据偏移量
* @param codec 帧类型
* Construct frame
* @param buf Data cache
* @param dts Decode timestamp
* @param pts Display timestamp
* @param prefix Frame prefix length
* @param offset Buffer valid data offset
* @param codec Frame type
* [AUTO-TRANSLATED:f1c42e38]
*/
FrameFromBuffer(CodecId codec, toolkit::Buffer::Ptr buf, uint64_t dts, uint64_t pts, size_t prefix = 0, size_t offset = 0)
: Parent(codec, buf->data() + offset, buf->size() - offset, dts, pts, prefix) {
@@ -472,6 +600,9 @@ public:
/**
* 该帧可缓存
* This frame is cacheable
* [AUTO-TRANSLATED:e089250f]
*/
bool cacheAble() const override { return true; }
@@ -481,6 +612,9 @@ private:
/**
* 合并一些时间戳相同的frame
* Merge some frames with the same timestamp
* [AUTO-TRANSLATED:392a23df]
*/
class FrameMerger {
public:
@@ -497,6 +631,10 @@ public:
/**
* 刷新输出缓冲注意此时会调用FrameMerger::inputFrame传入的onOutput回调
* 请注意回调捕获参数此时是否有效
* Refresh the output buffer, note that FrameMerger::inputFrame's onOutput callback will be called at this time
* Please note whether the callback capture parameters are valid at this time
* [AUTO-TRANSLATED:18c25a14]
*/
void flush();
void clear();
@@ -515,6 +653,9 @@ private:
/**
* 写帧接口的抽象接口类
* Abstract interface class for write frame interface
* [AUTO-TRANSLATED:dbe6a33c]
*/
class FrameWriterInterface {
public:
@@ -523,17 +664,26 @@ public:
/**
* 写入帧数据
* Write frame data
* [AUTO-TRANSLATED:d46c6fc2]
*/
virtual bool inputFrame(const Frame::Ptr &frame) = 0;
/**
* 刷新输出所有frame缓存
* Flush all frame caches in the output
* [AUTO-TRANSLATED:adaea568]
*/
virtual void flush() {};
};
/**
* 支持代理转发的帧环形缓存
* Frame circular buffer that supports proxy forwarding
* [AUTO-TRANSLATED:06bf1541]
*/
class FrameDispatcher : public FrameWriterInterface {
public:
@@ -541,6 +691,9 @@ public:
/**
* 添加代理
* Add proxy
* [AUTO-TRANSLATED:0be3c076]
*/
FrameWriterInterface* addDelegate(FrameWriterInterface::Ptr delegate) {
std::lock_guard<std::recursive_mutex> lck(_mtx);
@@ -551,6 +704,9 @@ public:
/**
* 删除代理
* Delete proxy
* [AUTO-TRANSLATED:c2c915aa]
*/
void delDelegate(FrameWriterInterface *ptr) {
std::lock_guard<std::recursive_mutex> lck(_mtx);
@@ -559,6 +715,9 @@ public:
/**
* 写入帧并派发
* Write frame and dispatch
* [AUTO-TRANSLATED:a3e7e6db]
*/
bool inputFrame(const Frame::Ptr &frame) override {
std::lock_guard<std::recursive_mutex> lck(_mtx);
@@ -574,6 +733,9 @@ public:
/**
* 返回代理个数
* Return the number of proxies
* [AUTO-TRANSLATED:93ebe7ec]
*/
size_t size() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
@@ -587,6 +749,9 @@ public:
/**
* 获取累计关键帧数
* Get the cumulative number of keyframes
* [AUTO-TRANSLATED:73cb2ab0]
*/
uint64_t getVideoKeyFrames() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
@@ -595,6 +760,9 @@ public:
/**
* 获取帧数
* Get the number of frames
* [AUTO-TRANSLATED:118b395e]
*/
uint64_t getFrames() const {
std::lock_guard<std::recursive_mutex> lck(_mtx);
@@ -619,12 +787,14 @@ public:
private:
void doStatistics(const Frame::Ptr &frame) {
if (!frame->configFrame() && !frame->dropAble()) {
// 忽略配置帧与可丢弃的帧
// 忽略配置帧与可丢弃的帧 [AUTO-TRANSLATED:da4ff7ac]
// Ignore configuration frames and discardable frames
++_frames;
int64_t out;
_stamp.revise(frame->dts(), frame->pts(), out, out);
if (frame->keyFrame() && frame->getTrackType() == TrackVideo) {
// 遇视频关键帧时统计
// 遇视频关键帧时统计 [AUTO-TRANSLATED:72b0e569]
// Statistics when encountering video keyframes
++_video_key_frames;
_gop_size = _frames - _last_frames;
_gop_interval_ms = _ticker.elapsedTime();