diff --git a/gumbleffmpeg/source.go b/gumbleffmpeg/source.go index b892677..d56bbf6 100644 --- a/gumbleffmpeg/source.go +++ b/gumbleffmpeg/source.go @@ -8,9 +8,9 @@ import ( // Source is a Stream source. type Source interface { // must include the -i - arguments() []string - start(*exec.Cmd) error - done() + Arguments() []string + Start(*exec.Cmd) error + Done() } // sourceFile @@ -22,15 +22,15 @@ func SourceFile(filename string) Source { return sourceFile(filename) } -func (s sourceFile) arguments() []string { +func (s sourceFile) Arguments() []string { return []string{"-i", string(s)} } -func (sourceFile) start(*exec.Cmd) error { +func (sourceFile) Start(*exec.Cmd) error { return nil } -func (sourceFile) done() { +func (sourceFile) Done() { } // sourceReader @@ -44,16 +44,16 @@ func SourceReader(r io.ReadCloser) Source { return &sourceReader{r} } -func (*sourceReader) arguments() []string { +func (*sourceReader) Arguments() []string { return []string{"-i", "-"} } -func (s *sourceReader) start(cmd *exec.Cmd) error { +func (s *sourceReader) Start(cmd *exec.Cmd) error { cmd.Stdin = s.r return nil } -func (s *sourceReader) done() { +func (s *sourceReader) Done() { s.r.Close() } @@ -75,11 +75,11 @@ func SourceExec(name string, arg ...string) Source { } } -func (*sourceExec) arguments() []string { +func (*sourceExec) Arguments() []string { return []string{"-i", "-"} } -func (s *sourceExec) start(cmd *exec.Cmd) error { +func (s *sourceExec) Start(cmd *exec.Cmd) error { s.cmd = exec.Command(s.name, s.arg...) r, err := s.cmd.StdoutPipe() if err != nil { @@ -93,7 +93,7 @@ func (s *sourceExec) start(cmd *exec.Cmd) error { return nil } -func (s *sourceExec) done() { +func (s *sourceExec) Done() { if s.cmd != nil { if p := s.cmd.Process; p != nil { p.Kill() diff --git a/gumbleffmpeg/stream.go b/gumbleffmpeg/stream.go index 55a83bf..a7d919b 100644 --- a/gumbleffmpeg/stream.go +++ b/gumbleffmpeg/stream.go @@ -83,7 +83,7 @@ func (s *Stream) Play() error { return errors.New("gumbleffmpeg: nil source") } - args := s.Source.arguments() + args := s.Source.Arguments() if s.Offset > 0 { args = append([]string{"-ss", strconv.FormatFloat(s.Offset.Seconds(), 'f', -1, 64)}, args...) } @@ -94,11 +94,11 @@ func (s *Stream) Play() error { if err != nil { return err } - if err := s.Source.start(cmd); err != nil { + if err := s.Source.Start(cmd); err != nil { return err } if err := cmd.Start(); err != nil { - s.Source.done() + s.Source.Done() return err } s.wg.Add(1) @@ -194,7 +194,7 @@ func (s *Stream) cleanup() { } s.cmd.Process.Kill() s.cmd.Wait() - s.Source.done() + s.Source.Done() for len(s.pause) > 0 { <-s.pause }