欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JT/T1078-RTP音视频封包

程序员文章站 2022-07-14 20:43:58
...

音视频应用开发系列文章目录

JT1078-RTP包结构

JT/T1078-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。