mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-28 05:29:24 +08:00
AI automatically translates all comments in the code into English (#3917)
This commit is contained in:
@@ -39,7 +39,8 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
|
||||
return nullptr;
|
||||
}
|
||||
if (!sample_rate) {
|
||||
//无法把时间戳转换成毫秒
|
||||
// 无法把时间戳转换成毫秒 [AUTO-TRANSLATED:ec2d97b6]
|
||||
// Unable to convert timestamp to milliseconds
|
||||
return nullptr;
|
||||
}
|
||||
RtpHeader *header = (RtpHeader *) ptr;
|
||||
@@ -47,11 +48,13 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
|
||||
throw BadRtpException("invalid rtp version");
|
||||
}
|
||||
if (header->getPayloadSize(len) < 0) {
|
||||
//rtp有效负载小于0,非法
|
||||
// rtp有效负载小于0,非法 [AUTO-TRANSLATED:07eb3ec3]
|
||||
// RTP payload is less than 0, illegal
|
||||
throw BadRtpException("invalid rtp payload size");
|
||||
}
|
||||
|
||||
//比对缓存ssrc
|
||||
// 比对缓存ssrc [AUTO-TRANSLATED:206cb66f]
|
||||
// Compare cache ssrc
|
||||
auto ssrc = ntohl(header->ssrc);
|
||||
|
||||
if (_pt == 0xFF) {
|
||||
@@ -62,16 +65,20 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
|
||||
}
|
||||
|
||||
if (!_ssrc) {
|
||||
//记录并锁定ssrc
|
||||
// 记录并锁定ssrc [AUTO-TRANSLATED:29452029]
|
||||
// Record and lock ssrc
|
||||
_ssrc = ssrc;
|
||||
_ssrc_alive.resetTime();
|
||||
} else if (_ssrc == ssrc) {
|
||||
//ssrc匹配正确,刷新计时器
|
||||
// ssrc匹配正确,刷新计时器 [AUTO-TRANSLATED:266518e6]
|
||||
// SSRC matches correctly, refresh timer
|
||||
_ssrc_alive.resetTime();
|
||||
} else {
|
||||
//ssrc错误
|
||||
// ssrc错误 [AUTO-TRANSLATED:b967d497]
|
||||
// SSRC error
|
||||
if (_ssrc_alive.elapsedTime() < 3 * 1000) {
|
||||
//接收正确ssrc的rtp在10秒内,那么我们认为存在多路rtp,忽略掉ssrc不匹配的rtp
|
||||
// 接收正确ssrc的rtp在10秒内,那么我们认为存在多路rtp,忽略掉ssrc不匹配的rtp [AUTO-TRANSLATED:2f98c2b5]
|
||||
// If the RTP with the correct SSRC is received within 10 seconds, we consider it to be multi-path RTP, and ignore the RTP with mismatched SSRC
|
||||
WarnL << "ssrc mismatch, rtp dropped:" << ssrc << " != " << _ssrc;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -81,25 +88,30 @@ RtpPacket::Ptr RtpTrack::inputRtp(TrackType type, int sample_rate, uint8_t *ptr,
|
||||
}
|
||||
|
||||
auto rtp = RtpPacket::create();
|
||||
//需要添加4个字节的rtp over tcp头
|
||||
// 需要添加4个字节的rtp over tcp头 [AUTO-TRANSLATED:a37d639b]
|
||||
// Need to add 4 bytes of RTP over TCP header
|
||||
rtp->setCapacity(RtpPacket::kRtpTcpHeaderSize + len);
|
||||
rtp->setSize(RtpPacket::kRtpTcpHeaderSize + len);
|
||||
rtp->sample_rate = sample_rate;
|
||||
rtp->type = type;
|
||||
|
||||
//赋值4个字节的rtp over tcp头
|
||||
// 赋值4个字节的rtp over tcp头 [AUTO-TRANSLATED:eeb990a9]
|
||||
// Assign 4 bytes of RTP over TCP header
|
||||
uint8_t *data = (uint8_t *) rtp->data();
|
||||
data[0] = '$';
|
||||
data[1] = 2 * type;
|
||||
data[2] = (len >> 8) & 0xFF;
|
||||
data[3] = len & 0xFF;
|
||||
//拷贝rtp
|
||||
// 拷贝rtp [AUTO-TRANSLATED:3a2466c2]
|
||||
// Copy RTP
|
||||
memcpy(&data[4], ptr, len);
|
||||
if (_disable_ntp) {
|
||||
//不支持ntp时间戳,例如国标推流,那么直接使用rtp时间戳
|
||||
// 不支持ntp时间戳,例如国标推流,那么直接使用rtp时间戳 [AUTO-TRANSLATED:20085979]
|
||||
// Does not support NTP timestamp, such as national standard streaming, so directly use RTP timestamp
|
||||
rtp->ntp_stamp = rtp->getStamp() * uint64_t(1000) / sample_rate;
|
||||
} else {
|
||||
//设置ntp时间戳
|
||||
// 设置ntp时间戳 [AUTO-TRANSLATED:5e60d5cf]
|
||||
// Set NTP timestamp
|
||||
rtp->ntp_stamp = _ntp_stamp.getNtpStamp(rtp->getStamp(), sample_rate);
|
||||
}
|
||||
onBeforeRtpSorted(rtp);
|
||||
|
||||
Reference in New Issue
Block a user