自动计算264前缀大小

This commit is contained in:
xiongziliang 2018-10-29 12:27:13 +08:00
parent 08c3c8e5b5
commit 274dab6e1d
2 changed files with 13 additions and 3 deletions

View File

@ -84,10 +84,21 @@ void DevChannel::inputPCM(char* pcData, int iDataLen, uint32_t uiStamp) {
} }
#endif //ENABLE_FAAC #endif //ENABLE_FAAC
void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t uiStamp , int prefixeSize) { void DevChannel::inputH264(const char* pcData, int iDataLen, uint32_t uiStamp) {
if(uiStamp == 0){ if(uiStamp == 0){
uiStamp = (uint32_t)_aTicker[0].elapsedTime(); uiStamp = (uint32_t)_aTicker[0].elapsedTime();
} }
int prefixeSize;
if (memcmp("\x00\x00\x00\x01", pcData, 4) == 0) {
prefixeSize = 4;
} else if (memcmp("\x00\x00\x01", pcData, 3) == 0) {
prefixeSize = 3;
} else {
prefixeSize = 0;
}
inputFrame(std::make_shared<H264FrameNoCopyAble>((char *)pcData,iDataLen,uiStamp,prefixeSize)); inputFrame(std::make_shared<H264FrameNoCopyAble>((char *)pcData,iDataLen,uiStamp,prefixeSize));
} }

View File

@ -99,9 +99,8 @@ public:
* @param pcData 264 * @param pcData 264
* @param iDataLen * @param iDataLen
* @param uiStamp 0 * @param uiStamp 0
* @param prefixSize 264 0x00 00 00 01 0x 00 00 01
*/ */
void inputH264(const char *pcData, int iDataLen, uint32_t uiStamp,int prefixSize = 4); void inputH264(const char *pcData, int iDataLen, uint32_t uiStamp);
/** /**
* adts头的aac帧 * adts头的aac帧