goloom

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package goloom defines the wire types and the WebSocket signalling client for Yandex Telemost's "goloom" SFU. Field tags mirror the JSON shape observed in C:\Users\pcex\VPSUTILS\telemost-dump\guest{1,2}-capture.json.

Each frame on the wire is a JSON object with:

  • a single "uid" UUID (request id, also echoed back in ack)
  • exactly one content key naming the message type

Index

Constants

This section is empty.

Variables

View Source
var ChromeSDKInfo = SDKInfo{
	Implementation: "browser",
	Version:        "5.27.1",
	UserAgent:      "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36",
	HwConcurrency:  8,
}

ChromeSDKInfo mirrors the sdkInfo block sent by the web client. Used as hello.sdkInfo verbatim — the server may gate features on implementation/ version so we identify as the production browser SDK.

View Source
var DefaultCapabilitiesOffer = map[string][]string{
	"offerAnswerMode":                       {"SEPARATE"},
	"initialSubscriberOffer":                {"ON_HELLO"},
	"slotsMode":                             {"FROM_CONTROLLER"},
	"simulcastMode":                         {"DISABLED", "STATIC"},
	"selfVadStatus":                         {"FROM_SERVER", "FROM_CLIENT"},
	"dataChannelSharing":                    {"TO_RTP"},
	"videoEncoderConfig":                    {"NO_CONFIG", "ONLY_INIT_CONFIG", "RUNTIME_CONFIG"},
	"dataChannelVideoCodec":                 {"VP8", "UNIQUE_CODEC_FROM_TRACK_DESCRIPTION"},
	"bandwidthLimitationReason":             {"BANDWIDTH_REASON_DISABLED", "BANDWIDTH_REASON_ENABLED"},
	"sdkDefaultDeviceManagement":            {"SDK_DEFAULT_DEVICE_MANAGEMENT_DISABLED", "SDK_DEFAULT_DEVICE_MANAGEMENT_ENABLED"},
	"joinOrderLayout":                       {"JOIN_ORDER_LAYOUT_DISABLED", "JOIN_ORDER_LAYOUT_ENABLED"},
	"pinLayout":                             {"PIN_LAYOUT_DISABLED"},
	"sendSelfViewVideoSlot":                 {"SEND_SELF_VIEW_VIDEO_SLOT_DISABLED", "SEND_SELF_VIEW_VIDEO_SLOT_ENABLED"},
	"serverLayoutTransition":                {"SERVER_LAYOUT_TRANSITION_DISABLED"},
	"sdkPublisherOptimizeBitrate":           {"SDK_PUBLISHER_OPTIMIZE_BITRATE_DISABLED", "SDK_PUBLISHER_OPTIMIZE_BITRATE_FULL", "SDK_PUBLISHER_OPTIMIZE_BITRATE_ONLY_SELF"},
	"sdkNetworkLostDetection":               {"SDK_NETWORK_LOST_DETECTION_DISABLED"},
	"sdkNetworkPathMonitor":                 {"SDK_NETWORK_PATH_MONITOR_DISABLED"},
	"publisherVp9":                          {"PUBLISH_VP9_DISABLED", "PUBLISH_VP9_ENABLED"},
	"svcMode":                               {"SVC_MODE_DISABLED", "SVC_MODE_L3T3", "SVC_MODE_L3T3_KEY"},
	"subscriberOfferAsyncAck":               {"SUBSCRIBER_OFFER_ASYNC_ACK_DISABLED", "SUBSCRIBER_OFFER_ASYNC_ACK_ENABLED"},
	"androidBluetoothRoutingFix":            {"ANDROID_BLUETOOTH_ROUTING_FIX_DISABLED"},
	"fixedIceCandidatesPoolSize":            {"FIXED_ICE_CANDIDATES_POOL_SIZE_DISABLED"},
	"sdkAndroidTelecomIntegration":          {"SDK_ANDROID_TELECOM_INTEGRATION_DISABLED"},
	"setActiveCodecsMode":                   {"SET_ACTIVE_CODECS_MODE_DISABLED", "SET_ACTIVE_CODECS_MODE_VIDEO_ONLY"},
	"subscriberDtlsPassiveMode":             {"SUBSCRIBER_DTLS_PASSIVE_MODE_DISABLED", "SUBSCRIBER_DTLS_PASSIVE_MODE_ENABLED"},
	"publisherOpusDred":                     {"PUBLISHER_OPUS_DRED_DISABLED"},
	"publisherOpusLowBitrate":               {"PUBLISHER_OPUS_LOW_BITRATE_DISABLED"},
	"sdkAndroidDestroySessionOnTaskRemoved": {"SDK_ANDROID_DESTROY_SESSION_ON_TASK_REMOVED_DISABLED"},
	"svcModes":                              {"FALSE"},
	"reportTelemetryModes":                  {"TRUE"},
	"keepDefaultDevicesModes":               {"FALSE"},
}

