feat/hk #1
@ -53,6 +53,7 @@ FrameManager::SetSecSetInfo(sec_set_info *info)
|
|||||||
void
|
void
|
||||||
FrameManager::Init()
|
FrameManager::Init()
|
||||||
{
|
{
|
||||||
|
_rtp_manager.SetHandler(this);
|
||||||
OnFrameEnqueue.connect(&_rtp_manager, &RTPManager::OnFrameEnqueue);
|
OnFrameEnqueue.connect(&_rtp_manager, &RTPManager::OnFrameEnqueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ int
|
|||||||
HK_udp_in(void *Handle, const char *buf, const uint32_t len, void *param)
|
HK_udp_in(void *Handle, const char *buf, const uint32_t len, void *param)
|
||||||
{
|
{
|
||||||
sign::FrameManager *fm = (sign::FrameManager *) Handle;
|
sign::FrameManager *fm = (sign::FrameManager *) Handle;
|
||||||
|
INFOL(">>> New Frame <<< \n");
|
||||||
auto frame = sign::Frame::CreateUDPFrame(buf, len);
|
auto frame = sign::Frame::CreateUDPFrame(buf, len);
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
ERROL("Create frame failed\n");
|
ERROL("Create frame failed\n");
|
||||||
|
@ -77,6 +77,9 @@ RTPManager::ProcessUDPFrame(Frame::Ptr frame)
|
|||||||
INFOL("Not a RTP packet. discard it.\n");
|
INFOL("Not a RTP packet. discard it.\n");
|
||||||
return;
|
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);
|
auto packet = RTPPacket::CreateCompleteRTPPacket(this, frame);
|
||||||
if (packet->payload_type() == 112) {
|
if (packet->payload_type() == 112) {
|
||||||
INFOL("RTCP packet pt=112. discard it.\n");
|
INFOL("RTCP packet pt=112. discard it.\n");
|
||||||
@ -99,15 +102,19 @@ RTPManager::ProcessPacket(RTPPacket::Ptr packet)
|
|||||||
|
|
||||||
MaybeSetSSRC(packet->ssrc());
|
MaybeSetSSRC(packet->ssrc());
|
||||||
if (packet->ssrc() != _cur_rtp_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,
|
WRNGL("RTP packet ssrc is mismatch. discard it. handler=%p, cur_ssrc=%ld, packet->ssrc=%d\n", _handler,
|
||||||
packet->ssrc());
|
_cur_rtp_ssrc, packet->ssrc());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeSetSeq(packet->seq());
|
MaybeSetSeq(packet->seq());
|
||||||
if (packet->seq() != _cur_rtp_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());
|
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();
|
IncCurSeq();
|
||||||
|
|
||||||
@ -195,8 +202,8 @@ RTPManager::OnRTPDecoded(RTPDecoder::DecodedPacket packet)
|
|||||||
}
|
}
|
||||||
auto str = ss.str();
|
auto str = ss.str();
|
||||||
if (!str.empty()) str.pop_back();
|
if (!str.empty()) str.pop_back();
|
||||||
INFOL("RTP decoded. type=%s, size=%5u seq=[%s]\n", ToString((H264Nal::H264Nal_t) h264_type), packet.bytes,
|
INFOL("RTP decoded. handler=%p, type=%s, size=%5u seq=[%s]\n", _handler, ToString((H264Nal::H264Nal_t) h264_type),
|
||||||
str.c_str());
|
packet.bytes, str.c_str());
|
||||||
if (h264_type == H264Nal::NAL_IDR) {
|
if (h264_type == H264Nal::NAL_IDR) {
|
||||||
// remove old sign
|
// remove old sign
|
||||||
ResetSignData();
|
ResetSignData();
|
||||||
|
@ -24,6 +24,8 @@ public:
|
|||||||
// HACK:
|
// HACK:
|
||||||
void SetSecSetInfo(sec_set_info *info);
|
void SetSecSetInfo(sec_set_info *info);
|
||||||
|
|
||||||
|
void SetHandler(void *handler) { _handler = handler; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitSecSet(void *info);
|
void InitSecSet(void *info);
|
||||||
void InitVerifySet(void *info);
|
void InitVerifySet(void *info);
|
||||||
@ -64,6 +66,7 @@ private:
|
|||||||
* 2. Insert SEI
|
* 2. Insert SEI
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
void *_handler{nullptr};
|
||||||
std::mutex _signed_packet_lock;
|
std::mutex _signed_packet_lock;
|
||||||
// std::vector<uint8_t> _sign_data;
|
// std::vector<uint8_t> _sign_data;
|
||||||
Signer::SignedPacket::Ptr _signed_packet{nullptr};
|
Signer::SignedPacket::Ptr _signed_packet{nullptr};
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "SVAC/src/sm2sm3/sm2.h"
|
#include "SVAC/src/sm2sm3/sm2.h"
|
||||||
#include "SVAC/src/sm2sm3/sm3.h"
|
|
||||||
}
|
}
|
||||||
|
#include "HuaWei/HWcommon.h"
|
||||||
|
|
||||||
namespace sign {
|
namespace sign {
|
||||||
uint8_t
|
uint8_t
|
||||||
@ -73,8 +73,16 @@ FindRTPOverTCPHeader(const uint8_t *data, size_t len, size_t *header_pos)
|
|||||||
bool
|
bool
|
||||||
IsRTPHeader(const uint8_t *data, size_t len)
|
IsRTPHeader(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
if (len < 12) { return false; }
|
if (len < 12) {
|
||||||
if (GetRTPVersion(data) != 2) { return false; }
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user