golanggohlsrtmpwebrtcmedia-serverobs-studiortcprtmp-proxyrtmp-serverrtprtsprtsp-proxyrtsp-relayrtsp-serversrtstreamingwebrtc-proxy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
549 B
35 lines
549 B
package bytecounter |
|
|
|
import ( |
|
"io" |
|
) |
|
|
|
// Writer allows to count written bytes. |
|
type Writer struct { |
|
w io.Writer |
|
count uint32 |
|
} |
|
|
|
// NewWriter allocates a Writer. |
|
func NewWriter(w io.Writer) *Writer { |
|
return &Writer{ |
|
w: w, |
|
} |
|
} |
|
|
|
// Write implements io.Writer. |
|
func (w *Writer) Write(p []byte) (int, error) { |
|
n, err := w.w.Write(p) |
|
w.count += uint32(n) |
|
return n, err |
|
} |
|
|
|
// Count returns written bytes. |
|
func (w Writer) Count() uint32 { |
|
return w.count |
|
} |
|
|
|
// SetCount sets written bytes. |
|
func (w *Writer) SetCount(v uint32) { |
|
w.count = v |
|
}
|
|
|