DefaultCapabilitiesOffer is a verbatim copy of the capabilitiesOffer block sent by the production Telemost web client (Chrome 5.27.1 SDK build) on hello. Order and string casing matter — the server compares values literally.

Reverse-engineered from C:\Users\pcex\VPSUTILS\telemost-dump\guest2-capture.json (first WS send frame, hello.capabilitiesOffer).

Several fields use ["TRUE"] / ["FALSE"] string singletons rather than booleans — that is intentional protobuf-style enum encoding. Do not "normalize" them.

Functions

func Dial

func Dial(ctx context.Context, urlStr string, opts DialOptions) (*websocket.Conn, error)

Dial opens the WS to the goloom signalling endpoint with the right headers. Telemost requires the Origin header; the UA is set as a courtesy / future platform-routing safety net.

Types

type Ack

type Ack struct {
	Status AckStatus `json:"status"`
}

Ack acknowledges receipt of a previous frame. The Envelope.UID of an Ack MUST equal the UID of the message being acknowledged (NOT a fresh UUID).

type AckStatus

type AckStatus struct {
	Code        string `json:"code"` // "OK" on success
	Description string `json:"description"`
}

AckStatus is the embedded status object inside Ack.

type Client

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

Client manages one goloom WebSocket session. Lifecycle:

c := NewClient(ws, log)
c.OnIncoming(handler)   // optional dispatch
c.Start(ctx)            // launches read+write loops
c.Send(env)             // typed send (Send queues, returns immediately)
c.SendAck(uid)          // shorthand
c.Close()

Ping and telemetry are driven by ConfigurePeriodicTasks once the server supplies pingPongConfiguration / telemetryConfiguration.

func NewClient

func NewClient(ws *websocket.Conn, lg *log.Logger) *Client

NewClient wraps an already-open WebSocket. UA/Origin headers must be set on the dialer by the caller.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the WS conn. Safe to call multiple times.

func (*Client) ConfigurePeriodicTasks

func (c *Client) ConfigurePeriodicTasks(ctx context.Context, ping PingPongConfiguration, telem TelemetryConfiguration)

ConfigurePeriodicTasks starts the ping and telemetry timers using values from serverHello. If either interval is zero we use sane defaults.

func (*Client) OnIncoming

func (c *Client) OnIncoming(h IncomingHandler)

OnIncoming registers a single dispatcher. The handler is invoked synchronously from the read loop, so it must not block on Send (use the fact that Send is non-blocking up to channel buffer).

func (*Client) Send

func (c *Client) Send(env Envelope) error

Send queues an envelope for transmission. UID is auto-assigned if blank. Non-blocking up to the send buffer; returns error only if the conn is already closed or the queue is full (buffer overflow indicates a bug).

func (*Client) SendAck

func (c *Client) SendAck(replyUID string) error

SendAck builds and sends an ack frame using the supplied uid (NOT a fresh one) and an OK status.

func (*Client) Start

func (c *Client) Start(ctx context.Context)

Start launches the read and write goroutines. Returns immediately. The goroutines exit when ctx is cancelled or the WS errors.

type DialOptions

type DialOptions struct {
	UserAgent string
	Origin    string
}

DialOptions lets the caller specify the headers required by the goloom endpoint (UA + Origin must mirror the web client).

type Envelope

type Envelope struct {
	UID                             string                           `json:"uid"`
	Hello                           *Hello                           `json:"hello,omitempty"`
	Ack                             *Ack                             `json:"ack,omitempty"`
	PublisherSdpOffer               *PublisherSdpOffer               `json:"publisherSdpOffer,omitempty"`
	SubscriberSdpAnswer             *SubscriberSdpAnswer             `json:"subscriberSdpAnswer,omitempty"`
	WebrtcIceCandidate              *WebrtcIceCandidate              `json:"webrtcIceCandidate,omitempty"`
	SetSlots                        *SetSlots                        `json:"setSlots,omitempty"`
	SdkCodecsInfo                   *SdkCodecsInfo                   `json:"sdkCodecsInfo,omitempty"`
	Telemetry                       *Telemetry                       `json:"telemetry,omitempty"`
	Ping                            *Ping                            `json:"ping,omitempty"`
	UpdatePublisherTrackDescription *UpdatePublisherTrackDescription `json:"updatePublisherTrackDescription,omitempty"`
	UpdateMe                        *UpdateMe                        `json:"updateMe,omitempty"`
}

Envelope is what we send. For receive we keep the raw bytes plus the type key so unknown/optional message types pass through without decode failures.

