webtransport

package module
v4.0.11 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 17 Imported by: 1

README

WebTransport 插件

通过WebTransport进行推拉流

插件地址

https://github.com/Monibuca/plugin-webtransport

插件引入

    import (  _ "m7s.live/plugin/webtransport/v4" )

配置

webtransport:
  listenaddr: :4433
  certfile: local.monibuca.com_bundle.pem
  keyfile: local.monibuca.com.key

API接口

  • /play/[streamPath] 用来播放
  • /push/[streamPath] 用来推流

建立双向流后传输flv格式的数据

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertFile

type CertFile struct {
	Path string
	Data []byte
}

A CertFile represents a TLS certificate or key, expressed either as a file path or as the certificate/key itself as a []byte.

type QuicConfig

type QuicConfig quic.Config

Wrapper for quic.Config

type ReceiveStream

type ReceiveStream struct {
	quic.ReceiveStream
	// contains filtered or unexported fields
}

ReceiveStream wraps a quic.ReceiveStream providing a unidirectional WebTransport client->server stream, including a Read function.

func (*ReceiveStream) Read

func (s *ReceiveStream) Read(p []byte) (int, error)

Read reads up to len(p) bytes from a WebTransport unidirectional stream, returning the actual number of bytes read.

type SendStream

type SendStream struct {
	quic.SendStream
	// contains filtered or unexported fields
}

SendStream wraps a quic.SendStream providing a unidirectional WebTransport server->client stream, including a Write function.

func (*SendStream) Write

func (s *SendStream) Write(p []byte) (int, error)

Write writes up to len(p) bytes to a WebTransport unidirectional stream, returning the actual number of bytes written.

type Server

type Server struct {
	http.Handler
	// ListenAddr sets an address to bind server to, e.g. ":4433"
	ListenAddr string
	// TLSCert defines a path to, or byte array containing, a certificate (CRT file)
	TLSCert CertFile
	// TLSKey defines a path to, or byte array containing, the certificate's private key (KEY file)
	TLSKey CertFile
	// AllowedOrigins represents list of allowed origins to connect from
	AllowedOrigins []string
	// Additional configuration parameters to pass onto QUIC listener
	QuicConfig *QuicConfig
}

A Server defines parameters for running a WebTransport server. Use http.HandleFunc to register HTTP/3 endpoints for handling WebTransport requests.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Starts a WebTransport server and blocks while it's running. Cancel the supplied Context to stop the server.

type Session

type Session struct {
	quic.Stream
	Session             quic.Connection
	ClientControlStream quic.ReceiveStream
	ServerControlStream quic.SendStream
	// contains filtered or unexported fields
}

Session is a WebTransport session (and the Body of a WebTransport http.Request) wrapping the request stream (a quic.Stream), the two control streams and a quic.Session.

func (*Session) AcceptSession

func (s *Session) AcceptSession()

AcceptSession accepts an incoming WebTransport session. Call it in your http.HandleFunc.

func (*Session) AcceptStream

func (s *Session) AcceptStream() (WtStream, error)

AcceptStream accepts an incoming (that is, client-initated) bidirectional stream, blocking if necessary until one is available. Supply your own context, or use the WebTransport session's Context() so that ending the WebTransport session automatically cancels this call.

func (*Session) AcceptUniStream

func (s *Session) AcceptUniStream(ctx context.Context) (ReceiveStream, error)

AcceptStream accepts an incoming (that is, client-initated) unidirectional stream, blocking if necessary until one is available. Supply your own context, or use the WebTransport session's Context() so that ending the WebTransport session automatically cancels this call.

func (*Session) CloseSession

func (s *Session) CloseSession()

CloseSession cleanly closes a WebTransport session. All active streams are cancelled before terminating the session.

func (*Session) CloseWithError

func (s *Session) CloseWithError(code quic.ApplicationErrorCode, str string)

CloseWithError closes a WebTransport session with a supplied error code and string.

func (*Session) Context

func (s *Session) Context() context.Context

Context returns the context for the WebTransport session.

func (*Session) OpenStream

func (s *Session) OpenStream() (WtStream, error)

OpenStream creates an outgoing (that is, server-initiated) bidirectional stream. It returns immediately.

func (*Session) OpenStreamSync

func (s *Session) OpenStreamSync(ctx context.Context) (WtStream, error)

OpenStream creates an outgoing (that is, server-initiated) bidirectional stream. It generally returns immediately, but if the session's maximum number of streams has been exceeded, it will block until a slot is available. Supply your own context, or use the WebTransport session's Context() so that ending the WebTransport session automatically cancels this call.

func (*Session) OpenUniStream

func (s *Session) OpenUniStream() (SendStream, error)

OpenUniStream creates an outgoing (that is, server-initiated) bidirectional stream. It returns immediately.

func (*Session) OpenUniStreamSync

func (s *Session) OpenUniStreamSync(ctx context.Context) (SendStream, error)

OpenUniStreamSync creates an outgoing (that is, server-initiated) unidirectional stream. It generally returns immediately, but if the session's maximum number of streams has been exceeded, it will block until a slot is available. Supply your own context, or use the WebTransport session's Context() so that ending the WebTransport session automatically cancels this call.

func (*Session) ReceiveMessage

func (s *Session) ReceiveMessage(ctx context.Context) ([]byte, error)

ReceiveMessage returns a datagram received from a WebTransport session, blocking if necessary until one is available. Supply your own context, or use the WebTransport session's Context() so that ending the WebTransport session automatically cancels this call. Note that datagrams are unreliable - depending on network conditions, datagrams sent by the client may never be received by the server.

func (*Session) RejectSession

func (s *Session) RejectSession(errorCode int)

AcceptSession rejects an incoming WebTransport session, returning the supplied HTML error code to the client. Call it in your http.HandleFunc.

func (*Session) SendMessage

func (s *Session) SendMessage(msg []byte) error

SendMessage sends a datagram over a WebTransport session. Supply your own context, or use the WebTransport session's Context() so that ending the WebTransport session automatically cancels this call. Note that datagrams are unreliable - depending on network conditions, datagrams sent by the server may never be received by the client.

type WebTransportConfig

type WebTransportConfig struct {
	ListenAddr string `default:":4433" desc:"监听地址端口(IP:PORT)IP可省略"`
	CertFile   string `desc:"证书文件"`
	KeyFile    string `desc:"密钥文件"`
}

func (*WebTransportConfig) OnEvent

func (c *WebTransportConfig) OnEvent(event any)

func (*WebTransportConfig) Run added in v4.0.3

func (c *WebTransportConfig) Run(mux http.Handler)

type WebTransportPublisher

type WebTransportPublisher struct {
	Publisher
}

func (*WebTransportPublisher) OnEvent

func (wt *WebTransportPublisher) OnEvent(event any)

type WebTransportSubscriber

type WebTransportSubscriber struct {
	Subscriber
}

func (*WebTransportSubscriber) OnEvent

func (wt *WebTransportSubscriber) OnEvent(event any)

type WtStream added in v4.0.1

type WtStream quic.Stream

Stream wraps a quic.Stream providing a bidirectional server<->client stream, including Read and Write functions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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