From 610e5f0543cec3868d8405b1b8d5218e90b63cfa Mon Sep 17 00:00:00 2001 From: Xiaofeng Wang Date: Sat, 6 Jan 2024 00:03:09 +0800 Subject: [PATCH] Support enhanced-RTMP ExVideoTagHeader --- epan/dissectors/packet-rtmpt.c | 68 +++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 9 deletions(-) diff --git a/epan/dissectors/packet-rtmpt.c b/epan/dissectors/packet-rtmpt.c index 275f735ea5..88bae48515 100644 --- a/epan/dissectors/packet-rtmpt.c +++ b/epan/dissectors/packet-rtmpt.c @@ -111,8 +111,11 @@ static int hf_rtmpt_audio_type; static int hf_rtmpt_audio_data; static int hf_rtmpt_video_control; +static int hf_rtmpt_video_is_ex_header; static int hf_rtmpt_video_type; static int hf_rtmpt_video_format; +static int hf_rtmpt_video_packet_type; +static int hf_rtmpt_video_fourcc; static int hf_rtmpt_video_data; static int hf_rtmpt_tag_type; @@ -193,6 +196,8 @@ static gboolean rtmpt_desegment = TRUE; #define RTMPT_UCM_PING_REQUEST 0x06 #define RTMPT_UCM_PING_RESPONSE 0x07 +#define RTMPT_IS_EX_HEADER 0x80 + #define RTMPT_TEXT_RTMP_HEADER "RTMP Header" #define RTMPT_TEXT_RTMP_BODY "RTMP Body" @@ -310,6 +315,19 @@ static const value_string rtmpt_video_codecs[] = { { 0, NULL } }; +/* + * https://raw.githubusercontent.com/veovera/enhanced-rtmp/main/enhanced-rtmp.pdf + */ +static const value_string rtmpt_video_packet_types[] = { + { 0, "PacketTypeSequenceStart" }, + { 1, "PacketTypeCodedFrames" }, + { 2, "PacketTypeSequenceEnd" }, + { 3, "PacketTypeCodedFramesX" }, + { 4, "PacketTypeMetadata" }, + { 5, "PacketTypeMPEG2TSSequenceStart" }, + { 0, NULL } +}; + static int proto_amf; static int hf_amf_version; @@ -1635,15 +1653,35 @@ dissect_rtmpt_body_video(tvbuff_t *tvb, gint offset, proto_tree *rtmpt_tree) proto_tree *vt; iCtl = tvb_get_guint8(tvb, offset); - vi = proto_tree_add_uint_format(rtmpt_tree, hf_rtmpt_video_control, tvb, offset, 1, iCtl, - "Control: 0x%02x (%s %s)", iCtl, - val_to_str_const((iCtl & 0xf0)>>4, rtmpt_video_types, "Unknown frame type"), - val_to_str_const(iCtl & 0x0f, rtmpt_video_codecs, "Unknown codec")); - vt = proto_item_add_subtree(vi, ett_rtmpt_video_control); - proto_tree_add_uint(vt, hf_rtmpt_video_type, tvb, offset, 1, iCtl); - proto_tree_add_uint(vt, hf_rtmpt_video_format, tvb, offset, 1, iCtl); - proto_tree_add_item(rtmpt_tree, hf_rtmpt_video_data, tvb, offset+1, -1, ENC_NA); + /* + * https://raw.githubusercontent.com/veovera/enhanced-rtmp/main/enhanced-rtmp.pdf + */ + if (iCtl & RTMPT_IS_EX_HEADER) { + vi = proto_tree_add_uint_format(rtmpt_tree, hf_rtmpt_video_control, tvb, offset, 1, iCtl, + "Control: 0x%02x (%s %s)", iCtl, + val_to_str_const((iCtl & 0x70)>>4, rtmpt_video_types, "Reserved frame type"), + val_to_str_const(iCtl & 0x0f, rtmpt_video_packet_types, "Reserved packet type")); + + vt = proto_item_add_subtree(vi, ett_rtmpt_video_control); + proto_tree_add_uint(vt, hf_rtmpt_video_is_ex_header, tvb, offset, 1, iCtl); + proto_tree_add_uint(vt, hf_rtmpt_video_type, tvb, offset, 1, iCtl); + proto_tree_add_uint(vt, hf_rtmpt_video_packet_type, tvb, offset, 1, iCtl); + + proto_tree_add_item(rtmpt_tree, hf_rtmpt_video_fourcc, tvb, offset+1, 4, ENC_ASCII); + proto_tree_add_item(rtmpt_tree, hf_rtmpt_video_data, tvb, offset+5, -1, ENC_NA); + } else { + vi = proto_tree_add_uint_format(rtmpt_tree, hf_rtmpt_video_control, tvb, offset, 1, iCtl, + "Control: 0x%02x (%s %s)", iCtl, + val_to_str_const((iCtl & 0xf0)>>4, rtmpt_video_types, "Reserved frame type"), + val_to_str_const(iCtl & 0x0f, rtmpt_video_codecs, "Unknown codec")); + + vt = proto_item_add_subtree(vi, ett_rtmpt_video_control); + proto_tree_add_uint(vt, hf_rtmpt_video_type, tvb, offset, 1, iCtl); + proto_tree_add_uint(vt, hf_rtmpt_video_format, tvb, offset, 1, iCtl); + + proto_tree_add_item(rtmpt_tree, hf_rtmpt_video_data, tvb, offset+1, -1, ENC_NA); + } } static void @@ -2714,14 +2752,26 @@ proto_register_rtmpt(void) { "Video control", "rtmpt.video.control", FT_UINT8, BASE_HEX, NULL, 0x0, "RTMPT Video control", HFILL }}, + { &hf_rtmpt_video_is_ex_header, + { "IsExHeader", "rtmpt.video.is_ex_header", FT_UINT8, BASE_DEC, + NULL, 0x80, "RTMPT IsExHeader flag introduced in enhanced RTMP", HFILL }}, + { &hf_rtmpt_video_type, { "Type", "rtmpt.video.type", FT_UINT8, BASE_DEC, - VALS(rtmpt_video_types), 0xf0, "RTMPT Video type", HFILL }}, + VALS(rtmpt_video_types), 0x70, "RTMPT Video type", HFILL }}, { &hf_rtmpt_video_format, { "Format", "rtmpt.video.format", FT_UINT8, BASE_DEC, VALS(rtmpt_video_codecs), 0x0f, "RTMPT Video format", HFILL }}, + { &hf_rtmpt_video_packet_type, + { "Packet Type", "rtmpt.video.packet_type", FT_UINT8, BASE_DEC, + VALS(rtmpt_video_packet_types), 0x0f, "RTMPT Video packet type", HFILL }}, + + { &hf_rtmpt_video_fourcc, + { "FourCC", "rtmpt.video.fourcc", FT_STRING, BASE_NONE, + NULL, 0x0, "RTMPT Video fourCC", HFILL }}, + { &hf_rtmpt_video_data, { "Video data", "rtmpt.video.data", FT_BYTES, BASE_NONE, NULL, 0x0, "RTMPT Video data", HFILL }},