On send we build an Envelope per message type (Hello, PublisherSdpOffer, Ack, ...). On receive we parse just the UID and the message-type key, then decode the inner payload only if a handler asks for it.

type Hello

type Hello struct {
	ParticipantMeta        ParticipantMeta     `json:"participantMeta"`
	ParticipantAttributes  ParticipantAttr     `json:"participantAttributes"`
	SendAudio              bool                `json:"sendAudio"`
	SendVideo              bool                `json:"sendVideo"`
	SendSharing            bool                `json:"sendSharing"`
	ParticipantID          string              `json:"participantId"`
	RoomID                 string              `json:"roomId"`
	ServiceName            string              `json:"serviceName"` // "telemost"
	Credentials            string              `json:"credentials"`
	CapabilitiesOffer      map[string][]string `json:"capabilitiesOffer"`
	SDKInfo                SDKInfo             `json:"sdkInfo"`
	SDKInitializationID    string              `json:"sdkInitializationId"`
	DisablePublisher       bool                `json:"disablePublisher"`
	DisableSubscriber      bool                `json:"disableSubscriber"`
	DisableSubscriberAudio bool                `json:"disableSubscriberAudio"`
}

Hello is the first send frame after WS open. credentials and participantId come from the /connection HTTP response.

type IncomingHandler

type IncomingHandler func(typeName string, env *RecvEnvelope, payload json.RawMessage)

IncomingHandler receives a parsed Envelope plus the raw bytes of the inner-typed payload (the JSON value of the type key, e.g. the bytes of the PublisherSdpAnswer object). Type tells which key was set on the envelope.

type ParticipantAttr

type ParticipantAttr struct {
	Name        string `json:"name"`
	Role        string `json:"role"`
	Description string `json:"description"`
}

ParticipantAttr is the static identity portion (no media flags).

type ParticipantMeta

type ParticipantMeta struct {
	Name        string `json:"name"`
	Role        string `json:"role"` // observed: "SPEAKER" for guests
	Description string `json:"description"`
	SendAudio   bool   `json:"sendAudio"`
	SendVideo   bool   `json:"sendVideo"`
}

ParticipantMeta is the active state portion of a participant identity. Echoed by the server back to other peers so they can render us correctly.

type Ping

type Ping struct{}

Ping carries no payload but the wrapper exists for type safety.

type PingPongConfiguration

type PingPongConfiguration struct {
	PingInterval int `json:"pingInterval"` // milliseconds
	AckTimeout   int `json:"ackTimeout"`   // milliseconds
}

PingPongConfiguration controls how often we ping and how long we wait for the matching ack. Falls back to {ping=5000, ackTimeout=9000} if the server omits the block.

type PublisherSdpAnswer

type PublisherSdpAnswer struct {
	PcSeq int    `json:"pcSeq"`
	SDP   string `json:"sdp"`
}

PublisherSdpAnswer is the SFU's answer to PublisherSdpOffer. No client ack is required — the answer itself acknowledges the offer.

type PublisherSdpOffer

type PublisherSdpOffer struct {
	PcSeq  int     `json:"pcSeq"` // 1 for the initial publisher offer
	SDP    string  `json:"sdp"`
	Tracks []Track `json:"tracks"`
}

PublisherSdpOffer is sent right after we ack the serverHello, with the offer SDP from Pion's CreateOffer + a one-entry-per-m-line tracks list describing what each transceiver carries.

type RecvEnvelope

type RecvEnvelope struct {
	UID     string
	Type    string          // e.g. "serverHello", "publisherSdpAnswer"
	Payload json.RawMessage // raw JSON value of the type field
	Raw     []byte          // entire frame
}

RecvEnvelope is the parse-side counterpart of Envelope. We only extract the uid and let the caller decode the typed payload as needed.

type RtcConfiguration

type RtcConfiguration struct {
	ICEServers []ServerICEEntry `json:"iceServers"`
}

RtcConfiguration carries the ice_servers list (with TURN credentials) that becomes webrtc.Configuration.ICEServers on both PeerConnections.

type SDKInfo

type SDKInfo struct {
	Implementation string `json:"implementation"`
	Version        string `json:"version"`
	UserAgent      string `json:"userAgent"`
	HwConcurrency  int    `json:"hwConcurrency"`
}

SDKInfo is sent inside Hello so the SFU can do per-client feature gating. We mimic Chrome 5.27.1 verbatim.

type SdkCodecsInfo

type SdkCodecsInfo struct {
	Codecs []json.RawMessage `json:"codecs"`
}

SdkCodecsInfo is sent once during setup; for PoC #1 we omit it.

type ServerHello

