liusuyi
6 天以前 307977cfb9fb88f845e36e4041c082ffdd691da5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package cn.org.hentai.jtt1078.entity;
 
import cn.org.hentai.jtt1078.util.TimeUtils;
import lombok.*;
 
/**
 * Description: JTT1078协议消息实体类
 * Author: lsy
 * Date: 2025年07月30日16:26
 **/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class Jt1078Message {
    // 包头标志 (0x30316364)
    private int header;
    // 版本/填充/扩展/CSRC计数 (V/P/X/CC)
    private byte vpxcc;
    // 标记位和负载类型 (M/PT)
    private byte mpt;
    // 包序号
    private short sequence;
    // SIM卡号 (BCD编码)
    private String sim;
    // 逻辑通道号
    private byte channel;
    // 数据类型 (4bit) + 分包处理标记 (4bit)
    private byte dataTypeAndSpm;
    // 时间戳 (8字节)
    private byte[] timestamp;
    // 与上一关键帧的相对时间
    private short lastIframeInterval;
    // 与上一帧的相对时间
    private short lastFrameInterval;
    // 数据体长度
    private short length;
    // 音视频数据
    private byte[] data;
 
    // 解析后的字段(方便使用)
    private int dataType;      // 数据类型
    private int spm;           // 分包处理标记
    private String timestampStr; // 格式化时间字符串
    private long timestampLong;     // 数值类型时间戳
    private int pt;  // 负载类型(M/PT字段的低7位)
    public void parseExtendedFields() {
        // 解析M/PT字段
        int m = (this.mpt >> 7) & 0x01;
        int pt = this.mpt & 0x7F;
 
        // 解析数据类型和分包标记
        this.dataType = (this.dataTypeAndSpm >> 4) & 0x0F;
        this.spm = this.dataTypeAndSpm & 0x0F;
 
        // 解析时间戳
        if (this.timestamp != null && this.timestamp.length == 8) {
            this.timestampStr = TimeUtils.bytes8ToTimeString(this.timestamp);
            this.timestampLong = TimeUtils.bytes8ToLong(this.timestamp);
        }
    }
 
}