rtp icon indicating copy to clipboard operation
rtp copied to clipboard

AV1Packet incompatible with sample builder

Open danjenkins opened this issue 2 years ago • 7 comments

When trying to use AV1Packet as a depacketiser I get an error...

cannot use &(codecs.AV1Packet literal) (value of type *"github.com/pion/rtp/codecs".AV1Packet) as "github.com/pion/rtp".Depacketizer value in assignment: *"github.com/pion/rtp/codecs".AV1Packet does not implement "github.com/pion/rtp".Depacketizer (missing method IsPartitionHead)

danjenkins avatar Jun 09 '22 22:06 danjenkins

I was hoping the solution was just as simple as patching https://github.com/pion/rtp/blob/master/codecs/av1_packet.go with:

diff --git a/codecs/av1_packet.go b/codecs/av1_packet.go
index 7aa3a55..d52e920 100644
--- a/codecs/av1_packet.go
+++ b/codecs/av1_packet.go
@@ -104,6 +104,8 @@ type AV1Packet struct {
       // Each AV1 RTP Packet is a collection of OBU Elements. Each OBU Element may be a full OBU, or just a fragment of one.
       // AV1Frame provides the tools to construct a collection of OBUs from a collection of OBU Elements
       OBUElements [][]byte
+
+       videoDepacketizer
}

// Unmarshal parses the passed byte slice and stores the result in the AV1Packet this method is called upon
@@ -156,3 +158,11 @@ func (p *AV1Packet) Unmarshal(payload []byte) ([]byte, error) {

       return payload[1:], nil
}
+
+// IsPartitionHead checks whether if this is a head of the AV1 partition
+func (*AV1Packet) IsPartitionHead(payload []byte) bool {
+       if len(payload) < 1 {
+               return false
+       }
+       return (payload[0] & 0x08) != 0
+}

but I'm a bit skeptical.

tmatth avatar Jun 29 '22 04:06 tmatth

@tmatth did you try it out? I can give it a go if not?

danjenkins avatar Jun 29 '22 17:06 danjenkins

@tmatth did you try it out? I can give it a go if not?

I did not, it's basically just the same code from the vp9 depacketizer and I'm guessing it means it's checking the RTP marker bit (which is also at position 0x08 for av1), see: https://aomediacodec.github.io/av1-rtp-spec/#42-rtp-header-marker-bit-m vs. https://tools.ietf.org/id/draft-ietf-payload-vp9-09.html#rfc.section.4.1

but again I'd be surprised if this worked.

tmatth avatar Jun 29 '22 19:06 tmatth

Any news on this fix?

mikebevz avatar Mar 01 '24 08:03 mikebevz

@tmatth I'm pretty sure your patch is not correct.

IsPartitionHead should be checking the Z bit in the AV1 aggregation header. That's bit 0x80, see https://aomediacodec.github.io/av1-rtp-spec/#44-av1-aggregation-header.

You'll also need some code to remove the aggregation headers when you generate samples. This will require some changes to the samplebuilder itself.

jech avatar Apr 14 '24 14:04 jech

@tmatth I'm pretty sure your patch is not correct.

I kind of assumed that'd be the case.

IsPartitionHead should be checking the Z bit in the AV1 aggregation header. That's bit 0x80, see https://aomediacodec.github.io/av1-rtp-spec/#44-av1-aggregation-header.

You'll also need some code to remove the aggregation headers when you generate samples. This will require some changes to the samplebuilder itself.

That's good to know. FWIW I started working an rtp muxer for AV1 in C so that should give me a better handle on the format, but if someone else wants to take a stab at this here it'd be most welcome.

tmatth avatar Apr 17 '24 16:04 tmatth

That's good to know. FWIW I started working an rtp muxer for AV1 in C so that should give me a better handle on the format, but if someone else wants to take a stab at this here it'd be most welcome.

Oh I see you've already started on this, tremendous: https://github.com/pion/rtp/pull/264

tmatth avatar Apr 17 '24 16:04 tmatth