Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update directory structure #145

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
check-latest: true
- run: go vet ./...
- run: go test -coverprofile=coverage.txt -covermode=atomic ./...
- run: go install ./mp4tool
- run: go install ./cmd/mp4tool
- name: Upload Coverage Report
if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.go-version == '1.19' }}
env:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ If you should reduce Read function calls, you can wrap the io.ReadSeeker by [buf
Install mp4tool as follows:

```sh
go install github.com/abema/go-mp4/mp4tool@latest
go install github.com/abema/go-mp4/cmd/mp4tool@latest

mp4tool -help
```
Expand Down
2 changes: 1 addition & 1 deletion box.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"math"

"github.com/abema/go-mp4/bitio"
"github.com/abema/go-mp4/internal/bitio"
)

const LengthUnlimited = math.MaxUint32
Expand Down
4 changes: 2 additions & 2 deletions box_types_iso14496_12.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"io"

"github.com/abema/go-mp4/bitio"
"github.com/abema/go-mp4/util"
"github.com/abema/go-mp4/internal/bitio"
"github.com/abema/go-mp4/internal/util"
)

/*************************** btrt ****************************/
Expand Down
2 changes: 1 addition & 1 deletion box_types_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mp4
import (
"fmt"

"github.com/abema/go-mp4/util"
"github.com/abema/go-mp4/internal/util"
)

