diff --git a/src/Device/Device.cpp b/src/Device/Device.cpp index f68683be..1308551d 100644 --- a/src/Device/Device.cpp +++ b/src/Device/Device.cpp @@ -117,6 +117,9 @@ void DevChannel::inputH264(char* pcData, int iDataLen, uint32_t uiStamp) { if (memcmp("\x00\x00\x01", pcData, 3) == 0) { iOffset = 3; } + if(uiStamp == 0){ + uiStamp = (uint32_t)m_aTicker[0].elapsedTime(); + } m_pRtpMaker_h264->makeRtp(pcData + iOffset, iDataLen - iOffset, uiStamp); } @@ -136,6 +139,9 @@ void DevChannel::inputAAC(char *pcDataWithoutAdts,int iDataLen, uint32_t uiStamp if (!m_bSdp_gotAAC && m_audio && pcAdtsHeader) { makeSDP_AAC((unsigned char*) pcAdtsHeader); } + if(uiStamp == 0){ + uiStamp = (uint32_t)m_aTicker[1].elapsedTime(); + } if(pcDataWithoutAdts && iDataLen){ m_pRtpMaker_aac->makeRtp(pcDataWithoutAdts, iDataLen, uiStamp); } diff --git a/src/Device/Device.h b/src/Device/Device.h index 18fe68ec..a164e99c 100644 --- a/src/Device/Device.h +++ b/src/Device/Device.h @@ -34,6 +34,7 @@ #include "RTP/RtpMakerAAC.h" #include "RTP/RtpMakerH264.h" #include "Rtsp/RtspToRtmpMediaSource.h" +#include "Util/TimeTicker.h" using namespace std; using namespace ZL::Rtsp; @@ -115,6 +116,7 @@ private: unsigned int m_uiPPSLen = 0; std::shared_ptr m_video; std::shared_ptr m_audio; + SmoothTicker m_aTicker[2]; };