Commit 435f46c5 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Add tests for codec manipulation and rtpconn data stuctures.

parent 6f9d7fc3
package rtpconn
import (
"testing"
)
var vp8 = []byte{
0x80, 0, 0, 42,
0, 0, 0, 0,
0, 0, 0, 0,
0x90, 0x80, 0x80, 57,
0, 0, 0, 0,
}
func TestPacketFlags(t *testing.T) {
buf := append([]byte{}, vp8...)
seqno, start, pid, tid, sid, layersync, discardable, err :=
packetFlags("video/vp8", buf)
if seqno != 42 || !start || pid != 57 || sid != 0 || tid != 0 ||
layersync || discardable || err != nil {
t.Errorf("Got %v, %v, %v, %v, %v, %v (%v)",
seqno, start, pid, sid, layersync, discardable, err,
)
}
}
func TestRewrite(t *testing.T) {
for i := uint16(0); i < 0x7fff; i++ {
buf := append([]byte{}, vp8...)
err := rewritePacket("video/vp8", buf, i, i)
if err != nil {
t.Errorf("rewrite: %v", err)
continue
}
seqno, _, pid, _, _, _, _, err := packetFlags("video/vp8", buf)
if err != nil || seqno != i || pid != (57 + i) & 0x7FFF {
t.Errorf("Expected %v %v, got %v %v (%v)",
i, (57 + i) & 0x7FFF, seqno, pid, err)
}
}
}
package rtpconn
import (
"testing"
"github.com/jech/galene/rtptime"
)
func TestDownTrackAtomics(t *testing.T) {
down := &rtpDownTrack{
atomics: &downTrackAtomics{},
maxBitrate: new(bitrate),
maxREMBBitrate: new(bitrate),
}
down.SetTimeOffset(1, 2)
down.setRTT(3)
down.setSRTime(4, 5)
down.maxBitrate.Set(6, rtptime.Jiffies())
down.maxREMBBitrate.Set(7, rtptime.Jiffies())
down.setLayerInfo(8, 9, 10)
ntp, rtp := down.getTimeOffset()
rtt := down.getRTT()
sr, srntp := down.getSRTime()
br, lbr := down.GetMaxBitrate()
l, w, m := down.getLayerInfo()
if ntp != 1 || rtp != 2 || rtt != 3 || sr != 4 || srntp != 5 ||
br != 6 || lbr != 8 || l != 8 || w != 9 || m != 10 {
t.Errorf(
"Expected 1 2 3 4 5 6 8 8 9 10, "+
"got %v %v %v %v %v %v %v %v %v %v",
ntp, rtp, rtt, sr, srntp, br, lbr, l, w, m,
)
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment