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

@@ -58,7 +58,8 @@ void RtmpPlayer::play(const string &url) {
_stream_id = findSubString(url.data(), (host_url + "/" + _app + "/").data(), NULL);
auto app_second = findSubString(_stream_id.data(), nullptr, "/");
if (!app_second.empty() && app_second.find('?') == std::string::npos) {
// _stream_id存在多级不包含'?', 说明分割符'/'不是url参数的一部分
// _stream_id存在多级不包含'?', 说明分割符'/'不是url参数的一部分 [AUTO-TRANSLATED:ef820905]
// _stream_id exists at multiple levels; it does not contain '?', indicating that the delimiter '/' is not part of the url parameter
_app += "/" + app_second;
_stream_id.erase(0, app_second.size() + 1);
}
@@ -92,33 +93,40 @@ void RtmpPlayer::play(const string &url) {
}
void RtmpPlayer::onError(const SockException &ex){
//定时器_pPlayTimer为空后表明握手结束了
// 定时器_pPlayTimer为空后表明握手结束了 [AUTO-TRANSLATED:6e2661f4]
// The timer _pPlayTimer is empty after the handshake is finished
onPlayResult_l(ex, !_play_timer);
}
void RtmpPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) {
if (ex.getErrCode() == Err_shutdown) {
//主动shutdown的不触发回调
// 主动shutdown的不触发回调 [AUTO-TRANSLATED:bd97b1c1]
// Active shutdown does not trigger a callback
return;
}
WarnL << ex.getErrCode() << " " << ex;
if (!handshake_done) {
//开始播放阶段
// 开始播放阶段 [AUTO-TRANSLATED:a246c5ee]
// Start playback stage
_play_timer.reset();
//是否为性能测试模式
// 是否为性能测试模式 [AUTO-TRANSLATED:1fde8234]
// Whether it is a performance test mode
_benchmark_mode = (*this)[Client::kBenchmarkMode].as<int>();
onPlayResult(ex);
} else if (ex) {
//播放成功后异常断开回调
// 播放成功后异常断开回调 [AUTO-TRANSLATED:b5c5fa80]
// Callback for abnormal disconnection after successful playback
onShutdown(ex);
} else {
//恢复播放
// 恢复播放 [AUTO-TRANSLATED:19a73f21]
// Resume playback
onResume();
}
if (!ex) {
//播放成功恢复rtmp接收超时定时器
// 播放成功恢复rtmp接收超时定时器 [AUTO-TRANSLATED:29b58110]
// After successful playback, restore the rtmp receive timeout timer
_rtmp_recv_ticker.resetTime();
auto timeout_ms = (*this)[Client::kMediaTimeoutMS].as<uint64_t>();
weak_ptr<RtmpPlayer> weak_self = static_pointer_cast<RtmpPlayer>(shared_from_this());
@@ -128,14 +136,16 @@ void RtmpPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) {
return false;
}
if (strong_self->_rtmp_recv_ticker.elapsedTime() > timeout_ms) {
//接收rtmp媒体数据超时
// 接收rtmp媒体数据超时 [AUTO-TRANSLATED:e14bc1fe]
// Receive rtmp media data timeout
SockException ex(Err_timeout, "receive rtmp timeout");
strong_self->onPlayResult_l(ex, true);
return false;
}
return true;
};
//创建rtmp数据接收超时检测定时器
// 创建rtmp数据接收超时检测定时器 [AUTO-TRANSLATED:d255312b]
// Create an rtmp data receive timeout detection timer
_rtmp_recv_timer = std::make_shared<Timer>(timeout_ms / 2000.0f, lam, getPoller());
} else {
shutdown(SockException(Err_shutdown,"teardown"));
@@ -158,14 +168,16 @@ void RtmpPlayer::onConnect(const SockException &err) {
void RtmpPlayer::onRecv(const Buffer::Ptr &buf){
try {
if (_benchmark_mode && !_play_timer) {
//在性能测试模式下如果rtmp握手完毕后不再解析rtmp包
// 在性能测试模式下如果rtmp握手完毕后不再解析rtmp包 [AUTO-TRANSLATED:a39356cc]
// In performance test mode, if the rtmp handshake is complete, the rtmp packet will no longer be parsed
_rtmp_recv_ticker.resetTime();
return;
}
onParseRtmp(buf->data(), buf->size());
} catch (exception &e) {
SockException ex(Err_other, e.what());
//定时器_pPlayTimer为空后表明握手结束了
// 定时器_pPlayTimer为空后表明握手结束了 [AUTO-TRANSLATED:6e2661f4]
// The timer _pPlayTimer is empty after the handshake is finished
onPlayResult_l(ex, !_play_timer);
}
}
@@ -182,15 +194,20 @@ void RtmpPlayer::send_connect() {
AMFValue obj(AMF_OBJECT);
obj.set("app", _app);
obj.set("tcUrl", _tc_url);
//未使用代理
// 未使用代理 [AUTO-TRANSLATED:fa1ef5d7]
// No proxy used
obj.set("fpad", false);
//参考librtmp,什么作用?
// 参考librtmp,什么作用? [AUTO-TRANSLATED:c6e3349f]
// Refer to librtmp, what is the role?
obj.set("capabilities", 15);
//SUPPORT_VID_CLIENT_SEEK 支持seek
// SUPPORT_VID_CLIENT_SEEK 支持seek [AUTO-TRANSLATED:81d2bb06]
// SUPPORT_VID_CLIENT_SEEK supports seek
obj.set("videoFunction", 1);
//只支持aac
// 只支持aac [AUTO-TRANSLATED:ab086b5b]
// Only supports aac
obj.set("audioCodecs", (double) (0x0400));
//只支持H264
// 只支持H264 [AUTO-TRANSLATED:d8fb8696]
// Only supports H264
obj.set("videoCodecs", (double) (0x0080));
AMFValue fourCcList(AMF_STRICT_ARRAY);
@@ -257,7 +274,8 @@ void RtmpPlayer::send_pause(bool pause) {
if (!pause) {
onPlayResult_l(SockException(Err_success, "resum rtmp success"), true);
} else {
//暂停播放
// 暂停播放 [AUTO-TRANSLATED:09cc521a]
// Pause playback
_rtmp_recv_timer.reset();
}
}
@@ -309,7 +327,8 @@ void RtmpPlayer::onCmd_onStatus(AMFDecoder &dec) {
auto level = val["level"];
auto code = val["code"].as_string();
if (level.type() == AMF_STRING) {
// warning 不应该断开
// warning 不应该断开 [AUTO-TRANSLATED:6db13b98]
// warning should not be disconnected
if (level.as_string() != "status" && level.as_string() != "warning") {
throw std::runtime_error(StrPrinter << "onStatus 失败:" << level.as_string() << " " << code << endl);
}
@@ -335,18 +354,22 @@ void RtmpPlayer::onStreamDry(uint32_t stream_index) {
void RtmpPlayer::onMediaData_l(RtmpPacket::Ptr chunk_data) {
_rtmp_recv_ticker.resetTime();
if (!_play_timer) {
//已经触发了onPlayResult事件直接触发onMediaData事件
// 已经触发了onPlayResult事件直接触发onMediaData事件 [AUTO-TRANSLATED:5c12bd46]
// The onPlayResult event has been triggered, directly trigger the onMediaData event
onRtmpPacket(chunk_data);
return;
}
if (chunk_data->isConfigFrame()) {
//输入配置帧以便初始化完成各个track
// 输入配置帧以便初始化完成各个track [AUTO-TRANSLATED:2f571d31]
// Input configuration frame to initialize each track
onRtmpPacket(chunk_data);
} else {
//先触发onPlayResult事件这个时候解码器才能初始化完毕
// 先触发onPlayResult事件这个时候解码器才能初始化完毕 [AUTO-TRANSLATED:403c9195]
// Trigger the onPlayResult event first, at this time the decoder can be initialized
onPlayResult_l(SockException(Err_success, "play rtmp success"), false);
//触发onPlayResult事件后再把帧数据输入到解码器
// 触发onPlayResult事件后再把帧数据输入到解码器 [AUTO-TRANSLATED:bf058334]
// After triggering the onPlayResult event, input the frame data to the decoder
onRtmpPacket(chunk_data);
}
}
@@ -383,7 +406,8 @@ void RtmpPlayer::onRtmpChunk(RtmpPacket::Ptr packet) {
case MSG_VIDEO: {
auto idx = chunk_data.type_id % 2;
if (_now_stamp_ticker[idx].elapsedTime() > 500) {
//计算播放进度时间轴用
// 计算播放进度时间轴用 [AUTO-TRANSLATED:383fd62c]
// Used to calculate the playback progress timeline
_now_stamp[idx] = chunk_data.time_stamp;
}
if (!_metadata_got) {