2019-12-20 03:12:51 +03:00
|
|
|
/*
|
|
|
|
NAME
|
|
|
|
filter.go
|
|
|
|
|
|
|
|
AUTHORS
|
|
|
|
Ella Pietraroia <ella@ausocean.org>
|
|
|
|
|
|
|
|
LICENSE
|
|
|
|
filter.go is Copyright (C) 2019 the Australian Ocean Lab (AusOcean)
|
|
|
|
|
|
|
|
It is free software: you can redistribute it and/or modify them
|
|
|
|
under the terms of the GNU General Public License as published by the
|
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
in gpl.txt. If not, see http://www.gnu.org/licenses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Package filter provides the interface and implementations of the filters to be used
|
2019-12-23 03:59:25 +03:00
|
|
|
// on video input that has been lexed.
|
2019-12-20 03:12:51 +03:00
|
|
|
package filter
|
|
|
|
|
|
|
|
import (
|
2020-01-20 06:39:42 +03:00
|
|
|
"fmt"
|
2019-12-20 03:12:51 +03:00
|
|
|
"io"
|
2020-01-20 06:39:42 +03:00
|
|
|
"time"
|
2019-12-20 03:12:51 +03:00
|
|
|
)
|
|
|
|
|
2019-12-23 04:29:17 +03:00
|
|
|
// Interface for all filters.
|
2019-12-20 03:12:51 +03:00
|
|
|
type Filter interface {
|
|
|
|
io.WriteCloser
|
2019-12-23 03:59:25 +03:00
|
|
|
//NB: Filter interface may evolve with more methods as required.
|
2019-12-20 03:12:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// The NoOp filter will perform no operation on the data that is being recieved,
|
|
|
|
// it will pass it on to the encoder with no changes.
|
|
|
|
type NoOp struct {
|
|
|
|
dst io.Writer
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewNoOp(dst io.Writer) *NoOp { return &NoOp{dst: dst} }
|
|
|
|
|
2020-01-20 06:39:42 +03:00
|
|
|
func (n *NoOp) Write(p []byte) (int, error) {
|
|
|
|
if frames == 0 {
|
|
|
|
t1 = time.Now()
|
|
|
|
}
|
|
|
|
frames++
|
|
|
|
if frames >= 24 {
|
|
|
|
fmt.Printf("25 frames takes: %dms\n\n", time.Now().Sub(t1).Milliseconds())
|
|
|
|
frames = 0
|
|
|
|
}
|
|
|
|
return n.dst.Write(p)
|
|
|
|
}
|
2019-12-20 03:12:51 +03:00
|
|
|
|
|
|
|
func (n *NoOp) Close() error { return nil }
|