diff --git a/internal/transport/datachannel/transport.go b/internal/transport/datachannel/transport.go index 504f957..8b61848 100644 --- a/internal/transport/datachannel/transport.go +++ b/internal/transport/datachannel/transport.go @@ -9,6 +9,8 @@ import ( "github.com/openlibrecommunity/olcrtc/internal/transport" ) +const defaultMaxPayloadSize = 12 * 1024 + type streamTransport struct { stream carrier.ByteStream } @@ -79,3 +81,13 @@ func (p *streamTransport) WatchConnection(ctx context.Context) { func (p *streamTransport) CanSend() bool { return p.stream.CanSend() } + +// Features describes the current datachannel transport semantics. +func (p *streamTransport) Features() transport.Features { + return transport.Features{ + Reliable: true, + Ordered: true, + MessageOriented: true, + MaxPayloadSize: defaultMaxPayloadSize, + } +} diff --git a/internal/transport/transport.go b/internal/transport/transport.go index 012b3c5..74c8c4c 100644 --- a/internal/transport/transport.go +++ b/internal/transport/transport.go @@ -11,6 +11,14 @@ var ( ErrTransportNotFound = errors.New("transport not found") ) +// Features describes the delivery semantics of a transport. +type Features struct { + Reliable bool + Ordered bool + MessageOriented bool + MaxPayloadSize int +} + // Transport defines a byte transport independent of the underlying carrier. type Transport interface { Connect(ctx context.Context) error @@ -21,6 +29,7 @@ type Transport interface { SetEndedCallback(cb func(string)) WatchConnection(ctx context.Context) CanSend() bool + Features() Features } // Config holds common transport configuration.