moqtransport

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 17 Imported by: 5

README

Media over QUIC Transport

Go Reference

moqtransport is an implementation of Media over QUIC Transport on top of quic-go and optionally webtransport-go.

Example: Chat Server and Client

The examples directory contains an implementation of MoQ Chat.

To run a simple chat server using MoQ Tranpsort on top of QUIC, run:

go run examples/chat-server/main.go

Then, open a new shell and start a client:

go run examples/chat-client/main.go

The client is a simple interactive shell that reads and writes messages from stdin and stdout (input and output is currently not well synchronized).

Open another shell and run a second client to chat with the first one using the commands join <roomID> <username> to join a room and msg <roomID> <message> to send messages to a room.

To use WebTransport, you need to create a TLS certificate. This can be done using mkcert:

mkcert localhost
mkcert -install

mkcert will generate a localhost.pem and a localhost-key.pem file. If you change the name of the files or use a different host name, you can use the -cert and -key flags of the server command to point it to the correct files.

Now start the server and client with the -webtransport and -addr flags to run MoQ Transport on top of WebTransport:

Server:

go run examples/chat-server/main.go -webtransport

Client:

go run examples/chat-client/main.go -webtransport -addr https://localhost:8080/moq

Documentation

Index

Constants

View Source
const (
	DRAFT_IETF_MOQ_TRANSPORT_00 = 0xff000000
	DRAFT_IETF_MOQ_TRANSPORT_01 = 0xff000001
	DRAFT_IETF_MOQ_TRANSPORT_02 = 0xff000002

	CURRENT_VERSION = DRAFT_IETF_MOQ_TRANSPORT_02
)

Variables

This section is empty.

Functions

func SetLogHandler added in v0.2.0

func SetLogHandler(handler slog.Handler)

Types

type Announcement added in v0.2.0

type Announcement struct {
	// contains filtered or unexported fields
}

func (*Announcement) Accept added in v0.2.0

func (a *Announcement) Accept()

func (*Announcement) Namespace added in v0.2.0

func (a *Announcement) Namespace() string

func (*Announcement) Reject added in v0.2.0

func (a *Announcement) Reject(err error)

type Location added in v0.2.0

type Location struct {
	Mode  LocationMode
	Value uint64
}

type LocationMode added in v0.2.0

type LocationMode int
const (
	LocationModeNone LocationMode = iota
	LocationModeAbsolute
	LocationModeRelativePrevious
	LocationModeRelativeNext
)

type ReceiveSubscription added in v0.2.0

type ReceiveSubscription struct {
	// contains filtered or unexported fields
}

func (*ReceiveSubscription) Read added in v0.2.0

func (s *ReceiveSubscription) Read(buf []byte) (int, error)

type Role added in v0.2.0

type Role uint64
const (
	IngestionRole Role = iota + 1
	DeliveryRole
	IngestionDeliveryRole
)

type SendSubscription added in v0.2.0

type SendSubscription struct {
	// contains filtered or unexported fields
}

func (*SendSubscription) Accept added in v0.2.0

func (s *SendSubscription) Accept()

func (*SendSubscription) EndGroup added in v0.2.0

func (s *SendSubscription) EndGroup() Location

func (*SendSubscription) EndObject added in v0.2.0

func (s *SendSubscription) EndObject() Location

func (*SendSubscription) Namespace added in v0.2.0

func (s *SendSubscription) Namespace() string

func (*SendSubscription) NewGroupHeaderStream added in v0.2.0

func (s *SendSubscription) NewGroupHeaderStream(groupID, objectSendOrder uint64) (*groupHeaderStream, error)

func (*SendSubscription) NewObjectPreferDatagram added in v0.2.0

func (s *SendSubscription) NewObjectPreferDatagram(groupID, objectID, objectSendOrder uint64, payload []byte) error

func (*SendSubscription) NewObjectStream added in v0.2.0

