From c86cc062bc369a13f3d949b74cc6fd679202b3d9 Mon Sep 17 00:00:00 2001 From: Lynne Date: Wed, 3 Jul 2024 12:39:05 +0200 Subject: [PATCH] Add extended stream data packet I hate it. But I see no other way. --- draft-avtransport-spec.bs | 181 +++++++++++++++++++++++++++++---- libavtransport/tools/spec2c.py | 29 +++--- 2 files changed, 179 insertions(+), 31 deletions(-) diff --git a/draft-avtransport-spec.bs b/draft-avtransport-spec.bs index e1f9b9a..8079df1 100644 --- a/draft-avtransport-spec.bs +++ b/draft-avtransport-spec.bs @@ -266,6 +266,10 @@ Below is a table of how they're allocated: [''0x0100'':''0x01FF''] [[#stream-data-packets]] + + [''0x0200'':''0x02FF''] + [[#extended-stream-data-packets]] + ''0x0300'' [[#time-synchronization-packets]] @@ -1338,7 +1342,7 @@ The data packets indicate the start of a stream packet, which may be fragmented more [[#stream-data-segment-packets]]. It is laid out as follows:
- +
@@ -1433,6 +1437,155 @@ For information on the layout of the specific codec-specific packet data, consul the [[#codec-encapsulation]] addenda. +## Extended stream data ## {#extended-stream-data-packets} + +Depending upon the codec, using an extended stream data header may be required. +It is laid out in the following way: + +
+
Type Name
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TypeNameDataDescription
b(16)extended_stream_data_descriptor_structure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
b(8)extended_stream_data_descriptor0x02
b(3)[=frame_type=]enum {{FrameType}}
b(1)ext_pkt_reservedReserved field. Must be set to 0.
b(1)[=pkt_in_fec_group=]Packet is part of an FEC group and must be retained.
b(1)[=field_id=]As defined in enum {{Interlacing}}.
b(2)[=pkt_compression=]enum {{DataCompression}}
+
b(16)[=stream_id=]Indicates the stream ID for which this packet is applicable.
u(32)[=global_seq=]Monotonically incrementing per-packet global sequence number.
i(64)[=pts=]Indicates the presentation timestamp for when this frame should be presented at. To interpret the value, read the [[#timestamps]] section.
i(64)[=dts=]Indicates the timestamp for when to input this frame should be input into the decoder. To interpret the value, read the [[#timestamps]] section.
u(32)[=data_length=]The size of the data in this packet.
b(64)[=ldpc_288_224=][=LDPC(288, 224)=]64-bits of LDPC parity data to correct the previous 224 bits of the packet.
[=data_length=]*b(8)[=packet_data=]payloadThe packet data itself.
i(64)[=duration=]The duration of this packet in stream timebase unis.
u(32)total_data_lengthThe total size of all data needed to receive the payload correctly. Must be either 0 if unknown, or the total size of the payload across all segments.
u(32)side_data_lengthLength of the side data, if any.
u(32)side_data_offsetThe offset within the packet where the side data is located at.
u(8)side_data_typeThe size of the data in this packet.
b(48)[=padding=]Padding, reserved for future use. MUST be ''0x0''.
b(64)[=ldpc_288_224=][=LDPC(288, 224)=]64-bits of LDPC parity data to correct the previous 224 bits of the packet.
[=data_length=]*b(8)[=packet_data=]payloadThe packet data itself.
+
+ +Extended stream data packets should only be used if there's a need to use them. +Regular stream data packets have a much lower overhead. + + ### Frame Type Enumeration (enum FrameType) ### {#enum-FrameType}
@@ -1442,16 +1595,6 @@ the [[#codec-encapsulation]] addenda. :: Packet data contains a scalable/switch frame, able to be decoded standalone, with acceptable degradation. : FRAME_TYPE_P = 0x2 :: Packet data contains an inter frame, requiring additional reference frames in order to be validly decoded. - : FRAME_TYPE_C1 = 0x3 - :: Packet data contains a frame with a type defined in [[#codec-encapsulation]]. - : FRAME_TYPE_C2 = 0x4 - :: Packet data contains a frame with a type defined in [[#codec-encapsulation]]. - : FRAME_TYPE_C3 = 0x5 - :: Packet data contains a frame with a type defined in [[#codec-encapsulation]]. - : FRAME_TYPE_C4 = 0x6 - :: Packet data contains a frame with a type defined in [[#codec-encapsulation]]. - : FRAME_TYPE_C5 = 0x7 - :: Packet data contains a frame with a type defined in [[#codec-encapsulation]].
@@ -3865,9 +4008,10 @@ For H264 encapsulation, the [=codec_id=] in [[#stream-registration-packets]] must be ''0x48323634'' (''H264''). -The [=packet_data=] must contain the following elements, in order: - - A single b(64) element with the [=dts=], the time, which indicates when a frame should be input into a synchronous 1-in-1-out decoder. - - ''Annex-B'' formatted NAL units, with startcode emulation bits included. +[[#extended-stream-data-packets]] must be used, as H264 requires a [=dts=]. + +The [=packet_data=] must contain ''Annex-B'' formatted NAL units, +with startcode emulation bits included. A [[#stream-configuration-packets]] packet may be sent, to speed up stream initialization. If they are present, they must contain an ''AVCDecoderConfigurationRecord'' structure, @@ -3888,9 +4032,10 @@ For H265 encapsulation, the [=codec_id=] in [[#stream-registration-packets]] must be ''0x48323635'' (''H265''). -The [=packet_data=] must contain the following elements, in order: - - A single b(64) element with the [=dts=], the time, which indicates when a frame should be input into a synchronous 1-in-1-out decoder. - - ''Annex-B'' formatted NAL units, with startcode emulation bits included. +[[#extended-stream-data-packets]] must be used, as H265 requires a [=dts=]. + +The [=packet_data=] must contain ''Annex-B'' formatted NAL units, +with startcode emulation bits included. ''Annex-B'' formatted packets must be used, with startcode emulation bits included. @@ -3905,6 +4050,8 @@ For Dirac or VC-2 encapsulation, the [=codec_id=] in [[#stream-registration-packets]] MUST be ''0x42424344'' (''BBCD''). +[[#extended-stream-data-packets]] must be used, as Dirac packets require a [=dts=]. + Dirac streams require no [[#stream-configuration-packets]] packets. The [=packet_data=] must contain raw sequences, diff --git a/libavtransport/tools/spec2c.py b/libavtransport/tools/spec2c.py index c4b84f4..4234dee 100755 --- a/libavtransport/tools/spec2c.py +++ b/libavtransport/tools/spec2c.py @@ -115,21 +115,22 @@ streamid_field_exceptions = [ "stream_id", "group_id", "user_field", "session_version" ] codec_tags = { } +# This is able to add arbitrary extra values to any structure during parsing extra_values = { - "AVTStreamData": [ - "dts", { - "fixed": None, - "ldpc": None, - "enum": None, - "size_bits": 64, - "bytestream": 8, - "datatype": "int64_t", - "struct": None, - "array_len": 0, - "string": False, - "payload": False, - } - ], +# "AVTStreamData": [ +# "dts", { +# "fixed": None, +# "ldpc": None, +# "enum": None, +# "size_bits": 64, +# "bytestream": 8, +# "datatype": "int64_t", +# "struct": None, +# "array_len": 0, +# "string": False, +# "payload": False, +# } +# ], } def iter_enum_fields(target_id):