18045010223
2025-07-07 0d3a683a0c97154b1f2e6657398664537e4e3e82
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
package org.yzh.protocol.commons.transform.parameter;
 
import io.github.yezhihao.protostar.Schema;
import io.github.yezhihao.protostar.annotation.Field;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
 
import java.util.Map;
import java.util.TreeMap;
 
/**
 * 单独视频通道参数设置
 * @author yezhihao
 * https://gitee.com/yezhihao/jt808-server
 */
@ToString
@Data
@Accessors(chain = true)
public class ParamVideoSingle {
 
    public static final Integer key = 0x0077;
 
    public static final Schema<ParamVideoSingle> SCHEMA = new ParamVideoSingleSchema();
 
    @Field(desc = "单独通道视频参数设置列表")
    private Map<Integer, ParamVideo> paramVideos = new TreeMap<>();
 
    private static class ParamVideoSingleSchema implements Schema<ParamVideoSingle> {
 
        private ParamVideoSingleSchema() {
        }
 
        @Override
        public ParamVideoSingle readFrom(ByteBuf input) {
            byte total = input.readByte();
            Map<Integer, ParamVideo> paramVideos = new TreeMap<>();
            for (int i = 0; i < total; i++) {
                byte channelNo = input.readByte();
                ParamVideo paramVideo = ParamVideo.SCHEMA_2.readFrom(input);
                paramVideos.put((int) channelNo, paramVideo);
            }
            return new ParamVideoSingle().setParamVideos(paramVideos);
        }
 
        @Override
        public void writeTo(ByteBuf output, ParamVideoSingle message) {
            Map<Integer, ParamVideo> paramVideos = message.paramVideos;
            output.writeByte(message.paramVideos.size());
            for (Map.Entry<Integer, ParamVideo> videoEntry : paramVideos.entrySet()) {
                output.writeByte(videoEntry.getKey());
                ParamVideo.SCHEMA_2.writeTo(output, videoEntry.getValue());
            }
        }
    }
}