Add a preferense to decode a dynamic payload type as H263-1998/H263-2000
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 21 Jan 2008 20:49:15 +0000 (20:49 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 21 Jan 2008 20:49:15 +0000 (20:49 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24153 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-h263.c

index 8f39e5b6304bee600ef8f8f60a6fe4fabd351185..2b68244482ad3b8f7814e3dca0ca9e4257bbb1fa 100644 (file)
@@ -50,6 +50,8 @@
 #include <epan/rtp_pt.h>
 #include <epan/iax2_codec_type.h>
 
+#include "prefs.h"
+
 static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree );
 
 /* H.263 header fields             */
@@ -224,6 +226,11 @@ static gint ett_h263P_extra_hdr = -1;
 static gint ett_h263P_payload  = -1;
 static gint ett_h263P_data = -1;
 
+/* The dynamic payload type which will be dissected as H.263-1998/H263-2000 */
+
+static guint dynamic_payload_type = 0;
+static guint temp_dynamic_payload_type = 0;
+
 static void
 dissect_h263( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree )
 {
@@ -1036,6 +1043,42 @@ static void dissect_h263_data( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr
                proto_tree_add_item( h263_payload_tree, hf_h263_data, tvb, offset, -1, FALSE );
 }
 
+void
+proto_reg_handoff_h263(void)
+{
+       dissector_handle_t h263_handle;
+
+       h263_handle = find_dissector("h263");
+       dissector_add("rtp.pt", PT_H263, h263_handle);
+       dissector_add("iax2.codec", AST_FORMAT_H263, h263_handle);
+}
+
+void
+proto_reg_handoff_h263P(void)
+{
+       dissector_handle_t h263P_handle;
+       static int h263P_prefs_initialized = FALSE;
+
+       h263P_handle = create_dissector_handle(dissect_h263P, proto_h263P);
+
+       if (!h263P_prefs_initialized) {
+               h263P_prefs_initialized = TRUE;
+         }
+       else {
+               if ( dynamic_payload_type > 95 )
+                       dissector_delete("rtp.pt", dynamic_payload_type, h263P_handle);
+       }
+       dynamic_payload_type = temp_dynamic_payload_type;
+
+       if ( dynamic_payload_type > 95 ){
+               dissector_add("rtp.pt", dynamic_payload_type, h263P_handle);
+       }
+
+       h263P_handle = find_dissector("h263P");
+       dissector_add_string("rtp_dyn_payload_type","H263-1998", h263P_handle);
+       dissector_add_string("rtp_dyn_payload_type","H263-2000", h263P_handle);
+}
+
 void
 proto_register_h263(void)
 {
@@ -1615,6 +1658,8 @@ proto_register_h263(void)
 void
 proto_register_h263P(void)
 {
+       module_t *h263P_module;
+
        static hf_register_info hf[] =
        {
                {
@@ -1781,26 +1826,16 @@ proto_register_h263P(void)
        proto_register_field_array(proto_h263P, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
 
-       register_dissector("h263P", dissect_h263P, proto_h263P);
+       h263P_module = prefs_register_protocol(proto_h263P, proto_reg_handoff_h263P);
 
-}
+       prefs_register_uint_preference(h263P_module, "dynamic.payload.type",
+                                                                  "H263-1998 and H263-2000 dynamic payload type",
+                                                                  "The dynamic payload type which will be interpreted as H264",
+                                                                  10,
+                                                                  &temp_dynamic_payload_type);
 
-void
-proto_reg_handoff_h263(void)
-{
-       dissector_handle_t h263_handle;
+       register_dissector("h263P", dissect_h263P, proto_h263P);
 
-       h263_handle = find_dissector("h263");
-       dissector_add("rtp.pt", PT_H263, h263_handle);
-       dissector_add("iax2.codec", AST_FORMAT_H263, h263_handle);
 }
 
-void
-proto_reg_handoff_h263P(void)
-{
-       dissector_handle_t h263P_handle;
 
-       h263P_handle = find_dissector("h263P");
-       dissector_add_string("rtp_dyn_payload_type","H263-1998", h263P_handle);
-       dissector_add_string("rtp_dyn_payload_type","H263-2000", h263P_handle);
-}