mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-10-31 00:37:39 +08:00
完善rtsp画面秒开机制
This commit is contained in:
parent
cc1a784384
commit
26dd99d159
@ -206,27 +206,25 @@ void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
|||||||
iSize = iLen - nOffset;
|
iSize = iLen - nOffset;
|
||||||
mark = true;
|
mark = true;
|
||||||
s_e_r_type = s_e_r_End + naluType;
|
s_e_r_type = s_e_r_End + naluType;
|
||||||
|
} else if (bFirst) {
|
||||||
|
s_e_r_type = s_e_r_Start + naluType;
|
||||||
} else {
|
} else {
|
||||||
if (bFirst == true) {
|
s_e_r_type = s_e_r_Mid + naluType;
|
||||||
s_e_r_type = s_e_r_Start + naluType;
|
|
||||||
bFirst = false;
|
|
||||||
} else {
|
|
||||||
s_e_r_type = s_e_r_Mid + naluType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
memcpy(_aucSectionBuf, &f_nri_type, 1);
|
memcpy(_aucSectionBuf, &f_nri_type, 1);
|
||||||
memcpy(_aucSectionBuf + 1, &s_e_r_type, 1);
|
memcpy(_aucSectionBuf + 1, &s_e_r_type, 1);
|
||||||
memcpy(_aucSectionBuf + 2, (unsigned char *) pcData + nOffset, iSize);
|
memcpy(_aucSectionBuf + 2, (unsigned char *) pcData + nOffset, iSize);
|
||||||
nOffset += iSize;
|
nOffset += iSize;
|
||||||
makeH264Rtp(naluType,_aucSectionBuf, iSize + 2, mark, uiStamp);
|
makeH264Rtp(naluType,_aucSectionBuf, iSize + 2, mark,bFirst, uiStamp);
|
||||||
|
bFirst = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
makeH264Rtp(naluType,pcData, iLen, true, uiStamp);
|
makeH264Rtp(naluType,pcData, iLen, true, true, uiStamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void H264RtpEncoder::makeH264Rtp(int nal_type,const void* data, unsigned int len, bool mark, uint32_t uiStamp) {
|
void H264RtpEncoder::makeH264Rtp(int nal_type,const void* data, unsigned int len, bool mark, bool first_packet, uint32_t uiStamp) {
|
||||||
RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),nal_type == H264Frame::NAL_SPS);
|
RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),first_packet && nal_type == H264Frame::NAL_IDR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
@ -93,7 +93,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void inputFrame(const Frame::Ptr &frame) override;
|
void inputFrame(const Frame::Ptr &frame) override;
|
||||||
private:
|
private:
|
||||||
void makeH264Rtp(int nal_type,const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp);
|
void makeH264Rtp(int nal_type,const void *pData, unsigned int uiLen, bool bMark, bool first_packet, uint32_t uiStamp);
|
||||||
private:
|
private:
|
||||||
unsigned char _aucSectionBuf[1600];
|
unsigned char _aucSectionBuf[1600];
|
||||||
};
|
};
|
||||||
|
@ -188,29 +188,28 @@ void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) {
|
|||||||
maxSize = iLen - nOffset;
|
maxSize = iLen - nOffset;
|
||||||
mark = true;
|
mark = true;
|
||||||
s_e_type = 1 << 6 | naluType;
|
s_e_type = 1 << 6 | naluType;
|
||||||
} else {
|
} else if (bFirst) {
|
||||||
if (bFirst == true) {
|
|
||||||
s_e_type = 1 << 7 | naluType;
|
s_e_type = 1 << 7 | naluType;
|
||||||
bFirst = false;
|
} else {
|
||||||
} else {
|
s_e_type = naluType;
|
||||||
s_e_type = naluType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//FU type
|
//FU type
|
||||||
_aucSectionBuf[0] = 49 << 1;
|
_aucSectionBuf[0] = 49 << 1;
|
||||||
_aucSectionBuf[1] = 1;
|
_aucSectionBuf[1] = 1;
|
||||||
_aucSectionBuf[2] = s_e_type;
|
_aucSectionBuf[2] = s_e_type;
|
||||||
memcpy(_aucSectionBuf + 3, pcData + nOffset, maxSize);
|
memcpy(_aucSectionBuf + 3, pcData + nOffset, maxSize);
|
||||||
nOffset += maxSize;
|
nOffset += maxSize;
|
||||||
makeH265Rtp(naluType,_aucSectionBuf, maxSize + 3, mark, uiStamp);
|
makeH265Rtp(naluType,_aucSectionBuf, maxSize + 3, mark,bFirst, uiStamp);
|
||||||
|
bFirst = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
makeH265Rtp(naluType,pcData, iLen, true, uiStamp);
|
makeH265Rtp(naluType,pcData, iLen, true, true, uiStamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void H265RtpEncoder::makeH265Rtp(int nal_type,const void* data, unsigned int len, bool mark, uint32_t uiStamp) {
|
void H265RtpEncoder::makeH265Rtp(int nal_type,const void* data, unsigned int len, bool mark, bool first_packet, uint32_t uiStamp) {
|
||||||
RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),nal_type == H265Frame::NAL_VPS);
|
RtpCodec::inputRtp(makeRtp(getTrackType(),data,len,mark,uiStamp),first_packet && H265Frame::isKeyFrame(nal_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
@ -94,7 +94,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void inputFrame(const Frame::Ptr &frame) override;
|
void inputFrame(const Frame::Ptr &frame) override;
|
||||||
private:
|
private:
|
||||||
void makeH265Rtp(int nal_type,const void *pData, unsigned int uiLen, bool bMark, uint32_t uiStamp);
|
void makeH265Rtp(int nal_type,const void *pData, unsigned int uiLen, bool bMark, bool first_packet,uint32_t uiStamp);
|
||||||
private:
|
private:
|
||||||
unsigned char _aucSectionBuf[1600];
|
unsigned char _aucSectionBuf[1600];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user