3 * Routines for MPEG4 dissection
4 * Copyright 2007-2008, Anders Broman <anders.broman[at]ericsson.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * http://www.ietf.org/rfc/rfc3016.txt?number=3016
40 #include <epan/packet.h>
41 #include <epan/proto.h>
42 #include <epan/asn1.h>
46 /* Initialize the protocol and registered fields */
47 static int proto_mp4ves = -1;
49 static int hf_mp4ves_config = -1;
50 static int hf_mp4ves_start_code_prefix = -1;
51 static int hf_mp4ves_start_code = -1;
52 static int hf_mp4ves_vop_coding_type = -1;
53 static int hf_mp4ves_profile_and_level_indication = -1;
54 static int hf_mp4ves_is_visual_object_identifier = -1;
55 static int hf_mp4ves_visual_object_type = -1;
56 static int hf_mp4ves_video_signal_type = -1;
57 static int hf_mp4ves_stuffing = -1;
58 static int hf_mp4ves_video_object_type_indication = -1;
59 static int hf_mp4ves_random_accessible_vol = -1;
60 static int hf_mp4ves_is_object_layer_identifier = -1;
61 static int hf_mp4ves_aspect_ratio_info = -1;
62 static int hf_mp4ves_vol_control_parameters = -1;
63 static int hf_mp4ves_video_object_layer_shape = -1;
65 /* Initialize the subtree pointers */
66 static int ett_mp4ves = -1;
67 static int ett_mp4ves_config = -1;
69 /* The dynamic payload type which will be dissected as MP4V-ES */
71 static guint global_dynamic_payload_type = 0;
75 14496-2, Annex G, Table G-1.
76 Table G-1 FLC table for profile_and_level_indication Profile/Level Code
78 const value_string mp4ves_level_indication_vals[] =
81 { 1, "Simple Profile/Level 1" },
82 { 2, "Simple Profile/Level 2" },
88 { 8, "Simple Profile/Level 0" },
89 { 9, "Simple Profile/Level 0b" },
90 /* Reserved 00001001 - 00010000 */
91 { 0x11, "Simple Scalable Profile/Level 1" },
92 { 0x12, "Simple Scalable Profile/Level 2" },
93 /* Reserved 00010011 - 00100000 */
94 { 0x21, "Core Profile/Level 1" },
95 { 0x22, "Core Profile/Level 2" },
96 /* Reserved 00100011 - 00110001 */
97 { 0x32, "Main Profile/Level 2" },
98 { 0x33, "Main Profile/Level 3" },
99 { 0x34, "Main Profile/Level 4" },
100 /* Reserved 00110101 - 01000001 */
101 { 0x42, "N-bit Profile/Level 2" },
102 /* Reserved 01000011 - 01010000 */
103 { 0x51, "Scalable Texture Profile/Level 1" },
104 /* Reserved 01010010 - 01100000 */
105 { 0x61, "Simple Face Animation Profile/Level 1" },
106 { 0x62, "Simple Face Animation Profile/Level 2" },
107 { 0x63, "Simple FBA Profile/Level 1" },
108 { 0x64, "Simple FBA Profile/Level 2" },
109 /* Reserved 01100101 - 01110000 */
110 { 0x71, "Basic Animated Texture Profile/Level 1" },
111 { 0x72, "Basic Animated Texture Profile/Level 2" },
112 /* Reserved 01110011 - 10000000 */
113 { 0x81, "Hybrid Profile/Level 1" },
114 { 0x82, "Hybrid Profile/Level 2" },
115 /* Reserved 10000011 - 10010000 */
116 { 0x91, "Advanced Real Time Simple Profile/Level 1" },
117 { 0x92, "Advanced Real Time Simple Profile/Level 2" },
118 { 0x93, "Advanced Real Time Simple Profile/Level 3" },
119 { 0x94, "Advanced Real Time Simple Profile/Level 4" },
120 /* Reserved 10010101 - 10100000 */
121 { 0xa1, "Core Scalable Profile/Level 1" },
122 { 0xa2, "Core Scalable Profile/Level 2" },
123 { 0xa3, "Core Scalable Profile/Level 3" },
124 /* Reserved 10100100 - 10110000 */
125 { 0xb1, "Advanced Coding Efficiency Profile/Level 1" },
126 { 0xb2, "Advanced Coding Efficiency Profile/Level 2" },
127 { 0xb3, "Advanced Coding Efficiency Profile/Level 3" },
128 { 0xb4, "Advanced Coding Efficiency Profile/Level 4" },
129 /* Reserved 10110101 - 11000000 */
130 { 0xc1, "Advanced Core Profile/Level 1" },
131 { 0xc2, "Advanced Core Profile/Level 2" },
132 /* Reserved 11000011 - 11010000 */
133 { 0xd1, "Advanced Scalable Texture/Level 1" },
134 { 0xd2, "Advanced Scalable Texture/Level 2" },
135 { 0xd3, "Advanced Scalable Texture/Level 3" },
136 /* Reserved 11010100 - 11100000 */
137 { 0xe1, "Simple Studio Profile/Level 1" },
138 { 0xe2, "Simple Studio Profile/Level 2" },
139 { 0xe3, "Simple Studio Profile/Level 3" },
140 { 0xe4, "Simple Studio Profile/Level 4" },
141 { 0xe5, "Core Studio Profile/Level 1" },
142 { 0xe6, "Core Studio Profile/Level 2" },
143 { 0xe7, "Core Studio Profile/Level 3" },
144 { 0xe8, "Core Studio Profile/Level 4" },
145 /* Reserved 11101001 - 11101111 */
146 { 0xf0, "Advanced Simple Profile/Level 0" },
147 { 0xf1, "Advanced Simple Profile/Level 1" },
148 { 0xf2, "Advanced Simple Profile/Level 2" },
149 { 0xf3, "Advanced Simple Profile/Level 3" },
150 { 0xf4, "Advanced Simple Profile/Level 4" },
151 { 0xf5, "Advanced Simple Profile/Level 5" },
152 /* Reserved 11110110 - 11110111 */
153 { 0xf8, "Fine Granularity Scalable Profile/Level 0" },
154 { 0xf9, "Fine Granularity Scalable Profile/Level 1" },
155 { 0xfa, "Fine Granularity Scalable Profile/Level 2" },
156 { 0xfb, "Fine Granularity Scalable Profile/Level 3" },
157 { 0xfc, "Fine Granularity Scalable Profile/Level 4" },
158 { 0xfd, "Fine Granularity Scalable Profile/Level 5" },
159 { 0xfe, "Reserved" },
160 { 0xff, "Reserved for Escape" },
163 static const range_string mp4ves_startcode_vals[] = {
164 { 0x00, 0x1f, "video_object_start_code" },
165 { 0x20, 0x2f, "video_object_layer_start_code" },
166 { 0x30, 0xaf, "reserved" },
167 { 0xb0, 0xb0, "visual_object_sequence_start_code" },
168 { 0xb1, 0xb1, "visual_object_sequence_end_code" },
169 { 0xb2, 0xb2, "user_data_start_code" },
170 { 0xb3, 0xb3, "group_of_vop_start_code" },
171 { 0xb4, 0xb4, "video_session_error_code" },
172 { 0xb5, 0xb5, "visual_object_start_code" },
173 { 0xb6, 0xb6, "vop_start_code" },
174 { 0xb7, 0xb9, "reserved" },
175 { 0xba, 0xba, "fba_object_start_code" },
176 { 0xbb, 0xbb, "fba_object_plane_start_code" },
177 { 0xbc, 0xbc, "mesh_object_start_code" },
178 { 0xbd, 0xbd, "mesh_object_plane_start_code" },
179 { 0xbe, 0xbe, "still_texture_object_start_code" },
180 { 0xbf, 0xbf, "texture_spatial_layer_start_code" },
181 { 0xc0, 0xc0, "texture_snr_layer_start_code" },
182 { 0xc1, 0xc1, "texture_tile_start_code" },
183 { 0xc2, 0xc2, "texture_shape_layer_start_code" },
184 { 0xc3, 0xc3, "stuffing_start_code" },
185 { 0xc4, 0xc5, "reserved" },
186 { 0xc6, 0xcf, "System start codes" }, /* NOTE System start codes are defined in ISO/IEC 14496-1:1999 */
190 static const value_string mp4ves_vop_coding_type_vals[] = {
191 { 0, "intra-coded (I)" },
192 { 1, "predictive-coded (P)" },
193 { 2, "bidirectionally-predictive-coded (B)" },
199 * FLC table for video_object_type indication
201 static const value_string mp4ves_video_object_type_vals[] = {
203 { 0x1, "Simple Object Type" },
204 { 0x2, "Simple Scalable Object Type" },
205 { 0x3, "Core Object Type" },
206 { 0x4, "Main Object Type" },
207 { 0x5, "N-bit Object Type" },
208 { 0x6, "Basic Anim. 2D Texture" },
209 { 0x7, "Anim. 2D Mesh" },
210 { 0x8, "Simple Face" },
211 { 0x9, "Still Scalable Texture" },
212 { 0xa, "Advanced Real Time Simple" },
213 { 0xb, "Core Scalable" },
214 { 0xc, "Advanced Coding Efficiency" },
215 { 0xd, "Advanced Scalable Texture" },
216 { 0xe, "Simple FBA" },
219 /* Visual object type */
220 static const value_string mp4ves_visual_object_type_vals[] = {
223 { 0x2, "still texture ID" },
226 { 0x5, "3D mesh ID" },
240 static const value_string mp4ves_video_object_type_indication_vals[] = {
242 { 0x1, "Simple Object Type" },
243 { 0x2, "Simple Scalable Object Type" },
244 { 0x3, "Core Object Type" },
245 { 0x4, "Main Object Type" },
246 { 0x5, "N-bit Object Type" },
247 { 0x6, "Basic Anim. 2D Texture" },
248 { 0x7, "Anim. 2D Mesh" },
249 { 0x8, "Simple Face" },
250 { 0x9, "Still Scalable Texture" },
251 { 0xa, "Advanced Real Time Simple" },
252 { 0xb, "Core Scalable" },
253 { 0xc, "Advanced Coding Efficiency" },
254 { 0xd, "Advanced Scalable Texture" },
255 { 0xe, "Simple FBA" },
257 /* Reserved 00001111 - 11111111 */
260 /* 6.2.2.1 User data */
262 dissect_mp4ves_user_data(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int bit_offset)
264 int start_bit_offset;
266 /* user_data_start_code */
267 proto_tree_add_bits_item(tree, hf_mp4ves_start_code_prefix, tvb, bit_offset, 24, FALSE);
269 proto_tree_add_bits_item(tree, hf_mp4ves_start_code, tvb, bit_offset, 8, FALSE);
271 start_bit_offset = bit_offset;
272 /* while( next_bits() != '000 0000 0000 0000 0000 0001') { */
273 while ( tvb_get_bits32(tvb,bit_offset, 24, FALSE) != 1){
275 /* user_data 8 bits */
277 proto_tree_add_text(tree, tvb, start_bit_offset>>3, (bit_offset - start_bit_offset)>>2, "User data");
284 while (!bytealigned())
289 dissect_mp4ves_next_start_code(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int bit_offset)
292 int start_bit_offset;
294 start_bit_offset = bit_offset;
296 zero_bit = tvb_get_bits8(tvb,bit_offset,1);
302 /* zero stuffing bits */
303 if(bit_offset %8 == 0)
306 while(bit_offset %8 != 0){
310 proto_tree_add_bits_item(tree, hf_mp4ves_stuffing, tvb, start_bit_offset, bit_offset-start_bit_offset, FALSE);
316 video_signal_type() {
318 if (video_signal_type) {
319 video_format 3 uimsbf
321 colour_description 1 bslbf
322 if (colour_description) {
323 colour_primaries 8 uimsbf
324 transfer_characteristics 8 uimsbf
325 matrix_coefficients 8 uimsbf
331 dissect_mp4ves_visual_object_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int bit_offset)
333 guint8 video_signal_type, colour_description;
335 video_signal_type = tvb_get_bits8(tvb,bit_offset,1);
336 proto_tree_add_bits_item(tree, hf_mp4ves_video_signal_type, tvb, bit_offset, 1, FALSE);
338 if (video_signal_type) {
339 /* video_format 3 bits */
341 /* video_range 1 bit */
343 /* colour_description 1 bit */
344 colour_description = tvb_get_bits8(tvb,bit_offset,1);
345 if (colour_description) {
346 /* colour_primaries 8 bits */
348 /* transfer_characteristics 8 bits */
350 /* matrix_coefficients 8 bits*/
358 * 6.2.3 Video Object Layer
362 * Table 6-12 -- Meaning of pixel aspect ratio
365 static const value_string mp4ves_aspect_ratio_info_vals[] = {
367 { 0x0, "Forbidden" },
368 { 0x1, "1:1 (Square)" },
369 { 0x2, "12:11 (625-type for 4:3 picture)" },
370 { 0x3, "10:11 (525-type for 4:3 picture)" },
371 { 0x4, "16:11 (625-type stretched for 16:9 picture)" },
372 { 0x5, "40:33 (525-type stretched for 16:9 picture)" },
382 { 0xf, "Extended PAR" },
386 /* Table 6-14 Video Object Layer shape type */
387 static const value_string mp4ves_video_object_layer_shape_vals[] = {
388 { 0x0, "rectangular" },
390 { 0x2, "binary only" },
391 { 0x3, "grayscale" },
396 dissect_mp4ves_VideoObjectLayer(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int bit_offset)
399 int current_bit_offset;
400 guint8 octet, is_object_layer_identifier, aspect_ratio_info, vol_control_parameters, vbv_parameters;
401 guint8 video_object_layer_shape, video_object_layer_verid = 0;
403 /* if(next_bits() == video_object_layer_start_code) { */
404 dword = tvb_get_bits32(tvb,bit_offset, 24, FALSE);
408 octet = tvb_get_bits8(tvb,bit_offset+24, 8);
409 if((octet>=0x20)&&(octet<=0x2f)){
414 /* video_object_layer_start_code */
415 proto_tree_add_bits_item(tree, hf_mp4ves_start_code_prefix, tvb, bit_offset, 24, FALSE);
417 proto_tree_add_bits_item(tree, hf_mp4ves_start_code, tvb, bit_offset, 8, FALSE);
420 /* short_video_header = 0 */
421 /* random_accessible_vol 1 */
422 proto_tree_add_bits_item(tree, hf_mp4ves_random_accessible_vol, tvb, bit_offset, 1, FALSE);
424 /* video_object_type_indication 8 */
425 proto_tree_add_bits_item(tree, hf_mp4ves_video_object_type_indication, tvb, bit_offset, 8, FALSE);
427 /* is_object_layer_identifier 1 */
428 is_object_layer_identifier = tvb_get_bits8(tvb,bit_offset, 1);
429 proto_tree_add_bits_item(tree, hf_mp4ves_is_object_layer_identifier, tvb, bit_offset, 1, FALSE);
431 if(is_object_layer_identifier) {
432 /* video_object_layer_verid 4 uimsbf */
434 /* video_object_layer_priority 3 uimsbf */
437 /* aspect_ratio_info 4 uimsbf */
438 aspect_ratio_info = tvb_get_bits8(tvb,bit_offset, 1);
439 proto_tree_add_bits_item(tree, hf_mp4ves_aspect_ratio_info, tvb, bit_offset, 4, FALSE);
440 if (aspect_ratio_info == 0xf /*"extended_PAR"*/ ) {
441 /* par_width 8 uimsbf */
443 /* par_height 8 uimsbf */
446 /* vol_control_parameters 1 bslbf */
447 /* vol_control_parameters 1 bslbf */
448 vol_control_parameters = tvb_get_bits8(tvb,bit_offset, 1);
449 proto_tree_add_bits_item(tree, hf_mp4ves_vol_control_parameters, tvb, bit_offset, 1, FALSE);
451 current_bit_offset = bit_offset;
452 if (vol_control_parameters) {
453 /* chroma_format 2 uimsbf */
455 /* low_delay 1 uimsbf */
457 /* vbv_parameters 1 blsbf */
458 vbv_parameters = tvb_get_bits8(tvb,bit_offset, 1);
460 if (vbv_parameters) {
461 /* first_half_bit_rate 15 uimsbf */
463 /* marker_bit 1 bslbf */
465 /* latter_half_bit_rate 15 uimsbf */
467 /* marker_bit 1 bslbf */
469 /* first_half_vbv_buffer_size 15 uimsbf */
471 /* marker_bit 1 bslbf */
473 /* latter_half_vbv_buffer_size 3 uimsbf */
475 /* first_half_vbv_occupancy 11 uimsbf */
477 /* marker_bit 1 blsbf */
479 /* latter_half_vbv_occupancy 15 uimsbf */
481 /* marker_bit 1 blsbf */
485 if(bit_offset-current_bit_offset > 0)
486 proto_tree_add_text(tree, tvb, current_bit_offset>>3, (bit_offset+7)>>3, "Not dissected bits");
487 /* video_object_layer_shape 2 uimsbf */
488 video_object_layer_shape = tvb_get_bits8(tvb,bit_offset, 2);
489 proto_tree_add_bits_item(tree, hf_mp4ves_video_object_layer_shape, tvb, bit_offset, 2, FALSE);
491 if (video_object_layer_shape == 3/*"grayscale"*/&& video_object_layer_verid != 1){
492 /* video_object_layer_shape_extension 4 uimsbf */
495 /* marker_bit 1 bslbf */
497 /* vop_time_increment_resolution 16 uimsbf */
499 /* marker_bit 1 bslbf */
501 /* fixed_vop_rate 1 bslbf */
510 visual_object_start_code
511 is_visual_object_identifier
512 if (is_visual_object_identifier) {
514 visual_object_priority
517 if (visual_object_type == "Video ID" || visual_object_type == "still textureID") {
521 while ( next_bits()== user_data_start_code){
524 if (visual_object_type == "Video ID") {
525 video_object_start_code
528 else if (visual_object_type == "still texture ID") {
531 else if (visual_object_type == "mesh ID") {
534 else if (visual_object_type == "FBA ID") {
537 else if (visual_object_type == "3D mesh ID") {
540 if (next_bits() != "0000 0000 0000 0000 0000 0001")
545 dissect_mp4ves_VisualObject(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int bit_offset)
548 guint8 is_visual_object_identifier, visual_object_type;
552 is_visual_object_identifier = tvb_get_bits8(tvb,bit_offset,1);
553 proto_tree_add_bits_item(tree, hf_mp4ves_is_visual_object_identifier, tvb, bit_offset, 1, FALSE);
555 if(is_visual_object_identifier){
556 /* visual_object_verid 4 bits*/
558 /* visual_object_priority 3 bits*/
561 /* visual_object_type 4 bits*/
562 visual_object_type = tvb_get_bits8(tvb,bit_offset,4);
563 proto_tree_add_bits_item(tree, hf_mp4ves_visual_object_type, tvb, bit_offset, 4, FALSE);
565 if ((visual_object_type == 1/*"Video ID"*/) || (visual_object_type == 2/*"still textureID"*/)) {
566 /* video_signal_type() */
567 bit_offset = dissect_mp4ves_visual_object_type(tvb, pinfo, tree, bit_offset);
569 /* next_start_code() */
570 bit_offset = dissect_mp4ves_next_start_code(tvb, pinfo, tree, bit_offset);
571 dword = tvb_get_bits32(tvb,bit_offset, 32, FALSE);
573 while ( next_bits()== user_data_start_code){
578 bit_offset = dissect_mp4ves_user_data(tvb, pinfo, tree, bit_offset);
579 dword = tvb_get_bits32(tvb,bit_offset, 32, FALSE);
581 if (visual_object_type == 1/*"Video ID"*/) {
583 * video_object_start_code
585 dword = tvb_get_bits32(tvb,bit_offset, 24, FALSE);
590 octet = tvb_get_bits8(tvb,bit_offset+24, 8);
595 proto_tree_add_bits_item(tree, hf_mp4ves_start_code_prefix, tvb, bit_offset, 24, FALSE);
597 proto_tree_add_bits_item(tree, hf_mp4ves_start_code, tvb, bit_offset, 8, FALSE);
599 if(tvb_length_remaining(tvb,(bit_offset>>3))==0){
600 item = proto_tree_add_text(tree, tvb, 0, -1, "Config string to short");
601 PROTO_ITEM_SET_GENERATED(item);
607 bit_offset = dissect_mp4ves_VideoObjectLayer(tvb, pinfo, tree, bit_offset);
614 dissect_mp4ves_VisualObjectSequence(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int bit_offset)
618 /*VisualObjectSequence() {
620 visual_object_sequence_start_code
623 /* Get start code prefix */
624 dword = tvb_get_bits32(tvb,bit_offset, 32, FALSE);
625 if ((dword & 0x00000100) != 0x00000100){
626 /* No start code prefix */
629 proto_tree_add_bits_item(tree, hf_mp4ves_start_code_prefix, tvb, bit_offset, 24, FALSE);
632 proto_tree_add_bits_item(tree, hf_mp4ves_start_code, tvb, bit_offset, 8, FALSE);
635 /* Expect visual_object_sequence_start_code */
638 /* profile_and_level_indication */
639 proto_tree_add_bits_item(tree, hf_mp4ves_profile_and_level_indication, tvb, bit_offset, 8, FALSE);
642 /* while ( next_bits()== user_data_start_code){
646 dword = tvb_get_bits32(tvb,bit_offset, 32, FALSE);
648 if ((dword & 0x00000100) != 0x00000100){
649 /* No start code prefix */
654 * user_data_start_code
655 * XXX call user data dissection here
663 bit_offset = dissect_mp4ves_VisualObject(tvb, pinfo, tree, bit_offset);
666 } while ( next_bits() != visual_object_sequence_end_code)
667 visual_object_sequence_end_code
673 dissect_mp4ves_config(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
676 proto_tree *mp4ves_tree;
678 item = proto_tree_add_item(tree, hf_mp4ves_config, tvb, 0, -1, FALSE);
679 mp4ves_tree = proto_item_add_subtree(item, ett_mp4ves_config);
681 dissect_mp4ves_VisualObjectSequence(tvb, pinfo, tree, 0);
685 dissect_mp4ves(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
689 proto_tree *mp4ves_tree;
692 /* Make entries in Protocol column and Info column on summary display */
693 col_set_str(pinfo->cinfo, COL_PROTOCOL, "MP4V-ES");
695 item = proto_tree_add_item(tree, proto_mp4ves, tvb, 0, -1, FALSE);
696 mp4ves_tree = proto_item_add_subtree(item, ett_mp4ves);
698 +------+------+------+------+
699 (a) | RTP | VS | VO | VOL |
700 |header|header|header|header|
701 +------+------+------+------+
703 +------+------+------+------+------------+
704 (b) | RTP | VS | VO | VOL |Video Packet|
705 |header|header|header|header| |
706 +------+------+------+------+------------+
708 +------+-----+------------------+
709 (c) | RTP | GOV |Video Object Plane|
711 +------+-----+------------------+
713 +------+------+------------+ +------+------+------------+
714 (d) | RTP | VOP |Video Packet| | RTP | VP |Video Packet|
715 |header|header| (1) | |header|header| (2) |
716 +------+------+------------+ +------+------+------------+
718 +------+------+------------+------+------------+------+------------+
719 (e) | RTP | VP |Video Packet| VP |Video Packet| VP |Video Packet|
720 |header|header| (1) |header| (2) |header| (3) |
721 +------+------+------------+------+------------+------+------------+
723 +------+------+------------+ +------+------------+
724 (f) | RTP | VOP |VOP fragment| | RTP |VOP fragment|
725 |header|header| (1) | |header| (2) | ___
726 +------+------+------------+ +------+------------+
728 Figure 2 - Examples of RTP packetized MPEG-4 Visual bitstream
730 So a valid packet should start with
731 VS - Visual Object Sequence Header
732 GOV - Group_of_VideoObjectPlane
733 VOP - Video Object Plane
735 Otherwies it's a VOP fragment.
737 visual_object_sequence_start_code: The visual_object_sequence_start_code is
738 the bit string '000001B0' in hexadecimal. It initiates a visual session.
740 group_of_vop_start_code: The group_of_vop_start_code is the bit string '000001B3' in hexadecimal. It identifies
741 the beginning of a GOV header.
743 vop_start_code: This is the bit string '000001B6' in hexadecimal.
747 if (tvb_length(tvb)< 4){
748 /* To short to be a start code */
749 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "Data");
752 dword = tvb_get_bits32(tvb,bit_offset, 24, FALSE);
754 /* if it's not 23 zeros followed by 1 it isn't a start code */
755 proto_tree_add_text(tree, tvb, bit_offset>>3, -1, "Data");
758 dword = tvb_get_bits8(tvb,24, 8);
759 bit_offset = bit_offset+8;
763 proto_tree_add_bits_item(tree, hf_mp4ves_start_code_prefix, tvb, bit_offset, 24, FALSE);
764 bit_offset = bit_offset+24;
765 /* vop_coding_type 2 bits */
766 proto_tree_add_bits_item(tree, hf_mp4ves_vop_coding_type, tvb, bit_offset, 2, FALSE);
770 bit_offset = dissect_mp4ves_VisualObjectSequence(tvb, pinfo, tree, 0);
773 proto_tree_add_bits_item(tree, hf_mp4ves_start_code_prefix, tvb, bit_offset, 24, FALSE);
774 bit_offset = bit_offset+24;
781 * Parameter name profileAndLevel
782 * Parameter description This is a nonCollapsing GenericParameter
783 * Parameter identifier value 0
784 * Parameter status Mandatory
785 * Parameter type unsignedMax. Shall be in the range 0..255.
787 * unsignedMax INTEGER(0..65535), -- Look for max
790 dissect_mp4ves_par_profile(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
794 const gchar *p = NULL;
797 actx = get_asn1_ctx(pinfo->private_data);
798 DISSECTOR_ASSERT(actx);
800 lvl = tvb_get_ntohs(tvb, offset);
801 p = match_strval(lvl, VALS(mp4ves_level_indication_vals));
803 proto_item_append_text(actx->created_item, " - profileAndLevel %s", p);
809 dissect_mp4ves_par_video_object_type(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
813 const gchar *p = NULL;
816 actx = get_asn1_ctx(pinfo->private_data);
817 DISSECTOR_ASSERT(actx);
819 lvl = tvb_get_ntohs(tvb, offset);
820 p = match_strval(lvl, VALS(mp4ves_video_object_type_vals));
822 proto_item_append_text(actx->created_item, " - video_object_type %s", p);
829 dissect_mp4ves_par_decoderConfigurationInformation(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_)
833 actx = get_asn1_ctx(pinfo->private_data);
834 DISSECTOR_ASSERT(actx);
836 dissect_mp4ves_config(tvb, pinfo, tree);
838 return tvb_length(tvb);
841 typedef struct _mp4ves_capability_t {
844 new_dissector_t content_pdu;
845 } mp4ves_capability_t;
847 static mp4ves_capability_t mp4ves_capability_tab[] = {
848 /* ITU-T H.245 capabilities ISO/IEC 14496-2(m*/
849 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/0", "profileAndLevel", dissect_mp4ves_par_profile },
850 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/1", "object", dissect_mp4ves_par_video_object_type },
851 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/2", "decoderConfigurationInformation", dissect_mp4ves_par_decoderConfigurationInformation },
852 { "GenericCapability/0.0.8.245.1.0.0/nonCollapsing/3", "drawingOrder", NULL },
853 { "GenericCapability/0.0.8.245.1.0.0/collapsing/4", "visualBackChannelHandle", NULL },
854 { NULL, NULL, NULL },
857 static mp4ves_capability_t *find_cap(const gchar *id) {
858 mp4ves_capability_t *ftr = NULL;
859 mp4ves_capability_t *f;
861 for (f=mp4ves_capability_tab; f->id; f++) {
862 if (!strcmp(id, f->id)) { ftr = f; break; }
868 dissect_mp4ves_name(tvbuff_t *tvb _U_, packet_info *pinfo, proto_tree *tree)
871 mp4ves_capability_t *ftr = NULL;
873 actx = get_asn1_ctx(pinfo->private_data);
874 DISSECTOR_ASSERT(actx);
876 ftr = find_cap(pinfo->match_string);
878 proto_item_append_text(actx->created_item, " - %s", ftr->name);
879 proto_item_append_text(proto_item_get_parent(proto_tree_get_parent(tree)), ": %s", ftr->name);
881 proto_item_append_text(actx->created_item, " - unknown(%s)", pinfo->match_string);
887 proto_reg_handoff_mp4ves(void);
890 proto_register_mp4ves(void)
894 /* Setup list of header fields See Section 1.6.1 for details*/
895 static hf_register_info hf[] = {
897 { "Configuration", "mp4ves.configuration",
898 FT_BYTES, BASE_NONE, NULL, 0x0,
901 { &hf_mp4ves_start_code_prefix,
902 { "start code prefix", "mp4ves.start_code_prefix",
903 FT_UINT32, BASE_HEX, NULL, 0x0,
906 { &hf_mp4ves_start_code,
907 { "Start code", "mp4ves.start_code",
908 FT_UINT8, BASE_RANGE_STRING|BASE_HEX, RVALS(&mp4ves_startcode_vals), 0x0,
911 { &hf_mp4ves_vop_coding_type,
912 { "vop_coding_type", "mp4ves.vop_coding_type",
913 FT_UINT8, BASE_DEC, VALS(mp4ves_vop_coding_type_vals), 0x0,
914 "Start code", HFILL }
916 {&hf_mp4ves_profile_and_level_indication,
917 { "profile_and_level_indication", "mp4ves.profile_and_level_indication",
918 FT_UINT8, BASE_DEC,VALS(mp4ves_level_indication_vals), 0x0,
921 { &hf_mp4ves_is_visual_object_identifier,
922 { "visual_object_identifier", "mp4ves.visual_object_identifier",
923 FT_UINT8, BASE_DEC, NULL, 0x0,
926 { &hf_mp4ves_visual_object_type,
927 { "visual_object_type", "mp4ves.visual_object_type",
928 FT_UINT32, BASE_DEC, VALS(mp4ves_visual_object_type_vals), 0x0,
931 { &hf_mp4ves_video_signal_type,
932 { "video_signal_type", "mp4ves.video_signal_type",
933 FT_UINT8, BASE_DEC, NULL, 0x0,
936 { &hf_mp4ves_stuffing,
937 { "Stuffing", "mp4ves.stuffing",
938 FT_UINT8, BASE_DEC, NULL, 0x0,
941 { &hf_mp4ves_video_object_type_indication,
942 { "video_object_type_indication", "mp4ves.video_object_type_indication",
943 FT_UINT8, BASE_DEC, VALS(mp4ves_video_object_type_indication_vals), 0x0,
946 { &hf_mp4ves_random_accessible_vol,
947 { "random_accessible_vol", "mp4ves.random_accessible_vol",
948 FT_UINT8, BASE_DEC, NULL, 0x0,
949 "video_object_type_indication", HFILL }
951 { &hf_mp4ves_is_object_layer_identifier,
952 { "is_object_layer_identifier", "mp4ves.is_object_layer_identifier",
953 FT_UINT8, BASE_DEC, NULL, 0x0,
956 { &hf_mp4ves_aspect_ratio_info,
957 { "aspect_ratio_info", "mp4ves.aspect_ratio_info",
958 FT_UINT8, BASE_DEC, VALS(mp4ves_aspect_ratio_info_vals), 0x0,
961 { &hf_mp4ves_vol_control_parameters,
962 { "vol_control_parameters", "mp4ves.vol_control_parameters",
963 FT_UINT8, BASE_DEC, NULL, 0x0,
966 { &hf_mp4ves_video_object_layer_shape,
967 { "video_object_layer_shape", "mp4ves.video_object_layer_shape",
968 FT_UINT8, BASE_DEC, VALS(mp4ves_video_object_layer_shape_vals), 0x0,
973 /* Setup protocol subtree array */
974 static gint *ett[] = {
979 module_t *mp4ves_module;
981 /* Register the protocol name and description */
982 proto_mp4ves = proto_register_protocol("MP4V-ES","MP4V-ES", "mp4v-es");
984 /* Required function calls to register the header fields and subtrees used */
985 proto_register_field_array(proto_mp4ves, hf, array_length(hf));
986 proto_register_subtree_array(ett, array_length(ett));
987 /* Register a configuration option for port */
989 register_dissector("mp4ves", dissect_mp4ves, proto_mp4ves);
991 /* Register a configuration option for port */
992 mp4ves_module = prefs_register_protocol(proto_mp4ves, proto_reg_handoff_mp4ves);
994 prefs_register_uint_preference(mp4ves_module,
995 "dynamic.payload.type",
996 "MP4V-ES dynamic payload type",
997 "The dynamic payload type which will be interpreted as MP4V-ES",
999 &global_dynamic_payload_type);
1004 proto_reg_handoff_mp4ves(void)
1006 static dissector_handle_t mp4ves_handle;
1007 static guint dynamic_payload_type;
1008 static gboolean mp4ves_prefs_initialized = FALSE;
1010 if (!mp4ves_prefs_initialized) {
1011 dissector_handle_t mp4ves_name_handle;
1012 mp4ves_capability_t *ftr;
1014 mp4ves_handle = find_dissector("mp4ves");
1015 dissector_add_string("rtp_dyn_payload_type","MP4V-ES", mp4ves_handle);
1016 mp4ves_prefs_initialized = TRUE;
1018 mp4ves_name_handle = create_dissector_handle(dissect_mp4ves_name, proto_mp4ves);
1019 for (ftr=mp4ves_capability_tab; ftr->id; ftr++) {
1021 dissector_add_string("h245.gef.name", ftr->id, mp4ves_name_handle);
1022 if (ftr->content_pdu)
1023 dissector_add_string("h245.gef.content", ftr->id, new_create_dissector_handle(ftr->content_pdu, proto_mp4ves));
1026 if ( dynamic_payload_type > 95 )
1027 dissector_delete("rtp.pt", dynamic_payload_type, mp4ves_handle);
1029 dynamic_payload_type = global_dynamic_payload_type;
1031 if ( dynamic_payload_type > 95 ){
1032 dissector_add("rtp.pt", dynamic_payload_type, mp4ves_handle);