Ethereal-dev: [Ethereal-dev] [PATCH] descriptive RTP Payload Type

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Thomas Anders <thomas.anders@xxxxxxxxxxxxx>
Date: Tue, 01 Jun 2004 13:49:55 +0200
With the attached patches packet-sdp.c dissects the RTP Payload Type
(if media protocol is RTP/AVP) with its descriptive name rather than the
raw value string, much like packet-rtp.c does already. To avoid duplicate
definitions, I moved the existing rtp_payload_type_vals[] definition from
packet-rtp.c and gtk/rtp_stream_dlg.c to rtp_pt.h and used that everywhere.

Works for me. Please apply.


+Thomas

--
Thomas Anders (thomas.anders at blue-cable.de)
--- packet-sdp.c.v145	2004-01-16 20:51:55.000000000 +0100
+++ packet-sdp.c	2004-06-01 13:46:31.000000000 +0200
@@ -48,6 +48,7 @@
 #include <epan/packet.h>
 #include <epan/conversation.h>
 #include <epan/strutil.h>
+#include "rtp_pt.h"
 
 static dissector_handle_t rtp_handle=NULL;
 static dissector_handle_t rtcp_handle=NULL;
@@ -774,6 +775,7 @@
 		  transport_info_t *transport_info){
   proto_tree *sdp_media_tree;
   gint offset, next_offset, tokenlen;
+  guint8 *media_format;
 
   offset = 0;
   next_offset = 0;
@@ -854,8 +856,14 @@
       tokenlen = next_offset - offset;
     }
 
-    proto_tree_add_item(sdp_media_tree, hf_media_format, tvb,
-			offset, tokenlen, FALSE);
+    media_format = tvb_get_string(tvb, offset, tokenlen);
+    if (!strcmp(transport_info->media_proto[transport_info->media_count], "RTP/AVP")) {
+      proto_tree_add_string(sdp_media_tree, hf_media_format, tvb,
+			    offset, tokenlen, val_to_str(atol(media_format), rtp_payload_type_vals, "%u"));
+    } else {
+      proto_tree_add_item(sdp_media_tree, hf_media_format, tvb,
+			  offset, tokenlen, FALSE);
+    }
   } while (next_offset != -1);
 
   /* Increase the count of media channels, but don't walk off the end
@@ -1033,7 +1041,7 @@
     { &hf_bandwidth_value,
       { "Bandwidth Value",
 	"sdp.bandwidth.value",FT_STRING, BASE_NONE, NULL, 0x0,
-	"Bandwidth Value", HFILL }},
+	"Bandwidth Value (in kbits/s)", HFILL }},
     { &hf_time_start,
       { "Session Start Time",
 	"sdp.time.start",FT_STRING, BASE_NONE, NULL, 0x0,
@@ -1093,7 +1101,7 @@
     { &hf_media_proto,
       { "Media Proto",
 	"sdp.media.proto",FT_STRING, BASE_NONE, NULL, 0x0,
-	"Media Proto", HFILL }},
+	"Media Protocol", HFILL }},
     { &hf_media_format,
       { "Media Format",
 	"sdp.media.format",FT_STRING, BASE_NONE, NULL, 0x0,
--- rtp_pt.h.v12	2003-09-25 21:35:02.000000000 +0200
+++ rtp_pt.h	2004-06-01 11:31:23.000000000 +0200
@@ -25,6 +25,8 @@
 #ifndef __RTP_PT_H__
 #define __RTP_PT_H__
 
+#include "epan/value_string.h"
+
 /*
  * RTP Payload types
  * Table B.2 / H.225.0
@@ -60,4 +62,35 @@
 #define PT_MP2T		33	/* RFC 2250 */
 #define PT_H263		34	/* from Chunrong Zhu of Intel; see the Web page */
 
+static const value_string rtp_payload_type_vals[] =
+{
+	{ PT_PCMU,	"ITU-T G.711 PCMU" },
+	{ PT_1016,	"USA Federal Standard FS-1016" },
+	{ PT_G721,	"ITU-T G.721" },
+	{ PT_GSM,	"GSM 06.10" },
+	{ PT_G723,	"ITU-T G.723" },
+	{ PT_DVI4_8000,	"DVI4 8000 samples/s" },
+	{ PT_DVI4_16000, "DVI4 16000 samples/s" },
+	{ PT_LPC,	"Experimental linear predictive encoding from Xerox PARC" },
+	{ PT_PCMA,	"ITU-T G.711 PCMA" },
+	{ PT_G722,	"ITU-T G.722" },
+	{ PT_L16_STEREO, "16-bit uncompressed audio, stereo" },
+	{ PT_L16_MONO,	"16-bit uncompressed audio, monaural" },
+	{ PT_QCELP,	"Qualcomm Code Excited Linear Predictive coding" },
+	{ PT_CN,	"Comfort noise" },
+	{ PT_MPA,	"MPEG-I/II Audio"},
+	{ PT_G728,	"ITU-T G.728" },
+	{ PT_DVI4_11025, "DVI4 11025 samples/s" },
+	{ PT_DVI4_22050, "DVI4 22050 samples/s" },
+	{ PT_G729,	"ITU-T G.729" },
+	{ PT_CELB,	"Sun CellB video encoding" },
+	{ PT_JPEG,	"JPEG-compressed video" },
+	{ PT_NV,	"'nv' program" },
+	{ PT_H261,	"ITU-T H.261" },
+	{ PT_MPV,	"MPEG-I/II Video"},
+	{ PT_MP2T,	"MPEG-II transport streams"},
+	{ PT_H263,	"ITU-T H.263" },
+	{ 0,		NULL },
+};
+
 #endif
