mediamtx/internal/protocols/rtmp/conn.go
Alessandro Ros 1b9dfbd367
Some checks are pending
code_lint / golangci_lint (push) Waiting to run
code_lint / mod_tidy (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
rtmp: support connecting to sources that require standard credentials (#4530)
2025-05-15 14:23:03 +02:00

46 lines
992 B
Go

package rtmp
import (
"io"
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/bytecounter"
"github.com/bluenviron/mediamtx/internal/protocols/rtmp/message"
)
// Conn is implemented by Client and ServerConn.
type Conn interface {
BytesReceived() uint64
BytesSent() uint64
Read() (message.Message, error)
Write(msg message.Message) error
}
type dummyConn struct {
rw io.ReadWriter
bc *bytecounter.ReadWriter
mrw *message.ReadWriter
}
func (c *dummyConn) initialize() {
c.bc = bytecounter.NewReadWriter(c.rw)
c.mrw = message.NewReadWriter(c.bc, c.bc, false)
}
// BytesReceived returns the number of bytes received.
func (c *dummyConn) BytesReceived() uint64 {
return c.bc.Reader.Count()
}
// BytesSent returns the number of bytes sent.
func (c *dummyConn) BytesSent() uint64 {
return c.bc.Writer.Count()
}
func (c *dummyConn) Read() (message.Message, error) {
return c.mrw.Read()
}
func (c *dummyConn) Write(msg message.Message) error {
return c.mrw.Write(msg)
}