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

@@ -30,7 +30,8 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
}
if (!poller->isCurrentThread()) {
weak_ptr<FlvMuxer> weak_self = getSharedPtr();
//延时两秒启动录制目的是为了等待config帧收集完毕
// 延时两秒启动录制目的是为了等待config帧收集完毕 [AUTO-TRANSLATED:d359f59d]
// Start recording after a delay of two seconds, the purpose is to wait for the config frame to be collected.
poller->doDelayTask(2000, [weak_self, poller, media, start_pts]() {
auto strong_self = weak_self.lock();
if (strong_self) {
@@ -91,7 +92,8 @@ BufferRaw::Ptr FlvMuxer::obtainBuffer(const void *data, size_t len) {
}
void FlvMuxer::onWriteFlvHeader(const RtmpMediaSource::Ptr &src) {
//发送flv文件头
// 发送flv文件头 [AUTO-TRANSLATED:ee2c5556]
// Send the flv file header.
auto buffer = obtainBuffer();
buffer->setCapacity(sizeof(FLVHeader));
buffer->setSize(sizeof(FLVHeader));
@@ -105,7 +107,8 @@ void FlvMuxer::onWriteFlvHeader(const RtmpMediaSource::Ptr &src) {
header->length = htonl(FLVHeader::kFlvHeaderLength);
header->have_video = src->haveVideo();
header->have_audio = src->haveAudio();
//memset时已经赋值为0
// memset时已经赋值为0 [AUTO-TRANSLATED:0f71eef1]
// It has already been assigned to 0 during memset.
//header->previous_tag_size0 = 0;
//flv header
@@ -167,13 +170,15 @@ void FlvRecorder::startRecord(const EventPoller::Ptr &poller, const RtmpMediaSou
const string &file_path) {
stop();
lock_guard<recursive_mutex> lck(_file_mtx);
//开辟文件写缓存
// 开辟文件写缓存 [AUTO-TRANSLATED:22d1c17f]
// Allocate file write cache.
std::shared_ptr<char> fileBuf(new char[FILE_BUF_SIZE], [](char *ptr) {
if (ptr) {
delete[] ptr;
}
});
//新建文件
// 新建文件 [AUTO-TRANSLATED:f3d512a6]
// Create a new file.
_file.reset(File::create_file(file_path, "wb"), [fileBuf](FILE *fp) {
if (fp) {
fflush(fp);
@@ -184,7 +189,8 @@ void FlvRecorder::startRecord(const EventPoller::Ptr &poller, const RtmpMediaSou
throw std::runtime_error(StrPrinter << "打开文件失败:" << file_path);
}
//设置文件写缓存
// 设置文件写缓存 [AUTO-TRANSLATED:a767e55c]
// Set the file write cache.
setvbuf(_file.get(), fileBuf.get(), _IOFBF, FILE_BUF_SIZE);
start(poller, media);
}