/* NAME filter.go AUTHORS Ella Pietraroia 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 // on video input that has been lexed. package filter import ( "fmt" "io" "time" ) // Interface for all filters. type Filter interface { io.WriteCloser //NB: Filter interface may evolve with more methods as required. } // 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} } 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) } func (n *NoOp) Close() error { return nil }