From 9409c3e41baec7bcb130647474fbd5767cb62515 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Mon, 10 Sep 2018 21:55:32 +0930 Subject: [PATCH 1/2] tools: remove package --- stream/mts/pes/pes.go | 17 +++++---- tools/helpers.go | 41 --------------------- tools/tools_test.go | 83 ------------------------------------------- 3 files changed, 11 insertions(+), 130 deletions(-) delete mode 100644 tools/helpers.go delete mode 100644 tools/tools_test.go diff --git a/stream/mts/pes/pes.go b/stream/mts/pes/pes.go index 01285981..1ec9bf71 100644 --- a/stream/mts/pes/pes.go +++ b/stream/mts/pes/pes.go @@ -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 +} diff --git a/tools/helpers.go b/tools/helpers.go deleted file mode 100644 index f0576353..00000000 --- a/tools/helpers.go +++ /dev/null @@ -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 - -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 -} diff --git a/tools/tools_test.go b/tools/tools_test.go deleted file mode 100644 index 302e1e93..00000000 --- a/tools/tools_test.go +++ /dev/null @@ -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 - -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!") - } - } -} From 57ff89746c5250adba2d2ed976e90f40125a41e4 Mon Sep 17 00:00:00 2001 From: Dan Kortschak Date: Mon, 10 Sep 2018 21:56:15 +0930 Subject: [PATCH 2/2] revid: remove non-automated tests --- revid/revid_test.go | 168 -------------------------------------------- 1 file changed, 168 deletions(-) delete mode 100644 revid/revid_test.go diff --git a/revid/revid_test.go b/revid/revid_test.go deleted file mode 100644 index 79f07fc4..00000000 --- a/revid/revid_test.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -NAME - revid_test.go - -DESCRIPTION - See Readme.md - -AUTHOR - Saxon Nelson-Milton - -LICENSE - revid_test.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 revid - -import ( - "testing" - "time" -) - -/* -// Test revidInst with a file input -func TestFileInput(t *testing.T){ - config := Config{ - Input: File, - InputFileName: "testInput.h264", - Output: File, - OutputFileName: "output/TestFileAsInput.ts", - } - revidInst, err := NewRevidInstance(config) - if err != nil { - t.Errorf("Should not have got error!: %v\n", err.Error()) - return - } - revidInst.Start() - time.Sleep(100*time.Second) - revidInst.Stop() -} - -// Test revidInst with a Raspivid h264 input -func TestRaspividH264Input(t *testing.T){ - config := Config{ - Input: Raspivid, - Output: File, - OutputFileName: "output/TestRaspividOutput.ts", - Width: "1280", - Height: "720", - FrameRate: "25", - } - revidInst, err := NewRevidInstance(config) - if err != nil { - t.Errorf("Should not have got an error!") - return - } - revidInst.Start() - time.Sleep(100*time.Second) - revidInst.Stop() -} - - -// Test revidInst with a raspivid mjpeg input -func TestRaspividMJPEGInput(t *testing.T){ - config := Config{ - Input: Raspivid, - InputCodec: Mjpeg, - Output: File, - OutputFileName: "output/TestMjpeg.mjpeg", - Width: "1280", - Bitrate: "10000000", - Height: "720", - FrameRate: "25", - } - revidInst, err := NewRevidInstance(config) - if err != nil { - t.Errorf("Should not of have got an error!: %v\n", err.Error()) - return - } - revidInst.Start() - time.Sleep(20*time.Second) - revidInst.Stop() -} - - - - -// Test h264 inputfile to flv output files -func TestFlvOutputFile(t *testing.T) { - config := Config{ - Input: File, - InputFileName: "betterInput.h264", - InputCodec: H264, - Output: File, - OutputFileName: "saxonOut.flv", - Packetization: Flv, - FrameRate: "25", - } - revidInst, err := NewRevidInstance(config) - if err != nil { - t.Errorf("Should not of have got an error!: %v\n", err.Error()) - return - } - revidInst.Start() - time.Sleep(30 * time.Second) - revidInst.Stop() -} -*/ - -/* -// Test h264 inputfile to flv format into rtmp using librtmp c wrapper -func TestRtmpOutputUsingLibRtmp(t *testing.T){ - config := Config{ - Input: File, - InputFileName: "input/betterInput.h264", - InputCodec: H264, - Output: Rtmp, - RtmpMethod: LibRtmp, - RtmpUrl: "rtmp://a.rtmp.youtube.com/live2/w44c-mkuu-aezg-ceb1", - FramesPerClip: 1, - Packetization: Flv, - FrameRate: "25", - } - revidInst, err := NewRevidInstance(config) - if err != nil { - t.Errorf("Should not of have got an error!: %v\n", err.Error()) - return - } - revidInst.Start() - time.Sleep(120*time.Second) - revidInst.Stop() -} -*/ - -// Test revidInst with a Raspivid h264 input -func TestRaspividToRtmp(t *testing.T) { - config := Config{ - Input: Raspivid, - Output: Rtmp, - RtmpMethod: LibRtmp, - QuantizationMode: QuantizationOff, - RtmpUrl: "rtmp://a.rtmp.youtube.com/live2/w44c-mkuu-aezg-ceb1", - Bitrate: "500000", - FramesPerClip: 1, - Packetization: Flv, - FrameRate: "25", - } - revidInst, err := NewRevid(config) - if err != nil { - t.Errorf("Should not have got an error!") - return - } - revidInst.Start() - time.Sleep(43200 * time.Second) - revidInst.Stop() -}