当前位置:网站首页>RTP gb28181 document testing tool
RTP gb28181 document testing tool
2022-07-06 04:39:00 【qianbo_ insist】
In the following cases GB28181 in udp Sending video streams , Some cameras udp Packet loss is serious , Some can , Focus on the analysis of problematic cameras
read ps
RTP The test tool is further upgraded
I wrote a program today , In order to solve the problem of flower screen , We need to know what the problem is , Saved hundreds ps file , Then read it out and save it as h264 file , Use vlc Tool reading , Simple frame skipping .
int main_ps()
{
int meetkeyframe = 0;
const char* buffer = "j:/ps/h264save%d.264";
char filename[128];
uint8_t* h264buffer = new uint8_t[1024 * 500];
int h264length = 0;
int skip = 0;
FILE* fpw = fopen("j:/out1.264", "wb");
for (int i = 0; i < 2855; i++)
{
sprintf(filename, buffer, i);
FILE* fp = fopen(filename, "rb");
if (fp != NULL)
{
fseek(fp, 0, SEEK_END);
long len = ftell(fp);
fseek(fp, 0, SEEK_SET);
//fread(pp, sizeof(char) * 4, 1, fp);
uint8_t* data = new uint8_t[len];
fread(data, len, 1, fp);
if (*data == 0x00 && *(data + 1) == 0x00 && *(data + 2) == 0x01 && *(data + 3) == 0xba)
{
GetH264FromPs((char*)data, len, (char*)h264buffer, &h264length);
if (h264length > 0)
{
if (meetkeyframe == 0)
{
uint8_t* pos = h264buffer + 4;
if ((*pos & 0x1f) == 0x07)
meetkeyframe = 1;
}
if (meetkeyframe == 1)
{
std::cout << "the length "<<len<< "--" << h264length << std::endl;
fwrite(h264buffer, h264length, 1, fpw);
}
else
{
std::cout << "skip num" << skip++ << std::endl;
}
}
}
std::cout << "the file of" << i << std::endl;
fclose(fp);
}
}
fclose(fpw);
return 0;
}
read rtp
To further identify the problem , Read 1 ten thousand 6000 individual RTP Packages are stored as files , Stored as h264 It depends on the situation
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include "../libRtpReceive/analysevideo.h"
#include "../libRtpReceive/c_rtp.h"
s_rtp_context g_ctx;
// Explain ps flow ,qianbo Please follow this path
int live_rtp_unpack_ps(s_rtp_context* ctx, uint8_t* payload, int payloadlen, uint32_t ssrc)
{
uint8_t* buffer = ctx->v_buffer;
int& buflen = ctx->v_len;
//analyse_struct &as = ctx->v_as;
#define D(x) *(payload+x)
if (D(0) == 0x00 && D(1) == 0x00 && D(2) == 0x01 && D(3) == 0xc0)
{
//( Audio packet )
//std::cout << "audio packet" << std::endl;
return 0;
}
if (D(0) == 0x00 && D(1) == 0x00 && D(2) == 0x01 && D(3) == 0xba)
{
if (buflen > 0)// The data has been gathered , Can send or display
{
#define B(x) *(buffer+x)
if (B(0) == 0x00 && B(1) == 0x00 && B(2) == 0x01 && B(3) == 0xba)
{
int h264length = 0;
uint8_t* h26xbuffer = new uint8_t[buflen];
GetH264FromPs((char*)buffer, buflen, (char*)h26xbuffer, &h264length);
if (h264length > 0)
{
if (g_ctx.v_meet_keyframe == 0)
{
uint8_t* pos = h26xbuffer + 4;
if ((*pos & 0x1f) == 0x07)
g_ctx.v_meet_keyframe = 1;
}
if (g_ctx.v_meet_keyframe == 1)
{
if (g_ctx.fwp == NULL)
g_ctx.fwp = fopen("j:/out2.264","wb");
//std::cout << "the length " << len << "--" << h264length << std::endl;
fwrite(h26xbuffer, h264length, 1, g_ctx.fwp);
}
else
{
//std::cout << "skip num" << skip++ << std::endl;
}
}
if (ctx->v_meet_keyframe == 0)
{
// write file
}
delete[]h26xbuffer;
}
buflen = 0;
}
}
// Frame combination
std::memcpy(buffer + buflen, payload, payloadlen);
buflen += payloadlen;
return 0;
}
int ReadRTPPacket(uint8_t* data, int dlen)
{
RTPFrame_ frame(data, (int)dlen);
uint8_t* payload = frame.GetPayloadPtr();
int payloadlen = frame.GetPayloadSize();
uint32_t timestamp = frame.GetTimestamp();
rtp_header* rtp = (rtp_header*)data;
//big(net) to little(home)
uint32_t ssrc = b2l(rtp->ssrc);
#define D(x) *(payload+x)
//if (ctx->v_is_ps == -1)// Not sure if ps flow
if (D(0) == 0x00 && D(1) == 0x00 && D(2) == 0x01 && D(3) == 0xba)
{
//std::cout << " the stream is " << stream << std::endl;
g_ctx.v_ssrc = ssrc;
g_ctx.v_is_ps = 1;
}
if (g_ctx.v_is_ps == 1)
{
uint16_t nowseq = frame.GetSequenceNumber();
std::cout << "seq:" << nowseq << " ";
if (nowseq - g_ctx.v_last_sequenceNum != 1)
{
std::cout << "not continue seq "<< nowseq - g_ctx.v_last_sequenceNum <<std::endl;
}
g_ctx.v_last_sequenceNum = frame.GetSequenceNumber();
g_ctx.v_payloadtype = frame.GetPayloadType();
live_rtp_unpack_ps(&g_ctx, payload, payloadlen, ssrc);
}
return 0;
}
int main()
{
const char* buffer = "j:/rtp/h264saveRTP%d.264";
char filename[128];
uint8_t* h264buffer = new uint8_t[1024 * 500];
int h264length = 0;
int skip = 0;
//FILE* fpw = fopen("j:/out2.264", "wb");
for (int i = 0; i < 16445; i++)
{
sprintf(filename, buffer, i);
FILE* fp = fopen(filename, "rb");
if (fp != NULL)
{
fseek(fp, 0, SEEK_END);
long len = ftell(fp);
fseek(fp, 0, SEEK_SET);
//fread(pp, sizeof(char) * 4, 1, fp);
uint8_t* data = new uint8_t[len];
fread(data, len, 1, fp);
ReadRTPPacket(data, len);
//std::cout <<i <<" ";
fclose(fp);
}
}
if(g_ctx.fwp!=NULL)
fclose(g_ctx.fwp);
}
By printing RTP Bag sequence number, Subtract and find , More packet losses , On average, it will be lost every certain time 3-4 individual RTP package , Sometimes dozens will be lost , Hundreds of bags , There are few cases of disorder , There is a , adopt seq number Subtract and you get a negative number .
RTP The tool will also add analysis RTP Visualization of protocols .
边栏推荐
- Certbot failed to update certificate solution
- P3500 [POI2010]TES-Intelligence Test(二分&离线)
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Coreldraw2022 new version new function introduction cdr2022
- During pycharm debugging, the view is read only and pause the process to use the command line appear on the console input
- A blog to achieve embedded entry
- [tomato assistant installation]
- Dynamic programming (tree DP)
- Microservice resource address
- P2022 有趣的数(二分&数位dp)
猜你喜欢
Use sentinel to interface locally
几种RS485隔离通讯的方案介绍
题解:《单词覆盖还原》、《最长连号》、《小玉买文具》、《小玉家的电费》
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
Easyrecovery reliable and toll free data recovery computer software
[network] channel attention network and spatial attention network
Recommendation system (IX) PNN model (product based neural networks)
How to estimate the population with samples? (mean, variance, standard deviation)
二叉树基本知识和例题
Mysql database storage engine
随机推荐
满足多元需求:捷码打造3大一站式开发套餐,助力高效开发
Implementation of knowledge consolidation source code 1: epoll implementation of TCP server
MIT CMS. 300 session 8 – immersion / immersion
优秀PM必须经历这3层蜕变!
[Chongqing Guangdong education] engineering fluid mechanics reference materials of southwestjiaotonguniversity
项目经理,你会画原型嘛?项目经理需要做产品设计了?
Lombok原理和同时使⽤@Data和@Builder 的坑
How does vs change the project type?
团队协作出了问题,项目经理怎么办?
Selection sort
[05-1, 05-02, 05-03] network protocol
I'd like to ask about the current MySQL CDC design. In the full volume phase, if a chunk's binlog backfill phase,
解决“C2001:常量中有换行符“编译问题
拉格朗日插值法
npm命令--安装依赖包--用法/详解
Coreldraw2022 new version new function introduction cdr2022
Can Flink SQL read multiple topics at the same time. How to write in with
Ue5 small knowledge freezerendering view rendered objects in the cone
[face recognition series] | realize automatic makeup
[HBZ share] reasons for slow addition and deletion of ArrayList and fast query