--- packet-rtp.c.v145	2004-02-14 23:48:53.000000000 +0100
+++ packet-rtp.c	2004-06-01 11:05:34.000000000 +0200
@@ -138,36 +138,7 @@
 /* Payload type is the last 7 bits */
 #define RTP_PAYLOAD_TYPE(octet)	((octet) & 0x7F)
 
-static const value_string rtp_payload_type_vals[] =
-{
-	{ PT_PCMU,	"ITU-T G.711 PCMU" },
-	{ PT_1016,	"USA Federal Standard FS-1016" },
-	{ PT_G721,	"ITU-T G.721" },
-	{ PT_GSM,	"GSM 06.10" },
-	{ PT_G723,	"ITU-T G.723" },
-	{ PT_DVI4_8000,	"DVI4 8000 samples/s" },
-	{ PT_DVI4_16000, "DVI4 16000 samples/s" },
-	{ PT_LPC,	"Experimental linear predictive encoding from Xerox PARC" },
-	{ PT_PCMA,	"ITU-T G.711 PCMA" },
-	{ PT_G722,	"ITU-T G.722" },
-	{ PT_L16_STEREO, "16-bit uncompressed audio, stereo" },
-	{ PT_L16_MONO,	"16-bit uncompressed audio, monaural" },
-	{ PT_QCELP,	"Qualcomm Code Excited Linear Predictive coding" },
-	{ PT_CN,	"Comfort noise" },
-	{ PT_MPA,	"MPEG-I/II Audio"},
-	{ PT_G728,	"ITU-T G.728" },
-	{ PT_DVI4_11025, "DVI4 11025 samples/s" },
-	{ PT_DVI4_22050, "DVI4 22050 samples/s" },
-	{ PT_G729,	"ITU-T G.729" },
-	{ PT_CELB,	"Sun CellB video encoding" },
-	{ PT_JPEG,	"JPEG-compressed video" },
-	{ PT_NV,	"'nv' program" },
-	{ PT_H261,	"ITU-T H.261" },
-	{ PT_MPV,	"MPEG-I/II Video"},
-	{ PT_MP2T,	"MPEG-II transport streams"},
-	{ PT_H263,	"ITU-T H.263" },
-	{ 0,		NULL },
-};
+/* rtp_payload_type_vals[] defined in rtp_pt.h */
 
 static address fake_addr;
 static int heur_init = FALSE;
--- gtk/rtp_stream_dlg.c.v120	2004-04-12 20:01:27.000000000 +0200
+++ gtk/rtp_stream_dlg.c	2004-06-01 11:35:28.000000000 +0200
@@ -51,37 +51,7 @@
 
 extern GtkWidget *main_display_filter_widget;
 
-static const value_string rtp_payload_type_vals[] =
-{
-	{ PT_PCMU,	"ITU-T G.711 PCMU" },
-	{ PT_1016,	"USA Federal Standard FS-1016" },
-	{ PT_G721,	"ITU-T G.721" },
-	{ PT_GSM,	"GSM 06.10" },
-	{ PT_G723,	"ITU-T G.723" },
-	{ PT_DVI4_8000,	"DVI4 8000 samples/s" },
-	{ PT_DVI4_16000, "DVI4 16000 samples/s" },
-	{ PT_LPC,	"Experimental linear predictive encoding from Xerox PARC" },
-	{ PT_PCMA,	"ITU-T G.711 PCMA" },
-	{ PT_G722,	"ITU-T G.722" },
-	{ PT_L16_STEREO, "16-bit uncompressed audio, stereo" },
-	{ PT_L16_MONO,	"16-bit uncompressed audio, monaural" },
-	{ PT_QCELP,	"Qualcomm Code Excited Linear Predictive coding" },
-	{ PT_CN,	"Comfort noise" },
-	{ PT_MPA,	"MPEG-I/II Audio"},
-	{ PT_G728,	"ITU-T G.728" },
-	{ PT_DVI4_11025, "DVI4 11025 samples/s" },
-	{ PT_DVI4_22050, "DVI4 22050 samples/s" },
-	{ PT_G729,	"ITU-T G.729" },
-	{ PT_CELB,	"Sun CellB video encoding" },
-	{ PT_JPEG,	"JPEG-compressed video" },
-	{ PT_NV,	"'nv' program" },
-	{ PT_H261,	"ITU-T H.261" },
-	{ PT_MPV,	"MPEG-I/II Video"},
-	{ PT_MP2T,	"MPEG-II transport streams"},
-	{ PT_H263,	"ITU-T H.263" },
-	{ 0,		NULL },
-};
-
+/* rtp_payload_type_vals[] defined in rtp_pt.h */
 
 typedef const guint8 * ip_addr_p;