当前位置:网站首页>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 .
边栏推荐
- P3500 [POI2010]TES-Intelligence Test(二分&离线)
- Use sentinel to interface locally
- P2102 floor tile laying (DFS & greed)
- One question per day (Mathematics)
- Is the mode of education together - on campus + off campus reliable
- Understanding of processes, threads, coroutines, synchronization, asynchrony, blocking, non blocking, concurrency, parallelism, and serialization
- Platformio create libopencm3 + FreeRTOS project
- ETCD数据库源码分析——etcdserver bootstrap初始化存储
- 2327. Number of people who know secrets (recursive)
- 2328. Number of incremental paths in the grid graph (memory search)
猜你喜欢

Solution of storage bar code management system in food industry

One question per day (Mathematics)

Lombok原理和同时使⽤@Data和@Builder 的坑

Sorting out the latest Android interview points in 2022 to help you easily win the offer - attached is the summary of Android intermediate and advanced interview questions in 2022

How to estimate the population with samples? (mean, variance, standard deviation)

Mysql database storage engine

Programmers' position in the Internet industry | daily anecdotes

Selection of slow motion function

二叉树基本知识和例题

程序员在互联网行业的地位 | 每日趣闻
随机推荐
Implementation of knowledge consolidation source code 2: TCP server receives and processes half packets and sticky packets
Solutions: word coverage restoration, longest serial number, Xiaoyu buys stationery, Xiaoyu's electricity bill
VNCTF2022 WriteUp
The most detailed and comprehensive update content and all functions of guitar pro 8.0
Can Flink SQL read multiple topics at the same time. How to write in with
11. Intranet penetration and automatic refresh
Meet diverse needs: jetmade creates three one-stop development packages to help efficient development
P2102 floor tile laying (DFS & greed)
Coreldraw2022 new version new function introduction cdr2022
P3500 [poi2010]tes intelligence test (two points & offline)
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
web工程导入了mysql驱动jar包却无法加载到驱动的问题
CADD course learning (7) -- Simulation of target and small molecule interaction (flexible docking autodock)
Recommendation system (IX) PNN model (product based neural networks)
SharedPreferences 源码分析
Ue5 small knowledge freezerendering view rendered objects in the cone
MIT CMS. 300 session 8 – immersion / immersion
Delete subsequence < daily question >
CADD课程学习(8)-- 化合物库虚拟筛选(Virtual Screening)
. Net interprocess communication