feat add info log

This commit is contained in:
tqcq 2024-08-28 17:23:00 +08:00
parent fe7da4f638
commit f5c77704c4
5 changed files with 28 additions and 8 deletions

View File

@ -53,6 +53,7 @@ FrameManager::SetSecSetInfo(sec_set_info *info)
void
FrameManager::Init()
{
_rtp_manager.SetHandler(this);
OnFrameEnqueue.connect(&_rtp_manager, &RTPManager::OnFrameEnqueue);
}

View File

@ -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");

View File

@ -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();

View File

@ -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<uint8_t> _sign_data;
Signer::SignedPacket::Ptr _signed_packet{nullptr};

View File

@ -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;
}