Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollback to v1 #227

Merged
merged 49 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0fbc63c
Revert to 4e87540 (last commit before v2)
aler9 Jun 12, 2023
bf2aefd
Update CI configs to v0.5.4
pionbot Jul 2, 2021
f47bfc0
Make VP8 PictureID optional
at-wat Jul 8, 2021
0100edd
Update CI configs to v0.5.6
pionbot Jul 13, 2021
1b9ca0b
Add Z bit to VP9 unmarshaller
jech May 17, 2021
e242a64
Update CI configs to v0.5.9
pionbot Jul 21, 2021
773f1c5
Implement a H265/HEVC packet decoder
Antonito Jun 25, 2021
6e439c5
Make MTU a uint16
metaclips Jan 28, 2021
a5a7078
Pack SPS and PPS in one STAP-A packet
baiyufei Jan 8, 2021
8fbcdd0
Implement partition head in Depacketizer
jech Aug 22, 2021
0f418e5
Fix unmarshal of packets with padding
boks1971 Oct 21, 2021
9fc6d60
Update CI configs to v0.6.0
pionbot Nov 16, 2021
65a3177
Add PaddingSize to rtp.Packet
boks1971 Nov 22, 2021
048cb66
Update CI configs to v0.6.2
pionbot Nov 28, 2021
718a9e5
Replace <= with == since mtu cannot be negative
Nov 25, 2021
1b48a66
Update CI configs to v0.6.4
pionbot Dec 19, 2021
86adc56
Adds zero-copy header extensions
kevmo314 Jan 3, 2022
a0dc500
Add IsPartitionHead and IsPartitionTail to H265
kevmo314 Feb 3, 2022
6f904a6
Update CI configs to v0.6.6
pionbot Feb 6, 2022
ce01e0a
Update CI configs to v0.6.7
pionbot Feb 27, 2022
7b52544
Update CI configs to v0.6.8
pionbot Mar 2, 2022
1cf3c2a
Remove pointer from constant functions
aler9 Mar 8, 2022
984aa65
Add AV1 Support
Sean-Der Mar 21, 2022
1c51eef
Fix AV1 /v2 imports
Sean-Der Apr 11, 2022
25d6b9f
Move AV1 Frame to new frame pkg
Sean-Der Apr 11, 2022
e0fef19
Add bounds check to AV1 Frame
Sean-Der Apr 12, 2022
c08b150
Update CI configs to v0.7.0
pionbot Apr 13, 2022
d0b52c5
Update CI configs to v0.7.1
pionbot Apr 13, 2022
58f4e41
Update CI configs to v0.7.2
pionbot Apr 24, 2022
4f20998
Update CI configs to v0.6.9
pionbot Mar 21, 2022
9f48864
Set CSRC as a empty (not nil) slice by default
Apr 21, 2022
d1b3865
Add experimental header extensions
kevmo314 Aug 1, 2022
8eda65a
Fix multiple crashes when using VP9 depacketizer
aler9 Jan 7, 2023
ce84b2d
Fix parsing of VP8 packets with degenerate header
jech Jan 6, 2023
3227750
Fix compatibility with gofmt
aler9 Feb 12, 2023
94ab88a
Fix errShortPacket with H264 EOS NALUs
kawaway Feb 2, 2023
e76983a
Cleanup common sections in README
stv0g Mar 11, 2023
19ff155
Update AUTHORS.txt
stv0g Mar 13, 2023
46ade2b
Harmonize sections in README
stv0g Apr 5, 2023
a4c81e3
Update CI configs to v0.10.7
pionbot Apr 18, 2023
503218c
Make repo REUSE compliant
stv0g May 5, 2023
beab487
Fix golangci-lint warnings
stv0g May 5, 2023
35fcf93
Update CI configs to v0.10.8
pionbot May 18, 2023
cb415a2
Update CI configs to v0.10.9
pionbot May 19, 2023
83323c4
Sync asset files with .goassets
aler9 Jun 12, 2023
30d0a23
Minimize changes
aler9 Jun 12, 2023
e020e24
Implement packet clone method
ffmiruz Feb 3, 2021
d41d817
Fix Packet.Raw population
aler9 Jun 12, 2023
5b8bbd2
Bump Go version
aler9 Jun 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codecs/av1_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package codecs

import (
"github.com/pion/rtp/v2/pkg/obu"
"github.com/pion/rtp/pkg/obu"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion codecs/av1_packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"reflect"
"testing"

"github.com/pion/rtp/v2/pkg/obu"
"github.com/pion/rtp/pkg/obu"
)

