update
This commit is contained in:
parent
471a3cabea
commit
e59d1b24d3
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
@ -35,8 +35,10 @@
|
|||||||
// "127.0.0.1","40001","udp src port 20002"],
|
// "127.0.0.1","40001","udp src port 20002"],
|
||||||
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapSender/signhw28181.pcap",
|
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapSender/signhw28181.pcap",
|
||||||
// "127.0.0.1","30001","udp src port 55763"],
|
// "127.0.0.1","30001","udp src port 55763"],
|
||||||
"args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/h265-hikvision-10min.pcap",
|
// "args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapRawSender/h265-hikvision-10min.pcap",
|
||||||
"127.0.0.1","40001","udp src port 15060"], //h265
|
// "127.0.0.1","40001","udp src port 15060"], //h265
|
||||||
|
"args": ["/media/alan/Data/Alan/Documents/WorkSpace/SecMedia/PcapSender/hkh264.pcap",
|
||||||
|
"127.0.0.1","60006","udp src port 15060"],
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"environment": [],
|
"environment": [],
|
||||||
|
@ -73,6 +73,7 @@ timespec TimeDiff(T && minu,U && sub){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ReadPcapAndSend(int socket,sockaddr_in & addr,const string & filename,const string & filter,void * sign_handle){
|
int ReadPcapAndSend(int socket,sockaddr_in & addr,const string & filename,const string & filter,void * sign_handle){
|
||||||
|
// auto sign_h2=EncrypInit();
|
||||||
auto reader=pcpp::IFileReaderDevice::getReader(filename);
|
auto reader=pcpp::IFileReaderDevice::getReader(filename);
|
||||||
// verify that a reader interface was indeed created
|
// verify that a reader interface was indeed created
|
||||||
if (reader == NULL)
|
if (reader == NULL)
|
||||||
@ -141,6 +142,8 @@ int ReadPcapAndSend(int socket,sockaddr_in & addr,const string & filename,const
|
|||||||
sendto(socket,sign_out_buf,offset_len,0,(const sockaddr*)&addr,sizeof(addr));
|
sendto(socket,sign_out_buf,offset_len,0,(const sockaddr*)&addr,sizeof(addr));
|
||||||
sendto(socket,sign_out_buf+offset_len,sign_out_len-offset_len,0,(const sockaddr*)&addr,sizeof(addr));
|
sendto(socket,sign_out_buf+offset_len,sign_out_len-offset_len,0,(const sockaddr*)&addr,sizeof(addr));
|
||||||
}
|
}
|
||||||
|
// GB28181_stream_in(sign_h2,(char*)payload,payload_len,nullptr);
|
||||||
|
// GB28181_stream_out(sign_h2,sign_out_buf,&sign_out_len,&offset_len,&append_len, ¶m);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -219,6 +222,7 @@ int main(int argc, char *argv[]){
|
|||||||
// {
|
// {
|
||||||
cout.flush();
|
cout.flush();
|
||||||
auto sign_h=EncrypInit();
|
auto sign_h=EncrypInit();
|
||||||
|
|
||||||
ReadPcapAndSend(sockfd,addr,filename,filter,sign_h);
|
ReadPcapAndSend(sockfd,addr,filename,filter,sign_h);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
@ -175,10 +175,9 @@ void L2SecurityStream::ThreadSign(){
|
|||||||
int L2UdpStream::RtpInput(const uint8_t* data,uint16_t len, void *param){
|
int L2UdpStream::RtpInput(const uint8_t* data,uint16_t len, void *param){
|
||||||
|
|
||||||
RTPpackage::rtp_cb_f rtp_cell_cb=[&](const RTPcell::Ptr &rtp_cell){
|
RTPpackage::rtp_cb_f rtp_cell_cb=[&](const RTPcell::Ptr &rtp_cell){
|
||||||
static uint16_t prv_seq=0;
|
|
||||||
rtp_cell->precessRTP();
|
rtp_cell->precessRTP();
|
||||||
|
|
||||||
if( (uint32_t)(prv_seq+1)%(uint32_t)(UINT16_MAX+1) == rtp_cell->seq || prv_seq==0){
|
if( (uint32_t)(_prv_seq+1)%(uint32_t)(UINT16_MAX+1) == rtp_cell->seq || _prv_seq==0){
|
||||||
// INFOL("PT: %u Seq: %u PT_len: %u mark: %u\n",rtp_cell->PT,rtp_cell->seq,rtp_cell->_PT_len,(uint8_t)rtp_cell->mark);
|
// INFOL("PT: %u Seq: %u PT_len: %u mark: %u\n",rtp_cell->PT,rtp_cell->seq,rtp_cell->_PT_len,(uint8_t)rtp_cell->mark);
|
||||||
_rtp_decoder.decodeRtp(rtp_cell->_buffer,rtp_cell->_RTP_len);
|
_rtp_decoder.decodeRtp(rtp_cell->_buffer,rtp_cell->_RTP_len);
|
||||||
// on_rtp_out(rtp_cell->_PT_data,rtp_cell->_PT_len,rtp_cell->timestamp,(int)rtp_cell->mark);
|
// on_rtp_out(rtp_cell->_PT_data,rtp_cell->_PT_len,rtp_cell->timestamp,(int)rtp_cell->mark);
|
||||||
@ -187,9 +186,9 @@ void L2SecurityStream::ThreadSign(){
|
|||||||
rtp_post_process(rtp_cell);
|
rtp_post_process(rtp_cell);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
WRNGL("Disorder rtp Seq: %u+1 != %u \n",prv_seq,rtp_cell->seq);
|
WRNGL("Disorder rtp Seq: %u+1 != %u \n",_prv_seq,rtp_cell->seq);
|
||||||
}
|
}
|
||||||
prv_seq=rtp_cell->seq;
|
_prv_seq=rtp_cell->seq;
|
||||||
|
|
||||||
};
|
};
|
||||||
RTPpackage::Ptr RTPpkg=make_shared<RTPpackage>(rtp_cell_cb,true);
|
RTPpackage::Ptr RTPpkg=make_shared<RTPpackage>(rtp_cell_cb,true);
|
||||||
|
@ -87,6 +87,8 @@ class L2UdpStream: public L2SecurityStream
|
|||||||
protected:
|
protected:
|
||||||
uint16_t _seq_increment=0;
|
uint16_t _seq_increment=0;
|
||||||
RtpDecoder _rtp_decoder;
|
RtpDecoder _rtp_decoder;
|
||||||
|
private:
|
||||||
|
uint16_t _prv_seq=0;
|
||||||
public:
|
public:
|
||||||
L2UdpStream(sec_set_info* set_info):L2SecurityStream(set_info){
|
L2UdpStream(sec_set_info* set_info):L2SecurityStream(set_info){
|
||||||
_rtp_decoder.setOnDecode([&](const uint8_t *packet, int bytes, uint32_t timestamp, int flags){
|
_rtp_decoder.setOnDecode([&](const uint8_t *packet, int bytes, uint32_t timestamp, int flags){
|
||||||
@ -105,20 +107,37 @@ protected:
|
|||||||
_seq_increment%=UINT16_MAX;
|
_seq_increment%=UINT16_MAX;
|
||||||
_seq_increment++;
|
_seq_increment++;
|
||||||
uint16_t seq=((uint32_t)_seq_increment+rtp_cell->seq)%((uint32_t)UINT16_MAX+1);
|
uint16_t seq=((uint32_t)_seq_increment+rtp_cell->seq)%((uint32_t)UINT16_MAX+1);
|
||||||
|
|
||||||
|
// if( (uint32_t)(_prv_seq+1)%(uint32_t)(UINT16_MAX+1) == seq || _prv_seq==0){
|
||||||
|
// _prv_seq=seq;
|
||||||
|
// }else{
|
||||||
|
// _prv_seq=seq;
|
||||||
|
// ERROL("OUTPUT Disorder rtp Seq: %u+1 != %u \n",_prv_seq,seq);
|
||||||
|
// }
|
||||||
|
|
||||||
if(seq<rtp_cell->seq){
|
if(seq<rtp_cell->seq){
|
||||||
_seq_increment=0;
|
_seq_increment=0;
|
||||||
}
|
}
|
||||||
|
// DEBUGL("increase seq:%u inc:%u\n",seq,_seq_increment);
|
||||||
seq=htons(seq);
|
seq=htons(seq);
|
||||||
memcpy(buf_ptr+rtp_cell->_tcp_prefix+2,(uint8_t*)&seq,2); // change sequence
|
memcpy(buf_ptr+rtp_cell->_tcp_prefix+2,(uint8_t*)&seq,2); // change sequence
|
||||||
return buf_ptr+rtp_cell->_prefix;
|
return buf_ptr+rtp_cell->_prefix;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void incrementRTPseq(const RTPcell::Ptr &rtp_cell) const {
|
void incrementRTPseq(const RTPcell::Ptr &rtp_cell) {
|
||||||
uint16_t seq=((uint32_t)_seq_increment+(uint32_t)rtp_cell->seq)%((uint32_t)UINT16_MAX+1);
|
uint16_t seq=((uint32_t)_seq_increment+(uint32_t)rtp_cell->seq)%((uint32_t)UINT16_MAX+1);
|
||||||
|
// DEBUGL("modify seq:%u old:%u inc:%u\n",seq,rtp_cell->seq,_seq_increment);
|
||||||
|
// if( (uint32_t)(_prv_seq+1)%(uint32_t)(UINT16_MAX+1) == seq || _prv_seq==0){
|
||||||
|
// _prv_seq=seq;
|
||||||
|
// }else{
|
||||||
|
// _prv_seq=seq;
|
||||||
|
// ERROL("OUTPUT Disorder rtp Seq: %u+1 != %u \n",_prv_seq,seq);
|
||||||
|
// }
|
||||||
if(rtp_cell->_RTPpkg_ptr){
|
if(rtp_cell->_RTPpkg_ptr){
|
||||||
seq=htons(seq);
|
seq=htons(seq);
|
||||||
rtp_cell->_RTPpkg_ptr->modifyData(rtp_cell->_RTPpkg_head_pos+rtp_cell->_tcp_prefix+2,(uint8_t*)&seq,2);
|
rtp_cell->_RTPpkg_ptr->modifyData(rtp_cell->_RTPpkg_head_pos+rtp_cell->_tcp_prefix+2,(uint8_t*)&seq,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user