Encoder interface

This commit is contained in:
DataHoarder 2022-09-15 15:36:19 +02:00
parent b60d7d1274
commit 4898ae67cf
Signed by: DataHoarder
SSH key fingerprint: SHA256:EnPQOqPpbCa7nzalCEJY2sd9iPluFIBuJu2rDFalACI
2 changed files with 20 additions and 0 deletions

10
encoder/encoder.go Normal file
View file

@ -0,0 +1,10 @@
package encoder
import "git.gammaspectra.live/S.O.N.G/Ignite/frame"
type Encoder interface {
Encode(pts int64, f frame.Frame) error
Flush() error
Close()
Version() string
}

View file

@ -29,6 +29,12 @@ type Encoder struct {
h *C.x264_t
}
var x264Version = "x264 " + C.GoString(C.X264_VERSION)
func Version() string {
return x264Version
}
func NewEncoder(w io.Writer, stream *y4m.Stream, settings map[string]any) (*Encoder, error) {
e := &Encoder{
w: w,
@ -225,6 +231,10 @@ func (e *Encoder) Flush() error {
return nil
}
func (e *Encoder) Version() string {
return Version()
}
func (e *Encoder) Close() {
if e.cleaned.Swap(true) == false {
if e.h != nil {