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

fix VP9 decoding on iOS (https://github.com/bluenviron/mediamtx/issues/3060) #553

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/bluenviron/mediacommon v1.9.3
github.com/google/uuid v1.6.0
github.com/pion/rtcp v1.2.14
github.com/pion/rtp v1.8.6
github.com/pion/rtp v1.8.7-0.20240429002300-bc5124c9d0d0
github.com/pion/sdp/v3 v3.0.9
github.com/stretchr/testify v1.9.0
golang.org/x/net v0.24.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
github.com/pion/rtcp v1.2.14 h1:KCkGV3vJ+4DAJmvP0vaQShsb0xkRfWkO540Gy102KyE=
github.com/pion/rtcp v1.2.14/go.mod h1:sn6qjxvnwyAkkPzPULIbVqSKI5Dv54Rv7VG0kNxh9L4=
github.com/pion/rtp v1.8.6 h1:MTmn/b0aWWsAzux2AmP8WGllusBVw4NPYPVFFd7jUPw=
github.com/pion/rtp v1.8.6/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
github.com/pion/rtp v1.8.7-0.20240429002300-bc5124c9d0d0 h1:yPAphilskTN7U3URvBVxlVr0PzheMeWqo7PaOqh//Hg=
github.com/pion/rtp v1.8.7-0.20240429002300-bc5124c9d0d0/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU=
github.com/pion/sdp/v3 v3.0.9 h1:pX++dCHoHUwq43kuwf3PyJfHlwIj4hXA7Vrifiq0IJY=
github.com/pion/sdp/v3 v3.0.9/go.mod h1:B5xmvENq5IXJimIO4zfp6LAe1fD9N+kFv+V/1lOdz8M=
github.com/pkg/profile v1.4.0/go.mod h1:NWz/XGvpEW1FyYQ7fCx4dqYBLlfTcE+A9FLAkNKqjFE=
Expand Down
30 changes: 23 additions & 7 deletions pkg/format/rtpvp9/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var cases = []struct {
}{
{
"single",
[]byte{0x01, 0x02, 0x03, 0x04},
[]byte{0x82, 0x49, 0x83, 0x42, 0x0, 0x77, 0xf0, 0x32, 0x34},
[]*rtp.Packet{
{
Header: rtp.Header{
Expand All @@ -49,13 +49,20 @@ var cases = []struct {
SequenceNumber: 17645,
SSRC: 0x9dbb7812,
},
Payload: []byte{0x9c, 0xb5, 0xaf, 0x01, 0x02, 0x03, 0x04},
Payload: []byte{
0x8f, 0xb5, 0xaf, 0x18, 0x07, 0x80, 0x03, 0x24,
0x01, 0x14, 0x01, 0x82, 0x49, 0x83, 0x42, 0x00,
0x77, 0xf0, 0x32, 0x34,
},
},
},
},
{
"fragmented",
bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 4096/4),
mergeBytes(
[]byte{0x82, 0x49, 0x83, 0x42, 0x0, 0x77, 0xf0, 0x32, 0x34},
bytes.Repeat([]byte{1, 2, 3, 4}, 4096/4),
),
[]*rtp.Packet{
{
Header: rtp.Header{
Expand All @@ -65,7 +72,13 @@ var cases = []struct {
SequenceNumber: 17645,
SSRC: 0x9dbb7812,
},
Payload: mergeBytes([]byte{0x98, 0xb5, 0xaf}, bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 364), []byte{0x01}),
Payload: mergeBytes(
[]byte{
0x8b, 0xb5, 0xaf, 0x18, 0x07, 0x80, 0x03, 0x24,
0x01, 0x14, 0x01, 0x82, 0x49, 0x83, 0x42, 0x00,
0x77, 0xf0, 0x32, 0x34,
},
bytes.Repeat([]byte{1, 2, 3, 4}, 360)),
},
{
Header: rtp.Header{
Expand All @@ -75,8 +88,9 @@ var cases = []struct {
SequenceNumber: 17646,
SSRC: 0x9dbb7812,
},
Payload: mergeBytes([]byte{0x90, 0xb5, 0xaf, 0x02, 0x03, 0x04},
bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 363), []byte{0x01, 0x02}),
Payload: mergeBytes(
[]byte{0x81, 0xb5, 0xaf},
bytes.Repeat([]byte{1, 2, 3, 4}, 364), []byte{1}),
},
{
Header: rtp.Header{
Expand All @@ -86,7 +100,9 @@ var cases = []struct {
SequenceNumber: 17647,
SSRC: 0x9dbb7812,
},
Payload: mergeBytes([]byte{0x94, 0xb5, 0xaf, 0x03, 0x04}, bytes.Repeat([]byte{0x01, 0x02, 0x03, 0x04}, 295)),
Payload: mergeBytes(
[]byte{0x85, 0xb5, 0xaf, 2, 3, 4},
bytes.Repeat([]byte{1, 2, 3, 4}, 299)),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/format/vp9_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestVP9DecEncoder(t *testing.T) {
enc, err := format.CreateEncoder()
require.NoError(t, err)

pkts, err := enc.Encode([]byte{0x01, 0x02, 0x03, 0x04})
pkts, err := enc.Encode([]byte{0x82, 0x49, 0x83, 0x42, 0x0, 0x77, 0xf0, 0x32, 0x34})
require.NoError(t, err)
require.Equal(t, format.PayloadType(), pkts[0].PayloadType)

Expand All @@ -31,5 +31,5 @@ func TestVP9DecEncoder(t *testing.T) {

byts, err := dec.Decode(pkts[0])
require.NoError(t, err)
require.Equal(t, []byte{0x01, 0x02, 0x03, 0x04}, byts)
require.Equal(t, []byte{0x82, 0x49, 0x83, 0x42, 0x0, 0x77, 0xf0, 0x32, 0x34}, byts)
}
Loading