mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-14 20:15:58 +08:00
统一成员变量命名风格
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
H264RtpDecoder::H264RtpDecoder() {
|
||||
m_h264frame = obtainFrame();
|
||||
_h264frame = obtainFrame();
|
||||
}
|
||||
|
||||
H264Frame::Ptr H264RtpDecoder::obtainFrame() {
|
||||
@@ -40,13 +40,13 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
|
||||
|
||||
if (nal.type >= 0 && nal.type < 24) {
|
||||
//a full frame
|
||||
m_h264frame->buffer.assign("\x0\x0\x0\x1", 4);
|
||||
m_h264frame->buffer.append((char *)frame, length);
|
||||
m_h264frame->type = nal.type;
|
||||
m_h264frame->timeStamp = rtppack->timeStamp / 90;
|
||||
m_h264frame->sequence = rtppack->sequence;
|
||||
auto isIDR = m_h264frame->type == 5;
|
||||
onGetH264(m_h264frame);
|
||||
_h264frame->buffer.assign("\x0\x0\x0\x1", 4);
|
||||
_h264frame->buffer.append((char *)frame, length);
|
||||
_h264frame->type = nal.type;
|
||||
_h264frame->timeStamp = rtppack->timeStamp / 90;
|
||||
_h264frame->sequence = rtppack->sequence;
|
||||
auto isIDR = _h264frame->type == 5;
|
||||
onGetH264(_h264frame);
|
||||
return (isIDR); //i frame
|
||||
}
|
||||
|
||||
@@ -57,31 +57,31 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
|
||||
if (fu.S == 1) {
|
||||
//FU-A start
|
||||
char tmp = (nal.forbidden_zero_bit << 7 | nal.nal_ref_idc << 5 | fu.type);
|
||||
m_h264frame->buffer.assign("\x0\x0\x0\x1", 4);
|
||||
m_h264frame->buffer.push_back(tmp);
|
||||
m_h264frame->buffer.append((char *)frame + 2, length - 2);
|
||||
m_h264frame->type = fu.type;
|
||||
m_h264frame->timeStamp = rtppack->timeStamp / 90;
|
||||
m_h264frame->sequence = rtppack->sequence;
|
||||
return (m_h264frame->type == 5); //i frame
|
||||
_h264frame->buffer.assign("\x0\x0\x0\x1", 4);
|
||||
_h264frame->buffer.push_back(tmp);
|
||||
_h264frame->buffer.append((char *)frame + 2, length - 2);
|
||||
_h264frame->type = fu.type;
|
||||
_h264frame->timeStamp = rtppack->timeStamp / 90;
|
||||
_h264frame->sequence = rtppack->sequence;
|
||||
return (_h264frame->type == 5); //i frame
|
||||
}
|
||||
|
||||
if (rtppack->sequence != (uint16_t)(m_h264frame->sequence + 1)) {
|
||||
m_h264frame->buffer.clear();
|
||||
WarnL << "丢包,帧废弃:" << rtppack->sequence << "," << m_h264frame->sequence;
|
||||
if (rtppack->sequence != (uint16_t)(_h264frame->sequence + 1)) {
|
||||
_h264frame->buffer.clear();
|
||||
WarnL << "丢包,帧废弃:" << rtppack->sequence << "," << _h264frame->sequence;
|
||||
return false;
|
||||
}
|
||||
m_h264frame->sequence = rtppack->sequence;
|
||||
_h264frame->sequence = rtppack->sequence;
|
||||
if (fu.E == 1) {
|
||||
//FU-A end
|
||||
m_h264frame->buffer.append((char *)frame + 2, length - 2);
|
||||
m_h264frame->timeStamp = rtppack->timeStamp / 90;
|
||||
auto isIDR = m_h264frame->type == 5;
|
||||
onGetH264(m_h264frame);
|
||||
_h264frame->buffer.append((char *)frame + 2, length - 2);
|
||||
_h264frame->timeStamp = rtppack->timeStamp / 90;
|
||||
auto isIDR = _h264frame->type == 5;
|
||||
onGetH264(_h264frame);
|
||||
return isIDR;
|
||||
}
|
||||
//FU-A mid
|
||||
m_h264frame->buffer.append((char *)frame + 2, length - 2);
|
||||
_h264frame->buffer.append((char *)frame + 2, length - 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) {
|
||||
void H264RtpDecoder::onGetH264(const H264Frame::Ptr &frame) {
|
||||
//写入环形缓存
|
||||
RtpCodec::inputFrame(frame);
|
||||
m_h264frame = obtainFrame();
|
||||
_h264frame = obtainFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
auto iLen = frame->size() - frame->prefixSize();
|
||||
|
||||
uiStamp %= cycleMS;
|
||||
int iSize = m_ui32MtuSize - 2;
|
||||
int iSize = _ui32MtuSize - 2;
|
||||
if (iLen > iSize) { //超过MTU
|
||||
const unsigned char s_e_r_Start = 0x80;
|
||||
const unsigned char s_e_r_Mid = 0x00;
|
||||
@@ -156,11 +156,11 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
s_e_r_type = s_e_r_Mid + naluType;
|
||||
}
|
||||
}
|
||||
memcpy(m_aucSectionBuf, &f_nri_type, 1);
|
||||
memcpy(m_aucSectionBuf + 1, &s_e_r_type, 1);
|
||||
memcpy(m_aucSectionBuf + 2, (unsigned char *) pcData + nOffset, iSize);
|
||||
memcpy(_aucSectionBuf, &f_nri_type, 1);
|
||||
memcpy(_aucSectionBuf + 1, &s_e_r_type, 1);
|
||||
memcpy(_aucSectionBuf + 2, (unsigned char *) pcData + nOffset, iSize);
|
||||
nOffset += iSize;
|
||||
makeH264Rtp(m_aucSectionBuf, iSize + 2, mark, uiStamp);
|
||||
makeH264Rtp(_aucSectionBuf, iSize + 2, mark, uiStamp);
|
||||
}
|
||||
} else {
|
||||
makeH264Rtp(pcData, iLen, true, uiStamp);
|
||||
@@ -169,19 +169,19 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
||||
|
||||
void H264RtpEncoder::makeH264Rtp(const void* data, unsigned int len, bool mark, uint32_t uiStamp) {
|
||||
uint16_t ui16RtpLen = len + 12;
|
||||
m_ui32TimeStamp = (m_ui32SampleRate / 1000) * uiStamp;
|
||||
uint32_t ts = htonl(m_ui32TimeStamp);
|
||||
uint16_t sq = htons(m_ui16Sequence);
|
||||
uint32_t sc = htonl(m_ui32Ssrc);
|
||||
_ui32TimeStamp = (_ui32SampleRate / 1000) * uiStamp;
|
||||
uint32_t ts = htonl(_ui32TimeStamp);
|
||||
uint16_t sq = htons(_ui16Sequence);
|
||||
uint32_t sc = htonl(_ui32Ssrc);
|
||||
|
||||
auto rtppkt = ResourcePoolHelper<RtpPacket>::obtainObj();
|
||||
unsigned char *pucRtp = rtppkt->payload;
|
||||
pucRtp[0] = '$';
|
||||
pucRtp[1] = m_ui8Interleaved;
|
||||
pucRtp[1] = _ui8Interleaved;
|
||||
pucRtp[2] = ui16RtpLen >> 8;
|
||||
pucRtp[3] = ui16RtpLen & 0x00FF;
|
||||
pucRtp[4] = 0x80;
|
||||
pucRtp[5] = (mark << 7) | m_ui8PlayloadType;
|
||||
pucRtp[5] = (mark << 7) | _ui8PlayloadType;
|
||||
memcpy(&pucRtp[6], &sq, 2);
|
||||
memcpy(&pucRtp[8], &ts, 4);
|
||||
//ssrc
|
||||
@@ -189,17 +189,17 @@ void H264RtpEncoder::makeH264Rtp(const void* data, unsigned int len, bool mark,
|
||||
//playload
|
||||
memcpy(&pucRtp[16], data, len);
|
||||
|
||||
rtppkt->PT = m_ui8PlayloadType;
|
||||
rtppkt->interleaved = m_ui8Interleaved;
|
||||
rtppkt->PT = _ui8PlayloadType;
|
||||
rtppkt->interleaved = _ui8Interleaved;
|
||||
rtppkt->mark = mark;
|
||||
rtppkt->length = len + 16;
|
||||
rtppkt->sequence = m_ui16Sequence;
|
||||
rtppkt->timeStamp = m_ui32TimeStamp;
|
||||
rtppkt->ssrc = m_ui32Ssrc;
|
||||
rtppkt->sequence = _ui16Sequence;
|
||||
rtppkt->timeStamp = _ui32TimeStamp;
|
||||
rtppkt->ssrc = _ui32Ssrc;
|
||||
rtppkt->type = TrackVideo;
|
||||
rtppkt->offset = 16;
|
||||
|
||||
uint8_t type = ((uint8_t *) (data))[0] & 0x1F;
|
||||
RtpCodec::inputRtp(rtppkt,type == 5);
|
||||
m_ui16Sequence++;
|
||||
_ui16Sequence++;
|
||||
}
|
||||
Reference in New Issue
Block a user