mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-11-24 00:47:21 +08:00
AI automatically translates all comments in the code into English (#3917)
This commit is contained in:
@@ -26,6 +26,9 @@ namespace mediakit {
|
||||
|
||||
/**
|
||||
* http content部分基类定义
|
||||
* Base class definition for http content part
|
||||
|
||||
* [AUTO-TRANSLATED:1eee419a]
|
||||
*/
|
||||
class HttpBody : public std::enable_shared_from_this<HttpBody>{
|
||||
public:
|
||||
@@ -34,6 +37,9 @@ public:
|
||||
|
||||
/**
|
||||
* 剩余数据大小,如果返回-1, 那么就不设置content-length
|
||||
* Remaining data size, if -1 is returned, then content-length is not set
|
||||
|
||||
* [AUTO-TRANSLATED:75375ce7]
|
||||
*/
|
||||
virtual int64_t remainSize() { return 0;};
|
||||
|
||||
@@ -41,6 +47,11 @@ public:
|
||||
* 读取一定字节数,返回大小可能小于size
|
||||
* @param size 请求大小
|
||||
* @return 字节对象,如果读完了,那么请返回nullptr
|
||||
* Read a certain number of bytes, the returned size may be less than size
|
||||
* @param size Request size
|
||||
* @return Byte object, if it is read, please return nullptr
|
||||
|
||||
* [AUTO-TRANSLATED:6fd85f91]
|
||||
*/
|
||||
virtual toolkit::Buffer::Ptr readData(size_t size) { return nullptr;};
|
||||
|
||||
@@ -48,11 +59,19 @@ public:
|
||||
* 异步请求读取一定字节数,返回大小可能小于size
|
||||
* @param size 请求大小
|
||||
* @param cb 回调函数
|
||||
* Asynchronously request to read a certain number of bytes, the returned size may be less than size
|
||||
* @param size Request size
|
||||
* @param cb Callback function
|
||||
|
||||
* [AUTO-TRANSLATED:a5304046]
|
||||
*/
|
||||
virtual void readDataAsync(size_t size,const std::function<void(const toolkit::Buffer::Ptr &buf)> &cb){
|
||||
//由于unix和linux是通过mmap的方式读取文件,所以把读文件操作放在后台线程并不能提高性能
|
||||
//反而会由于频繁的线程切换导致性能降低以及延时增加,所以我们默认同步获取文件内容
|
||||
//(其实并没有读,拷贝文件数据时在内核态完成文件读)
|
||||
// 由于unix和linux是通过mmap的方式读取文件,所以把读文件操作放在后台线程并不能提高性能 [AUTO-TRANSLATED:59ef443d]
|
||||
// Since unix and linux read files through mmap, putting file reading operations in the background thread does not improve performance
|
||||
// 反而会由于频繁的线程切换导致性能降低以及延时增加,所以我们默认同步获取文件内容 [AUTO-TRANSLATED:93d2a0b5]
|
||||
// On the contrary, frequent thread switching will lead to performance degradation and increased latency, so we get the file content synchronously by default
|
||||
// (其实并没有读,拷贝文件数据时在内核态完成文件读) [AUTO-TRANSLATED:6eb98a5d]
|
||||
// (Actually, there is no reading, the file data is copied in the kernel state when copying)
|
||||
cb(readData(size));
|
||||
}
|
||||
|
||||
@@ -60,6 +79,11 @@ public:
|
||||
* 使用sendfile优化文件发送
|
||||
* @param fd socket fd
|
||||
* @return 0成功,其他为错误代码
|
||||
* Use sendfile to optimize file sending
|
||||
* @param fd socket fd
|
||||
* @return 0 success, other error codes
|
||||
|
||||
* [AUTO-TRANSLATED:eacc5f98]
|
||||
*/
|
||||
virtual int sendFile(int fd) {
|
||||
return -1;
|
||||
@@ -68,6 +92,9 @@ public:
|
||||
|
||||
/**
|
||||
* std::string类型的content
|
||||
* std::string type content
|
||||
|
||||
* [AUTO-TRANSLATED:59fc3e5b]
|
||||
*/
|
||||
class HttpStringBody : public HttpBody{
|
||||
public:
|
||||
@@ -84,6 +111,9 @@ private:
|
||||
|
||||
/**
|
||||
* Buffer类型的content
|
||||
* Buffer type content
|
||||
|
||||
* [AUTO-TRANSLATED:350b9513]
|
||||
*/
|
||||
class HttpBufferBody : public HttpBody{
|
||||
public:
|
||||
@@ -99,6 +129,9 @@ private:
|
||||
|
||||
/**
|
||||
* 文件类型的content
|
||||
* File type content
|
||||
|
||||
* [AUTO-TRANSLATED:baf9c0f3]
|
||||
*/
|
||||
class HttpFileBody : public HttpBody {
|
||||
public:
|
||||
@@ -108,6 +141,11 @@ public:
|
||||
* 构造函数
|
||||
* @param file_path 文件路径
|
||||
* @param use_mmap 是否使用mmap方式访问文件
|
||||
* Constructor
|
||||
* @param file_path File path
|
||||
* @param use_mmap Whether to use mmap to access the file
|
||||
|
||||
* [AUTO-TRANSLATED:40c85c53]
|
||||
*/
|
||||
HttpFileBody(const std::string &file_path, bool use_mmap = true);
|
||||
|
||||
@@ -115,6 +153,11 @@ public:
|
||||
* 设置读取范围
|
||||
* @param offset 相对文件头的偏移量
|
||||
* @param max_size 最大读取字节数
|
||||
* Set the reading range
|
||||
* @param offset Offset relative to the file header
|
||||
* @param max_size Maximum number of bytes to read
|
||||
|
||||
* [AUTO-TRANSLATED:30532a4e]
|
||||
*/
|
||||
void setRange(uint64_t offset, uint64_t max_size);
|
||||
|
||||
@@ -134,6 +177,9 @@ class HttpArgs;
|
||||
|
||||
/**
|
||||
* http MultiForm 方式提交的http content
|
||||
* http MultiForm way to submit http content
|
||||
|
||||
* [AUTO-TRANSLATED:211a2d8e]
|
||||
*/
|
||||
class HttpMultiFormBody : public HttpBody {
|
||||
public:
|
||||
@@ -144,6 +190,13 @@ public:
|
||||
* @param args http提交参数列表
|
||||
* @param filePath 文件路径
|
||||
* @param boundary boundary字符串
|
||||
* Constructor
|
||||
* @param args http submission parameter list
|
||||
* @param filePath File path
|
||||
* @param boundary Boundary string
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:d093cfa7]
|
||||
*/
|
||||
HttpMultiFormBody(const HttpArgs &args,const std::string &filePath,const std::string &boundary = "0xKhTmLbOuNdArY");
|
||||
int64_t remainSize() override ;
|
||||
|
||||
Reference in New Issue
Block a user