1 /* packet-vp8.c
2 * Routines for VP8 dissection
3 * Copyright 2014, Owen Williams williams.owen@gmail.com
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12 /*
13 * RFC 6386 - VP8 Data Format and Decoding Guide
14 * RFC 7741 - RTP Payload Format for VP8 Video
15 */
16
17
18 #include "config.h"
19
20 #include <epan/packet.h>
21 #include <epan/prefs.h>
22 #include <epan/expert.h>
23
24 void proto_reg_handoff_vp8(void);
25 void proto_register_vp8(void);
26
27 #define BIT_1_MASK 0x80
28 #define BIT_2_MASK 0x40
29 #define BIT_3_MASK 0x20
30 #define BIT_4_MASK 0x10
31 #define BIT_5_MASK 0x08
32 #define BIT_6_MASK 0x04
33 #define BIT_7_MASK 0x02
34 #define BIT_8_MASK 0x01
35 #define BIT_123_MASK 0xE0
36 #define BIT_234_MASK 0x70
37 #define BIT_5678_MASK 0x0F
38 #define BIT_567_MASK 0x0E
39 #define BIT_45678_MASK 0x1F
40 #define BIT_12_MASK 0xC0
41 #define BIT_NO_MASK 0xFF
42
43 #define BIT_2BYTE_NO_MASK 0xFFFF
44 #define BIT_3BYTE_NO_MASK 0xFFFFFF
45 #define BIT_EXT_PICTURE_MASK 0x7FFF
46 #define BIT_PARTITION_SIZE_MASK 0xE0FFFF
47
48 static range_t *temp_dynamic_payload_type_range = NULL;
49
50 static dissector_handle_t vp8_handle;
51
52 /* Initialize the protocol and registered fields */
53 static int proto_vp8 = -1;
54 static int hf_vp8_pld_x_bit = -1;
55 static int hf_vp8_pld_r_bit = -1;
56 static int hf_vp8_pld_n_bit = -1;
57 static int hf_vp8_pld_s_bit = -1;
58 static int hf_vp8_pld_part_id = -1;
59 static int hf_vp8_pld_i_bit = -1;
60 static int hf_vp8_pld_l_bit = -1;
61 static int hf_vp8_pld_t_bit = -1;
62 static int hf_vp8_pld_k_bit = -1;
63 static int hf_vp8_pld_rsv_a = -1;
64 static int hf_vp8_pld_picture_id = -1;
65 static int hf_vp8_pld_extended_picture_id = -1;
66 static int hf_vp8_pld_tl0picidx = -1;
67 static int hf_vp8_pld_tid = -1;
68 static int hf_vp8_pld_y_bit = -1;
69 static int hf_vp8_pld_keyidx = -1;
70
71 /* payload header fields */
72 static int hf_vp8_hdr_frametype = -1;
73 static int hf_vp8_hdr_version = -1;
74 static int hf_vp8_hdr_show_bit = -1;
75 static int hf_vp8_hdr_first_partition_size = -1;
76
77 /* keyframe fields */
78 static int hf_vp8_keyframe_start_code = -1;
79 static int hf_vp8_keyframe_width = -1;
80 static int hf_vp8_keyframe_horizontal_scale = -1;
81 static int hf_vp8_keyframe_height = -1;
82 static int hf_vp8_keyframe_vertical_scale = -1;
83
84 /* Initialize the subtree pointers */
85 static int ett_vp8 = -1;
86 static int ett_vp8_payload_descriptor = -1;
87 static int ett_vp8_payload_header = -1;
88 static int ett_vp8_payload = -1;
89 static int ett_vp8_keyframe = -1;
90
91 static expert_field ei_vp8_startcode = EI_INIT;
92 static expert_field ei_vp8_undecoded = EI_INIT;
93 static expert_field ei_vp8_continuation = EI_INIT;
94 static expert_field ei_vp8_first_partition_split = EI_INIT;
95 static expert_field ei_vp8_first_partition_plus = EI_INIT;
96
97 static void
98 dissect_vp8_payload_descriptor(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *vp8_tree, gint *offset, gboolean *hasHeader);
99
100 static void
101 dissect_vp8_payload_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *vp8_tree, gint *offset, gint *frametype, gint *partition1_size);
102
103 static void
104 dissect_vp8_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *vp8_tree, gint *offset, gint *frametype, gint *partition1_size);
105
106 static gint *ett[] = {
107 &ett_vp8,
108 &ett_vp8_payload_descriptor,
109 &ett_vp8_payload_header,
110 &ett_vp8_payload,
111 &ett_vp8_keyframe
112 };
113
114 static const value_string vp8_type_values[] = {
115 { 0, "Keyframe" },
116 { 1, "Interframe" },
117 { 2, "Continuation" },
118 { 0, NULL }
119 };
120
121 static const range_string vp8_hdr_version_vals[] = {
122 { 0, 0, "Bicubic (Loop Filter=Normal)" },
123 { 1, 1, "Bilinear (Loop Filter=Simple)" },
124 { 2, 2, "Bilinear (Loop Filter=None)" },
125 { 3, 3, "No filters" },
126 { 4, 7, "Reserved for future use" },
127 { 0, 0, NULL }
128 };
129
130 static const true_false_string vp8_x_bit_vals = {
131 "Extended control bits present (I L T K)",
132 "Extended control bits not present"
133 };
134
135 static const true_false_string vp8_r_bit_vals = {
136 "Reserved for future use (error: should be zero)",
137 "Reserved for future use"
138 };
139
140 static const true_false_string vp8_n_bit_vals = {
141 "Non-reference frame",
142 "Reference frame"
143 };
144
145 static const true_false_string vp8_s_bit_vals = {
146 "Start of VP8 partition",
147 "Continuation of VP8 partition"
148 };
149
150 static const true_false_string vp8_i_bit_vals = {
151 "Picture ID byte present",
152 "No Picture byte ID"
153 };
154
155 static const true_false_string vp8_l_bit_vals = {
156 "TL0PICIDX byte present",
157 "TL0PICIDX byte not present"
158 };
159
160 static const true_false_string vp8_t_bit_vals = {
161 "TID (temporal layer index) present",
162 "TID (temporal layer index) not present"
163 };
164
165 static const true_false_string vp8_k_bit_vals = {
166 "KEYIDX present",
167 "KEYIDX not present"
168 };
169
170 static const true_false_string vp8_hdr_frametype_vals = {
171 "interframe",
172 "keyframe"
173 };
174
175 static int
dissect_vp8(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)176 dissect_vp8(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
177 {
178
179 proto_item *item;
180 gint offset = 0, frametype = 0, partition1_size = -1;
181 proto_tree *vp8_tree;
182 gboolean hasHeader = FALSE;
183
184 col_set_str(pinfo->cinfo, COL_PROTOCOL, "VP8");
185
186 item = proto_tree_add_item(tree, proto_vp8, tvb, 0, -1, ENC_NA);
187 vp8_tree = proto_item_add_subtree(item, ett_vp8);
188
189 frametype = 2; /*continuation, will get overridden if there is a payload header*/
190
191 dissect_vp8_payload_descriptor(tvb, pinfo, vp8_tree, &offset, &hasHeader);
192 if (hasHeader)
193 {
194 dissect_vp8_payload_header(tvb, pinfo, vp8_tree, &offset, &frametype, &partition1_size);
195 }
196
197 dissect_vp8_payload(tvb, pinfo, vp8_tree, &offset, &frametype, &partition1_size);
198
199 col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
200 val_to_str(frametype, vp8_type_values, "Unknown Type (%u)"));
201
202 return tvb_captured_length(tvb);
203 }
204
205 static void
dissect_vp8_payload_descriptor(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * vp8_tree,gint * offset,gboolean * hasHeader)206 dissect_vp8_payload_descriptor(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *vp8_tree, gint *offset, gboolean *hasHeader)
207 {
208 proto_item *item_descriptor;
209 guint8 extended_bit, s_bit, partId;
210 proto_tree *vp8_payload_descriptor_tree;
211
212 /*
213 The first octets after the RTP header are the VP8 payload descriptor,
214 with the following structure.
215
216 0 1 2 3 4 5 6 7
217 +-+-+-+-+-+-+-+-+
218 |X|R|N|S|R| PID | (REQUIRED), second R bit is parsed as part of PID
219 +-+-+-+-+-+-+-+-+
220 X: |I|L|T|K| RSV | (OPTIONAL)
221 +-+-+-+-+-+-+-+-+
222 I: |M| PictureID | (OPTIONAL)
223 +-+-+-+-+-+-+-+-+
224 L: | TL0PICIDX | (OPTIONAL)
225 +-+-+-+-+-+-+-+-+
226 T/K: |TID|Y| KEYIDX | (OPTIONAL)
227 +-+-+-+-+-+-+-+-+
228 */
229
230 vp8_payload_descriptor_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, -1, ett_vp8_payload_descriptor,
231 &item_descriptor, "Payload descriptor");
232
233 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_x_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
234 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_r_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
235 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_n_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
236 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_s_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
237 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_part_id, tvb, *offset, 1, ENC_BIG_ENDIAN);
238 extended_bit = tvb_get_guint8(tvb, *offset) & BIT_1_MASK;
239 s_bit = tvb_get_guint8(tvb, *offset) & BIT_4_MASK;
240 partId = tvb_get_guint8(tvb, *offset) & BIT_5678_MASK;
241
242 if ((s_bit > 0) && (partId == 0)) {
243 *hasHeader=TRUE;
244 }
245
246 if (extended_bit)
247 {
248 guint8 i_bit, l_bit, t_bit, k_bit;
249 (*offset)++;
250 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_i_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
251 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_l_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
252 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_t_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
253 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_k_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
254 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_rsv_a, tvb, *offset, 1, ENC_BIG_ENDIAN);
255
256 i_bit = tvb_get_guint8(tvb, *offset) & BIT_1_MASK;
257 l_bit = tvb_get_guint8(tvb, *offset) & BIT_2_MASK;
258 t_bit = tvb_get_guint8(tvb, *offset) & BIT_3_MASK;
259 k_bit = tvb_get_guint8(tvb, *offset) & BIT_4_MASK;
260 if (i_bit)
261 {
262 (*offset)++;
263 if(tvb_get_guint8(tvb, *offset) & BIT_1_MASK)
264 {
265 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_extended_picture_id, tvb, *offset, 2, ENC_BIG_ENDIAN);
266 (*offset)++;
267 }
268 else
269 {
270 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_picture_id, tvb, *offset, 1, ENC_BIG_ENDIAN);
271 }
272
273 }
274 if (l_bit)
275 {
276 (*offset)++;
277 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_tl0picidx, tvb, *offset, 1, ENC_BIG_ENDIAN);
278 }
279 if (t_bit || k_bit)
280 {
281 (*offset)++;
282 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_tid, tvb, *offset, 1, ENC_BIG_ENDIAN);
283 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_y_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
284 proto_tree_add_item(vp8_payload_descriptor_tree, hf_vp8_pld_keyidx, tvb, *offset, 1, ENC_BIG_ENDIAN);
285 }
286 }
287 (*offset)++;
288 /* now we know the length of payload descriptor */
289 proto_item_set_len(item_descriptor, *offset);
290 }
291
292 static void
dissect_vp8_payload_header(tvbuff_t * tvb,packet_info * pinfo _U_,proto_tree * vp8_tree,gint * offset,gint * frametype,gint * partition1_size)293 dissect_vp8_payload_header(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *vp8_tree, gint *offset, gint *frametype, gint *partition1_size)
294 {
295 proto_item *item_header;
296 proto_tree *vp8_payload_header_tree;
297 gint size0, size1, size2;
298
299 /*
300 The first three octets of an encoded VP8 frame are referred to as an
301 "uncompressed data chunk" in [RFC6386], and co-serve as payload
302 header in this RTP format. The codec bitstream format specifies two
303 different variants of the uncompressed data chunk: a 3 octet version
304 for interframes and a 10 octet version for key frames. The first 3
305 octets are common to both variants. In the case of a key frame the
306 remaining 7 octets are considered to be part of the remaining payload
307 in this RTP format. Note that the header is present only in packets
308 which have the S bit equal to one and the PartID equal to zero in the
309 payload descriptor. Subsequent packets for the same frame do not
310 carry the payload header.
311
312
313 0 1 2 3 4 5 6 7
314 +-+-+-+-+-+-+-+-+
315 |Size0|H| VER |P|
316 +-+-+-+-+-+-+-+-+
317 | Size1 |
318 +-+-+-+-+-+-+-+-+
319 | Size2 |
320 +-+-+-+-+-+-+-+-+
321 | Bytes 4..N of |
322 | VP8 payload |
323 : :
324 +-+-+-+-+-+-+-+-+
325 | OPTIONAL RTP |
326 | padding |
327 : :
328 +-+-+-+-+-+-+-+-+
329
330 */
331
332 vp8_payload_header_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, 3, ett_vp8_payload_header, &item_header, "Payload header");
333 proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_frametype, tvb, *offset, 1, ENC_BIG_ENDIAN);
334 proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_version, tvb, *offset, 1, ENC_BIG_ENDIAN);
335 proto_tree_add_item(vp8_payload_header_tree, hf_vp8_hdr_show_bit, tvb, *offset, 1, ENC_BIG_ENDIAN);
336
337 *frametype = tvb_get_guint8(tvb, *offset) & BIT_8_MASK;
338
339 size0 = (tvb_get_guint8(tvb, *offset) & BIT_123_MASK) >> 5;
340 size1 = tvb_get_guint8(tvb, *offset + 1);
341 size2 = tvb_get_guint8(tvb, *offset + 2);
342 (*partition1_size) = size0 + (size1*8) + (size2*2048);
343 proto_tree_add_uint(vp8_payload_header_tree, hf_vp8_hdr_first_partition_size, tvb, *offset, 3, *partition1_size);
344 (*offset)++;
345 (*offset)++;
346 (*offset)++;
347
348 }
349
350 static void
dissect_vp8_payload(tvbuff_t * tvb,packet_info * pinfo,proto_tree * vp8_tree,gint * offset,gint * frametype,gint * partition1_size)351 dissect_vp8_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *vp8_tree, gint *offset, gint *frametype, gint *partition1_size)
352 {
353 proto_tree *vp8_payload_tree;
354 proto_item *payload_item;
355 gint remainder;
356
357 vp8_payload_tree = proto_tree_add_subtree(vp8_tree, tvb, *offset, -1, ett_vp8_payload, &payload_item, "Payload");
358
359 if (*frametype == 0)
360 {
361 guint16 width, height;
362 gint start1, start2, start3, horizontal_scale, vertical_scale;
363 proto_tree *vp8_keyframe_tree;
364
365 vp8_keyframe_tree = proto_tree_add_subtree(vp8_payload_tree, tvb, *offset, -1, ett_vp8_keyframe, NULL, "Keyframe header");
366
367 proto_tree_add_item(vp8_keyframe_tree, hf_vp8_keyframe_start_code, tvb, *offset, 3, ENC_BIG_ENDIAN);
368 start1 = tvb_get_guint8(tvb, *offset);
369 start2 = tvb_get_guint8(tvb, *offset + 1);
370 start3 = tvb_get_guint8(tvb, *offset + 2);
371
372 /* check start code is correct */
373 if ((start1 != 0x9d) || (start2 != 0x01) || (start3 != 0x2a))
374 {
375 expert_add_info(pinfo, vp8_keyframe_tree, &ei_vp8_startcode);
376 }
377
378 (*offset)++;
379 (*offset)++;
380 (*offset)++;
381 width = tvb_get_letohs(tvb, *offset) & 0x3FFF;
382 horizontal_scale = tvb_get_letohs(tvb, *offset)>>14;
383
384 proto_tree_add_uint(vp8_keyframe_tree, hf_vp8_keyframe_horizontal_scale, tvb, *offset, 2, horizontal_scale);
385 proto_tree_add_uint(vp8_keyframe_tree, hf_vp8_keyframe_width, tvb, *offset, 2, width);
386 (*offset)++;
387 (*offset)++;
388
389 height = tvb_get_letohs(tvb, *offset) & 0x3FFF;
390 vertical_scale = tvb_get_letohs(tvb, *offset)>>14;
391 proto_tree_add_uint(vp8_keyframe_tree, hf_vp8_keyframe_vertical_scale, tvb, *offset, 2, vertical_scale);
392 proto_tree_add_uint(vp8_keyframe_tree, hf_vp8_keyframe_height, tvb, *offset, 2, height);
393 (*offset)++;
394 (*offset)++;
395 }
396
397 remainder = tvb_reported_length_remaining(tvb, (*offset));
398 if ((*partition1_size) == -1)
399 {
400 /*no header, continuation?*/
401 proto_tree_add_expert_format(vp8_payload_tree, pinfo, &ei_vp8_continuation, tvb, *offset, -1, "Continuation of partition fragment (%d bytes)", remainder);
402 }
403 else
404 {
405 if (remainder < *partition1_size)
406 {
407 /* partition size has already been added to vp8 header tree, but it would be useful to provide additional explanation */
408 proto_tree_add_expert_format(vp8_payload_tree, pinfo, &ei_vp8_first_partition_split, tvb, *offset, -1,
409 "First partition is split with %d bytes in this packet and %d bytes in subsequent frames", remainder, ((*partition1_size)-remainder));
410 }
411 else
412 {
413 (*offset)= (*offset) + (*partition1_size);
414 proto_tree_add_expert_format(vp8_payload_tree, pinfo, &ei_vp8_first_partition_plus, tvb, *offset, -1,
415 "This frame contains all of first partition (%d bytes) and also %d bytes from other partitions",
416 *partition1_size, remainder);
417 }
418 }
419 expert_add_info(pinfo, payload_item, &ei_vp8_undecoded);
420 }
421
422 void
proto_register_vp8(void)423 proto_register_vp8(void)
424 {
425 module_t *vp8_module;
426 expert_module_t* expert_vp8;
427
428 static hf_register_info hf[] = {
429 { &hf_vp8_pld_x_bit,
430 { "X bit", "vp8.pld.x",
431 FT_BOOLEAN, 8, TFS(&vp8_x_bit_vals), BIT_1_MASK,
432 NULL, HFILL }
433 },
434 { &hf_vp8_pld_r_bit,
435 { "R bit", "vp8.pld.r",
436 FT_BOOLEAN, 8, TFS(&vp8_r_bit_vals), BIT_2_MASK,
437 NULL, HFILL }
438 },
439 { &hf_vp8_pld_n_bit,
440 { "N bit", "vp8.pld.n",
441 FT_BOOLEAN, 8, TFS(&vp8_n_bit_vals), BIT_3_MASK,
442 NULL, HFILL }
443 },
444 { &hf_vp8_pld_s_bit,
445 { "S bit", "vp8.pld.s",
446 FT_BOOLEAN, 8, TFS(&vp8_s_bit_vals), BIT_4_MASK,
447 NULL, HFILL }
448 },
449 { &hf_vp8_pld_part_id,
450 { "2nd R bit and Part Id", "vp8.pld.partid",
451 FT_UINT8, BASE_DEC, NULL, BIT_5678_MASK,
452 NULL, HFILL }
453 },
454 { &hf_vp8_pld_i_bit,
455 { "I bit", "vp8.pld.i",
456 FT_BOOLEAN, 8, TFS(&vp8_i_bit_vals), BIT_1_MASK,
457 NULL, HFILL }
458 },
459 { &hf_vp8_pld_l_bit,
460 { "L bit", "vp8.pld.l",
461 FT_BOOLEAN, 8, TFS(&vp8_l_bit_vals), BIT_2_MASK,
462 NULL, HFILL }
463 },
464 { &hf_vp8_pld_t_bit,
465 { "T bit", "vp8.pld.t",
466 FT_BOOLEAN, 8, TFS(&vp8_t_bit_vals), BIT_3_MASK,
467 NULL, HFILL }
468 },
469 { &hf_vp8_pld_k_bit,
470 { "K bit", "vp8.pld.k",
471 FT_BOOLEAN, 8, TFS(&vp8_k_bit_vals), BIT_4_MASK,
472 NULL, HFILL }
473 },
474 { &hf_vp8_pld_rsv_a,
475 { "Reserved A", "vp8.pld.rsva",
476 FT_UINT8, BASE_DEC, NULL, BIT_5678_MASK,
477 NULL, HFILL }
478 },
479 { &hf_vp8_pld_picture_id,
480 { "Picture ID", "vp8.pld.pictureid",
481 FT_UINT8, BASE_DEC, NULL, BIT_NO_MASK,
482 NULL, HFILL }
483 },
484 { &hf_vp8_pld_extended_picture_id,
485 { "Extended Picture ID", "vp8.pld.pictureid",
486 FT_UINT8, BASE_DEC, NULL, BIT_EXT_PICTURE_MASK,
487 NULL, HFILL }
488 },
489 { &hf_vp8_pld_tl0picidx,
490 { "Temporal layer zero Picture Index (TL0PICIDX)", "vp8.pld.tl0picidx",
491 FT_UINT8, BASE_DEC, NULL, BIT_NO_MASK,
492 NULL, HFILL }
493 },
494 { &hf_vp8_pld_tid,
495 { "Temporal layer Index (TID)", "vp8.pld.tid",
496 FT_UINT8, BASE_DEC, NULL, BIT_12_MASK,
497 NULL, HFILL }
498 },
499 { &hf_vp8_pld_y_bit,
500 { "1 layer sync bit (Y)", "vp8.pld.y",
501 FT_BOOLEAN, 8, NULL, BIT_3_MASK,
502 NULL, HFILL }
503 },
504 { &hf_vp8_pld_keyidx,
505 { "Temporal Key Frame Index (KEYIDX)", "vp8.pld.keyidx",
506 FT_UINT8, BASE_DEC, NULL, BIT_45678_MASK,
507 NULL, HFILL }
508 },
509 { &hf_vp8_hdr_frametype,
510 { "frametype", "vp8.hdr.frametype",
511 FT_BOOLEAN, 8, TFS(&vp8_hdr_frametype_vals), BIT_8_MASK,
512 NULL, HFILL }
513 },
514 { &hf_vp8_hdr_version,
515 { "version", "vp8.hdr.version",
516 FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vp8_hdr_version_vals), BIT_567_MASK,
517 NULL, HFILL }
518 },
519 { &hf_vp8_hdr_show_bit,
520 { "Show bit", "vp8.hdr.show",
521 FT_BOOLEAN, 8, NULL, BIT_4_MASK,
522 "Set when current frame is for display", HFILL }
523 },
524 { &hf_vp8_hdr_first_partition_size,
525 { "First partition size", "vp8.hdr.partition_size",
526 FT_UINT8, BASE_DEC, NULL, BIT_PARTITION_SIZE_MASK,
527 NULL, HFILL }
528 },
529 { &hf_vp8_keyframe_start_code,
530 { "VP8 Start code", "vp8.keyframe.start_code",
531 FT_UINT24, BASE_HEX, NULL, BIT_3BYTE_NO_MASK,
532 NULL, HFILL }
533 },
534 { &hf_vp8_keyframe_width,
535 { "Width", "vp8.keyframe.width",
536 FT_UINT16, BASE_DEC, NULL, BIT_2BYTE_NO_MASK,
537 NULL, HFILL }
538 },
539 { &hf_vp8_keyframe_height,
540 { "Height", "vp8.keyframe.height",
541 FT_UINT16, BASE_DEC, NULL, BIT_2BYTE_NO_MASK,
542 NULL, HFILL }
543 },
544 { &hf_vp8_keyframe_horizontal_scale,
545 { "Horizontal Scale", "vp8.keyframe.horizontal_scale",
546 FT_UINT8, BASE_DEC, NULL, BIT_12_MASK,
547 NULL, HFILL }
548 },
549 { &hf_vp8_keyframe_vertical_scale,
550 { "Vertical Scale", "vp8.keyframe.vertical_scale",
551 FT_UINT8, BASE_DEC, NULL, BIT_12_MASK,
552 NULL, HFILL }
553 }
554
555 };
556
557 static ei_register_info ei[] = {
558 { &ei_vp8_startcode, { "vp8.keyframe.startcode", PI_PROTOCOL, PI_ERROR, "Startcode is incorrect", EXPFILL }},
559 { &ei_vp8_undecoded, { "vp8.undecoded", PI_UNDECODED, PI_NOTE, "Payload not fully decoded", EXPFILL }},
560 { &ei_vp8_continuation, { "vp8.continuation", PI_REASSEMBLE, PI_CHAT, "Continuation of partition fragment", EXPFILL }},
561 { &ei_vp8_first_partition_split, { "vp8.first_partition_split", PI_REASSEMBLE, PI_CHAT, "First partition is split", EXPFILL }},
562 { &ei_vp8_first_partition_plus, { "vp8.first_partition_plus", PI_REASSEMBLE, PI_CHAT, "This frame contains all of first partition and also bytes from other partitions", EXPFILL }},
563 };
564
565 proto_vp8 = proto_register_protocol (
566 "VP8", /* name */
567 "VP8", /* short name */
568 "vp8" /* abbrev */
569 );
570
571 proto_register_field_array(proto_vp8, hf, array_length(hf));
572 proto_register_subtree_array(ett, array_length(ett));
573
574 vp8_module = prefs_register_protocol(proto_vp8, proto_reg_handoff_vp8);
575
576 expert_vp8 = expert_register_protocol(proto_vp8);
577 expert_register_field_array(expert_vp8, ei, array_length(ei));
578
579 prefs_register_range_preference(vp8_module, "dynamic.payload.type",
580 "vp8 dynamic payload types",
581 "Dynamic payload types which will be interpreted as vp8"
582 "; Values must be in the range 1 - 127",
583 &temp_dynamic_payload_type_range, 127);
584
585 vp8_handle = register_dissector("vp8", dissect_vp8, proto_vp8);
586 }
587
588 void
proto_reg_handoff_vp8(void)589 proto_reg_handoff_vp8(void)
590 {
591 static range_t *dynamic_payload_type_range = NULL;
592 static gboolean vp8_prefs_initialized = FALSE;
593
594 if (!vp8_prefs_initialized) {
595 dissector_add_string("rtp_dyn_payload_type" , "VP8", vp8_handle);
596 vp8_prefs_initialized = TRUE;
597 } else {
598 dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, vp8_handle);
599 wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
600 }
601
602 dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
603 range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
604 dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, vp8_handle);
605 }
606
607 /*
608 * Editor modelines - https://www.wireshark.org/tools/modelines.html
609 *
610 * Local variables:
611 * c-basic-offset: 4
612 * tab-width: 8
613 * indent-tabs-mode: nil
614 * End:
615 *
616 * vi: set shiftwidth=4 tabstop=8 expandtab:
617 * :indentSize=4:tabSize=8:noTabs=true:
618 */
619