From f5c77704c46ff135cc68913c4c167b4c82b57511 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Wed, 28 Aug 2024 17:23:00 +0800 Subject: [PATCH] feat add info log --- src/base/frame_manager.cpp | 1 + src/base/hk_sign.cpp | 1 + src/base/rtp_manager.cpp | 17 ++++++++++++----- src/base/rtp_manager.h | 3 +++ src/base/util.cpp | 14 +++++++++++--- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/base/frame_manager.cpp b/src/base/frame_manager.cpp index eeb68c1..32940b1 100644 --- a/src/base/frame_manager.cpp +++ b/src/base/frame_manager.cpp @@ -53,6 +53,7 @@ FrameManager::SetSecSetInfo(sec_set_info *info) void FrameManager::Init() { + _rtp_manager.SetHandler(this); OnFrameEnqueue.connect(&_rtp_manager, &RTPManager::OnFrameEnqueue); } diff --git a/src/base/hk_sign.cpp b/src/base/hk_sign.cpp index 8f8b88e..59a1f2b 100644 --- a/src/base/hk_sign.cpp +++ b/src/base/hk_sign.cpp @@ -18,6 +18,7 @@ int HK_udp_in(void *Handle, const char *buf, const uint32_t len, void *param) { sign::FrameManager *fm = (sign::FrameManager *) Handle; + INFOL(">>> New Frame <<< \n"); auto frame = sign::Frame::CreateUDPFrame(buf, len); if (!frame) { ERROL("Create frame failed\n"); diff --git a/src/base/rtp_manager.cpp b/src/base/rtp_manager.cpp index cb9c6f8..cff26d5 100644 --- a/src/base/rtp_manager.cpp +++ b/src/base/rtp_manager.cpp @@ -77,6 +77,9 @@ RTPManager::ProcessUDPFrame(Frame::Ptr frame) INFOL("Not a RTP packet. discard it.\n"); return; } + INFOL("RTP info version=%d, payload_type=%d, seq=%d, ssrc=%d\n", GetRTPVersion(frame->data()), + GetRTPPayloadType(frame->data()), GetRTPSequenceNumber(frame->data()), GetRTPSSRC(frame->data())); + auto packet = RTPPacket::CreateCompleteRTPPacket(this, frame); if (packet->payload_type() == 112) { INFOL("RTCP packet pt=112. discard it.\n"); @@ -99,15 +102,19 @@ RTPManager::ProcessPacket(RTPPacket::Ptr packet) MaybeSetSSRC(packet->ssrc()); if (packet->ssrc() != _cur_rtp_ssrc) { - WRNGL("RTP packet ssrc is mismatch. discard it. cur_ssrc=%ld, packet->ssrc=%d\n", _cur_rtp_ssrc, - packet->ssrc()); + WRNGL("RTP packet ssrc is mismatch. discard it. handler=%p, cur_ssrc=%ld, packet->ssrc=%d\n", _handler, + _cur_rtp_ssrc, packet->ssrc()); return; } MaybeSetSeq(packet->seq()); if (packet->seq() != _cur_rtp_seq) { - WRNGL("RTP packet seq is not continuous. cur_seq=%ld, packet->seq=%d\n", _cur_rtp_seq, packet->seq()); + WRNGL("RTP packet seq is not continuous. handler=%p, cur_seq=%ld, packet->seq=%d\n", _handler, _cur_rtp_seq, + packet->seq()); SetCurSeq(packet->seq()); + } else { + INFOL("RTP packet seq is continuous. handler=%p, cur_seq=%ld, packet->seq=%d\n", _handler, _cur_rtp_seq, + packet->seq()); } IncCurSeq(); @@ -195,8 +202,8 @@ RTPManager::OnRTPDecoded(RTPDecoder::DecodedPacket packet) } auto str = ss.str(); if (!str.empty()) str.pop_back(); - INFOL("RTP decoded. type=%s, size=%5u seq=[%s]\n", ToString((H264Nal::H264Nal_t) h264_type), packet.bytes, - str.c_str()); + INFOL("RTP decoded. handler=%p, type=%s, size=%5u seq=[%s]\n", _handler, ToString((H264Nal::H264Nal_t) h264_type), + packet.bytes, str.c_str()); if (h264_type == H264Nal::NAL_IDR) { // remove old sign ResetSignData(); diff --git a/src/base/rtp_manager.h b/src/base/rtp_manager.h index dca2770..2c8c77e 100644 --- a/src/base/rtp_manager.h +++ b/src/base/rtp_manager.h @@ -24,6 +24,8 @@ public: // HACK: void SetSecSetInfo(sec_set_info *info); + void SetHandler(void *handler) { _handler = handler; } + private: void InitSecSet(void *info); void InitVerifySet(void *info); @@ -64,6 +66,7 @@ private: * 2. Insert SEI **/ + void *_handler{nullptr}; std::mutex _signed_packet_lock; // std::vector _sign_data; Signer::SignedPacket::Ptr _signed_packet{nullptr}; diff --git a/src/base/util.cpp b/src/base/util.cpp index 7bf8f93..8249132 100644 --- a/src/base/util.cpp +++ b/src/base/util.cpp @@ -1,8 +1,8 @@ #include "util.h" extern "C" { #include "SVAC/src/sm2sm3/sm2.h" -#include "SVAC/src/sm2sm3/sm3.h" } +#include "HuaWei/HWcommon.h" namespace sign { uint8_t @@ -73,8 +73,16 @@ FindRTPOverTCPHeader(const uint8_t *data, size_t len, size_t *header_pos) bool IsRTPHeader(const uint8_t *data, size_t len) { - if (len < 12) { return false; } - if (GetRTPVersion(data) != 2) { return false; } + if (len < 12) { + WRNGL("RTP header length error len=%ld", len); + return false; + } + + if (GetRTPVersion(data) != 2) { + INFOL("RTP version error version=%d", GetRTPVersion(data)); + return false; + } + return true; }