func TestAV1_Marshal(t *testing.T) {
Expand Down
11 changes: 10 additions & 1 deletion codecs/h264_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,18 @@ func (p *H264Packet) Unmarshal(payload []byte) ([]byte, error) {
return nil, fmt.Errorf("%w: %d", errUnhandledNALUType, naluType)
}

// H264PartitionHeadChecker is obsolete
// H264PartitionHeadChecker checks H264 partition head.
//
// Deprecated: replaced by H264Packet.IsPartitionHead()
type H264PartitionHeadChecker struct{}

// IsPartitionHead checks if this is the head of a packetized nalu stream.
//
// Deprecated: replaced by H264Packet.IsPartitionHead()
func (*H264PartitionHeadChecker) IsPartitionHead(packet []byte) bool {
return (&H264Packet{}).IsPartitionHead(packet)
}

// IsPartitionHead checks if this is the head of a packetized nalu stream.
func (*H264Packet) IsPartitionHead(payload []byte) bool {
if len(payload) < 2 {
Expand Down
11 changes: 10 additions & 1 deletion codecs/opus_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,14 @@ func (p *OpusPacket) Unmarshal(packet []byte) ([]byte, error) {
return packet, nil
}

// OpusPartitionHeadChecker is obsolete
// OpusPartitionHeadChecker checks Opus partition head.
//
// Deprecated: replaced by OpusPacket.IsPartitionHead()
type OpusPartitionHeadChecker struct{}

// IsPartitionHead checks whether if this is a head of the Opus partition.
//
// Deprecated: replaced by OpusPacket.IsPartitionHead()
func (*OpusPartitionHeadChecker) IsPartitionHead(packet []byte) bool {
return (&OpusPacket{}).IsPartitionHead(packet)
}
11 changes: 10 additions & 1 deletion codecs/vp8_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,18 @@ func (p *VP8Packet) Unmarshal(payload []byte) ([]byte, error) {
return p.Payload, nil
}

// VP8PartitionHeadChecker is obsolete
// VP8PartitionHeadChecker checks VP8 partition head
//
// Deprecated: replaced by VP8Packet.IsPartitionHead()
type VP8PartitionHeadChecker struct{}

// IsPartitionHead checks whether if this is a head of the VP8 partition.
//
// Deprecated: replaced by VP8Packet.IsPartitionHead()
func (*VP8PartitionHeadChecker) IsPartitionHead(packet []byte) bool {
return (&VP8Packet{}).IsPartitionHead(packet)
}

// IsPartitionHead checks whether if this is a head of the VP8 partition
func (*VP8Packet) IsPartitionHead(payload []byte) bool {
if len(payload) < 1 {
Expand Down
11 changes: 10 additions & 1 deletion codecs/vp9_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,18 @@ func (p *VP9Packet) parseSSData(packet []byte, pos int) (int, error) {
return pos, nil
}

// VP9PartitionHeadChecker is obsolete
// VP9PartitionHeadChecker checks VP9 partition head.
//
// Deprecated: replaced by VP9Packet.IsPartitionHead()
type VP9PartitionHeadChecker struct{}

// IsPartitionHead checks whether if this is a head of the VP9 partition.
//
// Deprecated: replaced by VP9Packet.IsPartitionHead()
func (*VP9PartitionHeadChecker) IsPartitionHead(packet []byte) bool {
return (&VP9Packet{}).IsPartitionHead(packet)
}

// IsPartitionHead checks whether if this is a head of the VP9 partition
func (*VP9Packet) IsPartitionHead(payload []byte) bool {
if len(payload) < 1 {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/pion/rtp/v2
module github.com/pion/rtp

go 1.13
go 1.19

require github.com/pion/randutil v0.1.0
44 changes: 28 additions & 16 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ type Extension struct {
}

// Header represents an RTP packet header
// NOTE: PayloadOffset is populated by Marshal/Unmarshal and should not be modified
type Header struct {
Version uint8
Padding bool
Extension bool
Marker bool
PayloadOffset int
PayloadType uint8
SequenceNumber uint16
Timestamp uint32
Expand All @@ -31,8 +33,10 @@ type Header struct {
}

// Packet represents an RTP Packet
// NOTE: Raw is populated by Marshal/Unmarshal and should not be modified
type Packet struct {
Header
Raw []byte
Payload []byte
PaddingSize byte
}
Expand Down Expand Up @@ -78,10 +82,9 @@ func (p Packet) String() string {
}

// Unmarshal parses the passed byte slice and stores the result in the Header.
// It returns the number of bytes read n and any error.
func (h *Header) Unmarshal(buf []byte) (n int, err error) { //nolint:gocognit
func (h *Header) Unmarshal(buf []byte) error { //nolint:gocognit
if len(buf) < headerLength {
return 0, fmt.Errorf("%w: %d < %d", errHeaderSizeInsufficient, len(buf), headerLength)
return fmt.Errorf("%w: %d < %d", errHeaderSizeInsufficient, len(buf), headerLength)
}

/*
Expand Down Expand Up @@ -109,10 +112,9 @@ func (h *Header) Unmarshal(buf []byte) (n int, err error) { //nolint:gocognit
h.CSRC = h.CSRC[:nCSRC]
}

n = csrcOffset + (nCSRC * csrcLength)
n := csrcOffset + (nCSRC * csrcLength)
if len(buf) < n {
return n, fmt.Errorf("size %d < %d: %w", len(buf), n,
errHeaderSizeInsufficient)
return fmt.Errorf("size %d < %d: %w", len(buf), n, errHeaderSizeInsufficient)
}

h.Marker = (buf[1] >> markerShift & markerMask) > 0
Expand All @@ -133,7 +135,7 @@ func (h *Header) Unmarshal(buf []byte) (n int, err error) { //nolint:gocognit

if h.Extension {
if expected := n + 4; len(buf) < expected {
return n, fmt.Errorf("size %d < %d: %w",
return fmt.Errorf("size %d < %d: %w",
len(buf), expected,
errHeaderSizeInsufficientForExtension,
)
Expand All @@ -145,7 +147,7 @@ func (h *Header) Unmarshal(buf []byte) (n int, err error) { //nolint:gocognit
n += 2

if expected := n + extensionLength; len(buf) < expected {
return n, fmt.Errorf("size %d < %d: %w",
return fmt.Errorf("size %d < %d: %w",
len(buf), expected,
errHeaderSizeInsufficientForExtension,
)
Expand Down Expand Up @@ -196,33 +198,38 @@ func (h *Header) Unmarshal(buf []byte) (n int, err error) { //nolint:gocognit

default: // RFC3550 Extension
if len(buf) < n+extensionLength {
return n, fmt.Errorf("%w: %d < %d",
errHeaderSizeInsufficientForExtension, len(buf), n+extensionLength)
return fmt.Errorf("%w: %d < %d", errHeaderSizeInsufficientForExtension, len(buf), n+extensionLength)
}

extension := Extension{id: 0, payload: buf[n : n+extensionLength]}
h.Extensions = append(h.Extensions, extension)
n += len(h.Extensions[0].payload)
}
}
return n, nil

h.PayloadOffset = n

return nil
}

// Unmarshal parses the passed byte slice and stores the result in the Packet.
func (p *Packet) Unmarshal(buf []byte) error {
n, err := p.Header.Unmarshal(buf)
if err != nil {
if err := p.Header.Unmarshal(buf); err != nil {
return err
}

end := len(buf)
if p.Header.Padding {
p.PaddingSize = buf[end-1]
end -= int(p.PaddingSize)
}
if end < n {
if end < p.PayloadOffset {
return errTooSmall
}
p.Payload = buf[n:end]

p.Payload = buf[p.PayloadOffset:end]
p.Raw = buf

return nil
}

Expand All @@ -234,6 +241,7 @@ func (h Header) Marshal() (buf []byte, err error) {
if err != nil {
return nil, err
}

return buf[:n], nil
}

Expand Down Expand Up @@ -331,6 +339,8 @@ func (h Header) MarshalTo(buf []byte) (n int, err error) {
}
}

h.PayloadOffset = n

return n, nil
}

Expand Down Expand Up @@ -472,7 +482,8 @@ func (p Packet) Marshal() (buf []byte, err error) {
}

// MarshalTo serializes the packet and writes to the buffer.
func (p Packet) MarshalTo(buf []byte) (n int, err error) {
func (p *Packet) MarshalTo(buf []byte) (n int, err error) {
p.Header.Padding = p.PaddingSize != 0
n, err = p.Header.MarshalTo(buf)
if err != nil {
return 0, err
Expand All @@ -484,6 +495,7 @@ func (p Packet) MarshalTo(buf []byte) (n int, err error) {
}

m := copy(buf[n:], p.Payload)
p.Raw = buf[:n+m]
if p.Header.Padding {
buf[n+m+int(p.PaddingSize-1)] = p.PaddingSize
}
Expand Down
Loading