H.265: Parsing media format specific parameter from SDP.

Change-Id: I2607068671f370517b1f0a2f65f47a221b630d91
Reviewed-on: https://code.wireshark.org/review/28725
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Asaf Kave 2018-07-16 14:23:50 +03:00 committed by Pascal Quantin
parent 9795cc0285
commit 8bb54d7a61
4 changed files with 106 additions and 1 deletions

View File

@ -366,6 +366,7 @@ set(DISSECTOR_PUBLIC_HEADERS
packet-h248.h
packet-h263.h
packet-h264.h
packet-h265.h
packet-h323.h
packet-h450-ros.h
packet-hpext.h

View File

@ -21,6 +21,7 @@
#include <epan/asn1.h>
#include <epan/expert.h>
#include <epan/prefs.h>
#include "packet-h265.h"
#include "math.h"
void proto_register_h265(void);
@ -38,6 +39,11 @@ static int hf_h265_end_bit = -1;
static int hf_h265_rbsp_stop_bit = -1;
static int hf_h265_rbsp_trailing_bits = -1;
/* SDP */
static int hf_h265_sdp_parameter_sprop_vps = -1;
static int hf_h265_sdp_parameter_sprop_sps = -1;
static int hf_h265_sdp_parameter_sprop_pps = -1;
/*vps*/
static int hf_h265_vps_video_parameter_set_id = -1;
static int hf_h265_vps_base_layer_internal_flag = -1;
@ -377,8 +383,10 @@ static int ett_h265_end_of_bitstream_rbsp = -1;
static int ett_h265_profile_tier_level = -1;
static int ett_h265_vui_parameters = -1;
static int ett_h265_hrd_parameters = -1;
static int ett_h265_sprop_parameters = -1;
static expert_field ei_h265_undecoded = EI_INIT;
static expert_field ei_h265_format_specific_parameter = EI_INIT;
/* The dynamic payload type range which will be dissected as H.265 */
@ -2790,6 +2798,41 @@ dissect_h265_unescap_nal_unit(tvbuff_t *tvb, packet_info *pinfo, int offset)
return tvb_rbsp;
}
void
dissect_h265_format_specific_parameter(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo)
{
int offset = 0;
proto_item *item;
proto_tree *h265_nal_tree;
guint8 type;
tvbuff_t *rbsp_tvb;
type = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN) >> 9 & 0x3F;
/* Unescape NAL unit */
rbsp_tvb = dissect_h265_unescap_nal_unit(tvb, pinfo, offset + 2);
switch (type) {
case 32: /* VPS_NUT - Video parameter set */
item = proto_tree_add_item(tree, hf_h265_sdp_parameter_sprop_vps, tvb, offset, -1, ENC_NA);
h265_nal_tree = proto_item_add_subtree(item, ett_h265_sprop_parameters);
dissect_h265_video_parameter_set_rbsp(h265_nal_tree, rbsp_tvb, pinfo, 0);
break;
case 33: /* SPS_NUT - Sequence parameter set*/
item = proto_tree_add_item(tree, hf_h265_sdp_parameter_sprop_sps, tvb, offset, -1, ENC_NA);
h265_nal_tree = proto_item_add_subtree(item, ett_h265_sprop_parameters);
dissect_h265_seq_parameter_set_rbsp(h265_nal_tree, rbsp_tvb, pinfo, 0);
break;
case 34: /* PPS_NUT - Picture parameter set */
item = proto_tree_add_item(tree, hf_h265_sdp_parameter_sprop_pps, tvb, offset, -1, ENC_NA);
h265_nal_tree = proto_item_add_subtree(item, ett_h265_sprop_parameters);
dissect_h265_pic_parameter_set_rbsp(h265_nal_tree, rbsp_tvb, pinfo, 0);
break;
default:
proto_tree_add_expert(tree, pinfo, &ei_h265_format_specific_parameter, tvb, offset, -1);
break;
}
}
/* Code to actually dissect the packets */
static int
@ -4492,6 +4535,22 @@ proto_register_h265(void)
FT_UINT32, BASE_DEC, VALS(h265_sei_payload_vals), 0x0,
NULL, HFILL }
},
/* SDP parameters*/
{ &hf_h265_sdp_parameter_sprop_vps,
{ "sprop-vps", "h265.sdp.sprop_vps",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h265_sdp_parameter_sprop_sps,
{ "sprop-sps", "h265.sdp.sprop_sps",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
{ &hf_h265_sdp_parameter_sprop_pps,
{ "sprop-pps", "h265.sdp.sprop_pps",
FT_BYTES, BASE_NONE, NULL, 0x0,
NULL, HFILL }
},
};
@ -4513,11 +4572,13 @@ proto_register_h265(void)
&ett_h265_end_of_bitstream_rbsp,
&ett_h265_profile_tier_level,
&ett_h265_vui_parameters,
&ett_h265_hrd_parameters
&ett_h265_hrd_parameters,
&ett_h265_sprop_parameters
};
static ei_register_info ei[] = {
{ &ei_h265_undecoded,{ "h265.undecoded", PI_UNDECODED, PI_WARN, "[Not decoded yet]", EXPFILL } },
{ &ei_h265_format_specific_parameter,{ "h265.format_specific_parameter", PI_UNDECODED, PI_WARN, "[Unspecified media format specific parameter]", EXPFILL } },
};
/* Register the protocol name and description */

View File

@ -0,0 +1,22 @@
/* packet-h265.h
* Routines for H.265 dissection
* Copyright 2018, Asaf Kave <kave.asaf[at]gmail.com>
* Based on the H.264 dissector, thanks!
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* References:
* https://tools.ietf.org/html/rfc7798
* http://www.itu.int/rec/T-REC-H.265/en
*/
#ifndef __PACKET_H265_H__
#define __PACKET_H265_H__
void dissect_h265_format_specific_parameter(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo);
#endif /* __PACKET_H265_H__ */

View File

@ -41,6 +41,7 @@
#include "packet-sprt.h"
#include "packet-h245.h"
#include "packet-h264.h"
#include "packet-h265.h"
#include "packet-mp4ves.h"
void proto_register_sdp(void);
@ -51,6 +52,7 @@ static dissector_handle_t rtcp_handle;
static dissector_handle_t sprt_handle;
static dissector_handle_t msrp_handle;
static dissector_handle_t h264_handle;
static dissector_handle_t h265_handle;
static dissector_handle_t mp4ves_config_handle;
static int sdp_tap = -1;
@ -1419,6 +1421,24 @@ decode_sdp_fmtp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset
}
}
/* Dissect the H265
* RFC 7798:
*/
else if ((mime_type != NULL) && (g_ascii_strcasecmp(mime_type, "H265") == 0)) {
if (strcmp(field_name, "sprop-vps") == 0 || strcmp(field_name, "sprop-sps") == 0 || strcmp(field_name, "sprop-pps") == 0) {
/* Move past '=' */
offset++;
tokenlen = end_offset - offset;
format_specific_parameter = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, tokenlen, ENC_UTF_8 | ENC_NA);
data_tvb = base64_to_tvb(tvb, format_specific_parameter);
add_new_data_source(pinfo, data_tvb, field_name);
if (h265_handle && data_tvb) {
dissect_h265_format_specific_parameter(tree, data_tvb, pinfo);
}
}
}
}
static const string_string ice_candidate_types[] = {
@ -3332,6 +3352,7 @@ proto_reg_handoff_sdp(void)
msrp_handle = find_dissector_add_dependency("msrp", proto_sdp);
sprt_handle = find_dissector_add_dependency("sprt", proto_sdp);
h264_handle = find_dissector_add_dependency("h264", proto_sdp);
h265_handle = find_dissector_add_dependency("h265", proto_sdp);
mp4ves_config_handle = find_dissector_add_dependency("mp4ves_config", proto_sdp);
proto_sprt = dissector_handle_get_protocol_index(find_dissector("sprt"));