@@ -34,82 +34,104 @@ typedef struct {
3434} DTXPrimitiveArrayHeader;
3535
3636
37- LittleEndian();
38- local uint64 remain;
39-
40- while (!FEof()) {
41- remain = FileSize() - FTell();
42- if (remain < 0x20) {
43- break;
37+ void EatAll() {
38+ FSeek(FileSize);
4439}
4540
46- struct {
41+ int ParseDTXMessage() {
42+ struct DTXMessage {
43+ local uint64 msg_start = FTell();
44+ DTXMessageHeader header;
45+ if (header.magic != 0x1F3D5B79 || header.message_header_size != 0x20) {
46+ Printf("bad DTXMessage magic=%d, pos=0x%X\n", header.magic, msg_start);
47+ EatAll();
48+ return -1;
49+ }
50+
51+ remain = FileSize() - FTell();
52+ if (remain < header.length) {
53+ EatAll();
54+ return -1;
55+ }
4756
48- DTXMessageHeader header;
49- if (header.magic != 0x1F3D5B79 || header.message_header_size != 0x20) {
50- Printf("bad DTXMessage magic=%d\n", header.magic);
51- break;
52- }
53- remain = FileSize() - FTell();
54- if (remain < header.length) {
55- break;
57+ if (header.fragment_count == 1) {
58+ DTXMessagePayloadHeader payloadHeader;
59+ local int64 payload_length = payloadHeader.total_length - payloadHeader.auxiliary_length;
60+ if (payloadHeader.auxiliary_length > 0) {
61+ DTXPrimitiveArrayHeader primitiveArrayHeader;
62+ local int64 auxiliary_end = FTell() + primitiveArrayHeader.size;
63+ while(FTell() < auxiliary_end) {
64+ struct {
65+ uint32 type;
66+ Printf("type=%d\n", type);
67+ switch (type) {
68+ case 1:
69+ case 2:
70+ struct {
71+ uint32 len;
72+ byte bytes[len];
73+ } value;
74+ break;
75+ case 3:
76+ struct {
77+ int32 val;
78+ } value;
79+ break;
80+ case 4:
81+ case 9:
82+ struct {
83+ int64 val;
84+ } value;
85+ break;
86+ case 5:
87+ struct {
88+ float val;
89+ } value;
90+ break;
91+ case 6:
92+ struct {
93+ double val;
94+ } value;
95+ break;
96+ case 10:
97+ default:
98+ break;
99+ }
100+ } auxiliary;
101+ } // end while
102+ } // end if
103+ if (payload_length > 0) {
104+ byte payload[payload_length];
105+ }
106+
107+ } else {
108+ Printf("header.fragment_index=%d, fragment_count=%d\n", header.fragment_index, header.fragment_count);
109+ if (header.fragment_index == 0) {
110+ // the first fragment only contains the DTXMessageHeader
111+ } else {
112+ Printf("FTell: %d\n", FTell());
113+ byte payload[header.length];
114+ }
115+ // TODO
116+ }
117+
118+ } msg;
119+ return 0;
56120}
57121
58- if (header.fragment_count == 1) {
59- DTXMessagePayloadHeader payloadHeader;
60- local int64 payload_length = payloadHeader.total_length - payloadHeader.auxiliary_length;
61- if (payloadHeader.auxiliary_length > 0) {
62- DTXPrimitiveArrayHeader primitiveArrayHeader;
63- local int64 auxiliary_end = FTell() + primitiveArrayHeader.size;
64- while(FTell() < auxiliary_end) {
65- struct {
66- uint32 type;
67- Printf("type=%d\n", type);
68- switch (type) {
69- case 1:
70- case 2:
71- struct {
72- uint32 len;
73- byte bytes[len];
74- } value;
75- break;
76- case 3:
77- struct {
78- int32 val;
79- } value;
80- break;
81- case 4:
82- case 9:
83- struct {
84- int64 val;
85- } value;
86- break;
87- case 5:
88- struct {
89- float val;
90- } value;
91- break;
92- case 6:
93- struct {
94- double val;
95- } value;
96- break;
97- case 10:
98- default:
99- break;
100- }
101- } auxiliary;
102- }
103- }
104- if (payload_length > 0) {
105- byte payload[payload_length];
106- }
107-
108122
109- } else {
110- Printf("header.fragment_count=%d\n", header.fragment_count);
111- // TODO
112- }
123+ LittleEndian();
124+ local uint64 remain;
125+ local int ret;
113126
114- } DTXMessage;
127+ while (!FEof()) {
128+ remain = FileSize() - FTell();
129+ if (remain < 0x20) {
130+ break;
131+ }
132+
133+ ret = ParseDTXMessage();
134+ if (ret != 0) {
135+ break;
136+ }
115137} // end of while EOF
0 commit comments