func (s *SendSubscription) NewObjectStream(groupID, objectID, objectSendOrder uint64) (*objectStream, error)

func (*SendSubscription) NewTrackHeaderStream added in v0.2.0

func (s *SendSubscription) NewTrackHeaderStream(objectSendOrder uint64) (*TrackHeaderStream, error)

func (*SendSubscription) Reject added in v0.2.0

func (s *SendSubscription) Reject(err error)

func (*SendSubscription) SetExpires added in v0.2.0

func (s *SendSubscription) SetExpires(d time.Duration)

func (*SendSubscription) StartGroup added in v0.2.0

func (s *SendSubscription) StartGroup() Location

func (*SendSubscription) StartObject added in v0.2.0

func (s *SendSubscription) StartObject() Location

func (*SendSubscription) Trackname added in v0.2.0

func (s *SendSubscription) Trackname() string

type Server

type Server struct {
	Handler   SessionHandler
	TLSConfig *tls.Config
	// contains filtered or unexported fields
}

func (*Server) Listen

func (s *Server) Listen(ctx context.Context, l listener) error

func (*Server) ListenQUIC

func (s *Server) ListenQUIC(ctx context.Context, addr string) error

func (*Server) ListenQUICListener added in v0.2.0

func (s *Server) ListenQUICListener(ctx context.Context, listener *quic.Listener) error

func (*Server) ListenWebTransport

func (s *Server) ListenWebTransport(ctx context.Context, addr string) error

func (*Server) ListenWebTransportPath added in v0.2.0

func (s *Server) ListenWebTransportPath(ctx context.Context, addr, path string) error

type Session added in v0.2.0

type Session struct {
	// contains filtered or unexported fields
}

func DialQUIC

func DialQUIC(addr string, role Role) (*Session, error)

func DialQUICConn added in v0.2.0

func DialQUICConn(conn quic.Connection, role Role) (*Session, error)

func DialWebTransport

func DialWebTransport(addr string, role Role) (*Session, error)

func NewWebtransportServerSession added in v0.2.0

func NewWebtransportServerSession(ctx context.Context, conn *webtransport.Session, enableDatagrams bool) (*Session, error)

func (*Session) Announce added in v0.2.0

func (s *Session) Announce(ctx context.Context, namespace string) error

func (*Session) CloseWithError added in v0.2.0

func (s *Session) CloseWithError(code uint64, msg string)

func (*Session) ReadAnnouncement added in v0.2.0

func (s *Session) ReadAnnouncement(ctx context.Context) (*Announcement, error)

func (*Session) ReadSubscription added in v0.2.0

func (s *Session) ReadSubscription(ctx context.Context) (*SendSubscription, error)

func (*Session) Subscribe added in v0.2.0

func (s *Session) Subscribe(ctx context.Context, subscribeID, trackAlias uint64, namespace, trackname, auth string) (*ReceiveSubscription, error)

type SessionHandler added in v0.2.0

type SessionHandler interface {
	Handle(*Session)
}

type SessionHandlerFunc added in v0.2.0

type SessionHandlerFunc func(*Session)

func (SessionHandlerFunc) Handle added in v0.2.0

func (h SessionHandlerFunc) Handle(p *Session)

type TrackHeaderStream added in v0.2.0

type TrackHeaderStream struct {
	// contains filtered or unexported fields
}

func (*TrackHeaderStream) Close added in v0.2.0

func (s *TrackHeaderStream) Close() error

func (*TrackHeaderStream) NewObject added in v0.2.0

func (s *TrackHeaderStream) NewObject(groupID, objectID uint64) *TrackHeaderStreamObject

type TrackHeaderStreamObject added in v0.2.0

type TrackHeaderStreamObject struct {
	// contains filtered or unexported fields
}

func (*TrackHeaderStreamObject) Write added in v0.2.0

func (o *TrackHeaderStreamObject) Write(payload []byte) (int, error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL