tools: remove package

This commit is contained in:
Dan Kortschak 2018-09-10 21:55:32 +09:30
parent 774c826a61
commit 9409c3e41b
3 changed files with 11 additions and 130 deletions

View File

@ -26,8 +26,6 @@ LICENSE
package pes
import "bitbucket.org/ausocean/av/tools"
const maxPesSize = 10000
/*
@ -101,10 +99,10 @@ func (p *Packet) Bytes() []byte {
p.StreamID,
byte((p.Length & 0xFF00) >> 8),
byte(p.Length & 0x00FF),
(0x2<<6 | p.SC<<4 | tools.BoolToByte(p.Priority)<<3 | tools.BoolToByte(p.DAI)<<2 |
tools.BoolToByte(p.Copyright)<<1 | tools.BoolToByte(p.Original)),
(p.PDI<<6 | tools.BoolToByte(p.ESCRF)<<5 | tools.BoolToByte(p.ESRF)<<4 | tools.BoolToByte(p.DSMTMF)<<3 |
tools.BoolToByte(p.ACIF)<<2 | tools.BoolToByte(p.CRCF)<<1 | tools.BoolToByte(p.EF)),
(0x2<<6 | p.SC<<4 | boolByte(p.Priority)<<3 | boolByte(p.DAI)<<2 |
boolByte(p.Copyright)<<1 | boolByte(p.Original)),
(p.PDI<<6 | boolByte(p.ESCRF)<<5 | boolByte(p.ESRF)<<4 | boolByte(p.DSMTMF)<<3 |
boolByte(p.ACIF)<<2 | boolByte(p.CRCF)<<1 | boolByte(p.EF)),
p.HeaderLength,
}...)
if p.PDI == byte(2) {
@ -121,3 +119,10 @@ func (p *Packet) Bytes() []byte {
buf = append(buf, append(p.Stuff, p.Data...)...)
return buf
}
func boolByte(b bool) byte {
if b {
return 1
}
return 0
}

View File

@ -1,41 +0,0 @@
/*
NAME
MpegTs.go - provides a data structure intended to encapsulate the properties
of an MpegTs packet.
DESCRIPTION
See Readme.md
AUTHOR
Saxon Nelson-Milton <saxon.milton@gmail.com>
LICENSE
MpegTs.go is Copyright (C) 2017 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 [GNU licenses](http://www.gnu.org/licenses).
*/
package tools
func BoolToByte(in bool) (out byte) {
if in {
out = 1
}
return
}
// uintToBool takes a uint and returns the bool equivalent
func UintToBool(x uint) bool {
return x != 0
}

View File

@ -1,83 +0,0 @@
/*
NAME
MpegTs.go - provides a data structure intended to encapsulate the properties
of an MpegTs packet.
DESCRIPTION
See Readme.md
AUTHOR
Saxon Nelson-Milton <saxon.milton@gmail.com>
LICENSE
MpegTs.go is Copyright (C) 2017 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 [GNU licenses](http://www.gnu.org/licenses).
*/
package tools
import (
"testing"
)
func TestH264Parsing(t *testing.T) {
// Using file
/*
file, err := os.Open(fileName)
if err != nil {
panic("Could not open file!")
return
}
stats, err := file.Stat()
if err != nil {
panic("Could not get file stats!")
}
buffer := make([]byte, stats.Size())
_, err = file.Read(buffer)
if err != nil {
panic("Could not read file!")
}
*/
// straight from buffer
someData := []byte{
0, 0, 1, 7, 59, 100, 45, 82, 93, 0, 0, 1, 8, 23, 78, 65, 0, 0, 1, 6, 45, 34, 23, 3, 2, 0, 0, 1, 5, 3, 4, 5,
56, 76, 4, 234, 78, 65, 34, 34, 43, 0, 0, 1, 7, 67, 10, 45, 8, 93, 0, 0, 1, 8, 23, 7, 5, 0, 0, 1, 6,
4, 34, 2, 3, 2, 0, 0, 1, 1, 3, 4, 5, 5, 76, 4, 234, 78, 65, 34, 34, 43, 45,
}
nalAccess1 := []byte{
0, 0, 1, 9, 240, 0, 0, 1, 7, 59, 100, 45, 82, 93, 0, 0, 1, 8, 23, 78, 65, 0, 0, 1, 6, 45, 34, 23, 3, 2, 0, 0, 1, 5, 3, 4, 5,
56, 76, 4, 234, 78, 65, 34, 34, 43,
}
nalAccess2 := []byte{
0, 0, 1, 9, 240, 0, 0, 1, 7, 67, 10, 45, 8, 93, 0, 0, 1, 8, 23, 7, 5, 0, 0, 1, 6,
4, 34, 2, 3, 2, 0, 0, 1, 1, 3, 4, 5, 5, 76, 4, 234, 78, 65, 34, 34, 43, 45,
}
aChannel := make(chan []byte, 10)
var nalAccessChan chan<- []byte
nalAccessChan = aChannel
go ParseH264Buffer(someData, nalAccessChan)
anAccessUnit := <-aChannel
for i := range anAccessUnit {
if anAccessUnit[i] != nalAccess1[i] {
t.Errorf("Should have been equal!")
}
}
anAccessUnit = <-aChannel
for i := range anAccessUnit {
if anAccessUnit[i] != nalAccess2[i] {
t.Errorf("Should have been equal!")
}
}
}