Skip to content

Commit

Permalink
Some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
djthorpe committed Jun 30, 2024
1 parent 0402cad commit 252ef43
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 46 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/djthorpe/go-tablewriter v0.0.8
github.com/mutablelogic/go-client v1.0.8
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842
)

require (
Expand Down
29 changes: 1 addition & 28 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import (
"errors"
"fmt"
"io"
"runtime"

// Package imports
version "github.com/mutablelogic/go-media/pkg/version"
ff "github.com/mutablelogic/go-media/sys/ffmpeg61"
)

Expand Down Expand Up @@ -312,32 +310,7 @@ func (manager *manager) Write(w io.Writer, format Format, metadata []Metadata, p

// Return version information for the media manager as a set of metadata
func (manager *manager) Version() []Metadata {
metadata := []Metadata{
newMetadata("libavcodec_version", ffVersionAsString(ff.AVCodec_version())),
newMetadata("libavformat_version", ffVersionAsString(ff.AVFormat_version())),
newMetadata("libavutil_version", ffVersionAsString(ff.AVUtil_version())),
newMetadata("libavdevice_version", ffVersionAsString(ff.AVDevice_version())),
// newMetadata("libavfilter_version", ff.AVFilter_version()),
newMetadata("libswscale_version", ffVersionAsString(ff.SWScale_version())),
newMetadata("libswresample_version", ffVersionAsString(ff.SWResample_version())),
}
if version.GitSource != "" {
metadata = append(metadata, newMetadata("git_source", version.GitSource))
}
if version.GitBranch != "" {
metadata = append(metadata, newMetadata("git_branch", version.GitBranch))
}
if version.GitTag != "" {
metadata = append(metadata, newMetadata("git_tag", version.GitTag))
}
if version.GoBuildTime != "" {
metadata = append(metadata, newMetadata("go_build_time", version.GoBuildTime))
}
if runtime.Version() != "" {
metadata = append(metadata, newMetadata("go_version", runtime.Version()))
metadata = append(metadata, newMetadata("go_arch", runtime.GOOS+"/"+runtime.GOARCH))
}
return metadata
return nil
}

// Log error messages
Expand Down
14 changes: 0 additions & 14 deletions manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@ func Test_manager_002(t *testing.T) {
t.Log(formats)
}

func Test_manager_003(t *testing.T) {
assert := assert.New(t)

manager, err := NewManager()
if !assert.NoError(err) {
t.SkipNow()
}

version := manager.Version()
assert.NotNil(version)

tablewriter.New(os.Stderr, tablewriter.OptHeader(), tablewriter.OptOutputText()).Write(version)
}

func Test_manager_004(t *testing.T) {
assert := assert.New(t)

Expand Down
2 changes: 1 addition & 1 deletion pkg/ffmpeg/rescaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func Test_rescaler_002(t *testing.T) {
assert := assert.New(t)

// Create an image generator
image, err := generator.NewYUV420P(ffmpeg.VideoPar("yuva420p", "1280x720", 25))
image, err := generator.NewYUV420P(ffmpeg.VideoPar("yuv420p", "1280x720", 25))
if !assert.NoError(err) {
t.FailNow()
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/generator/yuv420p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

func Test_yuv420p_001(t *testing.T) {
assert := assert.New(t)
image, err := generator.NewYUV420P(25, ffmpeg.VideoPar("yuva420p", "1280x720"))
image, err := generator.NewYUV420P(ffmpeg.VideoPar("yuv420p", "1280x720", 25))
if !assert.NoError(err) {
t.FailNow()
}
Expand All @@ -25,7 +25,7 @@ func Test_yuv420p_001(t *testing.T) {

func Test_yuv420p_002(t *testing.T) {
assert := assert.New(t)
image, err := generator.NewYUV420P(25, ffmpeg.VideoPar("yuva420p", "1280x720"))
image, err := generator.NewYUV420P(ffmpeg.VideoPar("yuv420p", "1280x720", 25))
if !assert.NoError(err) {
t.FailNow()
}
Expand All @@ -39,7 +39,7 @@ func Test_yuv420p_002(t *testing.T) {

func Test_yuv420p_003(t *testing.T) {
assert := assert.New(t)
image, err := generator.NewYUV420P(25, ffmpeg.VideoPar("yuva420p", "1280x720"))
image, err := generator.NewYUV420P(ffmpeg.VideoPar("yuv420p", "1280x720", 25))
if !assert.NoError(err) {
t.FailNow()
}
Expand Down
45 changes: 45 additions & 0 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
package version

import (
"fmt"
"runtime"

ffmpeg "github.com/mutablelogic/go-media/pkg/ffmpeg"
ff "github.com/mutablelogic/go-media/sys/ffmpeg61"
)

var (
GitSource string
GitTag string
GitBranch string
GoBuildTime string
)

// Return version information as a set of metadata
func Version() []*ffmpeg.Metadata {
metadata := []*ffmpeg.Metadata{
ffmpeg.NewMetadata("libavcodec_version", ffVersionAsString(ff.AVCodec_version())),
ffmpeg.NewMetadata("libavformat_version", ffVersionAsString(ff.AVFormat_version())),
ffmpeg.NewMetadata("libavutil_version", ffVersionAsString(ff.AVUtil_version())),
ffmpeg.NewMetadata("libavdevice_version", ffVersionAsString(ff.AVDevice_version())),
// newMetadata("libavfilter_version", ff.AVFilter_version()),
ffmpeg.NewMetadata("libswscale_version", ffVersionAsString(ff.SWScale_version())),
ffmpeg.NewMetadata("libswresample_version", ffVersionAsString(ff.SWResample_version())),
}
if GitSource != "" {
metadata = append(metadata, ffmpeg.NewMetadata("git_source", GitSource))
}
if GitBranch != "" {
metadata = append(metadata, ffmpeg.NewMetadata("git_branch", GitBranch))
}
if GitTag != "" {
metadata = append(metadata, ffmpeg.NewMetadata("git_tag", GitTag))
}
if GoBuildTime != "" {
metadata = append(metadata, ffmpeg.NewMetadata("go_build_time", GoBuildTime))
}
if runtime.Version() != "" {
metadata = append(metadata, ffmpeg.NewMetadata("go_version", runtime.Version()))
metadata = append(metadata, ffmpeg.NewMetadata("go_arch", runtime.GOOS+"/"+runtime.GOARCH))
}
return metadata
}

////////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS

func ffVersionAsString(version uint) string {
return fmt.Sprintf("%d.%d.%d", version&0xFF0000>>16, version&0xFF00>>8, version&0xFF)
}

0 comments on commit 252ef43

Please sign in to comment.