diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..bef5a6f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,19 @@ +name: Run tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '>=1.20.0' + - name: Run tests + run: go test -v \ No newline at end of file diff --git a/LICENSE b/LICENSE index d54bbcc..b359389 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2016-2017, Eleftherios (Lefteris) Zafiris +Copyright (c) 2016-2024, Eleftherios (Lefteris) Zafiris All rights reserved. Redistribution and use in source and binary forms, with or without modification, diff --git a/Readme.md b/Readme.md index dbfee79..74af993 100644 --- a/Readme.md +++ b/Readme.md @@ -1,5 +1,4 @@ # g711 --- import "github.com/zaf/g711" Package g711 implements encoding and decoding of G711 PCM sound data. G.711 is diff --git a/alaw.go b/alaw.go index e58e53f..34986fe 100644 --- a/alaw.go +++ b/alaw.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file diff --git a/alaw_test.go b/alaw_test.go index ffcd94c..f3c0f52 100644 --- a/alaw_test.go +++ b/alaw_test.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file diff --git a/cmd/g711dec/g711dec.go b/cmd/g711dec/g711dec.go index fd1447e..0a2ab20 100644 --- a/cmd/g711dec/g711dec.go +++ b/cmd/g711dec/g711dec.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file diff --git a/cmd/g711enc/g711enc.go b/cmd/g711enc/g711enc.go index b03abff..49d9655 100644 --- a/cmd/g711enc/g711enc.go +++ b/cmd/g711enc/g711enc.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file @@ -14,6 +14,7 @@ package main import ( "fmt" + "io" "os" "path/filepath" "strings" @@ -21,6 +22,8 @@ import ( "github.com/zaf/g711" ) +const wavHeader = 44 + func main() { if len(os.Args) < 3 || os.Args[1] == "help" || os.Args[1] == "--help" || (os.Args[1] != "ulaw" && os.Args[1] != "alaw") { fmt.Printf("%s Encodes 16bit 8kHz LPCM data to 8bit G711 PCM\n", os.Args[0]) @@ -43,7 +46,7 @@ func main() { } func encodeG711(file, format string) error { - input, err := os.ReadFile(file) + input, err := os.Open(file) if err != nil { return err } @@ -72,9 +75,8 @@ func encodeG711(file, format string) error { } } if extension == ".wav" { - _, err = encoder.Write(input[44:]) // Skip WAV header - return err + input.Seek(wavHeader, 0) // Skip wav header } - _, err = encoder.Write(input) + _, err = io.Copy(encoder, input) return err } diff --git a/g711.go b/g711.go index 8934459..3d9479c 100644 --- a/g711.go +++ b/g711.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file diff --git a/g711_test.go b/g711_test.go index c67f008..58f9b1d 100644 --- a/g711_test.go +++ b/g711_test.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file diff --git a/go.mod b/go.mod index 6e529b5..82251bb 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/zaf/g711 -go 1.17 +go 1.20 diff --git a/ulaw.go b/ulaw.go index 0c23b59..e04996a 100644 --- a/ulaw.go +++ b/ulaw.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file diff --git a/ulaw_test.go b/ulaw_test.go index f07ab4d..b9efdd6 100644 --- a/ulaw_test.go +++ b/ulaw_test.go @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 - 2017, Lefteris Zafiris + Copyright (C) 2016 - 2024, Lefteris Zafiris This program is free software, distributed under the terms of the BSD 3-Clause License. See the LICENSE file