internal

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartPionPublisher

func StartPionPublisher(
	l *log.Logger,
	clientIP string,
	initialBitrateBps int,
	impairment *pionutil.ImpairmentBinding,
) (*webrtc.PeerConnection, *webrtc.TrackLocalStaticRTP, func() int, string, error)

StartPionPublisher creates a PeerConnection in sendonly mode with GCC bandwidth estimation. Returns the PC, the RTP track, a function to get the current bandwidth estimate, and the offer SDP.

func StartPionSubscriber

func StartPionSubscriber(
	l *log.Logger,
	clientIP string,
	janusOfferSDP string,
	impairment *pionutil.ImpairmentBinding,
) (*webrtc.PeerConnection, string, error)

StartPionSubscriber creates a PeerConnection in recvonly mode, sets the Janus offer as the remote description, and returns the PC and answer SDP. The caller is responsible for setting pc.OnTrack before media flows.

func StartSimplePublisher

func StartSimplePublisher(l *log.Logger, clientIP string, impairment *pionutil.ImpairmentBinding) (
	*webrtc.PeerConnection, *webrtc.TrackLocalStaticSample, string, error,
)

StartSimplePublisher creates a sendonly PeerConnection without SVC or GCC.

Types

type Client

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

func NewClient

func NewClient(httpClient *http.Client, baseURL string) *Client

func (*Client) AttachPlugin

func (c *Client) AttachPlugin(sessionID int64, plugin string) (int64, error)

func (*Client) CreateSession

func (c *Client) CreateSession() (int64, error)

func (*Client) GetInfo

func (c *Client) GetInfo() (map[string]any, error)

func (*Client) Keepalive

func (c *Client) Keepalive(sessionID int64) error

func (*Client) LongPoll

func (c *Client) LongPoll(ctx context.Context, sessionID int64) ([]*JanusMsg, error)

LongPoll GETs /{sessionID}?maxev=5 and returns all events. With maxev>1 Janus always responds with a JSON array.

func (*Client) SendMessage

func (c *Client) SendMessage(sessionID, handleID int64, body map[string]any, jsep *JSEP, txn string) (*JanusMsg, error)

type JSEP

type JSEP struct {
	Type    string `json:"type"`
	SDP     string `json:"sdp"`
	Trickle bool   `json:"trickle,omitempty"`
}

type JanusError

type JanusError struct {
	Code   int    `json:"code"`
	Reason string `json:"reason"`
}

type JanusMsg

type JanusMsg struct {
	Janus       string         `json:"janus"`
	Transaction string         `json:"transaction"`
	PluginData  *PluginData    `json:"plugindata,omitempty"`
	JSEP        *JSEP          `json:"jsep,omitempty"`
	Data        map[string]any `json:"data,omitempty"`
	Error       *JanusError    `json:"error,omitempty"`
	Sender      int64          `json:"sender,omitempty"`
	SessionID   int64          `json:"session_id,omitempty"`
}

type PluginData

type PluginData struct {
	Plugin string         `json:"plugin"`
	Data   map[string]any `json:"data"`
}

type Session

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

Session manages one Janus HTTP session: runs an event-poll loop and dispatches events to pending transactions.

func NewSession

func NewSession(ctx context.Context, client *Client, sessionID int64, log *log.Logger) *Session

func (*Session) Close

func (s *Session) Close()

func (*Session) Events

func (s *Session) Events() <-chan *JanusMsg

Events returns a channel of unsolicited events (not matched to a pending txn).

func (*Session) Send

func (s *Session) Send(handleID int64, body map[string]any, jsep *JSEP) (*JanusMsg, error)

Send sends a message to the given handle and waits (up to 30s) for the corresponding event to arrive via long-poll.

Jump to

Keyboard shortcuts

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