3 * Routines for RFC 2250 MPEG-1 dissection
5 * $Id: packet-mpeg1.c,v 1.10 2003/08/23 06:36:46 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.
39 #include <epan/packet.h>
46 #define RTP_MPG_MBZ(word) ( word >> 11)
47 #define RTP_MPG_T(word) ( (word >> 10) & 1 )
48 #define RTP_MPG_TR(word) ( word & 0x3ff )
50 #define RTP_MPG_AN(octet) ( octet >> 7)
51 #define RTP_MPG_N(octet) ( (octet >> 6) & 1 )
52 #define RTP_MPG_S(octet) ( (octet >> 5) & 1 )
53 #define RTP_MPG_B(octet) ( (octet >> 4) & 1 )
54 #define RTP_MPG_E(octet) ( (octet >> 3) & 1 )
55 #define RTP_MPG_P(octet) ( octet & 7 )
57 #define RTP_MPG_FBV(octet) ( (octet >> 7) & 1 )
58 #define RTP_MPG_BFC(octet) ( (octet >> 4) & 7 )
59 #define RTP_MPG_FFV(octet) ( (octet >> 3) & 1 )
60 #define RTP_MPG_FFC(octet) ( octet & 7 )
63 /* MPEG1 header fields */
66 static int proto_mpg = -1;
68 static int hf_rtp_mpg_mbz = -1;
69 static int hf_rtp_mpg_T = -1;
70 static int hf_rtp_mpg_tr = -1;
71 static int hf_rtp_mpg_an = -1;
72 static int hf_rtp_mpg_n = -1;
73 static int hf_rtp_mpg_s = -1;
74 static int hf_rtp_mpg_b = -1;
75 static int hf_rtp_mpg_e = -1;
76 static int hf_rtp_mpg_p = -1;
79 static int hf_rtp_mpg_fbv = -1;
80 static int hf_rtp_mpg_bfc = -1;
81 static int hf_rtp_mpg_ffv = -1;
82 static int hf_rtp_mpg_ffc = -1;
83 static int hf_rtp_mpg_data = -1;
87 /* MPEG-1 fields defining a sub tree */
88 static gint ett_mpg = -1;
90 static const value_string rtp_mpg_picture_types_vals[] =
104 dissect_mpeg1( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
106 proto_item *ti = NULL;
107 proto_tree *mpg_tree = NULL;
108 unsigned int offset = 0;
128 if ( check_col( pinfo->cinfo, COL_PROTOCOL ) )
130 col_set_str( pinfo->cinfo, COL_PROTOCOL, "MPEG-1" );
133 if ( check_col( pinfo->cinfo, COL_INFO) )
135 col_set_str( pinfo->cinfo, COL_INFO, "MPEG-1 message");
138 /* Get MPEG-1 fields */
140 word = tvb_get_guint8( tvb, offset );
141 word = (word << 8) | tvb_get_guint8( tvb, offset +1 );
142 mpg_mbz = RTP_MPG_MBZ(word);
143 mpg_T = RTP_MPG_T(word);
144 mpg_tr = RTP_MPG_TR(word);
146 octet = tvb_get_guint8( tvb, offset + 2 );
147 mpg_an = RTP_MPG_AN(octet);
148 mpg_n = RTP_MPG_N(octet);
149 mpg_s = RTP_MPG_S(octet);
150 mpg_b = RTP_MPG_B(octet);
151 mpg_e = RTP_MPG_E(octet);
152 mpg_p = RTP_MPG_P(octet);
154 octet = tvb_get_guint8( tvb, offset + 3 );
156 mpg_fbv = RTP_MPG_FBV(octet);
157 mpg_bfc = RTP_MPG_BFC(octet);
158 mpg_ffv = RTP_MPG_FFV(octet);
159 mpg_ffc = RTP_MPG_FFC(octet);
164 ti = proto_tree_add_item( tree, proto_mpg, tvb, offset, -1, FALSE );
165 mpg_tree = proto_item_add_subtree( ti, ett_mpg );
167 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_mbz, tvb, offset, 1, mpg_mbz );
168 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_T , tvb, offset, 1, mpg_T );
169 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_tr , tvb, offset, 2, mpg_tr );
171 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_an, tvb, offset, 1, mpg_an );
172 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_n , tvb, offset, 1, mpg_n );
173 proto_tree_add_boolean( mpg_tree, hf_rtp_mpg_s , tvb, offset, 1, mpg_s );
174 proto_tree_add_boolean( mpg_tree, hf_rtp_mpg_b , tvb, offset, 1, mpg_b );
175 proto_tree_add_boolean( mpg_tree, hf_rtp_mpg_e , tvb, offset, 1, mpg_e );
177 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_p, tvb , offset, 1, mpg_p );
180 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_fbv, tvb, offset, 1, mpg_fbv );
181 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_bfc, tvb, offset, 1, mpg_bfc );
182 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_ffv, tvb, offset, 1, mpg_ffv );
183 proto_tree_add_uint( mpg_tree, hf_rtp_mpg_ffc, tvb, offset, 1, mpg_ffc );
186 /* The rest of the packet is the MPEG-1 stream */
187 proto_tree_add_item( mpg_tree, hf_rtp_mpg_data, tvb, offset, -1, FALSE );
193 proto_register_mpeg1(void)
195 static hf_register_info hf[] =
201 "rtp.payload_mpeg_mbz",
213 "rtp.payload_mpeg_T",
224 "Temporal Reference",
225 "rtp.payload_mpeg_tr",
237 "rtp.payload_mpeg_an",
249 "New Picture Header",
250 "rtp.payload_mpeg_n",
263 "rtp.payload_mpeg_s",
275 "Beginning-of-slice",
276 "rtp.payload_mpeg_b",
289 "rtp.payload_mpeg_an",
302 "rtp.payload_mpeg_p",
305 VALS(rtp_mpg_picture_types_vals),
315 "rtp.payload_mpeg_fbv",
328 "rtp.payload_mpeg_bfc",
340 "rtp.payload_mpeg_ffv",
353 "rtp.payload_mpeg_ffc",
382 proto_mpg = proto_register_protocol("RFC 2250 MPEG1","MPEG1","mpeg1");
383 proto_register_field_array(proto_mpg, hf, array_length(hf));
384 proto_register_subtree_array(ett, array_length(ett));
388 proto_reg_handoff_mpeg1(void)
390 dissector_handle_t mpeg1_handle;
392 mpeg1_handle = create_dissector_handle(dissect_mpeg1, proto_mpg);
393 dissector_add("rtp.pt", PT_MPV, mpeg1_handle);