diff --git a/_old/ffmpeg/avdevice.go b/_old/ffmpeg/avdevice.go deleted file mode 100755 index 8e50cb1..0000000 --- a/_old/ffmpeg/avdevice.go +++ /dev/null @@ -1,91 +0,0 @@ -// +build ffmpeg - -package ffmpeg - -import ( - "sync" -) - -//////////////////////////////////////////////////////////////////////////////// -// CGO - -/* -#cgo pkg-config: libavdevice -#include -*/ -import "C" - -//////////////////////////////////////////////////////////////////////////////// -// TYPES - -//////////////////////////////////////////////////////////////////////////////// -// GLOBALS - -var ( - once_avdevice_init sync.Once -) - -//////////////////////////////////////////////////////////////////////////////// -// INIT - -// Register all devices -func AVDeviceInit() { - once_avdevice_init.Do(func() { - C.avdevice_register_all() - }) -} - -//////////////////////////////////////////////////////////////////////////////// -// ENMERATE DEVICES - -func AllAudioInputDevices() []*AVInputFormat { - formats := make([]*AVInputFormat, 0) - ptr := (*C.AVInputFormat)(nil) - for { - if ptr = C.av_input_audio_device_next(ptr); ptr == nil { - break - } else { - formats = append(formats, (*AVInputFormat)(ptr)) - } - } - return formats -} - -func AllVideoInputDevices() []*AVInputFormat { - formats := make([]*AVInputFormat, 0) - ptr := (*C.AVInputFormat)(nil) - for { - if ptr = C.av_input_video_device_next(ptr); ptr == nil { - break - } else { - formats = append(formats, (*AVInputFormat)(ptr)) - } - } - return formats -} - -func AllVideoOutputDevices() []*AVOutputFormat { - formats := make([]*AVOutputFormat, 0) - ptr := (*C.AVOutputFormat)(nil) - for { - if ptr = C.av_output_video_device_next(ptr); ptr == nil { - break - } else { - formats = append(formats, (*AVOutputFormat)(ptr)) - } - } - return formats -} - -func AllAudioOutputDevices() []*AVOutputFormat { - formats := make([]*AVOutputFormat, 0) - ptr := (*C.AVOutputFormat)(nil) - for { - if ptr = C.av_output_audio_device_next(ptr); ptr == nil { - break - } else { - formats = append(formats, (*AVOutputFormat)(ptr)) - } - } - return formats -} diff --git a/_old/ffmpeg/avdevice_test.go b/_old/ffmpeg/avdevice_test.go deleted file mode 100755 index 769f563..0000000 --- a/_old/ffmpeg/avdevice_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// +build ffmpeg - -package ffmpeg_test - -import ( - "testing" - - ffmpeg "github.com/djthorpe/gopi/v3/pkg/sys/ffmpeg" -) - -//////////////////////////////////////////////////////////////////////////////// -// TEST - -func Test_avdevice_000(t *testing.T) { - ffmpeg.AVDeviceInit() - t.Log("Test_avdevice_000") -} - -func Test_avdevice_001(t *testing.T) { - ffmpeg.AVDeviceInit() - - audioinput := ffmpeg.AllAudioInputDevices() - t.Log(audioinput) -} - -func Test_avdevice_002(t *testing.T) { - ffmpeg.AVDeviceInit() - - inputs := ffmpeg.AllVideoInputDevices() - t.Log(inputs) -} - -func Test_avdevice_003(t *testing.T) { - ffmpeg.AVDeviceInit() - - outputs := ffmpeg.AllAudioOutputDevices() - t.Log(outputs) -} - -func Test_avdevice_004(t *testing.T) { - ffmpeg.AVDeviceInit() - - outputs := ffmpeg.AllVideoOutputDevices() - t.Log(outputs) -} diff --git a/_old/ffmpeg/avformat.go b/_old/ffmpeg/avformat.go deleted file mode 100755 index e3a2239..0000000 --- a/_old/ffmpeg/avformat.go +++ /dev/null @@ -1,228 +0,0 @@ -package ffmpeg - -import ( - "unsafe" - "sync" - "fmt" - "strconv" - "reflect" -) - -//////////////////////////////////////////////////////////////////////////////// -// CGO - -/* -#cgo pkg-config: libavformat -#include -*/ -import "C" - -//////////////////////////////////////////////////////////////////////////////// -// TYPES - -type ( - AVFormatContext C.struct_AVFormatContext - AVInputFormat C.struct_AVInputFormat - AVOutputFormat C.struct_AVOutputFormat - AVStream C.struct_AVStream -) - -type ( - AVIOFlags int -) - -//////////////////////////////////////////////////////////////////////////////// -// CONSTANTS - -const ( - AVIO_FLAG_NONE AVIOFlags = 0 - AVIO_FLAG_READ AVIOFlags = 1 - AVIO_FLAG_WRITE AVIOFlags = 2 - AVIO_FLAG_READ_WRITE AVIOFlags = (AVIO_FLAG_READ | AVIO_FLAG_WRITE) -) - -var ( - once_init,once_deinit sync.Once -) - -//////////////////////////////////////////////////////////////////////////////// -// INIT AND DEINIT - -// Register and Deregister -func AVFormatInit() { - once_init.Do(func() { - C.avformat_network_init() - }) -} - -func AVFormatDeinit() { - once_deinit.Do(func() { - C.avformat_network_deinit() - }) -} - -//////////////////////////////////////////////////////////////////////////////// -// AVFORMATCONTEXT - -// NewAVFormatContext creates a new format context -func NewAVFormatContext() *AVFormatContext { - return (*AVFormatContext)(C.avformat_alloc_context()) -} - -// Free AVFormatContext -func (this *AVFormatContext) Free() { - ctx := (*C.AVFormatContext)(unsafe.Pointer(this)) - C.avformat_free_context(ctx) -} - -// Open Input -func (this *AVFormatContext) OpenInput(filename string, input_format *AVInputFormat) error { - filename_ := C.CString(filename) - defer C.free(unsafe.Pointer(filename_)) - ctx := (*C.AVFormatContext)(unsafe.Pointer(this)) - dict := new(AVDictionary) - if err := AVError(C.avformat_open_input( - &ctx, - filename_, - (*C.struct_AVInputFormat)(input_format), - (**C.struct_AVDictionary)(unsafe.Pointer(dict)), - )); err != 0 { - return err - } else { - return nil - } -} - -// Close Input -func (this *AVFormatContext) CloseInput() { - ctx := (*C.AVFormatContext)(unsafe.Pointer(this)) - C.avformat_close_input(&ctx) -} - -// Return Metadata Dictionary -func (this *AVFormatContext) Metadata() *AVDictionary { - return &AVDictionary{ctx: this.metadata} -} - -// Return Filename -func (this *AVFormatContext) Filename() string { - return C.GoString(&this.filename[0]) -} - -// Return number of streams -func (this *AVFormatContext) NumStreams() uint { - ctx := (*C.AVFormatContext)(unsafe.Pointer(this)) - return uint(ctx.nb_streams) -} - -// Return Streams -func (this *AVFormatContext) Streams() []*AVStream { - var streams []*AVStream - - // Get context - ctx := (*C.AVFormatContext)(unsafe.Pointer(this)) - - // Make a fake slice - if nb_streams := this.NumStreams(); nb_streams > 0 { - // Make a fake slice - sliceHeader := (*reflect.SliceHeader)((unsafe.Pointer(&streams))) - sliceHeader.Cap = int(nb_streams) - sliceHeader.Len = int(nb_streams) - sliceHeader.Data = uintptr(unsafe.Pointer(ctx.streams)) - } - return streams -} - -//////////////////////////////////////////////////////////////////////////////// -// AVInputFormat and AVOutputFormat - -// Return input formats -func EnumerateInputFormats() []*AVInputFormat { - a := make([]*AVInputFormat,0,100) - p := unsafe.Pointer(uintptr(0)) - for { - if iformat := (*AVInputFormat)(C.av_demuxer_iterate(&p)); iformat == nil { - break - } else { - a = append(a,iformat) - } - } - return a -} - - -// Return output formats -func EnumerateOutputFormats() []*AVOutputFormat { - a := make([]*AVOutputFormat,0,100) - p := unsafe.Pointer(uintptr(0)) - for { - if oformat := (*AVOutputFormat)(C.av_muxer_iterate(&p)); oformat == nil { - break - } else { - a = append(a,oformat) - } - } - return a -} - -func (this *AVInputFormat) Name() string { - return C.GoString(this.name) -} - -func (this *AVInputFormat) Description() string { - return C.GoString(this.long_name) -} - -func (this *AVInputFormat) Ext() string { - return C.GoString(this.extensions) -} - -func (this *AVInputFormat) MimeType() string { - return C.GoString(this.mime_type) -} - - -func (this *AVOutputFormat) Name() string { - return C.GoString(this.name) -} - -func (this *AVOutputFormat) Description() string { - return C.GoString(this.long_name) -} - -func (this *AVOutputFormat) Ext() string { - return C.GoString(this.extensions) -} - -func (this *AVOutputFormat) MimeType() string { - return C.GoString(this.mime_type) -} - -func (this *AVInputFormat) String() string { - return fmt.Sprintf("{ name=%v description=%v ext=%v mime_type=%v }",strconv.Quote(this.Name()),strconv.Quote(this.Description()),strconv.Quote(this.Ext()),strconv.Quote(this.MimeType())) -} - -func (this *AVOutputFormat) String() string { - return fmt.Sprintf("{ name=%v description=%v ext=%v mime_type=%v }",strconv.Quote(this.Name()),strconv.Quote(this.Description()),strconv.Quote(this.Ext()),strconv.Quote(this.MimeType())) -} - -//////////////////////////////////////////////////////////////////////////////// -// AVStream - -func (this *AVStream) Index() int { - ctx := (*C.AVStream)(unsafe.Pointer(this)) - return int(ctx.index) -} - -func (this *AVStream) Id() int { - ctx := (*C.AVStream)(unsafe.Pointer(this)) - return int(ctx.id) -} - -func (this *AVStream) Metadata() *AVDictionary { - return &AVDictionary{ctx: this.metadata} -} - -func (this *AVStream) String() string { - return fmt.Sprintf("{ index=%v id=%v metadata=%v }",this.Index(),this.Id(),this.Metadata()) -} \ No newline at end of file diff --git a/_old/ffmpeg/avformat_test.go b/_old/ffmpeg/avformat_test.go deleted file mode 100755 index 58f0228..0000000 --- a/_old/ffmpeg/avformat_test.go +++ /dev/null @@ -1,97 +0,0 @@ -package ffmpeg_test - -import ( - "testing" - - // Frameworks - ffmpeg "github.com/djthorpe/gopi-media/ffmpeg" -) - -//////////////////////////////////////////////////////////////////////////////// -// TEST ENUMS - -func Test_avformat_000(t *testing.T) { - t.Log("Test_avformat_000") -} - -func Test_avformat_002(t *testing.T) { - if ctx := ffmpeg.NewAVFormatContext(); ctx == nil { - t.Fatal("NewAVFormatContext failed") - } else { - ctx.Free() - } -} - -func Test_avformat_003(t *testing.T) { - if ctx := ffmpeg.NewAVFormatContext(); ctx == nil { - t.Fatal("NewAVFormatContext failed") - } else if err := ctx.OpenInput("../etc/sample.mp4", nil); err != nil { - t.Error(err) - } else { - ctx.CloseInput() - } -} - -func Test_avformat_004(t *testing.T) { - if ctx := ffmpeg.NewAVFormatContext(); ctx == nil { - t.Fatal("NewAVFormatContext failed") - } else if err := ctx.OpenInput("../etc/sample.mp4", nil); err != nil { - t.Error(err) - } else { - t.Log(ctx.Metadata()) - ctx.CloseInput() - } -} - -func Test_avformat_005(t *testing.T) { - if ctx := ffmpeg.NewAVFormatContext(); ctx == nil { - t.Fatal("NewAVFormatContext failed") - } else if err := ctx.OpenInput("../etc/sample.mp4", nil); err != nil { - t.Error(err) - } else { - t.Log(ctx.Filename()) - ctx.CloseInput() - } -} - -func Test_avformat_006(t *testing.T) { - ffmpeg.AVFormatInit() - ffmpeg.AVFormatInit() - ffmpeg.AVFormatDeinit() - ffmpeg.AVFormatDeinit() -} - -func Test_avformat_007(t *testing.T) { - if iformats := ffmpeg.EnumerateInputFormats(); len(iformats) == 0 { - t.Error("EnumerateInputFormats expected a return value") - } else { - for _, iformat := range iformats { - t.Log(iformat) - } - } -} - -func Test_avformat_008(t *testing.T) { - if oformats := ffmpeg.EnumerateOutputFormats(); len(oformats) == 0 { - t.Error("EnumerateOutputFormats expected a return value") - } else { - for _, oformat := range oformats { - t.Log(oformat) - } - } -} - -func Test_avformat_009(t *testing.T) { - if ctx := ffmpeg.NewAVFormatContext(); ctx == nil { - t.Fatal("NewAVFormatContext failed") - } else if err := ctx.OpenInput("../etc/sample.mp4", nil); err != nil { - t.Error(err) - } else if streams := ctx.Streams(); len(streams) == 0 { - t.Error("No streams found") - ctx.CloseInput() - } else { - for _, stream := range streams { - t.Log(stream) - } - } -} diff --git a/_old/ffmpeg/swresample.go b/_old/ffmpeg/swresample.go deleted file mode 100755 index 2e8a81e..0000000 --- a/_old/ffmpeg/swresample.go +++ /dev/null @@ -1,108 +0,0 @@ -// +build ffmpeg - -package ffmpeg - -//////////////////////////////////////////////////////////////////////////////// -// CGO - -/* -#cgo pkg-config: libswresample -#include - -*/ -import "C" -import "fmt" - -//////////////////////////////////////////////////////////////////////////////// -// TYPES - -type ( - SwrContext C.SwrContext -) - -//////////////////////////////////////////////////////////////////////////////// -// VERSION - -//////////////////////////////////////////////////////////////////////////////// -// INIT - -func NewSwrContext() *SwrContext { - return (*SwrContext)(C.swr_alloc()) -} - -func NewSwrContextEx(in_sample_fmt, out_sample_fmt AVSampleFormat, in_rate, out_rate int, in_ch_layout, out_ch_layout AVChannelLayout) *SwrContext { - return (*SwrContext)(C.swr_alloc_set_opts( - nil, - C.int64_t(out_ch_layout), - C.enum_AVSampleFormat(out_sample_fmt), - C.int(out_rate), - C.int64_t(in_ch_layout), - C.enum_AVSampleFormat(in_sample_fmt), - C.int(in_rate), - 0, nil)) -} - -func (this *SwrContext) Init() error { - ctx := (*C.SwrContext)(this) - if err := AVError(C.swr_init(ctx)); err != 0 { - return err - } else { - return nil - } -} - -func (this *SwrContext) Close() { - ctx := (*C.SwrContext)(this) - C.swr_close(ctx) -} - -func (this *SwrContext) Free() { - ctx := (*C.SwrContext)(this) - C.swr_free(&ctx) -} - -func (this *SwrContext) IsInitialized() bool { - ctx := (*C.SwrContext)(this) - return C.swr_is_initialized(ctx) != 0 -} - -//////////////////////////////////////////////////////////////////////////////// -// AVFrame - -func (this *SwrContext) ConfigFrame(out, in *AVFrame) error { - ctx := (*C.SwrContext)(this) - if err := AVError(C.swr_config_frame(ctx, (*C.AVFrame)(out), (*C.AVFrame)(in))); err != 0 { - return err - } else if err := this.Init(); err != nil { - return err - } else { - return nil - } -} - -func (this *SwrContext) ConvertFrame(out, in *AVFrame) error { - ctx := (*C.SwrContext)(this) - if err := AVError(C.swr_convert_frame(ctx, (*C.AVFrame)(out), (*C.AVFrame)(in))); err != 0 { - return err - } else { - return nil - } -} - -func (this *SwrContext) FlushFrame(out *AVFrame) error { - ctx := (*C.SwrContext)(this) - if err := AVError(C.swr_convert_frame(ctx, (*C.AVFrame)(out), nil)); err != 0 { - return err - } else { - return nil - } -} - -//////////////////////////////////////////////////////////////////////////////// -// STRINGIFY - -func (this *SwrContext) String() string { - str := "" -} diff --git a/_old/ffmpeg/swresample_test.go b/_old/ffmpeg/swresample_test.go deleted file mode 100755 index e168452..0000000 --- a/_old/ffmpeg/swresample_test.go +++ /dev/null @@ -1,98 +0,0 @@ -// +build ffmpeg - -package ffmpeg_test - -import ( - "testing" - - ffmpeg "github.com/djthorpe/gopi/v3/pkg/sys/ffmpeg" -) - -//////////////////////////////////////////////////////////////////////////////// -// TEST ENUMS - -func Test_swresample_000(t *testing.T) { - t.Log("Test_swresample_000") -} - -func Test_swresample_001(t *testing.T) { - if ctx := ffmpeg.NewSwrContext(); ctx == nil { - t.Error("Unexpected nil return from NewSwrContext") - } else { - defer ctx.Free() - t.Log(ctx) - } -} - -func Test_swresample_002(t *testing.T) { - if ctx := ffmpeg.NewSwrContextEx( - ffmpeg.AV_SAMPLE_FMT_U8, - ffmpeg.AV_SAMPLE_FMT_U8, - 44100, - 44100, - ffmpeg.AV_CH_LAYOUT_MONO, - ffmpeg.AV_CH_LAYOUT_MONO, - ); ctx == nil { - t.Error("Unexpected nil return from NewSwrContext") - } else { - defer ctx.Free() - if err := ctx.Init(); err != nil { - t.Error(err) - } else if ctx.IsInitialized() == false { - t.Error("Expected IsInitialized=true") - } else { - t.Log(ctx) - } - } -} - -func Test_swresample_003(t *testing.T) { - ctx := ffmpeg.NewSwrContext() - if ctx == nil { - t.Error("Unexpected nil return from NewSwrContext") - } - defer ctx.Free() - - in := ffmpeg.NewAudioFrame(ffmpeg.AV_SAMPLE_FMT_U8, 44100, ffmpeg.AV_CH_LAYOUT_MONO) - if in == nil { - t.Fatal("Unexpected nil return for NewAudioFrame") - } else { - t.Log("in=", in) - } - defer in.Free() - - out := ffmpeg.NewAudioFrame(ffmpeg.AV_SAMPLE_FMT_U8, 11025, ffmpeg.AV_CH_LAYOUT_STEREO) - if out == nil { - t.Fatal("Unexpected nil return for NewAudioFrame") - } else { - t.Log("out=", out) - } - defer out.Free() - - if err := ctx.ConfigFrame(out, in); err != nil { - t.Error(err) - } else if ctx.IsInitialized() == false { - t.Error("Expected IsInitialized=true") - } else { - t.Log(ctx) - } - - // Set number of samples to 10 - if err := in.GetAudioBuffer(10); err != nil { - t.Error(err) - } - - // Write out 10 lots of 10 zero samples - for i := 0; i < 10; i++ { - if err := ctx.ConvertFrame(out, in); err != nil { - t.Error(err) - } else { - t.Log("out=", out.Buffer(0), " samples=", out.NumSamples()) - } - } - if err := ctx.FlushFrame(out); err != nil { - t.Error(err) - } else { - t.Log("out=", out.Buffer(0), " samples=", out.NumSamples()) - } -} diff --git a/_old/pkg/_old/_config/version.go b/_old/pkg/_old/_config/version.go deleted file mode 100755 index 7136c9b..0000000 --- a/_old/pkg/_old/_config/version.go +++ /dev/null @@ -1,31 +0,0 @@ -package config - -import ( - "fmt" - "io" - "runtime" -) - -/////////////////////////////////////////////////////////////////////////////// -// GLOBALS - -var ( - GitSource string - GitTag string - GitBranch string - GitHash string - GoBuildTime string -) - -func PrintVersion(w io.Writer) { - if GitSource != "" { - fmt.Fprintf(w, " URL: https://%v\n", GitSource) - } - if GitTag != "" || GitBranch != "" { - fmt.Fprintf(w, " Version: %v (branch: %q hash:%q)\n", GitTag, GitBranch, GitHash) - } - if GoBuildTime != "" { - fmt.Fprintf(w, " Build Time: %v\n", GoBuildTime) - } - fmt.Fprintf(w, " Go: %v (%v/%v)\n", runtime.Version(), runtime.GOOS, runtime.GOARCH) -} diff --git a/_old/sys/_dvb/demux.go b/sys/dvb/demux.go similarity index 100% rename from _old/sys/_dvb/demux.go rename to sys/dvb/demux.go diff --git a/_old/sys/_dvb/demux_test.go b/sys/dvb/demux_test.go similarity index 100% rename from _old/sys/_dvb/demux_test.go rename to sys/dvb/demux_test.go diff --git a/_old/sys/_dvb/device.go b/sys/dvb/device.go similarity index 100% rename from _old/sys/_dvb/device.go rename to sys/dvb/device.go diff --git a/_old/sys/_dvb/device_test.go b/sys/dvb/device_test.go similarity index 100% rename from _old/sys/_dvb/device_test.go rename to sys/dvb/device_test.go diff --git a/_old/sys/_dvb/doc.go b/sys/dvb/doc.go similarity index 100% rename from _old/sys/_dvb/doc.go rename to sys/dvb/doc.go diff --git a/_old/sys/_dvb/frontend.go b/sys/dvb/frontend.go similarity index 100% rename from _old/sys/_dvb/frontend.go rename to sys/dvb/frontend.go diff --git a/_old/sys/_dvb/frontend_test.go b/sys/dvb/frontend_test.go similarity index 100% rename from _old/sys/_dvb/frontend_test.go rename to sys/dvb/frontend_test.go diff --git a/_old/sys/_dvb/tunetable.go b/sys/dvb/tunetable.go similarity index 100% rename from _old/sys/_dvb/tunetable.go rename to sys/dvb/tunetable.go diff --git a/_old/sys/_dvb/tunetable_test.go b/sys/dvb/tunetable_test.go similarity index 100% rename from _old/sys/_dvb/tunetable_test.go rename to sys/dvb/tunetable_test.go