Refactor application structure and initialize core components

I decided to rewrite the program taking into account the experience gained.
This commit is contained in:
2025-06-06 14:50:16 +05:00
parent 43d794373a
commit b24155caf6
24 changed files with 1295 additions and 63 deletions

19
internal/ffmpeg/ffmpeg.go Normal file
View File

@@ -0,0 +1,19 @@
package ffmpeg
type FFmpegContract interface {
SetPath(path string)
}
type ffmpeg struct {
path string
}
func newFFmpeg(path string) FFmpegContract {
return &ffmpeg{
path: path,
}
}
func (f *ffmpeg) SetPath(path string) {
f.path = path
}

19
internal/ffmpeg/ffplay.go Normal file
View File

@@ -0,0 +1,19 @@
package ffmpeg
type FFplayContract interface {
SetPath(path string)
}
type ffplay struct {
path string
}
func newFFplay(path string) FFplayContract {
return &ffplay{
path: path,
}
}
func (f *ffplay) SetPath(path string) {
f.path = path
}

View File

@@ -0,0 +1,19 @@
package ffmpeg
type FFprobeContract interface {
SetPath(path string)
}
type ffprobe struct {
path string
}
func newFFprobe(path string) FFprobeContract {
return &ffprobe{
path: path,
}
}
func (f *ffprobe) SetPath(path string) {
f.path = path
}

View File

@@ -0,0 +1,48 @@
package ffmpeg
import (
"git.kor-elf.net/kor-elf/gui-for-ffmpeg/internal/application/setting"
)
type UtilitiesContract interface {
GetFFmpeg() FFmpegContract
GetFFprobe() FFprobeContract
GetFFplay() FFplayContract
}
type utilities struct {
setting setting.SettingContract
ffmpeg FFmpegContract
ffprobe FFprobeContract
ffplay FFplayContract
}
func NewUtilities(setting setting.SettingContract) UtilitiesContract {
return &utilities{
setting: setting,
}
}
func (u *utilities) GetFFmpeg() FFmpegContract {
if u.ffmpeg == nil {
u.ffmpeg = newFFmpeg(u.setting.GetFFmpegPath())
}
return u.ffmpeg
}
func (u *utilities) GetFFprobe() FFprobeContract {
if u.ffprobe != nil {
u.ffprobe = newFFprobe(u.setting.GetFFprobePath())
}
return u.ffprobe
}
func (u *utilities) GetFFplay() FFplayContract {
if u.ffplay == nil {
u.ffplay = newFFplay(u.setting.GetFFplayPath())
}
return u.ffplay
}