3 * Routines for RFC 2250 MPEG-1 dissection
5 * $Id: packet-mpeg1.c,v 1.3 2001/07/16 05:16:57 guy Exp $
8 * Francisco Javier Cabello Torres, <fjcabello@vtools.es>
10 * Ethereal - Network traffic analyzer
11 * By Gerald Combs <gerald@ethereal.com>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 * This dissector tries to dissect the MPEG-1 video streams.
32 * This dissector is called by the RTP dissector
43 #ifdef HAVE_SYS_TYPES_H
44 # include <sys/types.h>
47 #ifdef HAVE_NETINET_IN_H
48 # include <netinet/in.h>
54 #define RTP_MPG_MBZ(word) ( word >> 11)
55 #define RTP_MPG_T(word) ( (word >> 10) & 1 )
56 #define RTP_MPG_TR(word) ( word & 0x3ff )
58 #define RTP_MPG_AN(octet) ( octet >> 7)
59 #define RTP_MPG_N(octet) ( (octet >> 6) & 1 )
60 #define RTP_MPG_S(octet) ( (octet >> 5) & 1 )
61 #define RTP_MPG_B(octet) ( (octet >> 4) & 1 )
62 #define RTP_MPG_E(octet) ( (octet >> 3) & 1 )
63 #define RTP_MPG_P(octet) ( octet & 7 )
65 #define RTP_MPG_FBV(octet) ( (octet >> 7) & 1 )
66 #define RTP_MPG_BFC(octet) ( (octet >> 4) & 7 )
67 #define RTP_MPG_FFV(octet) ( (octet >> 3) & 1 )
68 #define RTP_MPG_FFC(octet) ( octet & 7 )
71 /* MPEG1 header fields */
74 static int proto_mpg = -1;
76 static int hf_rtp_mpg_mbz = -1;
77 static int hf_rtp_mpg_T = -1;
78 static int hf_rtp_mpg_tr = -1;
79 static int hf_rtp_mpg_an = -1;
80 static int hf_rtp_mpg_n = -1;
81 static int hf_rtp_mpg_s = -1;
82 static int hf_rtp_mpg_b = -1;
83 static int hf_rtp_mpg_e = -1;
84 static int hf_rtp_mpg_p = -1;
87 static int hf_rtp_mpg_fbv = -1;
88 static int hf_rtp_mpg_bfc = -1;
89 static int hf_rtp_mpg_ffv = -1;
90 static int hf_rtp_mpg_ffc = -1;
91 static int hf_rtp_mpg_data = -1;
95 /* MPEG-1 fields defining a sub tree */
96 static gint ett_mpg = -1;
98 static const value_string rtp_mpg_picture_types_vals[] =
112 dissect_mpeg1( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
114 proto_item *ti = NULL;
115 proto_tree *mpg_tree = NULL;
116 unsigned int offset = 0;
136 if ( check_col( pinfo->fd, COL_PROTOCOL ) )
138 col_set_str( pinfo->fd, COL_PROTOCOL, "MPEG-1" );
141 if ( check_col( pinfo->fd, COL_INFO) )
143 col_set_str( pinfo->fd, COL_INFO, "MPEG-1 message");
146 /* Get MPEG-1 fields */
148 word = tvb_get_guint8( tvb, offset );
149 word = (word << 8) | tvb_get_guint8( tvb, offset +1 );
150 mpg_mbz = RTP_MPG_MBZ(word);
151 mpg_T = RTP_MPG_T(word);
152 mpg_tr = RTP_MPG_TR(word);
154 octet = tvb_get_guint8( tvb, offset + 2 );
155 mpg_an = RTP_MPG_AN(octet);
156 mpg_n = RTP_MPG_N(octet);
157 mpg_s = RTP_MPG_S(octet);
158 mpg_b = RTP_MPG_B(octet);
159 mpg_e = RTP_MPG_E(octet);
160 mpg_p = RTP_MPG_P(octet);
162 octet = tvb_get_guint8( tvb, offset + 3 );
164 mpg_fbv = RTP_MPG_FBV(octet);
165 mpg_bfc = RTP_MPG_BFC(octet);
166 mpg_ffv = RTP_MPG_FFV(octet);
167 mpg_ffc = RTP_MPG_FFC(octet);
172 ti = proto_tree_add_item( tree, proto_mpg, tvb, offset, tvb_length( tvb ), FALSE );
173 mpg_tree = proto_item_add_subtree( ti, ett_mpg );
175 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_mbz, tvb, offset, 1, mpg_mbz );
176 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_T , tvb, offset, 1, mpg_T );
177 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_tr , tvb, offset, 2, mpg_tr );
179 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_an, tvb, offset, 1, mpg_an );
180 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_n , tvb, offset, 1, mpg_n );
181 proto_tree_add_boolean( mpg_tree, hf_rtp_mpg_s , tvb, offset, 1, mpg_s );
182 proto_tree_add_boolean( mpg_tree, hf_rtp_mpg_b , tvb, offset, 1, mpg_b );
183 proto_tree_add_boolean( mpg_tree, hf_rtp_mpg_e , tvb, offset, 1, mpg_e );
185 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_p, tvb , offset, 1, mpg_p );
188 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_fbv, tvb, offset, 1, mpg_fbv );
189 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_bfc, tvb, offset, 1, mpg_bfc );
190 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_ffv, tvb, offset, 1, mpg_ffv );
191 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_ffc, tvb, offset, 1, mpg_ffc );
194 /* The rest of the packet is the MPEG-1 stream */
195 proto_tree_add_item( mpg_tree, hf_rtp_mpg_data, tvb, offset, tvb_length_remaining( tvb, offset ), FALSE );
201 proto_register_mpeg1(void)
203 static hf_register_info hf[] =
209 "rtp.payload_mpeg_mbz",
221 "rtp.payload_mpeg_T",
232 "Temporal Reference",
233 "rtp.payload_mpeg_tr",
245 "rtp.payload_mpeg_an",
257 "New Picture Header",
258 "rtp.payload_mpeg_n",
271 "rtp.payload_mpeg_s",
283 "Beginning-of-slice",
284 "rtp.payload_mpeg_b",
297 "rtp.payload_mpeg_an",
310 "rtp.payload_mpeg_p",
313 VALS(rtp_mpg_picture_types_vals),
323 "rtp.payload_mpeg_fbv",
336 "rtp.payload_mpeg_bfc",
348 "rtp.payload_mpeg_ffv",
361 "rtp.payload_mpeg_ffc",
390 proto_mpg = proto_register_protocol("RFC 2250 MPEG1","MPEG1","mpeg1");
391 proto_register_field_array(proto_mpg, hf, array_length(hf));
392 proto_register_subtree_array(ett, array_length(ett));
394 register_dissector("mpeg1", dissect_mpeg1, proto_mpg);