3 * Routines for RFC-4629-encapsulated H.263 dissection
5 * Copyright 2003 Niklas Ogren <niklas.ogren@7l.se>
6 * Seven Levels Consultants AB
8 * Copyright 2008 Richard van der Hoff, MX Telecom
9 * <richardv@mxtelecom.com>
13 * Wireshark - Network traffic analyzer
14 * By Gerald Combs <gerald@wireshark.org>
15 * Copyright 1998 Gerald Combs
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 #include <epan/packet.h>
37 #include <epan/prefs.h>
39 #include "packet-h263.h"
41 static int proto_h263P
= -1;
43 /* H.263 RFC 4629 fields */
44 static int hf_h263P_payload
= -1;
45 static int hf_h263P_rr
= -1;
46 static int hf_h263P_pbit
= -1;
47 static int hf_h263P_vbit
= -1;
48 static int hf_h263P_plen
= -1;
49 static int hf_h263P_pebit
= -1;
50 static int hf_h263P_tid
= -1;
51 static int hf_h263P_trun
= -1;
52 static int hf_h263P_s
= -1;
53 static int hf_h263P_extra_hdr
= -1;
54 /* static int hf_h263P_PSC = -1; */
55 /* static int hf_h263P_TR = -1; */
58 /* H.263-1998 fields defining a sub tree */
59 static gint ett_h263P
= -1;
60 static gint ett_h263P_extra_hdr
= -1;
61 static gint ett_h263P_payload
= -1;
62 static gint ett_h263P_data
= -1;
64 /* The dynamic payload type which will be dissected as H.263-1998/H263-2000 */
66 static guint temp_dynamic_payload_type
= 0;
70 dissect_h263P( tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
72 proto_item
*ti
= NULL
;
73 proto_item
*data_item
= NULL
;
74 proto_item
*extra_hdr_item
= NULL
;
75 proto_tree
*h263P_tree
= NULL
;
76 proto_tree
*h263P_extr_hdr_tree
= NULL
;
77 proto_tree
*h263P_data_tree
= NULL
;
78 unsigned int offset
= 0;
86 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "H.263 RFC4629 ");
89 ti
= proto_tree_add_item( tree
, proto_h263P
, tvb
, offset
, -1, ENC_NA
);
90 h263P_tree
= proto_item_add_subtree( ti
, ett_h263P
);
92 data16
= tvb_get_ntohs(tvb
,offset
);
93 proto_tree_add_item( h263P_tree
, hf_h263P_rr
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
94 proto_tree_add_item( h263P_tree
, hf_h263P_pbit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
95 proto_tree_add_item( h263P_tree
, hf_h263P_vbit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
96 proto_tree_add_item( h263P_tree
, hf_h263P_plen
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
97 proto_tree_add_item( h263P_tree
, hf_h263P_pebit
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
102 * Indicates the presence of an 8-bit field containing information
103 * for Video Redundancy Coding (VRC), which follows immediately after
104 * the initial 16 bits of the payload header, if present. For syntax
105 * and semantics of that 8-bit VRC field, see Section 5.2.
108 if ((data16
&0x0200)==0x0200){
110 * The format of the VRC header extension is as follows:
119 * Thread ID. Up to 7 threads are allowed. Each frame of H.263+ VRC
120 * data will use as reference information only sync frames or frames
121 * within the same thread. By convention, thread 0 is expected to be
122 * the "canonical" thread, which is the thread from which the sync frame
123 * should ideally be used. In the case of corruption or loss of the
124 * thread 0 representation, a representation of the sync frame with a
125 * higher thread number can be used by the decoder. Lower thread
126 * numbers are expected to contain representations of the sync frames
127 * equal to or better than higher thread numbers in the absence of data
128 * corruption or loss. See [Vredun] for a detailed discussion of VRC.
132 * Monotonically increasing (modulo 16) 4-bit number counting the packet
133 * number within each thread.
137 * A bit that indicates that the packet content is for a sync frame.
140 proto_tree_add_item( h263P_tree
, hf_h263P_tid
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
141 proto_tree_add_item( h263P_tree
, hf_h263P_trun
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
142 proto_tree_add_item( h263P_tree
, hf_h263P_s
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
146 /* Length, in bytes, of the extra picture header. */
147 plen
= (data16
& 0x01f8) >> 3;
149 extra_hdr_item
= proto_tree_add_item( h263P_tree
, hf_h263P_extra_hdr
, tvb
, offset
, plen
, ENC_NA
);
150 h263P_extr_hdr_tree
= proto_item_add_subtree( extra_hdr_item
, ett_h263P_extra_hdr
);
151 dissect_h263_picture_layer( tvb
, pinfo
, h263P_extr_hdr_tree
, offset
, plen
, TRUE
);
154 if ((data16
&0x0400)!=0){
156 data_item
= proto_tree_add_item( h263P_tree
, hf_h263P_payload
, tvb
, offset
, -1, ENC_NA
);
157 h263P_data_tree
= proto_item_add_subtree( data_item
, ett_h263P_data
);
158 /* Startc code holds bit 17 -23 of the codeword */
159 startcode
= tvb_get_guint8(tvb
,offset
)&0xfe;
160 if (startcode
& 0x80){
161 /* All picture, slice, and EOSBS start codes
162 * shall be byte aligned, and GOB and EOS start codes may be byte aligned.
166 /* End Of Sub-Bitstream code (EOSBS)
167 * EOSBS codes shall be byte aligned
173 /* Picture Start Code (PSC)
176 col_append_str( pinfo
->cinfo
, COL_INFO
, "(PSC) ");
177 dissect_h263_picture_layer( tvb
, pinfo
, h263P_data_tree
, offset
, -1, TRUE
);
181 /* End Of Sequence (EOS)
185 /* Group of Block Start Code (GBSC) or
186 * Slice Start Code (SSC)
188 col_append_str( pinfo
->cinfo
, COL_INFO
, "(GBSC) ");
189 dissect_h263_group_of_blocks_layer( tvb
, h263P_data_tree
, offset
,TRUE
);
197 proto_tree_add_item( h263P_tree
, hf_h263P_payload
, tvb
, offset
, -1, ENC_NA
);
202 proto_reg_handoff_h263P(void)
204 static dissector_handle_t h263P_handle
;
205 static guint dynamic_payload_type
;
206 static gboolean h263P_prefs_initialized
= FALSE
;
208 if (!h263P_prefs_initialized
) {
209 h263P_handle
= find_dissector("h263P");
210 dissector_add_string("rtp_dyn_payload_type","H263-1998", h263P_handle
);
211 dissector_add_string("rtp_dyn_payload_type","H263-2000", h263P_handle
);
212 h263P_prefs_initialized
= TRUE
;
215 if ( dynamic_payload_type
> 95 )
216 dissector_delete_uint("rtp.pt", dynamic_payload_type
, h263P_handle
);
218 dynamic_payload_type
= temp_dynamic_payload_type
;
220 if ( dynamic_payload_type
> 95 ){
221 dissector_add_uint("rtp.pt", dynamic_payload_type
, h263P_handle
);
227 proto_register_h263P(void)
229 module_t
*h263P_module
;
231 static hf_register_info hf
[] =
236 "H.263 RFC4629 payload",
242 "The actual H.263 RFC4629 data", HFILL
254 "Reserved SHALL be zero", HFILL
266 "Indicates (GOB/Slice) start or (EOS or EOSBS)", HFILL
278 "presence of Video Redundancy Coding (VRC) field", HFILL
290 "Length, in bytes, of the extra picture header", HFILL
302 "number of bits that shall be ignored in the last byte of the picture header", HFILL
328 "Monotonically increasing (modulo 16) 4-bit number counting the packet number within each thread", HFILL
340 "Indicates that the packet content is for a sync frame", HFILL
346 "Extra picture header",
365 "Picture Start Code(PSC)", HFILL
373 "H.263 Temporal Reference",
379 "Temporal Reference, TR", HFILL
389 &ett_h263P_extra_hdr
,
395 proto_h263P
= proto_register_protocol("ITU-T Recommendation H.263 RTP Payload header (RFC4629)",
398 proto_register_field_array(proto_h263P
, hf
, array_length(hf
));
399 proto_register_subtree_array(ett
, array_length(ett
));
401 h263P_module
= prefs_register_protocol(proto_h263P
, proto_reg_handoff_h263P
);
403 prefs_register_uint_preference(h263P_module
, "dynamic.payload.type",
404 "H263-1998 and H263-2000 dynamic payload type",
405 "The dynamic payload type which will be interpreted as H264"
406 "; The value must be greater than 95",
408 &temp_dynamic_payload_type
);
410 register_dissector("h263P", dissect_h263P
, proto_h263P
);