/*************************** ilst ****************************/
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion mp4tool/dump/dump.go → cmd/mp4tool/internal/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/abema/go-mp4"
"github.com/abema/go-mp4/mp4tool/util"
"github.com/abema/go-mp4/cmd/mp4tool/internal/util"
"github.com/sunfish-shogi/bufseekio"
"golang.org/x/term"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,24 @@ func TestDump(t *testing.T) {
}{
{
name: "sample.mp4 no-options",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
wants: sampleMP4Output,
},
{
name: "sample.mp4 with -full mvhd,loci option",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
options: []string{"-full", "mvhd,loci"},
wants: sampleMP4OutputFullMvhdLoci,
},
{
name: "sample.mp4 with -offset option",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
options: []string{"-offset"},
wants: sampleMP4OutputOffset,
},
{
name: "sample.mp4 with -hex option",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
options: []string{"-hex"},
wants: sampleMP4OutputHex,
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"

"github.com/abema/go-mp4"
"github.com/abema/go-mp4/mp4tool/util"
"github.com/abema/go-mp4/cmd/mp4tool/internal/util"
"github.com/sunfish-shogi/bufseekio"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ func TestExtract(t *testing.T) {
}{
{
name: "sample.mp4/ftyp",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
boxType: "ftyp",
expectedSize: 32,
},
{
name: "sample.mp4/mdhd",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
boxType: "mdhd",
expectedSize: 64, // = 32 (1st trak) + 32 (2nd trak)
},
{
name: "sample_fragmented.mp4/trun",
file: "../../_examples/sample_fragmented.mp4",
file: "../../../../testdata/sample_fragmented.mp4",
boxType: "trun",
expectedSize: 452,
},
Expand All @@ -56,11 +56,11 @@ func TestExtract(t *testing.T) {

func TestValidation(t *testing.T) {
// valid
require.Zero(t, Main([]string{"xxxx", "../../_examples/sample.mp4"}))
require.Zero(t, Main([]string{"xxxx", "../../../../testdata/sample.mp4"}))

// invalid
require.NotZero(t, Main([]string{}))
require.NotZero(t, Main([]string{"xxxx"}))
require.NotZero(t, Main([]string{"xxxxx", "../../_examples/sample.mp4"}))
require.NotZero(t, Main([]string{"xxxxx", "../../../../testdata/sample.mp4"}))
require.NotZero(t, Main([]string{"xxxx", "not_found.mp4"}))
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ func TestProbe(t *testing.T) {
}{
{
name: "sample.mp4 no-options",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
wants: sampleMP4JSONOutput,
},
{
name: "sample.mp4 format-json",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
options: []string{"-format", "json"},
wants: sampleMP4JSONOutput,
},
{
name: "sample.mp4 format-json",
file: "../../_examples/sample.mp4",
file: "../../../../testdata/sample.mp4",
options: []string{"-format", "yaml"},
wants: sampleMP4YamlOutput,
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestPsshdump(t *testing.T) {
}{
{
name: "sample_init.encv.mp4",
file: "../../_examples/sample_init.encv.mp4",
file: "../../../../testdata/sample_init.encv.mp4",
wants: "0:\n" +
" offset: 1307\n" +
" size: 52\n" +
Expand All @@ -31,7 +31,7 @@ func TestPsshdump(t *testing.T) {
},
{
name: "sample_init.encv.mp4",
file: "../../_examples/sample_init.enca.mp4",
file: "../../../../testdata/sample_init.enca.mp4",
wants: "0:\n" +
" offset: 1307\n" +
" size: 52\n" +
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions mp4tool/main.go → cmd/mp4tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"fmt"
"os"

"github.com/abema/go-mp4/mp4tool/divide"
"github.com/abema/go-mp4/mp4tool/dump"
"github.com/abema/go-mp4/mp4tool/edit"
"github.com/abema/go-mp4/mp4tool/extract"
"github.com/abema/go-mp4/mp4tool/probe"
"github.com/abema/go-mp4/mp4tool/psshdump"
"github.com/abema/go-mp4/cmd/mp4tool/internal/divide"
"github.com/abema/go-mp4/cmd/mp4tool/internal/dump"
"github.com/abema/go-mp4/cmd/mp4tool/internal/edit"
"github.com/abema/go-mp4/cmd/mp4tool/internal/extract"
"github.com/abema/go-mp4/cmd/mp4tool/internal/probe"
"github.com/abema/go-mp4/cmd/mp4tool/internal/psshdump"
)

func main() {
Expand Down
8 changes: 4 additions & 4 deletions extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestExtractBoxWithPayload(t *testing.T) {

for _, c := range testCases {
t.Run(c.name, func(t *testing.T) {
f, err := os.Open("./_examples/sample.mp4")
f, err := os.Open("./testdata/sample.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down Expand Up @@ -166,7 +166,7 @@ func TestExtractBox(t *testing.T) {

for _, c := range testCases {
t.Run(c.name, func(t *testing.T) {
f, err := os.Open("./_examples/sample.mp4")
f, err := os.Open("./testdata/sample.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down Expand Up @@ -234,7 +234,7 @@ func TestExtractBoxes(t *testing.T) {

for _, c := range testCases {
t.Run(c.name, func(t *testing.T) {
f, err := os.Open("./_examples/sample.mp4")
f, err := os.Open("./testdata/sample.mp4")
require.NoError(t, err)
defer f.Close()

Expand All @@ -251,7 +251,7 @@ func TestExtractBoxes(t *testing.T) {
}

func TestExtractDescendantBox(t *testing.T) {
f, err := os.Open("./_examples/sample.mp4")
f, err := os.Open("./testdata/sample.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion marshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"math"
"reflect"

"github.com/abema/go-mp4/bitio"
"github.com/abema/go-mp4/internal/bitio"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion marshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/abema/go-mp4/bitio"
"github.com/abema/go-mp4/internal/bitio"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
2 changes: 1 addition & 1 deletion probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"errors"
"io"

"github.com/abema/go-mp4/bitio"
"github.com/abema/go-mp4/internal/bitio"
)

type ProbeInfo struct {
Expand Down
10 changes: 5 additions & 5 deletions probe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestProbe(t *testing.T) {
f, err := os.Open("./_examples/sample.mp4")
f, err := os.Open("./testdata/sample.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down Expand Up @@ -75,7 +75,7 @@ func TestProbe(t *testing.T) {
}

func TestProbeEncryptedVideo(t *testing.T) {
f, err := os.Open("./_examples/sample_init.encv.mp4")
f, err := os.Open("./testdata/sample_init.encv.mp4")
require.NoError(t, err)
defer f.Close()

Expand All @@ -94,7 +94,7 @@ func TestProbeEncryptedVideo(t *testing.T) {
}

func TestProbeEncryptedAudio(t *testing.T) {
f, err := os.Open("./_examples/sample_init.enca.mp4")
f, err := os.Open("./testdata/sample_init.enca.mp4")
require.NoError(t, err)
defer f.Close()

Expand All @@ -111,7 +111,7 @@ func TestProbeEncryptedAudio(t *testing.T) {
}

func TestProbeWithFMP4(t *testing.T) {
f, err := os.Open("./_examples/sample_fragmented.mp4")
f, err := os.Open("./testdata/sample_fragmented.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down Expand Up @@ -165,7 +165,7 @@ func TestProbeWithFMP4(t *testing.T) {
}

func TestProbeFra(t *testing.T) {
f, err := os.Open("./_examples/sample_fragmented.mp4")
f, err := os.Open("./testdata/sample_fragmented.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down
6 changes: 3 additions & 3 deletions read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestReadBoxStructure(t *testing.T) {
f, err := os.Open("./_examples/sample.mp4")
f, err := os.Open("./testdata/sample.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down Expand Up @@ -74,7 +74,7 @@ func TestReadBoxStructure(t *testing.T) {
assert.Equal(t, 57, n)
}

// > mp4tool dump _examples/sample.mp4 | cat -n
// > mp4tool dump testdata/sample.mp4 | cat -n
// 1 [ftyp] Size=32 MajorBrand="isom" MinorVersion=512 CompatibleBrands=[{CompatibleBrand="isom"}, {CompatibleBrand="iso2"}, {CompatibleBrand="avc1"}, {CompatibleBrand="mp41"}]
// 2 [free] Size=8 Data=[...] (use "-full free" to show all)
// 3 [mdat] Size=6402 Data=[...] (use "-full mdat" to show all)
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestReadBoxStructure(t *testing.T) {
// 57 [loci] (unsupported box type) Size=35 Data=[...] (use "-full loci" to show all)

func TestReadBoxStructureQT(t *testing.T) {
f, err := os.Open("./_examples/sample_qt.mp4")
f, err := os.Open("./testdata/sample_qt.mp4")
require.NoError(t, err)
defer f.Close()

Expand Down
2 changes: 1 addition & 1 deletion string.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"reflect"
"strconv"

"github.com/abema/go-mp4/util"
"github.com/abema/go-mp4/internal/util"
)

type stringifier struct {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.