3 * Routines for RFC 2250 MPEG-1 dissection
8 * Francisco Javier Cabello Torres, <fjcabello@vtools.es>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 * This dissector tries to dissect the MPEG-1 video streams.
37 #include <epan/packet.h>
39 #include <epan/rtp_pt.h>
41 #define RTP_MPG_MBZ(word) ( word >> 11)
42 #define RTP_MPG_T(word) ( (word >> 10) & 1 )
43 #define RTP_MPG_TR(word) ( word & 0x3ff )
45 #define RTP_MPG_AN(octet) ( octet >> 7)
46 #define RTP_MPG_N(octet) ( (octet >> 6) & 1 )
47 #define RTP_MPG_S(octet) ( (octet >> 5) & 1 )
48 #define RTP_MPG_B(octet) ( (octet >> 4) & 1 )
49 #define RTP_MPG_E(octet) ( (octet >> 3) & 1 )
50 #define RTP_MPG_P(octet) ( octet & 7 )
52 #define RTP_MPG_FBV(octet) ( (octet >> 7) & 1 )
53 #define RTP_MPG_BFC(octet) ( (octet >> 4) & 7 )
54 #define RTP_MPG_FFV(octet) ( (octet >> 3) & 1 )
55 #define RTP_MPG_FFC(octet) ( octet & 7 )
58 /* MPEG1 header fields */
61 static int proto_mpg
= -1;
63 static int hf_rtp_mpg_mbz
= -1;
64 static int hf_rtp_mpg_T
= -1;
65 static int hf_rtp_mpg_tr
= -1;
66 static int hf_rtp_mpg_an
= -1;
67 static int hf_rtp_mpg_n
= -1;
68 static int hf_rtp_mpg_s
= -1;
69 static int hf_rtp_mpg_b
= -1;
70 static int hf_rtp_mpg_e
= -1;
71 static int hf_rtp_mpg_p
= -1;
74 static int hf_rtp_mpg_fbv
= -1;
75 static int hf_rtp_mpg_bfc
= -1;
76 static int hf_rtp_mpg_ffv
= -1;
77 static int hf_rtp_mpg_ffc
= -1;
78 static int hf_rtp_mpg_data
= -1;
82 /* MPEG-1 fields defining a sub tree */
83 static gint ett_mpg
= -1;
85 static const value_string rtp_mpg_picture_types_vals
[] =
99 dissect_mpeg1( tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
101 proto_item
*ti
= NULL
;
102 proto_tree
*mpg_tree
= NULL
;
103 unsigned int offset
= 0;
123 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "MPEG-1");
125 col_set_str(pinfo
->cinfo
, COL_INFO
, "MPEG-1 message");
127 /* Get MPEG-1 fields */
129 word
= tvb_get_guint8( tvb
, offset
);
130 word
= (word
<< 8) | tvb_get_guint8( tvb
, offset
+1 );
131 mpg_mbz
= RTP_MPG_MBZ(word
);
132 mpg_T
= RTP_MPG_T(word
);
133 mpg_tr
= RTP_MPG_TR(word
);
135 octet
= tvb_get_guint8( tvb
, offset
+ 2 );
136 mpg_an
= RTP_MPG_AN(octet
);
137 mpg_n
= RTP_MPG_N(octet
);
138 mpg_s
= RTP_MPG_S(octet
);
139 mpg_b
= RTP_MPG_B(octet
);
140 mpg_e
= RTP_MPG_E(octet
);
141 mpg_p
= RTP_MPG_P(octet
);
143 octet
= tvb_get_guint8( tvb
, offset
+ 3 );
145 mpg_fbv
= RTP_MPG_FBV(octet
);
146 mpg_bfc
= RTP_MPG_BFC(octet
);
147 mpg_ffv
= RTP_MPG_FFV(octet
);
148 mpg_ffc
= RTP_MPG_FFC(octet
);
153 ti
= proto_tree_add_item( tree
, proto_mpg
, tvb
, offset
, -1, ENC_NA
);
154 mpg_tree
= proto_item_add_subtree( ti
, ett_mpg
);
156 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_mbz
, tvb
, offset
, 1, mpg_mbz
);
157 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_T
, tvb
, offset
, 1, mpg_T
);
158 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_tr
, tvb
, offset
, 2, mpg_tr
);
160 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_an
, tvb
, offset
, 1, mpg_an
);
161 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_n
, tvb
, offset
, 1, mpg_n
);
162 proto_tree_add_boolean( mpg_tree
, hf_rtp_mpg_s
, tvb
, offset
, 1, mpg_s
);
163 proto_tree_add_boolean( mpg_tree
, hf_rtp_mpg_b
, tvb
, offset
, 1, mpg_b
);
164 proto_tree_add_boolean( mpg_tree
, hf_rtp_mpg_e
, tvb
, offset
, 1, mpg_e
);
166 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_p
, tvb
, offset
, 1, mpg_p
);
169 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_fbv
, tvb
, offset
, 1, mpg_fbv
);
170 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_bfc
, tvb
, offset
, 1, mpg_bfc
);
171 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_ffv
, tvb
, offset
, 1, mpg_ffv
);
172 proto_tree_add_uint( mpg_tree
, hf_rtp_mpg_ffc
, tvb
, offset
, 1, mpg_ffc
);
175 /* The rest of the packet is the MPEG-1 stream */
176 proto_tree_add_item( mpg_tree
, hf_rtp_mpg_data
, tvb
, offset
, -1, ENC_NA
);
182 proto_register_mpeg1(void)
184 static hf_register_info hf
[] =
190 "rtp.payload_mpeg_mbz",
202 "rtp.payload_mpeg_T",
213 "Temporal Reference",
214 "rtp.payload_mpeg_tr",
226 "rtp.payload_mpeg_an",
238 "New Picture Header",
239 "rtp.payload_mpeg_n",
252 "rtp.payload_mpeg_s",
264 "Beginning-of-slice",
265 "rtp.payload_mpeg_b",
278 "rtp.payload_mpeg_an",
291 "rtp.payload_mpeg_p",
294 VALS(rtp_mpg_picture_types_vals
),
304 "rtp.payload_mpeg_fbv",
317 "rtp.payload_mpeg_bfc",
329 "rtp.payload_mpeg_ffv",
342 "rtp.payload_mpeg_ffc",
371 proto_mpg
= proto_register_protocol("RFC 2250 MPEG1","MPEG1","mpeg1");
372 proto_register_field_array(proto_mpg
, hf
, array_length(hf
));
373 proto_register_subtree_array(ett
, array_length(ett
));
377 proto_reg_handoff_mpeg1(void)
379 dissector_handle_t mpeg1_handle
;
381 mpeg1_handle
= create_dissector_handle(dissect_mpeg1
, proto_mpg
);
382 dissector_add_uint("rtp.pt", PT_MPV
, mpeg1_handle
);