diff --git a/src/Common/Device.cpp b/src/Common/Device.cpp index 6dabebef..67ab696e 100644 --- a/src/Common/Device.cpp +++ b/src/Common/Device.cpp @@ -84,10 +84,21 @@ void DevChannel::inputPCM(char* pcData, int iDataLen, uint32_t uiStamp) { } #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){ 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((char *)pcData,iDataLen,uiStamp,prefixeSize)); } diff --git a/src/Common/Device.h b/src/Common/Device.h index 081d98d7..73832294 100644 --- a/src/Common/Device.h +++ b/src/Common/Device.h @@ -99,9 +99,8 @@ public: * @param pcData 264单帧数据指针 * @param iDataLen 数据指针长度 * @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帧