mirror of
https://github.com/thinkonmay/sunshine-sdk.git
synced 2026-01-03 07:02:26 +00:00
remove av1 test
This commit is contained in:
parent
91264dc166
commit
78ba877fc2
@ -1,47 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// Package frame provides code to construct complete media frames from packetized media.
|
||||
package frame
|
||||
|
||||
import "github.com/pion/rtp/codecs"
|
||||
|
||||
// AV1 represents a collection of OBUs given a stream of AV1 Packets.
|
||||
// Each AV1 RTP Packet is a collection of OBU Elements. Each OBU Element may be a full OBU, or just a fragment of one.
|
||||
// AV1 provides the tools to construct a collection of OBUs from a collection of OBU Elements. This structure
|
||||
// contains an internal cache and should be used for the entire RTP Stream.
|
||||
type AV1 struct {
|
||||
// Buffer for fragmented OBU. If ReadFrames is called on a RTP Packet
|
||||
// that doesn't contain a fully formed OBU
|
||||
obuBuffer []byte
|
||||
}
|
||||
|
||||
func (f *AV1) pushOBUElement(isFirstOBUFragment *bool, obuElement []byte, obuList [][]byte) [][]byte {
|
||||
if *isFirstOBUFragment {
|
||||
*isFirstOBUFragment = false
|
||||
// Discard pushed because we don't have a fragment to combine it with
|
||||
if f.obuBuffer == nil {
|
||||
return obuList
|
||||
}
|
||||
obuElement = append(f.obuBuffer, obuElement...)
|
||||
f.obuBuffer = nil
|
||||
}
|
||||
return append(obuList, obuElement)
|
||||
}
|
||||
|
||||
// ReadFrames processes the codecs.AV1Packet and returns fully constructed frames
|
||||
func (f *AV1) ReadFrames(pkt *codecs.AV1Packet) ([][]byte, error) {
|
||||
OBUs := [][]byte{}
|
||||
isFirstOBUFragment := pkt.Z
|
||||
|
||||
for i := range pkt.OBUElements {
|
||||
OBUs = f.pushOBUElement(&isFirstOBUFragment, pkt.OBUElements[i], OBUs)
|
||||
}
|
||||
|
||||
if pkt.Y && len(OBUs) > 0 {
|
||||
// Take copy of OBUElement that is being cached
|
||||
f.obuBuffer = append(f.obuBuffer, append([]byte{}, OBUs[len(OBUs)-1]...)...)
|
||||
OBUs = OBUs[:len(OBUs)-1]
|
||||
}
|
||||
return OBUs, nil
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package frame
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/pion/rtp/codecs"
|
||||
)
|
||||
|
||||
// First is Fragment (and no buffer)
|
||||
// Self contained OBU
|
||||
// OBU spread across 3 packets
|
||||
func TestAV1_ReadFrames(t *testing.T) {
|
||||
// First is Fragment of OBU, but no OBU Elements is cached
|
||||
f := &AV1{}
|
||||
frames, err := f.ReadFrames(&codecs.AV1Packet{Z: true, OBUElements: [][]byte{{0x01}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(frames, [][]byte{}) {
|
||||
t.Fatalf("No frames should be generated, %v", frames)
|
||||
}
|
||||
|
||||
f = &AV1{}
|
||||
frames, err = f.ReadFrames(&codecs.AV1Packet{OBUElements: [][]byte{{0x01}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(frames, [][]byte{{0x01}}) {
|
||||
t.Fatalf("One frame should be generated, %v", frames)
|
||||
}
|
||||
|
||||
f = &AV1{}
|
||||
frames, err = f.ReadFrames(&codecs.AV1Packet{Y: true, OBUElements: [][]byte{{0x00}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(frames, [][]byte{}) {
|
||||
t.Fatalf("No frames should be generated, %v", frames)
|
||||
}
|
||||
|
||||
frames, err = f.ReadFrames(&codecs.AV1Packet{Z: true, OBUElements: [][]byte{{0x01}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if !reflect.DeepEqual(frames, [][]byte{{0x00, 0x01}}) {
|
||||
t.Fatalf("One frame should be generated, %v", frames)
|
||||
}
|
||||
}
|
||||
|
||||
// Marshal some AV1 Frames to RTP, assert that AV1 can get them back in the original format
|
||||
func TestAV1_ReadFrames_E2E(t *testing.T) {
|
||||
const mtu = 1500
|
||||
frames := [][]byte{
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A},
|
||||
{0x00, 0x01},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A},
|
||||
{0x00, 0x01},
|
||||
}
|
||||
|
||||
frames = append(frames, []byte{})
|
||||
for i := 0; i <= 5; i++ {
|
||||
frames[len(frames)-1] = append(frames[len(frames)-1], []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}...)
|
||||
}
|
||||
|
||||
frames = append(frames, []byte{})
|
||||
for i := 0; i <= 500; i++ {
|
||||
frames[len(frames)-1] = append(frames[len(frames)-1], []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A}...)
|
||||
}
|
||||
|
||||
payloader := &codecs.Payloader{}
|
||||
f := &AV1{}
|
||||
for _, originalFrame := range frames {
|
||||
for _, payload := range payloader.Payload(mtu, originalFrame) {
|
||||
rtpPacket := &codecs.AV1Packet{}
|
||||
if _, err := rtpPacket.Unmarshal(payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
decodedFrame, err := f.ReadFrames(rtpPacket)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
} else if len(decodedFrame) != 0 && !reflect.DeepEqual(originalFrame, decodedFrame[0]) {
|
||||
t.Fatalf("Decode(%02x) and Original(%02x) are not equal", decodedFrame[0], originalFrame)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user