forked from foxglove/mcap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcap.ksy
297 lines (272 loc) · 7.88 KB
/
mcap.ksy
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# This Kaitai Struct definition describes the MCAP binary file format. It can be used with tools
# like the web IDE (https://ide.kaitai.io/) or CLI visualizer
# (https://github.com/kaitai-io/kaitai_struct_visualizer) to parse and visualize MCAP files.
meta:
title: MCAP
id: mcap
file-extension: mcap
license: Apache-2.0
endian: le
doc: |
MCAP is a modular container format and logging library for pub/sub messages with
arbitrary message serialization. It is primarily intended for use in robotics
applications, and works well under various workloads, resource constraints, and
durability requirements.
doc-ref: https://github.com/foxglove/mcap
seq:
- id: header_magic
contents: [0x89, "MCAP0\r\n"]
- id: records
type: record
repeat: until
repeat-until: _.op == opcode::footer
- id: footer_magic
contents: [0x89, "MCAP0\r\n"]
instances:
footer:
pos: _io.size - 8 - 20 - 9
size-eos: true
type: record
enums:
opcode:
0x01: header
0x02: footer
0x03: schema
0x04: channel
0x05: message
0x06: chunk
0x07: message_index
0x08: chunk_index
0x09: attachment
0x0a: attachment_index
0x0b: statistics
0x0c: metadata
0x0d: metadata_index
0x0e: summary_offset
0x0f: data_end
types:
prefixed_str:
seq:
- { id: len, type: u4 }
- { id: str, type: str, size: len, encoding: UTF-8 }
tuple_str_str:
seq:
- { id: key, type: prefixed_str }
- { id: value, type: prefixed_str }
map_str_str:
types:
entries:
seq:
- { id: entry, type: tuple_str_str, repeat: eos }
seq:
- { id: len, type: u4 }
- { id: entry, size: len, type: entries }
records:
seq:
- id: records
type: record
repeat: until
repeat-until: "_io.pos + 8 >= _io.size"
record:
seq:
- { id: op, type: u1, enum: opcode }
- { id: len, type: u8 }
- id: body
size: len
type:
switch-on: op
cases:
opcode::header: header
opcode::footer: footer
opcode::schema: schema
opcode::channel: channel
opcode::message: message
opcode::chunk: chunk
opcode::message_index: message_index
opcode::chunk_index: chunk_index
opcode::attachment: attachment
opcode::attachment_index: attachment_index
opcode::statistics: statistics
opcode::metadata: metadata
opcode::metadata_index: metadata_index
opcode::summary_offset: summary_offset
opcode::data_end: data_end
header:
seq:
- { id: profile, type: prefixed_str }
- { id: library, type: prefixed_str }
footer:
seq:
- { id: summary_start, type: u8 }
- { id: summary_offset_start, type: u8 }
- { id: summary_crc, type: u4 }
instances:
summary_section:
io: _root._io
pos: summary_start
size: "(summary_offset_start != 0 ? summary_offset_start : _root._io.size - 8 - 20 - 9) - summary_start"
type: records
if: summary_start != 0
summary_offset_section:
io: _root._io
pos: summary_offset_start
size: "_root._io.size - 8 - 20 - 9 - summary_offset_start"
type: records
if: summary_offset_start != 0
schema:
seq:
- { id: id, type: u2 }
- { id: name, type: prefixed_str }
- { id: encoding, type: prefixed_str }
- { id: len_data, type: u4 }
- { id: data, size: len_data }
channel:
seq:
- { id: id, type: u2 }
- { id: schema_id, type: u2 }
- { id: topic, type: prefixed_str }
- { id: message_encoding, type: prefixed_str }
- { id: metadata, type: map_str_str }
message:
seq:
- { id: channel_id, type: u2 }
- { id: sequence, type: u4 }
- { id: log_time, type: u8 }
- { id: publish_time, type: u8 }
- { id: data, size-eos: true }
chunk:
types:
uncompressed_chunk:
seq:
- { id: records, type: record, repeat: eos }
seq:
- { id: message_start_time, type: u8 }
- { id: message_end_time, type: u8 }
- { id: uncompressed_size, type: u8 }
- { id: uncompressed_crc, type: u4 }
- { id: compression, type: prefixed_str }
- { id: len_records, type: u8 }
- id: records
size: len_records
type:
switch-on: compression.str
cases:
'""': uncompressed_chunk
message_index:
types:
message_index_entry:
seq:
- { id: log_time, type: u8 }
- { id: offset, type: u8 }
message_index_entries:
seq:
- { id: entries, type: message_index_entry, repeat: eos }
seq:
- { id: channel_id, type: u2 }
- { id: len_records, type: u4 }
- { id: records, size: len_records, type: message_index_entries }
chunk_index:
types:
message_index_offset:
seq:
- { id: channel_id, type: u2 }
- { id: offset, type: u8 }
message_index_offsets:
seq:
- { id: entry, type: message_index_offset, repeat: eos }
seq:
- { id: message_start_time, type: u8 }
- { id: message_end_time, type: u8 }
- { id: chunk_start_offset, type: u8 }
- { id: chunk_length, type: u8 }
- { id: len_message_index_offsets, type: u4 }
- id: message_index_offsets
size: len_message_index_offsets
type: message_index_offsets
- { id: message_index_length, type: u8 }
- { id: compression, type: prefixed_str }
- { id: compressed_size, type: u8 }
- { id: uncompressed_size, type: u8 }
instances:
chunk:
io: _root._io
pos: chunk_start_offset
size: chunk_length
type: record
attachment:
seq:
- { id: log_time, type: u8 }
- { id: create_time, type: u8 }
- { id: name, type: prefixed_str }
- { id: content_type, type: prefixed_str }
- { id: data_size, type: u8 }
- { id: data, size: data_size }
- { id: crc, type: u4 }
attachment_index:
seq:
- { id: offset, type: u8 }
- { id: length, type: u8 }
- { id: log_time, type: u8 }
- { id: create_time, type: u8 }
- { id: data_size, type: u8 }
- { id: name, type: prefixed_str }
- { id: content_type, type: prefixed_str }
instances:
attachment:
io: _root._io
pos: offset
size: length
type: record
statistics:
types:
channel_message_counts:
seq:
- id: entry
type: channel_message_count
repeat: eos
channel_message_count:
seq:
- { id: channel_id, type: u2 }
- { id: message_count, type: u8 }
seq:
- { id: message_count, type: u8 }
- { id: schema_count, type: u2 }
- { id: channel_count, type: u4 }
- { id: attachment_count, type: u4 }
- { id: metadata_count, type: u4 }
- { id: chunk_count, type: u4 }
- { id: message_start_time, type: u8 }
- { id: message_end_time, type: u8 }
- { id: channel_message_counts_size, type: u4 }
- id: channel_message_counts
size: channel_message_counts_size
type: channel_message_counts
metadata:
seq:
- { id: name, type: prefixed_str }
- { id: metadata, type: map_str_str }
metadata_index:
seq:
- { id: offset, type: u8 }
- { id: length, type: u8 }
- { id: name, type: prefixed_str }
instances:
metadata:
io: _root._io
pos: offset
size: length
type: record
summary_offset:
seq:
- { id: group_opcode, type: u1, enum: opcode }
- { id: group_start, type: u8 }
- { id: group_length, type: u8 }
instances:
group:
io: _root._io
pos: group_start
size: group_length
type: records
data_end:
seq:
- { id: data_section_crc, type: u4 }