type ServerHello struct {
	CapabilitiesAnswer     map[string]string          `json:"capabilitiesAnswer"`
	RtcConfiguration       RtcConfiguration           `json:"rtcConfiguration"`
	PingPongConfiguration  PingPongConfiguration      `json:"pingPongConfiguration"`
	TelemetryConfiguration TelemetryConfiguration     `json:"telemetryConfiguration"`
	SdkFeatureFlags        map[string]json.RawMessage `json:"sdkFeatureFlags"`
}

ServerHello mirrors the response after our hello. We decode only the fields we actually act on; everything else is preserved by leaving extra keys in the raw payload.

type ServerICEEntry

type ServerICEEntry struct {
	URLs       []string `json:"urls"`
	Username   string   `json:"username"`
	Credential string   `json:"credential"`
}

ServerICEEntry mirrors RTCIceServer JSON. Empty username/credential are permitted (STUN entries have them blank).

type SetSlots

type SetSlots struct {
	Slots              []SlotSize `json:"slots"`
	AudioSlotsCount    int        `json:"audioSlotsCount"`
	Key                int        `json:"key"`
	ShutdownAllVideo   *bool      `json:"shutdownAllVideo"`
	WithSelfView       bool       `json:"withSelfView"`
	SelfViewVisibility string     `json:"selfViewVisibility"` // "ON_LOADING_THEN_SHOW"
	GridConfig         struct{}   `json:"gridConfig"`
}

SetSlots is the client-side layout request. For PoC #1 we send 12 zero- sized slots once and never touch it again.

type SlotSize

type SlotSize struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

SlotSize sets the requested resolution for one slot. {0,0} means we don't need any pixels for that slot.

type SubscriberSdpAnswer

type SubscriberSdpAnswer struct {
	PcSeq int    `json:"pcSeq"`
	SDP   string `json:"sdp"`
}

SubscriberSdpAnswer carries Pion's CreateAnswer SDP back to the SFU.

type SubscriberSdpOffer

type SubscriberSdpOffer struct {
	PcSeq int    `json:"pcSeq"`
	SDP   string `json:"sdp"`
}

SubscriberSdpOffer arrives unprompted soon after our publisherSdpOffer (the SFU's "ON_HELLO" initial subscriber offer behaviour). We answer it with SubscriberSdpAnswer.

type Telemetry

type Telemetry struct {
	PublisherRawStatsReport []string `json:"publisherRawStatsReport"`
}

Telemetry carries periodic stats reports. We send a minimal stub every telemetryConfiguration.sendingInterval to keep the SFU's liveness counter happy.

type TelemetryConfiguration

type TelemetryConfiguration struct {
	SendingInterval int `json:"sendingInterval"` // milliseconds
}

TelemetryConfiguration controls how often we emit publisherRawStatsReport.

type Track

type Track struct {
	MID            string                 `json:"mid"`
	TransceiverMID string                 `json:"transceiverMid"`
	Kind           string                 `json:"kind"` // "AUDIO" | "VIDEO"
	Priority       int                    `json:"priority"`
	Label          string                 `json:"label"`
	Codecs         map[string]interface{} `json:"codecs"`      // {} on initial offer
	GroupID        int                    `json:"groupId"`     // 1
	Description    string                 `json:"description"` // ""
}

Track describes one m-line in our publisherSdpOffer. mid and transceiverMid must match the values Pion baked into the SDP (typically "0", "1", ...).

type UpdateMe

type UpdateMe struct {
	ParticipantMeta       ParticipantMeta `json:"participantMeta"`
	ParticipantAttributes ParticipantAttr `json:"participantAttributes"`
	SendAudio             bool            `json:"sendAudio"`
	SendVideo             bool            `json:"sendVideo"`
	SendSharing           bool            `json:"sendSharing"`
}

UpdateMe lets us mutate our participant flags after hello (mute/unmute, camera off, etc). Not used in PoC #1 directly.

type UpdatePublisherTrackDescription

type UpdatePublisherTrackDescription struct {
	PublisherTrackDescriptions []Track `json:"publisherTrackDescriptions"`
}

UpdatePublisherTrackDescription is sent after a successful renegotiation to declare the full track inventory (camera + display tracks). The JSON field is publisherTrackDescriptions per Phase 1 dump.

type WebrtcIceCandidate

type WebrtcIceCandidate struct {
	PcSeq            int    `json:"pcSeq"`
	Target           string `json:"target"` // "PUBLISHER" | "SUBSCRIBER"
	Candidate        string `json:"candidate"`
	SdpMid           string `json:"sdpMid"`
	SdpMlineIndex    int    `json:"sdpMlineIndex"`
	UsernameFragment string `json:"usernameFragment,omitempty"`
}

WebrtcIceCandidate carries one ICE candidate either way. Target tells the other side which PeerConnection it belongs to. UsernameFragment is set on the client-to-server direction (Pion exposes c.SDPMid + ufrag inferred from candidate string).

Jump to

Keyboard shortcuts

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