2019-04-16 10:15:44 +03:00
|
|
|
/*
|
|
|
|
NAME
|
|
|
|
rtcp_test.go
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
rtcp_test.go contains testing utilities for functionality provided in rtcp_test.go.
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
This is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
2019-04-23 08:08:26 +03:00
|
|
|
for more details.
|
2019-04-16 10:15:44 +03:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
2019-04-10 10:03:12 +03:00
|
|
|
package rtcp
|
|
|
|
|
2019-04-10 10:24:01 +03:00
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"math"
|
|
|
|
"testing"
|
|
|
|
)
|
2019-04-10 10:03:12 +03:00
|
|
|
|
2019-04-15 07:31:38 +03:00
|
|
|
// TestReceiverReportBytes checks that we can correctly obtain a []byte of an
|
|
|
|
// RTCP receiver report from the struct representation.
|
2019-04-10 10:03:12 +03:00
|
|
|
func TestReceiverReportBytes(t *testing.T) {
|
2019-04-10 10:24:01 +03:00
|
|
|
expect := []byte{
|
|
|
|
0x81, 0xc9, 0x00, 0x07,
|
|
|
|
0xd6, 0xe0, 0x98, 0xda,
|
|
|
|
0x6f, 0xad, 0x40, 0xc6,
|
|
|
|
0x00, 0xff, 0xff, 0xff,
|
|
|
|
0x00, 0x01, 0x83, 0x08,
|
|
|
|
0x00, 0x00, 0x00, 0x20,
|
|
|
|
0xb9, 0xe1, 0x25, 0x2a,
|
|
|
|
0x00, 0x00, 0x2b, 0xf9,
|
|
|
|
}
|
2019-04-10 10:03:12 +03:00
|
|
|
|
2019-04-10 10:24:01 +03:00
|
|
|
report := ReceiverReport{
|
|
|
|
Header: Header{
|
|
|
|
Version: 2,
|
|
|
|
Padding: false,
|
|
|
|
ReportCount: 1,
|
|
|
|
Type: typeReceiverReport,
|
|
|
|
},
|
2019-04-12 04:44:07 +03:00
|
|
|
SenderSSRC: 3605043418,
|
2019-04-10 10:24:01 +03:00
|
|
|
Blocks: []ReportBlock{
|
|
|
|
ReportBlock{
|
2019-04-23 08:00:05 +03:00
|
|
|
SourceIdentifier: 1873625286,
|
|
|
|
FractionLost: 0,
|
|
|
|
PacketsLost: math.MaxUint32,
|
|
|
|
HighestSequence: 99080,
|
|
|
|
Jitter: 32,
|
|
|
|
SenderReportTs: 3118540074,
|
|
|
|
SenderReportDelay: 11257,
|
2019-04-10 10:24:01 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Extensions: nil,
|
|
|
|
}
|
|
|
|
|
2019-04-15 10:26:52 +03:00
|
|
|
got := report.Bytes(nil)
|
2019-04-10 10:24:01 +03:00
|
|
|
if !bytes.Equal(got, expect) {
|
|
|
|
t.Errorf("did not get expected result. \nGot: %v\nWant: %v\n", got, expect)
|
|
|
|
}
|
2019-04-10 10:03:12 +03:00
|
|
|
}
|
|
|
|
|
2019-04-15 07:31:38 +03:00
|
|
|
// TestSourceDescriptionBytes checks that we can correctly obtain a []byte of an
|
|
|
|
// RTCP source description from the struct representation.
|
2019-04-10 10:03:12 +03:00
|
|
|
func TestSourceDescriptionBytes(t *testing.T) {
|
2019-04-12 04:44:07 +03:00
|
|
|
expect := []byte{
|
|
|
|
0x81, 0xca, 0x00, 0x04,
|
|
|
|
0xd6, 0xe0, 0x98, 0xda,
|
|
|
|
0x01, 0x08, 0x73, 0x61,
|
|
|
|
0x78, 0x6f, 0x6e, 0x2d,
|
|
|
|
0x70, 0x63, 0x00, 0x00,
|
|
|
|
}
|
2019-04-10 10:03:12 +03:00
|
|
|
|
2019-04-23 08:03:27 +03:00
|
|
|
description := Description{
|
2019-04-12 04:44:07 +03:00
|
|
|
Header: Header{
|
|
|
|
Version: 2,
|
|
|
|
Padding: false,
|
|
|
|
ReportCount: 1,
|
2019-04-23 08:03:27 +03:00
|
|
|
Type: typeDescription,
|
2019-04-12 04:44:07 +03:00
|
|
|
},
|
|
|
|
Chunks: []Chunk{
|
|
|
|
Chunk{
|
|
|
|
SSRC: 3605043418,
|
|
|
|
Items: []SDESItem{
|
|
|
|
SDESItem{
|
|
|
|
Type: typeCName,
|
|
|
|
Text: []byte("saxon-pc"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2019-04-15 10:26:52 +03:00
|
|
|
got := description.Bytes(nil)
|
2019-04-12 04:44:07 +03:00
|
|
|
if !bytes.Equal(got, expect) {
|
|
|
|
t.Errorf("Did not get expected result.\nGot: %v\n Want: %v\n", got, expect)
|
|
|
|
}
|
2019-04-10 10:03:12 +03:00
|
|
|
}
|