JT/T1078-RTP音视频封包
程序员文章站
2022-07-14 20:43:58
...
JT1078-RTP包结构
JT1078-RTP音视频包定义
#pragma pack(push)
#pragma pack (1)
typedef struct Jt1078AudioRtpPacket_T {
unsigned char head[4];
#if IS_JT1078RTP_BIGENDIAN // 大小端模式
unsigned char v : 2;
unsigned char p : 1;
unsigned char x : 1;
unsigned char cc : 4;
unsigned char m : 1;
unsigned char pt : 7;
#else
unsigned char cc : 4;
unsigned char x : 1;
unsigned char p : 1;
unsigned char v : 2;
unsigned char pt : 7;
unsigned char m : 1;
#endif
unsigned short seq;
unsigned char sim[6];
unsigned char ch;
#if IS_JT1078RTP_BIGENDIAN
unsigned char frame_type : 4;
unsigned char packet_type : 4;
#else
unsigned char packet_type : 4;
unsigned char frame_type : 4;
#endif
int64_t timestamp;
unsigned short payload_size;
}Jt1078AudioRtpPacket;
JT1078-RTP视频包定义
#pragma pack(push)
#pragma pack (1)
typedef struct Jt1078VideoRtpPacket_T {
unsigned char head[4];
#if IS_JT1078RTP_BIGENDIAN
unsigned char v : 2;
unsigned char p : 1;
unsigned char x : 1;
unsigned char cc : 4;
unsigned char m : 1;
unsigned char pt : 7;
#else
unsigned char cc : 4;
unsigned char x : 1;
unsigned char p : 1;
unsigned char v : 2;
unsigned char pt : 7;
unsigned char m : 1;
#endif
unsigned short seq;
unsigned char sim[6];
unsigned char ch;
#if IS_JT1078RTP_BIGENDIAN
unsigned char frame_type : 4;
unsigned char packet_type : 4;
#else
unsigned char packet_type : 4;
unsigned char frame_type : 4;
#endif
int64_t timestamp;
unsigned short i_frame_interval;
unsigned short frame_interval;
unsigned short payload_size;
}Jt1078VideoRtpPacket;
#pragma pack(pop)
JT1078-RTP音频包封装
填充结构体Jt1078AudioRtpPacket即可,需要注意的是sim是BCD码,大小端根据实际情况转换。payload_size,最大是950byte。音频帧无需分包,每包能发950就发950。
JT1078-RTP视频包封装
填充结构体Jt1078VideoRtpPacket即可,需要注意的是sim是BCD码,大小端根据实际情况转换。如果视频帧大于950byte,需要分包发送。比如某帧视频的大小是2000byte,则先发950且packet_type为第一包,再发950且packet_type为中间包,最后发100且packet_type为最后一个包,可以在一个循环内完成。***以RTP包递增,不管是音频还是视频,共用同一个seq。
上一篇: 腾讯云实时音视频三互动直播流程图
下一篇: 机器学习--k-近邻(kNN)算法
推荐阅读