From 274dab6e1dd20ea3f94eb902cf36bb6d7ec3e38c Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 29 Oct 2018 12:27:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E8=AE=A1=E7=AE=97264?= =?UTF-8?q?=E5=89=8D=E7=BC=80=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Common/Device.cpp | 13 ++++++++++++- src/Common/Device.h | 3 +-- 2 files changed, 13 insertions(+), 3 deletions(-) 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帧