mirror of https://bitbucket.org/ausocean/av.git
78 lines
2.0 KiB
Go
78 lines
2.0 KiB
Go
|
/*
|
||
|
NAME
|
||
|
flv_test.go
|
||
|
|
||
|
DESCRIPTION
|
||
|
flv_test.go provides testing for functionality provided in flv.go.
|
||
|
|
||
|
AUTHORS
|
||
|
Saxon A. Nelson-Milton <saxon@ausocean.org>
|
||
|
|
||
|
LICENSE
|
||
|
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
|
||
|
for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with revid in gpl.txt. If not, see http://www.gnu.org/licenses.
|
||
|
*/
|
||
|
|
||
|
package flv
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestVideoTagBytes(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
tag VideoTag
|
||
|
expected []byte
|
||
|
}{
|
||
|
{
|
||
|
tag: VideoTag{
|
||
|
TagType: VideoTagType,
|
||
|
DataSize: 12,
|
||
|
Timestamp: 1234,
|
||
|
TimestampExtended: 56,
|
||
|
FrameType: KeyFrameType, // 1
|
||
|
Codec: H264, // 7
|
||
|
PacketType: AVCNALU, // 1
|
||
|
CompositionTime: 0,
|
||
|
Data: []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07},
|
||
|
},
|
||
|
expected: []byte{
|
||
|
0x09, // TagType.
|
||
|
0x00, 0x00, 0x0c, // DataSize.
|
||
|
0x00, 0x04, 0xd2, // Timestamp.
|
||
|
0x38, // TimestampExtended.
|
||
|
0x00, 0x00, 0x00, // StreamID. (always 0)
|
||
|
0x17, // FrameType=0001, Codec=0111
|
||
|
0x01, // PacketType.
|
||
|
0x00, 0x00, 0x00, // CompositionTime
|
||
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // VideoData.
|
||
|
0x00, 0x00, 0x00, 0x00, // previousTagSize.
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for testNum, test := range tests {
|
||
|
got := test.tag.Bytes()
|
||
|
if !bytes.Equal(got, test.expected) {
|
||
|
t.Errorf("did not get expected result for test: %v.\n Got: %v\n Want: %v\n", testNum, got, test.expected)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestAudioTagBytes(t *testing.T) {
|
||
|
|
||
|
}
|