mediasoup

package
v0.0.0-...-08a5344 Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: MIT, ISC Imports: 27 Imported by: 0

README

Mediasoup library in golang

This golang library is aiming to help people who want to use mediasoup without coding in node.js. Be attention, in order to communicate with mediasoup worker, it uses the feature of Cmd.ExtraFiles which doesn't work on Windows platform. Because mediasoup uses single thread in C++ code, you still need to use PipeTransport to make use of multi-core cpu.

Install

Build mediasoup worker binary

npm install -g github:versatica/mediasoup#v3

or set environment variable MEDIASOUP_WORKER_BIN to your mediasoup worker binary path. It can also be done in golang

mediasoup.WorkerBin = "your mediasoup worker binary path"

In golang project.

import "mediasoup-go"

Document

Golang API document. mediasoup-go api is consistent with the node.js api. It would be very helpful to read official document.

Demo Application

mediasoup-go-demo.

Usage

package main

import (
	"encoding/json"

	"mediasoup-go"
	"github.com/gaochao1/mediasoup-go/mediasoup/h264"
)

var logger = mediasoup.NewLogger("ExampleApp")

var consumerDeviceCapabilities = mediasoup.RtpCapabilities{
	Codecs: []*mediasoup.RtpCodecCapability{
		{
			MimeType:             "audio/opus",
			Kind:                 "audio",
			PreferredPayloadType: 100,
			ClockRate:            48000,
			Channels:             2,
		},
		{
			MimeType:             "video/H264",
			Kind:                 "video",
			PreferredPayloadType: 101,
			ClockRate:            90000,
			Parameters: mediasoup.RtpCodecSpecificParameters{
				RtpParameter: h264.RtpParameter{
					LevelAsymmetryAllowed: 1,
					PacketizationMode:     1,
					ProfileLevelId:        "4d0032",
				},
			},
			RtcpFeedback: []mediasoup.RtcpFeedback{
				{Type: "nack", Parameter: ""},
				{Type: "nack", Parameter: "pli"},
				{Type: "ccm", Parameter: "fir"},
				{Type: "goog-remb", Parameter: ""},
			},
		},
		{
			MimeType:             "video/rtx",
			Kind:                 "video",
			PreferredPayloadType: 102,
			ClockRate:            90000,
			Parameters: mediasoup.RtpCodecSpecificParameters{
				Apt: 101,
			},
		},
	},
}

func main() {
	worker, err := mediasoup.NewWorker()
	if err != nil {
		panic(err)
	}
	worker.On("died", func(err error) {
		logger.Error("%s", err)
	})

	dump, _ := worker.Dump()
	logger.Debug("dump: %+v", dump)

	usage, err := worker.GetResourceUsage()
	if err != nil {
		panic(err)
	}
	data, _ := json.Marshal(usage)
	logger.Debug("usage: %s", data)

	router, err := worker.CreateRouter(mediasoup.RouterOptions{
		MediaCodecs: []*mediasoup.RtpCodecCapability{
			{
				Kind:      "audio",
				MimeType:  "audio/opus",
				ClockRate: 48000,
				Channels:  2,
			},
			{
				Kind:      "video",
				MimeType:  "video/VP8",
				ClockRate: 90000,
			},
			{
				Kind:      "video",
				MimeType:  "video/H264",
				ClockRate: 90000,
				Parameters: mediasoup.RtpCodecSpecificParameters{
					RtpParameter: h264.RtpParameter{
						LevelAsymmetryAllowed: 1,
						PacketizationMode:     1,
						ProfileLevelId:        "4d0032",
					},
				},
			},
		},
	})
	if err != nil {
		panic(err)
	}

	sendTransport, err := router.CreateWebRtcTransport(mediasoup.WebRtcTransportOptions{
		ListenIps: []mediasoup.TransportListenIp{
			{Ip: "0.0.0.0", AnnouncedIp: "192.168.1.101"}, // AnnouncedIp is optional
		},
	})
	if err != nil {
		panic(err)
	}

	producer, err := sendTransport.Produce(mediasoup.ProducerOptions{
		Kind: mediasoup.MediaKind_Audio,
		RtpParameters: mediasoup.RtpParameters{
			Mid: "VIDEO",
			Codecs: []*mediasoup.RtpCodecParameters{
				{
					MimeType:    "video/h264",
					PayloadType: 112,
					ClockRate:   90000,
					Parameters: mediasoup.RtpCodecSpecificParameters{
						RtpParameter: h264.RtpParameter{
							PacketizationMode: 1,
							ProfileLevelId:    "4d0032",
						},
					},
					RtcpFeedback: []mediasoup.RtcpFeedback{
						{Type: "nack", Parameter: ""},
						{Type: "nack", Parameter: "pli"},
						{Type: "goog-remb", Parameter: ""},
					},
				},
				{
					MimeType:    "video/rtx",
					PayloadType: 113,
					ClockRate:   90000,
					Parameters:  mediasoup.RtpCodecSpecificParameters{Apt: 112},
				},
			},
			HeaderExtensions: []mediasoup.RtpHeaderExtensionParameters{
				{
					Uri: "urn:ietf:params:rtp-hdrext:sdes:mid",
					Id:  10,
				},
				{
					Uri: "urn:3gpp:video-orientation",
					Id:  13,
				},
			},
			Encodings: []mediasoup.RtpEncodingParameters{
				{Ssrc: 22222222, Rtx: &mediasoup.RtpEncodingRtx{Ssrc: 22222223}},
				{Ssrc: 22222224, Rtx: &mediasoup.RtpEncodingRtx{Ssrc: 22222225}},
				{Ssrc: 22222226, Rtx: &mediasoup.RtpEncodingRtx{Ssrc: 22222227}},
				{Ssrc: 22222228, Rtx: &mediasoup.RtpEncodingRtx{Ssrc: 22222229}},
			},
			Rtcp: mediasoup.RtcpParameters{
				Cname: "video-1",
			},
		},
		AppData: mediasoup.H{"foo": 1, "bar": "2"},
	})
	if err != nil {
		panic(err)
	}

	recvTransport, err := router.CreateWebRtcTransport(mediasoup.WebRtcTransportOptions{
		ListenIps: []mediasoup.TransportListenIp{
			{Ip: "0.0.0.0", AnnouncedIp: "192.168.1.101"}, // AnnouncedIp is optional
		},
	})
	if err != nil {
		panic(err)
	}

	producer.Pause()

	// TODO: sent back producer id to client

	consumer, err := recvTransport.Consume(mediasoup.ConsumerOptions{
		ProducerId:      producer.Id(),
		RtpCapabilities: consumerDeviceCapabilities,
		AppData:         mediasoup.H{"baz": "LOL"},
	})
	if err != nil {
		panic(err)
	}

	consumerDump, _ := consumer.Dump()
	data, _ = json.Marshal(consumerDump)
	logger.Debug("consumer, %s", data)

	wait := make(chan struct{})
	<-wait
}

License

ISC

Documentation

Index

Constants

View Source
const (
	// netstring length for a 4194304 bytes payload.
	NS_MESSAGE_MAX_LEN = 4194313
	NS_PAYLOAD_MAX_LEN = 4194304
)
View Source
const (
	ConsumerTraceEventType_Rtp      ConsumerTraceEventType = "rtp"
	ConsumerTraceEventType_Keyframe                        = "keyframe"
	ConsumerTraceEventType_Nack                            = "nack"
	ConsumerTraceEventType_Pli                             = "pli"
	ConsumerTraceEventType_Fir                             = "fir"
)
View Source
const (
	ConsumerType_Simple    ConsumerType = "simple"
	ConsumerType_Simulcast              = "simulcast"
	ConsumerType_Svc                    = "svc"
	ConsumerType_Pipe                   = "pipe"
)
View Source
const (
	PPID_WEBRTC_STRING int = 51
	PPID_WEBRTC_BINARY     = 53
)
View Source
const (
	// DebugLevel defines debug log level.
	DebugLevel = zerolog.DebugLevel
	// InfoLevel defines info log level.
	InfoLevel = zerolog.InfoLevel
	// WarnLevel defines warn log level.
	WarnLevel = zerolog.WarnLevel
	// ErrorLevel defines error log level.
	ErrorLevel = zerolog.ErrorLevel
	// Disabled disables the logger.
	Disabled = zerolog.Disabled
)
View Source
const (
	ProducerTraceEventType_Rtp      ProducerTraceEventType = "rtp"
	ProducerTraceEventType_Keyframe                        = "keyframe"
	ProducerTraceEventType_Nack                            = "nack"
	ProducerTraceEventType_Pli                             = "pli"
	ProducerTraceEventType_Fir                             = "fir"
)
View Source
const (
	ProducerType_Simple    ProducerType = ConsumerType_Simple
	ProducerType_Simulcast              = ConsumerType_Simulcast
	ProducerType_Svc                    = ConsumerType_Svc
)
View Source
const (
	Direction_Sendrecv RtpHeaderExtensionDirection = "sendrecv"
	Direction_Sendonly                             = "sendonly"
	Direction_Recvonly                             = "recvonly"
	Direction_Inactive                             = "inactive"
)
View Source
const (
	SctpState_New        = "new"
	SctpState_Connecting = "connecting"
	SctpState_Connected  = "connected"
	SctpState_Failed     = "failed"
	SctpState_Closed     = "closed"
)
View Source
const (
	TransportType_Direct TransportType = "DirectTransport"
	TransportType_Plain                = "PlainTransport"
	TransportType_Pipe                 = "PipeTransport"
	TransportType_Webrtc               = "WebrtcTransport"
)
View Source
const (
	IceState_New          IceState = "new"
	IceState_Connected             = "connected"
	IceState_Completed             = "completed"
	IceState_Disconnected          = "disconnected"
	IceState_Closed                = "closed"
)
View Source
const (
	DtlsRole_Auto   DtlsRole = "auto"
	DtlsRole_Client          = "client"
	DtlsRole_Server          = "server"
)
View Source
const (
	DtlsState_New        = "new"
	DtlsState_Connecting = "connecting"
	DtlsState_Connected  = "connected"
	DtlsState_Failed     = "failed"
	DtlsState_Closed     = "closed"
)
View Source
const (
	WorkerLogLevel_Debug WorkerLogLevel = "debug"
	WorkerLogLevel_Warn                 = "warn"
	WorkerLogLevel_Error                = "error"
	WorkerLogLevel_None                 = "none"
)
View Source
const (
	WorkerLogTag_INFO      WorkerLogTag = "info"
	WorkerLogTag_ICE                    = "ice"
	WorkerLogTag_DTLS                   = "dtls"
	WorkerLogTag_RTP                    = "rtp"
	WorkerLogTag_SRTP                   = "srtp"
	WorkerLogTag_RTCP                   = "rtcp"
	WorkerLogTag_RTX                    = "rtx"
	WorkerLogTag_BWE                    = "bwe"
	WorkerLogTag_Score                  = "score"
	WorkerLogTag_Simulcast              = "simulcast"
	WorkerLogTag_SVC                    = "svc"
	WorkerLogTag_SCTP                   = "sctp"
	WorkerLogTag_Message                = "message"
)
View Source
const VERSION = "3.7.1"

Variables

View Source
var (
	// DefaultLevel defines default log level.
	DefaultLevel = DebugLevel
	// NewLogger defines function to create logger instance.
	NewLogger = newDefaultLogger
	// NewLoggerWriter defines function to create logger writer.
	NewLoggerWriter = func() io.Writer {
		writer := zerolog.ConsoleWriter{
			Out:        os.Stdout,
			TimeFormat: time.RFC3339,
		}

		if hideDate := os.Getenv("DEBUG_HIDE_DATE"); len(hideDate) > 0 {
			val, err := strconv.ParseBool(hideDate)
			if err == nil && val {
				writer.FormatTimestamp = func(interface{}) string {
					return ""
				}
			}
		}

		if color := os.Getenv("DEBUG_COLORS"); len(color) > 0 {
			val, err := strconv.ParseBool(color)
			if err == nil {
				writer.NoColor = !val
			}
		}

		return writer
	}
)
View Source
var DYNAMIC_PAYLOAD_TYPES = [...]byte{
	100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
	116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 96, 97, 98, 99, 77,
	78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 35, 36,
	37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
	57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
}
View Source
var WorkerBin string = os.Getenv("MEDIASOUP_WORKER_BIN")

Functions

func Bool

func Bool(b bool) *bool

func NewInvalidStateError

func NewInvalidStateError(format string, args ...interface{}) error

func NewTypeError

func NewTypeError(format string, args ...interface{}) error

func NewUnsupportedError

func NewUnsupportedError(format string, args ...interface{}) error

Types

type AudioLevelObserver

type AudioLevelObserver struct {
	IRtpObserver
	// contains filtered or unexported fields
}

func (*AudioLevelObserver) Observer

func (o *AudioLevelObserver) Observer() IEventEmitter

*

  • Observer. *
  • @emits close
  • @emits pause
  • @emits resume
  • @emits addproducer - (producer: Producer)
  • @emits removeproducer - (producer: Producer)
  • @emits volumes - (volumes: AudioLevelObserverVolume[])
  • @emits silence

type AudioLevelObserverOptions

type AudioLevelObserverOptions struct {
	/**
	 * Maximum int of entries in the 'volumes”' event. Default 1.
	 */
	MaxEntries int `json:"maxEntries"`

	/**
	 * Minimum average volume (in dBvo from -127 to 0) for entries in the
	 * 'volumes' event.	Default -80.
	 */
	Threshold int `json:"threshold"`

	/**
	 * Interval in ms for checking audio volumes. Default 1000.
	 */
	Interval int `json:"interval"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

func NewAudioLevelObserverOptions

func NewAudioLevelObserverOptions() AudioLevelObserverOptions

type AudioLevelObserverVolume

type AudioLevelObserverVolume struct {
	/**
	 * The audio producer instance.
	 */
	Producer *Producer

	/**
	 * The average volume (in dBvo from -127 to 0) of the audio producer in the
	 * last interval.
	 */
	Volume int
}

type Channel

type Channel struct {
	IEventEmitter
	// contains filtered or unexported fields
}

func (*Channel) Close

func (c *Channel) Close()

func (*Channel) Closed

func (c *Channel) Closed() bool

func (*Channel) Request

func (c *Channel) Request(method string, internal interface{}, data ...interface{}) (rsp workerResponse)

func (*Channel) Start

func (c *Channel) Start()

type Consumer

type Consumer struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • Consumer
  • @emits transportclose
  • @emits producerclose
  • @emits producerpause
  • @emits producerresume
  • @emits score - (score: ConsumerScore)
  • @emits layerschange - (layers: ConsumerLayers | undefined)
  • @emits rtp - (packet: Buffer)
  • @emits trace - (trace: ConsumerTraceEventData)
  • @emits @close
  • @emits @producerclose

func (*Consumer) AppData

func (consumer *Consumer) AppData() interface{}

App custom data.

func (*Consumer) Close

func (consumer *Consumer) Close() (err error)

Close the Consumer.

func (*Consumer) Closed

func (consumer *Consumer) Closed() bool

Whether the Consumer is closed.

func (*Consumer) ConsumerId

func (consumer *Consumer) ConsumerId() string

Associated Consumer id.

func (*Consumer) CurrentLayers

func (consumer *Consumer) CurrentLayers() *ConsumerLayers

Current video layers.

func (*Consumer) Dump

func (consumer *Consumer) Dump() (dump *ConsumerDump, err error)

Dump Consumer.

func (*Consumer) EnableTraceEvent

func (consumer *Consumer) EnableTraceEvent(types ...ConsumerTraceEventType) error

*

  • Enable 'trace' event.

func (*Consumer) GetStats

func (consumer *Consumer) GetStats() (stats []*ConsumerStat, err error)

Get Consumer stats.

func (*Consumer) Id

func (consumer *Consumer) Id() string

Consumer id

func (*Consumer) Kind

func (consumer *Consumer) Kind() MediaKind

Media kind.

func (*Consumer) Observer

func (consumer *Consumer) Observer() IEventEmitter

*

  • Observer. *
  • @emits close
  • @emits pause
  • @emits resume
  • @emits score - (score: ConsumerScore)
  • @emits layerschange - (layers: ConsumerLayers | undefined)
  • @emits trace - (trace: ConsumerTraceEventData)

func (*Consumer) Pause

func (consumer *Consumer) Pause() (err error)

Pause the Consumer.

func (*Consumer) Paused

func (consumer *Consumer) Paused() bool

Whether the Consumer is paused.

func (*Consumer) PreferredLayers

func (consumer *Consumer) PreferredLayers() *ConsumerLayers

Preferred video layers.

func (*Consumer) Priority

func (consumer *Consumer) Priority() uint32

Current priority.

func (*Consumer) ProducerId

func (consumer *Consumer) ProducerId() string

Associated Producer id.

func (*Consumer) ProducerPaused

func (consumer *Consumer) ProducerPaused() bool

Whether the associate Producer is paused.

func (*Consumer) RequestKeyFrame

func (consumer *Consumer) RequestKeyFrame() error

Request a key frame to the Producer.

func (*Consumer) Resume

func (consumer *Consumer) Resume() (err error)

Resume the Consumer.

func (*Consumer) RtpParameters

func (consumer *Consumer) RtpParameters() RtpParameters

RTP parameters.

func (*Consumer) Score

func (consumer *Consumer) Score() ConsumerScore

Consumer score with consumer and consumer keys.

func (*Consumer) SetPreferredLayers

func (consumer *Consumer) SetPreferredLayers(layers ConsumerLayers) (err error)

Set preferred video layers.

func (*Consumer) SetPriority

func (consumer *Consumer) SetPriority(priority uint32) (err error)

Set priority.

func (*Consumer) Type

func (consumer *Consumer) Type() ConsumerType

Consumer type.

func (*Consumer) UnsetPriority

func (consumer *Consumer) UnsetPriority() (err error)

Unset priority.

type ConsumerDump

type ConsumerDump struct {
	Id                         string               `json:"id,omitempty"`
	ProducerId                 string               `json:"producerId,omitempty"`
	Kind                       string               `json:"kind,omitempty"`
	Type                       string               `json:"type,omitempty"`
	RtpParameters              RtpParameters        `json:"rtpParameters,omitempty"`
	ConsumableRtpEncodings     []RtpMappingEncoding `json:"consumableRtpEncodings,omitempty"`
	SupportedCodecPayloadTypes []uint32             `json:"supportedCodecPayloadTypes,omitempty"`
	Paused                     bool                 `json:"paused,omitempty"`
	ProducerPaused             bool                 `json:"producerPaused,omitempty"`
	Priority                   uint8                `json:"priority,omitempty"`
	TraceEventTypes            string               `json:"traceEventTypes,omitempty"`
	RtpStreams                 []RtpStream          `json:"rtpStreams,omitempty"`
	RtpStream                  *RtpStream           `json:"rtpStream,omitempty"` // dump by SvcConsumer
	*SimulcastConsumerDump
}

type ConsumerLayers

type ConsumerLayers struct {
	/**
	 * The spatial layer index (from 0 to N).
	 */
	SpatialLayer uint8 `json:"spatialLayer"`

	/**
	 * The temporal layer index (from 0 to N).
	 */
	TemporalLayer uint8 `json:"temporalLayer"`
}

type ConsumerOptions

type ConsumerOptions struct {
	/**
	 * The id of the Producer to consume.
	 */
	ProducerId string `json:"producerId,omitempty"`

	/**
	 * RTP capabilities of the consuming endpoint.
	 */
	RtpCapabilities RtpCapabilities `json:"rtpCapabilities,omitempty"`

	/**
	 * Whether the Consumer must start in paused mode. Default false.
	 *
	 * When creating a video Consumer, it's recommended to set paused to true,
	 * then transmit the Consumer parameters to the consuming endpoint and, once
	 * the consuming endpoint has created its local side Consumer, unpause the
	 * server side Consumer using the resume() method. This is an optimization
	 * to make it possible for the consuming endpoint to render the video as far
	 * as possible. If the server side Consumer was created with paused false,
	 * mediasoup will immediately request a key frame to the remote Producer and
	 * suych a key frame may reach the consuming endpoint even before it's ready
	 * to consume it, generating “black” video until the device requests a keyframe
	 * by itself.
	 */
	Paused bool `json:"paused,omitempty"`

	/**
	 * Preferred spatial and temporal layer for simulcast or SVC media sources.
	 * If unset, the highest ones are selected.
	 */
	PreferredLayers *ConsumerLayers `json:"preferredLayers,omitempty"`

	/**
	 * Whether this Consumer should consume all RTP streams generated by the
	 * Producer.
	 */
	Pipe bool

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type ConsumerScore

type ConsumerScore struct {
	/**
	 * The score of the RTP stream of the consumer.
	 */
	Score uint16 `json:"score"`

	/**
	 * The score of the currently selected RTP stream of the producer.
	 */
	ProducerScore uint16 `json:"producerScore"`

	/**
	 * The scores of all RTP streams in the producer ordered by encoding (just
	 * useful when the producer uses simulcast).
	 */
	ProducerScores []uint16 `json:"producerScores,omitempty"`
}

type ConsumerStat

type ConsumerStat = ProducerStat

type ConsumerTraceEventData

type ConsumerTraceEventData struct {
	/**
	 * Trace type.
	 */
	Type ConsumerTraceEventType `json:"type,omitempty"`

	/**
	 * Event timestamp.
	 */
	Timestamp int64 `json:"timestamp,omitempty"`

	/**
	 * Event direction, "in" | "out".
	 */
	Direction string `json:"direction,omitempty"`

	/**
	 * Per type information.
	 */
	Info H `json:"info,omitempty"`
}

*

  • 'trace' event data.

type ConsumerTraceEventType

type ConsumerTraceEventType string

*

  • Valid types for 'trace' event.

type ConsumerType

type ConsumerType string

*

  • Consumer type.

type DataConsumer

type DataConsumer struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • DataConsumer
  • @emits transportclose
  • @emits dataproducerclose
  • @emits message - (message: Buffer, ppid: number)
  • @emits sctpsendbufferfull
  • @emits bufferedamountlow - (bufferedAmount: number)
  • @emits @close
  • @emits @dataproducerclose

func (*DataConsumer) AppData

func (c *DataConsumer) AppData() interface{}

*

  • App custom data.

func (*DataConsumer) Close

func (c *DataConsumer) Close() (err error)

Close the DataConsumer.

func (*DataConsumer) Closed

func (c *DataConsumer) Closed() bool

Whether the DataConsumer is closed.

func (*DataConsumer) DataProducerId

func (c *DataConsumer) DataProducerId() string

Associated DataProducer id.

func (*DataConsumer) Dump

func (c *DataConsumer) Dump() (data DataConsumerDump, err error)

Dump DataConsumer.

func (*DataConsumer) GetBufferedAmount

func (c *DataConsumer) GetBufferedAmount() (bufferedAmount int64, err error)

*

  • Get buffered amount size.

func (*DataConsumer) GetStats

func (c *DataConsumer) GetStats() (stats []*DataConsumerStat, err error)

Get DataConsumer stats.

func (*DataConsumer) Id

func (c *DataConsumer) Id() string

DataConsumer id

func (*DataConsumer) Label

func (c *DataConsumer) Label() string

*

  • DataChannel label.

func (*DataConsumer) Observer

func (c *DataConsumer) Observer() IEventEmitter

*

  • Observer. *
  • @emits close

func (*DataConsumer) Protocol

func (c *DataConsumer) Protocol() string

*

  • DataChannel protocol.

func (*DataConsumer) SctpStreamParameters

func (c *DataConsumer) SctpStreamParameters() *SctpStreamParameters

*

  • SCTP stream parameters.

func (*DataConsumer) Send

func (c *DataConsumer) Send(data []byte, ppid ...int) (err error)

*

  • Send data.

func (*DataConsumer) SendText

func (c *DataConsumer) SendText(message string) error

*

  • Send text.

func (*DataConsumer) SetBufferedAmountLowThreshold

func (c *DataConsumer) SetBufferedAmountLowThreshold(threshold int) error

*

  • Set buffered amount low threshold.

func (*DataConsumer) Type

func (c *DataConsumer) Type() DataConsumerType

DataConsumer type.

type DataConsumerDump

type DataConsumerDump struct {
	Id                         string                `json:"id,omitempty"`
	DataProducerId             string                `json:"dataProducerId,omitempty"`
	Type                       string                `json:"type,omitempty"`
	SctpStreamParameters       *SctpStreamParameters `json:"sctpStreamParameters,omitempty"`
	Label                      string                `json:"label,omitempty"`
	Protocol                   string                `json:"protocol,omitempty"`
	BufferedAmount             uint32                `json:"bufferedAmount,omitempty"`
	BufferedAmountLowThreshold uint32                `json:"bufferedAmountLowThreshold,omitempty"`
}

type DataConsumerOptions

type DataConsumerOptions struct {
	/**
	 * The id of the DataProducer to consume.
	 */
	DataProducerId string `json:"dataProducerId,omitempty"`

	/**
	 * Just if consuming over SCTP.
	 * Whether data messages must be received in order. If true the messages will
	 * be sent reliably. Defaults to the value in the DataProducer if it has type
	 * 'sctp' or to true if it has type 'direct'.
	 */
	Ordered *bool `json:"ordered,omitempty"`

	/**
	 * Just if consuming over SCTP.
	 * When ordered is false indicates the time (in milliseconds) after which a
	 * SCTP packet will stop being retransmitted. Defaults to the value in the
	 * DataProducer if it has type 'sctp' or unset if it has type 'direct'.
	 */
	MaxPacketLifeTime uint16 `json:"maxPacketLifeTime,omitempty"`

	/**
	 * Just if consuming over SCTP.
	 * When ordered is false indicates the maximum number of times a packet will
	 * be retransmitted. Defaults to the value in the DataProducer if it has type
	 * 'sctp' or unset if it has type 'direct'.
	 */
	MaxRetransmits uint16 `json:"maxRetransmits,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type DataConsumerStat

type DataConsumerStat struct {
	Type           string `json:"type,omitempty"`
	Timestamp      int64  `json:"timestamp,omitempty"`
	Label          string `json:"label,omitempty"`
	Protocol       string `json:"protocol,omitempty"`
	MessagesSent   int64  `json:"messagesSent,omitempty"`
	BytesSent      int64  `json:"bytesSent,omitempty"`
	BufferedAmount uint32 `json:"bufferedAmount,omitempty"`
}

type DataConsumerType

type DataConsumerType string

*

  • DataConsumer type.
const (
	DataConsumerType_Sctp   DataConsumerType = "sctp"
	DataConsumerType_Direct                  = "direct"
)

type DataProducer

type DataProducer struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • DataProducer
  • @emits transportclose
  • @emits @close

func (*DataProducer) AppData

func (p *DataProducer) AppData() interface{}

*

  • App custom data.

func (*DataProducer) Close

func (p *DataProducer) Close() (err error)

Close the DataProducer.

func (*DataProducer) Closed

func (p *DataProducer) Closed() bool

Whether the DataProducer is closed.

func (*DataProducer) Dump

func (p *DataProducer) Dump() (dump DataProducerDump, err error)

Dump DataConsumer.

func (*DataProducer) GetStats

func (p *DataProducer) GetStats() (stats []*DataProducerStat, err error)

Get DataConsumer stats.

func (*DataProducer) Id

func (p *DataProducer) Id() string

DataProducer id

func (*DataProducer) Label

func (p *DataProducer) Label() string

*

  • DataChannel label.

func (*DataProducer) Observer

func (p *DataProducer) Observer() IEventEmitter

*

  • Observer. *
  • @emits close

func (*DataProducer) Protocol

func (p *DataProducer) Protocol() string

*

  • DataChannel protocol.

func (*DataProducer) SctpStreamParameters

func (p *DataProducer) SctpStreamParameters() SctpStreamParameters

*

  • SCTP stream parameters.

func (*DataProducer) Send

func (p *DataProducer) Send(data []byte, ppid ...int) (err error)

*

  • Send data.

func (*DataProducer) SendText

func (p *DataProducer) SendText(message string) error

*

  • Send text.

func (*DataProducer) Type

func (p *DataProducer) Type() DataConsumerType

DataProducer type.

type DataProducerDump

type DataProducerDump struct {
	Id                   string                `json:"id,omitempty"`
	Type                 string                `json:"type,omitempty"`
	SctpStreamParameters *SctpStreamParameters `json:"sctpStreamParameters,omitempty"`
	Label                string                `json:"label,omitempty"`
	Protocol             string                `json:"protocol,omitempty"`
}

type DataProducerOptions

type DataProducerOptions struct {
	/**
	 * DataProducer id (just for Router.pipeToRouter() method).
	 */
	Id string `json:"id,omitempty"`

	/**
	 * SCTP parameters defining how the endpoint is sending the data.
	 * Just if messages are sent over SCTP.
	 */
	SctpStreamParameters *SctpStreamParameters `json:"sctpStreamParameters,omitempty"`

	/**
	 * A label which can be used to distinguish this DataChannel from others.
	 */
	Label string `json:"label,omitempty"`

	/**
	 * Name of the sub-protocol used by this DataChannel.
	 */
	Protocol string `json:"protocol,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"app_data,omitempty"`
}

type DataProducerStat

type DataProducerStat struct {
	Type             string
	Timestamp        int64
	Label            string
	Protocol         string
	MessagesReceived int64
	BytesReceived    int64
}

type DataProducerType

type DataProducerType = DataConsumerType

*

  • DataProducer type.
const (
	DataProducerType_Sctp   DataProducerType = DataConsumerType_Sctp
	DataProducerType_Direct                  = DataConsumerType_Direct
)

type DirectTransport

type DirectTransport struct {
	ITransport
	// contains filtered or unexported fields
}

*

  • DirectTransport
  • @emits rtcp - (packet: []byte)
  • @emits trace - (trace: TransportTraceEventData)

func (*DirectTransport) Connect

func (transport *DirectTransport) Connect(TransportConnectOptions) error

*

  • NO-OP method in DirectTransport. *
  • @override

func (*DirectTransport) Observer

func (transport *DirectTransport) Observer() IEventEmitter

*

  • Observer. *
  • @override
  • @emits close
  • @emits newdataproducer - (dataProducer: DataProducer)
  • @emits newdataconsumer - (dataProducer: DataProducer)
  • @emits trace - (trace: TransportTraceEventData)

func (*DirectTransport) SendRtcp

func (transport *DirectTransport) SendRtcp(rtcpPacket []byte) error

*

  • Send RTCP packet.

type DirectTransportOptions

type DirectTransportOptions struct {
	/**
	 * Maximum allowed size for direct messages sent from DataProducers.
	 * Default 262144.
	 */
	MaxMessageSize uint32 `json:"maxMessageSize,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type DtlsFingerprint

type DtlsFingerprint struct {
	Algorithm string `json:"algorithm"`
	Value     string `json:"value"`
}

*

  • The hash function algorithm (as defined in the "Hash function Textual Names"
  • registry initially specified in RFC 4572 Section 8) and its corresponding
  • certificate fingerprint value (in lowercase hex string as expressed utilizing
  • the syntax of "fingerprint" in RFC 4572 Section 5).

type DtlsParameters

type DtlsParameters struct {
	Role         DtlsRole          `json:"role,omitempty"`
	Fingerprints []DtlsFingerprint `json:"fingerprints"`
}

type DtlsRole

type DtlsRole string

type DtlsState

type DtlsState string

type H

type H map[string]interface{}

type IEventEmitter

type IEventEmitter = eventemitter.IEventEmitter

func NewEventEmitter

func NewEventEmitter() IEventEmitter

type IRtpObserver

type IRtpObserver interface {
	IEventEmitter

	Id() string
	Closed() bool
	Paused() bool
	Observer() IEventEmitter
	Close()

	Pause()
	Resume()
	AddProducer(producerId string)
	RemoveProducer(producerId string)
	// contains filtered or unexported methods
}

type ITransport

type ITransport interface {
	IEventEmitter
	Id() string
	Closed() bool
	AppData() interface{}
	Observer() IEventEmitter
	Close()

	Dump() (*TransportDump, error)
	GetStats() ([]*TransportStat, error)
	Connect(TransportConnectOptions) error
	SetMaxIncomingBitrate(bitrate int) error
	Produce(ProducerOptions) (*Producer, error)
	Consume(ConsumerOptions) (*Consumer, error)
	ProduceData(DataProducerOptions) (*DataProducer, error)
	ConsumeData(DataConsumerOptions) (*DataConsumer, error)
	EnableTraceEvent(types ...TransportTraceEventType) error
	// contains filtered or unexported methods
}

type IceCandidate

type IceCandidate struct {
	Foundation string            `json:"foundation"`
	Priority   uint32            `json:"priority"`
	Ip         string            `json:"ip"`
	Protocol   TransportProtocol `json:"protocol"`
	Port       uint32            `json:"port"`
	// alway "host"
	Type string `json:"type,omitempty"`
	// "passive" | undefined
	TcpType string `json:"tcpType,omitempty"`
}

type IceParameters

type IceParameters struct {
	UsernameFragment string `json:"usernameFragment"`
	Password         string `json:"password"`
	IceLite          bool   `json:"iceLite,omitempty"`
}

type IceState

type IceState string

type InvalidStateError

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

InvalidStateError produced when calling a method in an invalid state.

func (InvalidStateError) Error

func (e InvalidStateError) Error() string

type Logger

type Logger interface {
	Debug(format string, v ...interface{})
	Info(format string, v ...interface{})
	Warn(format string, v ...interface{})
	Error(format string, v ...interface{})
}

type MediaKind

type MediaKind string

*

  • Media kind ('audio' or 'video').
const (
	MediaKind_Audio MediaKind = "audio"
	MediaKind_Video           = "video"
)

type NumSctpStreams

type NumSctpStreams struct {
	/**
	 * Initially requested int of outgoing SCTP streams.
	 */
	OS uint16 `json:"OS"`

	/**
	 * Maximum int of incoming SCTP streams.
	 */
	MIS uint16 `json:"MIS"`
}

*

  • Both OS and MIS are part of the SCTP INIT+ACK handshake. OS refers to the
  • initial int of outgoing SCTP streams that the server side transport creates
  • (to be used by DataConsumers), while MIS refers to the maximum int of
  • incoming SCTP streams that the server side transport can receive (to be used
  • by DataProducers). So, if the server side transport will just be used to
  • create data producers (but no data consumers), OS can be low (~1). However,
  • if data consumers are desired on the server side transport, OS must have a
  • proper value and such a proper value depends on whether the remote endpoint
  • supports SCTP_ADD_STREAMS extension or not. *
  • libwebrtc (Chrome, Safari, etc) does not enable SCTP_ADD_STREAMS so, if data
  • consumers are required, OS should be 1024 (the maximum int of DataChannels
  • that libwebrtc enables). *
  • Firefox does enable SCTP_ADD_STREAMS so, if data consumers are required, OS
  • can be lower (16 for instance). The mediasoup transport will allocate and
  • announce more outgoing SCTM streams when needed. *
  • mediasoup-client provides specific per browser/version OS and MIS values via
  • the device.sctpCapabilities getter.

type Option

type Option func(w *WorkerSettings)

func WithCustomOption

func WithCustomOption(key string, value interface{}) Option

func WithDtlsCert

func WithDtlsCert(dtlsCertificateFile, dtlsPrivateKeyFile string) Option

func WithLogLevel

func WithLogLevel(logLevel WorkerLogLevel) Option

func WithLogTags

func WithLogTags(logTags []WorkerLogTag) Option

func WithRtcMaxPort

func WithRtcMaxPort(rtcMaxPort uint16) Option

func WithRtcMinPort

func WithRtcMinPort(rtcMinPort uint16) Option

type PayloadChannel

type PayloadChannel struct {
	IEventEmitter
	// contains filtered or unexported fields
}

func (*PayloadChannel) Close

func (c *PayloadChannel) Close()

func (*PayloadChannel) Closed

func (c *PayloadChannel) Closed() bool

func (*PayloadChannel) Notify

func (c *PayloadChannel) Notify(event string, internal interface{}, data interface{}, payload []byte) (err error)

func (*PayloadChannel) Request

func (c *PayloadChannel) Request(method string, internal interface{}, data interface{}, payload []byte) (rsp workerResponse)

type PipeToRouterOptions

type PipeToRouterOptions struct {
	/**
	 * The id of the Producer to consume.
	 */
	ProducerId string `json:"producerId,omitempty"`

	/**
	 * The id of the DataProducer to consume.
	 */
	DataProducerId string `json:"dataProducerId,omitempty"`

	/**
	 * Target Router instance.
	 */
	Router *Router `json:"router,omitempty"`

	/**
	 * IP used in the PipeTransport pair. Default '127.0.0.1'.
	 */
	ListenIp TransportListenIp `json:"listenIp,omitempty"`

	/**
	 * Create a SCTP association. Default false.
	 */
	EnableSctp bool `json:"enableSctp,omitempty"`

	/**
	 * SCTP streams number.
	 */
	NumSctpStreams NumSctpStreams `json:"numSctpStreams,omitempty"`

	/**
	 * Enable RTX and NACK for RTP retransmission.
	 */
	EnableRtx bool `json:"enableRtx,omitempty"`

	/**
	 * Enable SRTP.
	 */
	EnableSrtp bool `json:"enableSrtp,omitempty"`
}

type PipeToRouterResult

type PipeToRouterResult struct {
	/**
	 * The Consumer created in the current Router.
	 */
	PipeConsumer *Consumer

	/**
	 * The Producer created in the target Router.
	 */
	PipeProducer *Producer

	/**
	 * The DataConsumer created in the current Router.
	 */
	PipeDataConsumer *DataConsumer

	/**
	 * The DataProducer created in the target Router.
	 */
	PipeDataProducer *DataProducer
}

type PipeTransport

type PipeTransport struct {
	ITransport
	// contains filtered or unexported fields
}

*

  • PipeTransport
  • @emits sctpstatechange - (sctpState: SctpState)
  • @emits trace - (trace: TransportTraceEventData)

func (*PipeTransport) Close

func (transport *PipeTransport) Close()

*

  • Close the PipeTransport. *
  • @override

func (*PipeTransport) Connect

func (transport *PipeTransport) Connect(options TransportConnectOptions) (err error)

*

  • Provide the PlainTransport remote parameters. *
  • @override

func (*PipeTransport) Consume

func (transport *PipeTransport) Consume(options ConsumerOptions) (consumer *Consumer, err error)

*

  • Create a pipe Consumer. *
  • @override

func (*PipeTransport) Observer

func (transport *PipeTransport) Observer() IEventEmitter

*

  • Observer. *
  • @override
  • @emits close
  • @emits newproducer - (producer: Producer)
  • @emits newconsumer - (consumer: Consumer)
  • @emits newdataproducer - (dataProducer: DataProducer)
  • @emits newdataconsumer - (dataConsumer: DataConsumer)
  • @emits sctpstatechange - (sctpState: SctpState)
  • @emits trace - (trace: TransportTraceEventData)

func (PipeTransport) SctpParameters

func (t PipeTransport) SctpParameters() SctpParameters

*

  • SCTP parameters.

func (PipeTransport) SctpState

func (t PipeTransport) SctpState() SctpState

*

  • SCTP state.

func (PipeTransport) SrtpParameters

func (t PipeTransport) SrtpParameters() *SrtpParameters

*

  • SRTP parameters.

func (PipeTransport) Tuple

func (t PipeTransport) Tuple() TransportTuple

*

  • Transport tuple.

type PipeTransportOptions

type PipeTransportOptions struct {
	/**
	 * Listening IP address.
	 */
	ListenIp TransportListenIp `json:"listenIp,omitempty"`

	/**
	 * Create a SCTP association. Default false.
	 */
	EnableSctp bool `json:"enableSctp,omitempty"`

	/**
	 * SCTP streams number.
	 */
	NumSctpStreams NumSctpStreams `json:"numSctpStreams,omitempty"`

	/**
	 * Maximum allowed size for SCTP messages sent by DataProducers.
	 * Default 268435456.
	 */
	MaxSctpMessageSize int `json:"maxSctpMessageSize,omitempty"`

	/**
	 * Maximum SCTP send buffer used by DataConsumers.
	 * Default 268435456.
	 */
	SctpSendBufferSize int `json:"sctpSendBufferSize,omitempty"`

	/**
	 * Enable RTX and NACK for RTP retransmission. Useful if both Routers are
	 * located in different hosts and there is packet lost in the link. For this
	 * to work, both PipeTransports must enable this setting. Default false.
	 */
	EnableRtx bool `json:"enableRtx,omitempty"`

	/**
	 * Enable SRTP. Useful to protect the RTP and RTCP traffic if both Routers
	 * are located in different hosts. For this to work, connect() must be called
	 * with remote SRTP parameters. Default false.
	 */
	EnableSrtp bool `json:"enableSrtp,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type PlainTransport

type PlainTransport struct {
	ITransport
	// contains filtered or unexported fields
}

*

  • PlainTransport
  • @emits tuple - (tuple: TransportTuple)
  • @emits rtcptuple - (rtcpTuple: TransportTuple)
  • @emits sctpstatechange - (sctpState: SctpState)
  • @emits trace - (trace: TransportTraceEventData)

func (*PlainTransport) Close

func (transport *PlainTransport) Close()

*

  • Close the PlainTransport. *
  • @override

func (*PlainTransport) Connect

func (transport *PlainTransport) Connect(options TransportConnectOptions) (err error)

*

  • Provide the PlainTransport remote parameters. *
  • @override

func (*PlainTransport) Observer

func (transport *PlainTransport) Observer() IEventEmitter

*

  • Observer. *
  • @override
  • @emits close
  • @emits newproducer - (producer: Producer)
  • @emits newconsumer - (consumer: Consumer)
  • @emits newdataproducer - (dataProducer: DataProducer)
  • @emits newdataconsumer - (dataConsumer: DataConsumer)
  • @emits tuple - (tuple: TransportTuple)
  • @emits rtcptuple - (rtcpTuple: TransportTuple)
  • @emits sctpstatechange - (sctpState: SctpState)
  • @emits trace - (trace: TransportTraceEventData)

func (PlainTransport) RtcpTuple

func (t PlainTransport) RtcpTuple() *TransportTuple

*

  • Transport RTCP tuple.

func (PlainTransport) SctpParameters

func (t PlainTransport) SctpParameters() SctpParameters

*

  • SCTP parameters.

func (PlainTransport) SctpState

func (t PlainTransport) SctpState() SctpState

*

  • SCTP state.

func (PlainTransport) SrtpParameters

func (t PlainTransport) SrtpParameters() *SrtpParameters

*

  • SRTP parameters.

func (PlainTransport) Tuple

func (t PlainTransport) Tuple() *TransportTuple

*

  • Transport tuple.

type PlainTransportDump

type PlainTransportDump struct {
	RtcpMux        bool            `json:"rtcpMux,omitempty"`
	Comedia        bool            `json:"comedia,omitempty"`
	Tuple          *TransportTuple `json:"tuple,omitempty"`
	RtcpTuple      *TransportTuple `json:"rtcpTuple,omitempty"`
	SrtpParameters *SrtpParameters `json:"srtpParameters,omitempty"`
}

type PlainTransportOptions

type PlainTransportOptions struct {
	/**
	 * Listening IP address.
	 */
	ListenIp TransportListenIp `json:"listenIp,omitempty"`

	/**
	 * Use RTCP-mux (RTP and RTCP in the same port). Default true.
	 */
	RtcpMux *bool `json:"rtcpMux,omitempty"`

	/**
	 * Whether remote IP:port should be auto-detected based on first RTP/RTCP
	 * packet received. If enabled, connect() method must not be called unless
	 * SRTP is enabled. If so, it must be called with just remote SRTP parameters.
	 * Default false.
	 */
	Comedia bool `json:"comedia,omitempty"`

	/**
	 * Create a SCTP association. Default false.
	 */
	EnableSctp bool `json:"enableSctp,omitempty"`

	/**
	 * SCTP streams number.
	 */
	NumSctpStreams NumSctpStreams `json:"numSctpStreams,omitempty"`

	/**
	 * Maximum allowed size for SCTP messages sent by DataProducers.
	 * Default 262144.
	 */
	MaxSctpMessageSize int `json:"maxSctpMessageSize,omitempty"`

	/**
	 * Maximum SCTP send buffer used by DataConsumers.
	 * Default 262144.
	 */
	SctpSendBufferSize int `json:"sctpSendBufferSize,omitempty"`

	/**
	 * Enable SRTP. For this to work, connect() must be called
	 * with remote SRTP parameters. Default false.
	 */
	EnableSrtp bool `json:"enableSrtp,omitempty"`

	/**
	 * The SRTP crypto suite to be used if enableSrtp is set. Default
	 * 'AES_CM_128_HMAC_SHA1_80'.
	 */
	SrtpCryptoSuite SrtpCryptoSuite `json:"srtpCryptoSuite,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type PlainTransportSpecificStat

type PlainTransportSpecificStat struct {
	RtcpMux   bool            `json:"rtcp_mux"`
	Comedia   bool            `json:"comedia"`
	Tuple     TransportTuple  `json:"tuple"`
	RtcpTuple *TransportTuple `json:"rtcpTuple,omitempty"`
}

type Producer

type Producer struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • Producer
  • @emits transportclose
  • @emits score - (score: ProducerScore[])
  • @emits videoorientationchange - (videoOrientation: ProducerVideoOrientation)
  • @emits trace - (trace: ProducerTraceEventData)
  • @emits @close

func (*Producer) AppData

func (producer *Producer) AppData() interface{}

App custom data.

func (*Producer) Close

func (producer *Producer) Close() (err error)

Close the Producer.

func (*Producer) Closed

func (producer *Producer) Closed() bool

Whether the Producer is closed.

func (*Producer) ConsumableRtpParameters

func (producer *Producer) ConsumableRtpParameters() RtpParameters

Consumable RTP parameters.

func (*Producer) Dump

func (producer *Producer) Dump() (dump ProducerDump, err error)

Dump Producer.

func (*Producer) EnableTraceEvent

func (producer *Producer) EnableTraceEvent(types ...ProducerTraceEventType) error

*

  • Enable 'trace' event.

func (*Producer) GetStats

func (producer *Producer) GetStats() (stats []*ProducerStat, err error)

Get Producer stats.

func (*Producer) Id

func (producer *Producer) Id() string

Producer id

func (*Producer) Kind

func (producer *Producer) Kind() MediaKind

Media kind.

func (*Producer) Observer

func (producer *Producer) Observer() IEventEmitter

*

  • Observer. *
  • @emits close
  • @emits pause
  • @emits resume
  • @emits score - (score: ProducerScore[])
  • @emits videoorientationchange - (videoOrientation: ProducerVideoOrientation)
  • @emits trace - (trace: ProducerTraceEventData)

func (*Producer) Pause

func (producer *Producer) Pause() (err error)

Pause the Producer.

func (*Producer) Paused

func (producer *Producer) Paused() bool

Whether the Producer is paused.

func (*Producer) Resume

func (producer *Producer) Resume() (err error)

Resume the Producer.

func (*Producer) RtpParameters

func (producer *Producer) RtpParameters() RtpParameters

RTP parameters.

func (*Producer) Score

func (producer *Producer) Score() []ProducerScore

Producer score list.

func (*Producer) Send

func (producer *Producer) Send(rtpPacket []byte) error

*

  • Send RTP packet (just valid for Producers created on a DirectTransport).

func (*Producer) Type

func (producer *Producer) Type() ProducerType

Producer type.

type ProducerDump

type ProducerDump struct {
	Id              string             `json:"id,omitempty"`
	Kind            string             `json:"kind,omitempty"`
	Type            string             `json:"type,omitempty"`
	RtpParameters   RtpParameters      `json:"rtpParameters,omitempty"`
	RtpMapping      RtpMapping         `json:"rtpMapping,omitempty"`
	Encodings       RtpMappingEncoding `json:"encodings,omitempty"`
	RtpStreams      []RtpStream        `json:"rtpStreams,omitempty"`
	Paused          bool               `json:"paused,omitempty"`
	TraceEventTypes string             `json:"traceEventTypes,omitempty"`
}

type ProducerOptions

type ProducerOptions struct {
	/**
	 * Producer id (just for Router.pipeToRouter() method).
	 */
	Id string `json:"id,omitempty"`

	/**
	 * Media kind ('audio' or 'video').
	 */
	Kind MediaKind `json:"kind,omitempty"`

	/**
	 * RTP parameters defining what the endpoint is sending.
	 */
	RtpParameters RtpParameters `json:"rtpParameters,omitempty"`

	/**
	 * Whether the producer must start in paused mode. Default false.
	 */
	Paused bool `json:"paused,omitempty"`

	/**
	 * Just for video. Time (in ms) before asking the sender for a new key frame
	 * after having asked a previous one. Default 0.
	 */
	KeyFrameRequestDelay uint32 `json:"keyFrameRequestDelay,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type ProducerScore

type ProducerScore struct {
	/**
	 * SSRC of the RTP stream.
	 */
	Ssrc uint32 `json:"ssrc,omitempty"`

	/**
	 * RID of the RTP stream.
	 */
	Rid string `json:"rid,omitempty"`

	/**
	 * The score of the RTP stream.
	 */
	Score uint32 `json:"score"`
}

type ProducerStat

type ProducerStat struct {
	// Common to all RtpStreams.
	Type                 string  `json:"type,omitempty"`
	Timestamp            int64   `json:"timestamp,omitempty"`
	Ssrc                 uint32  `json:"ssrc,omitempty"`
	RtxSsrc              uint32  `json:"rtxSsrc,omitempty"`
	Rid                  string  `json:"rid,omitempty"`
	Kind                 string  `json:"kind,omitempty"`
	MimeType             string  `json:"mimeType,omitempty"`
	PacketsLost          uint32  `json:"packetsLost,omitempty"`
	FractionLost         uint32  `json:"fractionLost,omitempty"`
	PacketsDiscarded     uint32  `json:"packetsDiscarded,omitempty"`
	PacketsRetransmitted uint32  `json:"packetsRetransmitted,omitempty"`
	PacketsRepaired      uint32  `json:"packetsRepaired,omitempty"`
	NackCount            uint32  `json:"nackCount,omitempty"`
	NackPacketCount      uint32  `json:"nackPacketCount,omitempty"`
	PliCount             uint32  `json:"pliCount,omitempty"`
	FirCount             uint32  `json:"firCount,omitempty"`
	Score                uint32  `json:"score,omitempty"`
	PacketCount          int64   `json:"packetCount,omitempty"`
	ByteCount            int64   `json:"byteCount,omitempty"`
	Bitrate              uint32  `json:"bitrate,omitempty"`
	RoundTripTime        float32 `json:"roundTripTime,omitempty"`
	RtxPacketsDiscarded  uint32  `json:"rtxPacketsDiscarded,omitempty"`

	// RtpStreamRecv specific.
	Jitter         uint32 `json:"jitter,omitempty"`
	BitrateByLayer H      `json:"bitrateByLayer,omitempty"`
}

type ProducerTraceEventData

type ProducerTraceEventData struct {
	/**
	 * Trace type.
	 */
	Type ProducerTraceEventType `json:"type,omitempty"`

	/**
	 * Event timestamp.
	 */
	Timestamp uint32 `json:"timestamp,omitempty"`

	/**
	 * Event direction, "in" | "out".
	 */
	Direction string `json:"direction,omitempty"`

	/**
	 * Per type information.
	 */
	Info H `json:"info,omitempty"`
}

*

  • 'trace' event data.

type ProducerTraceEventType

type ProducerTraceEventType string

*

  • Valid types for 'trace' event.

type ProducerType

type ProducerType = ConsumerType

*

  • Producer type.

type ProducerVideoOrientation

type ProducerVideoOrientation struct {
	/**
	 * Whether the source is a video camera.
	 */
	Camera bool `json:"Camera,omitempty"`

	/**
	 * Whether the video source is flipped.
	 */
	Flip bool `json:"flip,omitempty"`

	/**
	 * Rotation degrees (0, 90, 180 or 270).
	 */
	Rotation uint32 `json:"rotation"`
}

type RecvRtpHeaderExtensions

type RecvRtpHeaderExtensions struct {
	Mid               uint8 `json:"mid,omitempty"`
	Rid               uint8 `json:"rid,omitempty"`
	Rrid              uint8 `json:"rrid,omitempty"`
	AbsSendTime       uint8 `json:"absSendTime,omitempty"`
	TransportWideCc01 uint8 `json:"transportWideCc01,omitempty"`
}

type Router

type Router struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • Router
  • @emits workerclose
  • @emits @close

func (*Router) CanConsume

func (router *Router) CanConsume(producerId string, rtpCapabilities RtpCapabilities) bool

*

  • Check whether the given RTP capabilities can consume the given Producer.

func (*Router) Close

func (router *Router) Close()

Close the Router.

func (*Router) Closed

func (router *Router) Closed() bool

Whether the Router is closed.

func (*Router) CreateAudioLevelObserver

func (router *Router) CreateAudioLevelObserver(options ...func(o *AudioLevelObserverOptions)) (rtpObserver IRtpObserver, err error)

*

  • Create an AudioLevelObserver.

func (*Router) CreateDirectTransport

func (router *Router) CreateDirectTransport(params ...DirectTransportOptions) (transport *DirectTransport, err error)

*

  • Create a DirectTransport.

func (*Router) CreatePipeTransport

func (router *Router) CreatePipeTransport(option PipeTransportOptions) (transport *PipeTransport, err error)

*

  • Create a PipeTransport.

func (*Router) CreatePlainTransport

func (router *Router) CreatePlainTransport(option PlainTransportOptions) (transport *PlainTransport, err error)

*

  • Create a PlainTransport.

func (*Router) CreateWebRtcTransport

func (router *Router) CreateWebRtcTransport(option WebRtcTransportOptions) (transport *WebRtcTransport, err error)

*

  • Create a WebRtcTransport.

func (*Router) Dump

func (router *Router) Dump() (data *RouterDump, err error)

Dump Router.

func (*Router) Id

func (router *Router) Id() string

Router id

func (*Router) Observer

func (router *Router) Observer() IEventEmitter

func (*Router) PipeToRouter

func (router *Router) PipeToRouter(option PipeToRouterOptions) (result *PipeToRouterResult, err error)

*

  • Pipes the given Producer or DataProducer into another Router in same host.

func (*Router) RtpCapabilities

func (router *Router) RtpCapabilities() RtpCapabilities

RTC capabilities of the Router.

type RouterDump

type RouterDump struct {
	Id                               string              `json:"id,omitempty"`
	TransportIds                     []string            `json:"transportIds,omitempty"`
	RtpObserverIds                   []string            `json:"rtpObserverIds,omitempty"`
	MapProducerIdConsumerIds         map[string][]string `json:"mapProducerIdConsumerIds,omitempty"`
	MapConsumerIdProducerId          map[string]string   `json:"mapConsumerIdProducerId,omitempty"`
	MapProducerIdObserverIds         map[string][]string `json:"mapProducerIdObserverIds,omitempty"`
	MapDataProducerIdDataConsumerIds map[string][]string `json:"mapDataProducerIdDataConsumerIds,omitempty"`
	MapDataConsumerIdDataProducerId  map[string]string   `json:"mapDataConsumerIdDataProducerId,omitempty"`
}

type RouterOptions

type RouterOptions struct {
	/**
	 * Router media codecs.
	 */
	MediaCodecs []*RtpCodecCapability `json:"mediaCodecs,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type RtcpFeedback

type RtcpFeedback struct {
	/**
	 * RTCP feedback type.
	 */
	Type string `json:"type"`

	/**
	 * RTCP feedback parameter.
	 */
	Parameter string `json:"parameter,omitempty"`
}

*

  • Provides information on RTCP feedback messages for a specific codec. Those
  • messages can be transport layer feedback messages or codec-specific feedback
  • messages. The list of RTCP feedbacks supported by mediasoup is defined in the
  • supportedRtpCapabilities.ts file.

type RtcpParameters

type RtcpParameters struct {
	/**
	 * The Canonical Name (CNAME) used by RTCP (e.g. in SDES messages).
	 */
	Cname string `json:"cname,omitempty"`

	/**
	 * Whether reduced size RTCP RFC 5506 is configured (if true) or compound RTCP
	 * as specified in RFC 3550 (if false). Default true.
	 */
	ReducedSize *bool `json:"reducedSize,omitempty"`

	/**
	 * Whether RTCP-mux is used. Default true.
	 */
	Mux *bool `json:"mux,omitempty"`
}

*

  • Provides information on RTCP settings within the RTP parameters. *
  • If no cname is given in a producer's RTP parameters, the mediasoup transport
  • will choose a random one that will be used into RTCP SDES messages sent to
  • all its associated consumers. *
  • mediasoup assumes reducedSize to always be true.

type RtpCapabilities

type RtpCapabilities struct {
	/**
	 * Supported media and RTX codecs.
	 */
	Codecs []*RtpCodecCapability `json:"codecs,omitempty"`

	/**
	 * Supported RTP header extensions.
	 */
	HeaderExtensions []*RtpHeaderExtension `json:"headerExtensions,omitempty"`

	/**
	 * Supported FEC mechanisms.
	 */
	FecMechanisms []string `json:"fecMechanisms,omitempty"`
}

*

  • The RTP capabilities define what mediasoup or an endpoint can receive at
  • media level.

func GetSupportedRtpCapabilities

func GetSupportedRtpCapabilities() (rtpCapabilities RtpCapabilities)

type RtpCodecCapability

type RtpCodecCapability struct {
	/**
	 * Media kind.
	 */
	Kind MediaKind `json:"kind"`

	/**
	 * The codec MIME media type/subtype (e.g. 'audio/opus', 'video/VP8').
	 */
	MimeType string `json:"mimeType"`

	/**
	 * The preferred RTP payload type.
	 */
	PreferredPayloadType byte `json:"preferredPayloadType,omitempty"`

	/**
	 * Codec clock rate expressed in Hertz.
	 */
	ClockRate int `json:"clockRate"`

	/**
	 * The int of channels supported (e.g. two for stereo). Just for audio.
	 * Default 1.
	 */
	Channels int `json:"channels,omitempty"`

	/**
	 * Codec specific parameters. Some parameters (such as 'packetization-mode'
	 * and 'profile-level-id' in H264 or 'profile-id' in VP9) are critical for
	 * codec matching.
	 */
	Parameters RtpCodecSpecificParameters `json:"parameters,omitempty"`

	/**
	 * Transport layer and codec-specific feedback messages for this codec.
	 */
	RtcpFeedback []RtcpFeedback `json:"rtcpFeedback,omitempty"`
}

*

  • Provides information on the capabilities of a codec within the RTP
  • capabilities. The list of media codecs supported by mediasoup and their
  • settings is defined in the supportedRtpCapabilities.ts file. *
  • Exactly one RtpCodecCapability will be present for each supported combination
  • of parameters that requires a distinct value of preferredPayloadType. For
  • example *
  • - Multiple H264 codecs, each with their own distinct 'packetization-mode' and
  • 'profile-level-id' values.
  • - Multiple VP9 codecs, each with their own distinct 'profile-id' value. *
  • RtpCodecCapability entries in the mediaCodecs array of RouterOptions do not
  • require preferredPayloadType field (if unset, mediasoup will choose a random
  • one). If given, make sure it's in the 96-127 range.

type RtpCodecParameters

type RtpCodecParameters struct {
	/**
	 * The codec MIME media type/subtype (e.g. 'audio/opus', 'video/VP8').
	 */
	MimeType string `json:"mimeType"`

	/**
	 * The value that goes in the RTP Payload Type Field. Must be unique.
	 */
	PayloadType byte `json:"payloadType"`

	/**
	 * Codec clock rate expressed in Hertz.
	 */
	ClockRate int `json:"clockRate"`

	/**
	 * The int of channels supported (e.g. two for stereo). Just for audio.
	 * Default 1.
	 */
	Channels int `json:"channels,omitempty"`

	/**
	 * Codec-specific parameters available for signaling. Some parameters (such
	 * as 'packetization-mode' and 'profile-level-id' in H264 or 'profile-id' in
	 * VP9) are critical for codec matching.
	 */
	Parameters RtpCodecSpecificParameters `json:"parameters,omitempty"`

	/**
	 * Transport layer and codec-specific feedback messages for this codec.
	 */
	RtcpFeedback []RtcpFeedback `json:"rtcpFeedback,omitempty"`
}

*

  • Provides information on codec settings within the RTP parameters. The list
  • of media codecs supported by mediasoup and their settings is defined in the
  • supportedRtpCapabilities.ts file.

type RtpCodecSpecificParameters

type RtpCodecSpecificParameters struct {
	h264.RtpParameter          // used by h264 codec
	ProfileId           string `json:"profile-id,omitempty"`   // used by vp9
	Apt                 byte   `json:"apt,omitempty"`          // used by rtx codec
	SpropStereo         uint8  `json:"sprop-stereo,omitempty"` // used by audio, 1 or 0
	Useinbandfec        uint8  `json:"useinbandfec,omitempty"` // used by audio, 1 or 0
	Usedtx              uint8  `json:"usedtx,omitempty"`       // used by audio, 1 or 0
	Maxplaybackrate     uint32 `json:"maxplaybackrate,omitempty"`
	XGoogleMinBitrate   uint32 `json:"x-google-min-bitrate,omitempty"`
	XGoogleMaxBitrate   uint32 `json:"x-google-max-bitrate,omitempty"`
	XGoogleStartBitrate uint32 `json:"x-google-start-bitrate,omitempty"`
}

*

  • RtpCodecSpecificParameters the Codec-specific parameters available for signaling. Some parameters (such
  • as 'packetization-mode' and 'profile-level-id' in H264 or 'profile-id' in
  • VP9) are critical for codec matching.

type RtpEncodingParameters

type RtpEncodingParameters struct {
	/**
	 * The media SSRC.
	 */
	Ssrc uint32 `json:"ssrc,omitempty"`

	/**
	 * The RID RTP extension value. Must be unique.
	 */
	Rid string `json:"rid,omitempty"`

	/**
	 * Codec payload type this encoding affects. If unset, first media codec is
	 * chosen.
	 */
	CodecPayloadType byte `json:"codecPayloadType,omitempty"`

	/**
	 * RTX stream information. It must contain a numeric ssrc field indicating
	 * the RTX SSRC.
	 */
	Rtx *RtpEncodingRtx `json:"rtx,omitempty"`

	/**
	 * It indicates whether discontinuous RTP transmission will be used. Useful
	 * for audio (if the codec supports it) and for video screen sharing (when
	 * static content is being transmitted, this option disables the RTP
	 * inactivity checks in mediasoup). Default false.
	 */
	Dtx bool `json:"dtx,omitempty"`

	/**
	 * int of spatial and temporal layers in the RTP stream (e.g. 'L1T3').
	 * See webrtc-svc.
	 */
	ScalabilityMode string `json:"scalabilityMode,omitempty"`

	/**
	 * Others.
	 */
	ScaleResolutionDownBy int `json:"scaleResolutionDownBy,omitempty"`
	MaxBitrate            int `json:"maxBitrate,omitempty"`
}

*

  • Provides information relating to an encoding, which represents a media RTP
  • stream and its associated RTX stream (if any).

type RtpEncodingRtx

type RtpEncodingRtx struct {
	Ssrc uint32 `json:"ssrc"`
}

RtpEncodingRtx represents the associated RTX stream for RTP stream.

type RtpHeaderExtension

type RtpHeaderExtension struct {
	/**
	 * Media kind. If empty string, it's valid for all kinds.
	 * Default any media kind.
	 */
	Kind MediaKind `json:"kind"`

	/*
	 * The URI of the RTP header extension, as defined in RFC 5285.
	 */
	Uri string `json:"uri"`

	/**
	 * The preferred numeric identifier that goes in the RTP packet. Must be
	 * unique.
	 */
	PreferredId int `json:"preferredId"`

	/**
	 * If true, it is preferred that the value in the header be encrypted as per
	 * RFC 6904. Default false.
	 */
	PreferredEncrypt bool `json:"preferredEncrypt,omitempty"`

	/**
	 * If 'sendrecv', mediasoup supports sending and receiving this RTP extension.
	 * 'sendonly' means that mediasoup can send (but not receive) it. 'recvonly'
	 * means that mediasoup can receive (but not send) it.
	 */
	Direction RtpHeaderExtensionDirection `json:"direction,omitempty"`
}

*

  • Provides information relating to supported header extensions. The list of
  • RTP header extensions supported by mediasoup is defined in the
  • supportedRtpCapabilities.ts file. *
  • mediasoup does not currently support encrypted RTP header extensions. The
  • direction field is just present in mediasoup RTP capabilities (retrieved via
  • router.rtpCapabilities or mediasoup.getSupportedRtpCapabilities()). It's
  • ignored if present in endpoints' RTP capabilities.

type RtpHeaderExtensionDirection

type RtpHeaderExtensionDirection string

*

  • Direction of RTP header extension.

type RtpHeaderExtensionParameters

type RtpHeaderExtensionParameters struct {
	/**
	 * The URI of the RTP header extension, as defined in RFC 5285.
	 */
	Uri string `json:"uri"`

	/**
	 * The numeric identifier that goes in the RTP packet. Must be unique.
	 */
	Id int `json:"id"`

	/**
	 * If true, the value in the header is encrypted as per RFC 6904. Default false.
	 */
	Encrypt bool `json:"encrypt,omitempty"`

	/**
	 * Configuration parameters for the header extension.
	 */
	Parameters *RtpCodecSpecificParameters `json:"parameters,omitempty"`
}

*

  • Defines a RTP header extension within the RTP parameters. The list of RTP
  • header extensions supported by mediasoup is defined in the
  • supportedRtpCapabilities.ts file. *
  • mediasoup does not currently support encrypted RTP header extensions and no
  • parameters are currently considered.

type RtpListener

type RtpListener struct {
	SsrcTable map[string]string `json:"ssrcTable,omitempty"`
	MidTable  map[string]string `json:"midTable,omitempty"`
	RidTable  map[string]string `json:"ridTable,omitempty"`
}

type RtpMapping

type RtpMapping struct {
	Codecs    []RtpMappingCodec    `json:"codecs,omitempty"`
	Encodings []RtpMappingEncoding `json:"encodings,omitempty"`
}

type RtpMappingCodec

type RtpMappingCodec struct {
	PayloadType       byte `json:"payloadType"`
	MappedPayloadType byte `json:"mappedPayloadType"`
}

type RtpMappingEncoding

type RtpMappingEncoding struct {
	Ssrc            uint32 `json:"ssrc,omitempty"`
	Rid             string `json:"rid,omitempty"`
	ScalabilityMode string `json:"scalabilityMode,omitempty"`
	MappedSsrc      uint32 `json:"mappedSsrc"`
}

type RtpObserver

type RtpObserver struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • RtpObserver
  • @interface
  • @emits routerclose
  • @emits @close

func (*RtpObserver) AddProducer

func (o *RtpObserver) AddProducer(producerId string)

*

  • Add a Producer to the RtpObserver.

func (*RtpObserver) AppData

func (o *RtpObserver) AppData() interface{}

*

  • App custom data.

func (*RtpObserver) Close

func (o *RtpObserver) Close()

*

  • Close the RtpObserver.

func (*RtpObserver) Closed

func (o *RtpObserver) Closed() bool

*

  • Whether the RtpObserver is closed.

func (*RtpObserver) Id

func (o *RtpObserver) Id() string

*

  • RtpObserver id.

func (*RtpObserver) Observer

func (o *RtpObserver) Observer() IEventEmitter

*

  • Observer. *
  • @emits close
  • @emits pause
  • @emits resume
  • @emits addproducer - (producer: Producer)
  • @emits removeproducer - (producer: Producer)

func (*RtpObserver) Pause

func (o *RtpObserver) Pause()

*

  • Pause the RtpObserver.

func (*RtpObserver) Paused

func (o *RtpObserver) Paused() bool

*

  • Whether the RtpObserver is paused.

func (*RtpObserver) RemoveProducer

func (o *RtpObserver) RemoveProducer(producerId string)

*

  • Remove a Producer from the RtpObserver.

func (*RtpObserver) Resume

func (o *RtpObserver) Resume()

*

  • Resume the RtpObserver.

type RtpParameters

type RtpParameters struct {
	/**
	 * The MID RTP extension value as defined in the BUNDLE specification.
	 */
	Mid string `json:"mid,omitempty"`

	/**
	 * Media and RTX codecs in use.
	 */
	Codecs []*RtpCodecParameters `json:"codecs"`

	/**
	 * RTP header extensions in use.
	 */
	HeaderExtensions []RtpHeaderExtensionParameters `json:"headerExtensions,omitempty"`

	/**
	 * Transmitted RTP streams and their settings.
	 */
	Encodings []RtpEncodingParameters `json:"encodings,omitempty"`

	/**
	 * Parameters used for RTCP.
	 */
	Rtcp RtcpParameters `json:"rtcp,omitempty"`
}

*

  • The RTP send parameters describe a media stream received by mediasoup from
  • an endpoint through its corresponding mediasoup Producer. These parameters
  • may include a mid value that the mediasoup transport will use to match
  • received RTP packets based on their MID RTP extension value. *
  • mediasoup allows RTP send parameters with a single encoding and with multiple
  • encodings (simulcast). In the latter case, each entry in the encodings array
  • must include a ssrc field or a rid field (the RID RTP extension value). Check
  • the Simulcast and SVC sections for more information. *
  • The RTP receive parameters describe a media stream as sent by mediasoup to
  • an endpoint through its corresponding mediasoup Consumer. The mid value is
  • unset (mediasoup does not include the MID RTP extension into RTP packets
  • being sent to endpoints). *
  • There is a single entry in the encodings array (even if the corresponding
  • producer uses simulcast). The consumer sends a single and continuous RTP
  • stream to the endpoint and spatial/temporal layer selection is possible via
  • consumer.setPreferredLayers(). *
  • As an exception, previous bullet is not true when consuming a stream over a
  • PipeTransport, in which all RTP streams from the associated producer are
  • forwarded verbatim through the consumer. *
  • The RTP receive parameters will always have their ssrc values randomly
  • generated for all of its encodings (and optional rtx { ssrc XXXX } if the
  • endpoint supports RTX), regardless of the original RTP send parameters in
  • the associated producer. This applies even if the producer's encodings have
  • rid set.

type RtpStream

type RtpStream struct {
	Params    RtpStreamParams `json:"params,omitempty"`
	Score     uint8           `json:"score,omitempty"`
	RtxStream *RtpStream      `json:"rtxStream,omitempty"`
}

type RtpStreamParams

type RtpStreamParams struct {
	EncodingIdx    int    `json:"encodingIdx,omitempty"`
	Ssrc           uint32 `json:"ssrc,omitempty"`
	PayloadType    uint8  `json:"payloadType,omitempty"`
	MimeType       string `json:"mimeType,omitempty"`
	ClockRate      uint32 `json:"clockRate,omitempty"`
	Rid            string `json:"rid,omitempty"`
	RRid           string `json:"rrid,omitempty"`
	Cname          string `json:"cname,omitempty"`
	RtxSsrc        uint32 `json:"rtxSsrc,omitempty"`
	RtxPayloadType uint8  `json:"rtxPayloadType,omitempty"`
	UseNack        bool   `json:"useNack,omitempty"`
	UsePli         bool   `json:"usePli,omitempty"`
	UseFir         bool   `json:"useFir,omitempty"`
	UseInBandFec   bool   `json:"useInBandFec,omitempty"`
	UseDtx         bool   `json:"useDtx,omitempty"`
	SpatialLayers  uint8  `json:"spatialLayers,omitempty"`
	TemporalLayers uint8  `json:"temporalLayers,omitempty"`
}

type ScalabilityMode

type ScalabilityMode struct {
	SpatialLayers  uint8 `json:"spatialLayers"`
	TemporalLayers uint8 `json:"temporalLayers"`
	Ksvc           bool  `json:"ksvc"`
}

func ParseScalabilityMode

func ParseScalabilityMode(scalabilityMode string) ScalabilityMode

type SctpCapabilities

type SctpCapabilities struct {
	NumStreams NumSctpStreams `json:"numStreams"`
}

type SctpListener

type SctpListener struct {
	StreamIdTable map[string]string `json:"streamIdTable,omitempty"`
}

type SctpParameters

type SctpParameters struct {
	/**
	 * Must always equal 5000.
	 */
	Port uint16 `json:"port"`

	/**
	 * Initially requested int of outgoing SCTP streams.
	 */
	OS uint16 `json:"os"`

	/**
	 * Maximum int of incoming SCTP streams.
	 */
	MIS uint16 `json:"mis"`

	/**
	 * Maximum allowed size for SCTP messages.
	 */
	MaxMessageSize uint32 `json:"maxMessageSize"`

	/**
	 * Set by worker.
	 */
	IsDataChannel      bool `json:"isDataChannel,omitempty"`
	SctpBufferedAmount int  `json:"sctpBufferedAmount,omitempty"`
	SendBufferSize     int  `json:"sendBufferSize,omitempty"`
}

type SctpState

type SctpState string

type SctpStreamParameters

type SctpStreamParameters struct {
	/**
	 * SCTP stream id.
	 */
	StreamId uint16 `json:"streamId"`

	/**
	 * Whether data messages must be received in order. If true the messages will
	 * be sent reliably. Default true.
	 */
	Ordered *bool `json:"ordered,omitempty"`

	/**
	 * When ordered is false indicates the time (in milliseconds) after which a
	 * SCTP packet will stop being retransmitted.
	 */
	MaxPacketLifeTime uint16 `json:"maxPacketLifeTime,omitempty"`

	/**
	 * When ordered is false indicates the maximum number of times a packet will
	 * be retransmitted.
	 */
	MaxRetransmits uint16 `json:"maxRetransmits,omitempty"`
}

*

  • SCTP stream parameters describe the reliability of a certain SCTP stream.
  • If ordered is true then maxPacketLifeTime and maxRetransmits must be
  • false.
  • If ordered if false, only one of maxPacketLifeTime or maxRetransmits
  • can be true.

type SimulcastConsumerDump

type SimulcastConsumerDump struct {
	PreferredSpatialLayer  int16 `json:"preferredSpatialLayer,omitempty"`
	TargetSpatialLayer     int16 `json:"targetSpatialLayer,omitempty"`
	CurrentSpatialLayer    int16 `json:"currentSpatialLayer,omitempty"`
	PreferredTemporalLayer int16 `json:"preferredTemporalLayer,omitempty"`
	TargetTemporalLayer    int16 `json:"targetTemporalLayer,omitempty"`
	CurrentTemporalLayer   int16 `json:"currentTemporalLayer,omitempty"`
}

type SrtpCryptoSuite

type SrtpCryptoSuite string

*

  • SRTP crypto suite.
const (
	AES_CM_128_HMAC_SHA1_80 SrtpCryptoSuite = "AES_CM_128_HMAC_SHA1_80"
	AES_CM_128_HMAC_SHA1_32                 = "AES_CM_128_HMAC_SHA1_32"
)

type SrtpParameters

type SrtpParameters struct {
	/**
	 * Encryption and authentication transforms to be used.
	 */
	CryptoSuite SrtpCryptoSuite `json:"cryptoSuite"`

	/**
	 * SRTP keying material (master key and salt) in Base64.
	 */
	KeyBase64 string `json:"keyBase64"`
}

*

  • SRTP parameters.

type Transport

type Transport struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • Transport
  • @emits routerclose
  • @emits @close
  • @emits @newproducer - (producer: Producer)
  • @emits @producerclose - (producer: Producer)
  • @emits @newdataproducer - (dataProducer: DataProducer)
  • @emits @dataproducerclose - (dataProducer: DataProducer)

func (*Transport) AppData

func (transport *Transport) AppData() interface{}

App custom data.

func (*Transport) Close

func (transport *Transport) Close()

Close the Transport.

func (*Transport) Closed

func (transport *Transport) Closed() bool

Whether the Transport is closed.

func (*Transport) Connect

func (transport *Transport) Connect(TransportConnectOptions) error

*

  • Provide the Transport remote parameters.

func (*Transport) Consume

func (transport *Transport) Consume(options ConsumerOptions) (consumer *Consumer, err error)

*

  • Create a Consumer.

func (*Transport) ConsumeData

func (transport *Transport) ConsumeData(options DataConsumerOptions) (dataConsumer *DataConsumer, err error)

*

  • Create a DataConsumer.

func (*Transport) Dump

func (transport *Transport) Dump() (data *TransportDump, err error)

Dump Transport.

func (*Transport) EnableTraceEvent

func (transport *Transport) EnableTraceEvent(types ...TransportTraceEventType) error

*

  • Enable 'trace' event.

func (*Transport) GetStats

func (transport *Transport) GetStats() (stat []*TransportStat, err error)

Get Transport stats.

func (*Transport) Id

func (transport *Transport) Id() string

Transport id

func (*Transport) Observer

func (transport *Transport) Observer() IEventEmitter

*

  • Observer. *
  • @emits close
  • @emits newproducer - (producer: Producer)
  • @emits newconsumer - (producer: Producer)
  • @emits newdataproducer - (dataProducer: DataProducer)
  • @emits newdataconsumer - (dataProducer: DataProducer)

func (*Transport) Produce

func (transport *Transport) Produce(options ProducerOptions) (producer *Producer, err error)

*

  • Create a Producer.

func (*Transport) ProduceData

func (transport *Transport) ProduceData(options DataProducerOptions) (dataProducer *DataProducer, err error)

*

  • Create a DataProducer.

func (*Transport) SetMaxIncomingBitrate

func (transport *Transport) SetMaxIncomingBitrate(bitrate int) error

*

  • Set maximum incoming bitrate for receiving media.

type TransportConnectOptions

type TransportConnectOptions struct {
	// pipe and plain transport
	Ip             string          `json:"ip,omitempty"`
	Port           uint16          `json:"port,omitempty"`
	SrtpParameters *SrtpParameters `json:"srtpParameters,omitempty"`

	// plain transport
	RtcpPort uint16 `json:"rtcpPort,omitempty"`

	// webrtc transport
	DtlsParameters *DtlsParameters `json:"dtlsParameters,omitempty"`
}

type TransportDump

type TransportDump struct {
	Id                      string                   `json:"id,omitempty"`
	Direct                  bool                     `json:"direct,omitempty"`
	ProducerIds             []string                 `json:"producerIds,omitempty"`
	ConsumerIds             []string                 `json:"consumerIds,omitempty"`
	MapSsrcConsumerId       map[string]string        `json:"mapSsrcConsumerId,omitempty"`
	MapRtxSsrcConsumerId    map[string]string        `json:"mapRtxSsrcConsumerId,omitempty"`
	DataProducerIds         []string                 `json:"dataProducerIds,omitempty"`
	DataConsumerIds         []string                 `json:"dataConsumerIds,omitempty"`
	RecvRtpHeaderExtensions *RecvRtpHeaderExtensions `json:"recvRtpHeaderExtensions,omitempty"`
	RtpListener             *RtpListener             `json:"rtpListener,omitempty"`
	SctpParameters          SctpParameters           `json:"SctpParameters,omitempty"`
	SctpState               SctpState                `json:"sctpState,omitempty"`
	SctpListener            *SctpListener            `json:"sctpListener,omitempty"`
	TraceEventTypes         string                   `json:"traceEventTypes,omitempty"`

	// plain transport
	*PlainTransportDump

	// webrtc transport
	*WebRtcTransportDump
}

type TransportListenIp

type TransportListenIp struct {
	/**
	 * Listening IPv4 or IPv6.
	 */
	Ip string `json:"ip,omitempty"`

	/**
	 * Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with
	 * private IP).
	 */
	AnnouncedIp string `json:"announcedIp,omitempty"`
}

type TransportProtocol

type TransportProtocol string

*

  • Transport protocol.
const (
	TransportProtocol_Udp TransportProtocol = "udp"
	TransportProtocol_Tcp                   = "tcp"
)

type TransportStat

type TransportStat struct {
	// Common to all Transports.
	Type                     string    `json:"type"`
	TransportId              string    `json:"transportId"`
	Timestamp                int64     `json:"timestamp"`
	SctpState                SctpState `json:"sctpState,omitempty"`
	BytesReceived            int64     `json:"bytesReceived"`
	RecvBitrate              int64     `json:"recvBitrate"`
	BytesSent                int64     `json:"bytesSent"`
	SendBitrate              int64     `json:"sendBitrate"`
	RtpBytesReceived         int64     `json:"rtpBytesReceived"`
	RtpRecvBitrate           int64     `json:"rtpRecvBitrate"`
	RtpBytesSent             int64     `json:"rtpBytesSent"`
	RtpSendBitrate           int64     `json:"rtpSendBitrate"`
	RtxBytesReceived         int64     `json:"rtxBytesReceived"`
	RtxRecvBitrate           int64     `json:"rtxRecvBitrate"`
	RtxBytesSent             int64     `json:"rtxBytesSent"`
	RtxSendBitrate           int64     `json:"rtxSendBitrate"`
	ProbationBytesSent       int64     `json:"probationBytesSent"`
	ProbationSendBitrate     int64     `json:"probationSendBitrate"`
	AvailableOutgoingBitrate int64     `json:"availableOutgoingBitrate,omitempty"`
	AvailableIncomingBitrate int64     `json:"availableIncomingBitrate,omitempty"`
	MaxIncomingBitrate       int64     `json:"maxIncomingBitrate,omitempty"`

	*WebRtcTransportSpecificStat
	*PlainTransportSpecificStat // share tuple with pipe transport stat
}

type TransportTraceEventData

type TransportTraceEventData struct {
	/**
	 * Trace type.
	 */
	Type TransportTraceEventType `json:"type,omitempty"`
	/**
	 * Event timestamp.
	 */
	Timestamp int64 `json:"timestamp,omitempty"`
	/**
	 * Event direction.
	 */
	Direction string `json:"direction,omitempty"`
	/**
	 * Per type information.
	 */
	Info interface{} `json:"info,omitempty"`
}

type TransportTraceEventType

type TransportTraceEventType string
const (
	TransportTraceEventType_Probation TransportTraceEventType = "probation"
	TransportTraceEventType_Bwe                               = "bwe"
)

type TransportTuple

type TransportTuple struct {
	LocalIp    string `json:"localIp,omitempty"`
	LocalPort  uint16 `json:"localPort,omitempty"`
	RemoteIp   string `json:"remoteIp,omitempty"`
	RemotePort uint16 `json:"remotePort,omitempty"`
	Protocol   string `json:"protocol,omitempty"`
}

type TransportType

type TransportType string

type TypeError

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

func (TypeError) Error

func (e TypeError) Error() string

type UnsupportedError

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

UnsupportedError indicating not support for something.

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

type WebRtcTransport

type WebRtcTransport struct {
	ITransport
	// contains filtered or unexported fields
}

*

  • WebRtcTransport
  • @emits icestatechange - (iceState: IceState)
  • @emits iceselectedtuplechange - (iceSelectedTuple: TransportTuple)
  • @emits dtlsstatechange - (dtlsState: DtlsState)
  • @emits sctpstatechange - (sctpState: SctpState)
  • @emits trace - (trace: TransportTraceEventData)

func (*WebRtcTransport) Close

func (transport *WebRtcTransport) Close()

*

  • Close the WebRtcTransport. *
  • @override

func (*WebRtcTransport) Connect

func (transport *WebRtcTransport) Connect(options TransportConnectOptions) (err error)

*

  • Provide the PlainTransport remote parameters. *
  • @override

func (WebRtcTransport) DtlsParameters

func (t WebRtcTransport) DtlsParameters() DtlsParameters

*

  • DTLS parameters.

func (WebRtcTransport) DtlsRemoteCert

func (t WebRtcTransport) DtlsRemoteCert() string

*

  • Remote certificate in PEM format.

func (WebRtcTransport) DtlsState

func (t WebRtcTransport) DtlsState() DtlsState

*

  • DTLS state.

func (WebRtcTransport) IceCandidates

func (t WebRtcTransport) IceCandidates() []IceCandidate

*

  • ICE candidates.

func (WebRtcTransport) IceParameters

func (t WebRtcTransport) IceParameters() IceParameters

*

  • ICE parameters.

func (WebRtcTransport) IceRole

func (t WebRtcTransport) IceRole() string

*

  • ICE role.

func (WebRtcTransport) IceSelectedTuple

func (t WebRtcTransport) IceSelectedTuple() *TransportTuple

*

  • ICE selected tuple.

func (WebRtcTransport) IceState

func (t WebRtcTransport) IceState() IceState

*

  • ICE state.

func (*WebRtcTransport) Observer

func (transport *WebRtcTransport) Observer() IEventEmitter

*

  • Observer. *
  • @override
  • @emits close
  • @emits newproducer - (producer: Producer)
  • @emits newconsumer - (consumer: Consumer)
  • @emits newdataproducer - (dataProducer: DataProducer)
  • @emits newdataconsumer - (dataConsumer: DataConsumer)
  • @emits icestatechange - (iceState: IceState)
  • @emits iceselectedtuplechange - (iceSelectedTuple: TransportTuple)
  • @emits dtlsstatechange - (dtlsState: DtlsState)
  • @emits sctpstatechange - (sctpState: SctpState)
  • @emits trace - (trace: TransportTraceEventData)

func (*WebRtcTransport) RestartIce

func (transport *WebRtcTransport) RestartIce() (iceParameters IceParameters, err error)

*

  • Restart ICE.

func (WebRtcTransport) SctpParameters

func (t WebRtcTransport) SctpParameters() SctpParameters

*

  • SCTP parameters.

func (WebRtcTransport) SctpState

func (t WebRtcTransport) SctpState() SctpState

*

  • SRTP parameters.

type WebRtcTransportDump

type WebRtcTransportDump struct {
	IceRole          string          `json:"iceRole,omitempty"`
	IceParameters    IceParameters   `json:"iceParameters,omitempty"`
	IceCandidates    []IceCandidate  `json:"iceCandidates,omitempty"`
	IceState         IceState        `json:"iceState,omitempty"`
	IceSelectedTuple *TransportTuple `json:"iceSelectedTuple,omitempty"`
	DtlsParameters   DtlsParameters  `json:"dtlsParameters,omitempty"`
	DtlsState        DtlsState       `json:"dtlsState,omitempty"`
	DtlsRemoteCert   string          `json:"dtlsRemoteCert,omitempty"`
}

type WebRtcTransportOptions

type WebRtcTransportOptions struct {
	/**
	 * Listening IP address or addresses in order of preference (first one is the
	 * preferred one).
	 */
	ListenIps []TransportListenIp `json:"listenIps,omitempty"`

	/**
	 * Listen in UDP. Default true.
	 */
	EnableUdp *bool `json:"enableUdp,omitempty"`

	/**
	 * Listen in TCP. Default false.
	 */
	EnableTcp bool `json:"enableTcp,omitempty"`

	/**
	 * Prefer UDP. Default false.
	 */
	PreferUdp bool `json:"preferUdp,omitempty"`

	/**
	 * Prefer TCP. Default false.
	 */
	PreferTcp bool `json:"preferTcp,omitempty"`

	/**
	 * Initial available outgoing bitrate (in bps). Default 600000.
	 */
	InitialAvailableOutgoingBitrate uint32 `json:"initialAvailableOutgoingBitrate,omitempty"`

	/**
	 * Create a SCTP association. Default false.
	 */
	EnableSctp bool `json:"enableSctp,omitempty"`

	/**
	 * SCTP streams uint32.
	 */
	NumSctpStreams NumSctpStreams `json:"numSctpStreams,omitempty"`

	/**
	 * Maximum allowed size for SCTP messages sent by DataProducers.
	 * Default 262144.
	 */
	MaxSctpMessageSize int `json:"maxSctpMessageSize,omitempty"`

	/**
	 * Maximum SCTP send buffer used by DataConsumers.
	 * Default 262144.
	 */
	SctpSendBufferSize int `json:"sctpSendBufferSize,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`
}

type WebRtcTransportSpecificStat

type WebRtcTransportSpecificStat struct {
	IceRole          string          `json:"iceRole"`
	IceState         IceState        `json:"iceState"`
	DtlsState        DtlsRole        `json:"dtlsState"`
	IceSelectedTuple *TransportTuple `json:"iceSelectedTuple,omitempty"`
}

type Worker

type Worker struct {
	IEventEmitter
	// contains filtered or unexported fields
}

*

  • Worker
  • @emits died - (error: Error)
  • @emits @success
  • @emits @failure - (error: Error)

func NewWorker

func NewWorker(options ...Option) (worker *Worker, err error)

func (*Worker) AppData

func (w *Worker) AppData() interface{}

*

  • App custom data.

func (*Worker) Close

func (w *Worker) Close()

*

  • Close the Worker.

func (*Worker) Closed

func (w *Worker) Closed() bool

*

  • Whether the Worker is closed.

func (*Worker) CreateRouter

func (w *Worker) CreateRouter(options RouterOptions) (router *Router, err error)

CreateRouter creates a router.

func (*Worker) Dump

func (w *Worker) Dump() (dump WorkerDump, err error)

Dump Worker.

func (*Worker) GetResourceUsage

func (w *Worker) GetResourceUsage() (usage WorkerResourceUsage, err error)

*

  • Get mediasoup-worker process resource usage.

func (*Worker) Observer

func (w *Worker) Observer() IEventEmitter

Observer

func (*Worker) Pid

func (w *Worker) Pid() int

*

  • Worker process identifier (PID).

func (*Worker) UpdateSettings

func (w *Worker) UpdateSettings(settings WorkerUpdateableSettings) error

UpdateSettings Update settings.

type WorkerDump

type WorkerDump struct {
	Pid       int      `json:"pid,omitempty"`
	RouterIds []string `json:"routerIds,omitempty"`
}

type WorkerLogLevel

type WorkerLogLevel string

type WorkerLogTag

type WorkerLogTag string

type WorkerResourceUsage

type WorkerResourceUsage struct {
	/**
	 * User CPU time used (in ms).
	 */
	RU_Utime int64 `json:"ru_utime"`

	/**
	 * System CPU time used (in ms).
	 */
	RU_Stime int64 `json:"ru_stime"`

	/**
	 * Maximum resident set size.
	 */
	RU_Maxrss int64 `json:"ru_maxrss"`

	/**
	 * Integral shared memory size.
	 */
	RU_Ixrss int64 `json:"ru_ixrss"`

	/**
	 * Integral unshared data size.
	 */
	RU_Idrss int64 `json:"ru_idrss"`

	/**
	 * Integral unshared stack size.
	 */
	RU_Isrss int64 `json:"ru_isrss"`

	/**
	 * Page reclaims (soft page faults).
	 */
	RU_Minflt int64 `json:"ru_minflt"`

	/**
	 * Page faults (hard page faults).
	 */
	RU_Majflt int64 `json:"ru_majflt"`

	/**
	 * Swaps.
	 */
	RU_Nswap int64 `json:"ru_nswap"`

	/**
	 * Block input operations.
	 */
	RU_Inblock int64 `json:"ru_inblock"`

	/**
	 * Block output operations.
	 */
	RU_Oublock int64 `json:"ru_oublock"`

	/**
	 * IPC messages sent.
	 */
	RU_Msgsnd int64 `json:"ru_msgsnd"`

	/**
	 * IPC messages received.
	 */
	RU_Msgrcv int64 `json:"ru_msgrcv"`

	/**
	 * Signals received.
	 */
	RU_Nsignals int64 `json:"ru_nsignals"`

	/**
	 * Voluntary context switches.
	 */
	RU_Nvcsw int64 `json:"ru_nvcsw"`

	/**
	 * Involuntary context switches.
	 */
	RU_Nivcsw int64 `json:"ru_nivcsw"`
}

*

  • An object with the fields of the uv_rusage_t struct. *
  • - http//docs.libuv.org/en/v1.x/misc.html#c.uv_rusage_t
  • - https//linux.die.net/man/2/getrusage

type WorkerSettings

type WorkerSettings struct {
	/**
	 * Logging level for logs generated by the media worker subprocesses (check
	 * the Debugging documentation). Valid values are 'debug', 'warn', 'error' and
	 * 'none'. Default 'error'.
	 */
	LogLevel WorkerLogLevel `json:"logLevel,omitempty"`

	/**
	 * Log tags for debugging. Check the meaning of each available tag in the
	 * Debugging documentation.
	 */
	LogTags []WorkerLogTag `json:"logTags,omitempty"`

	/**
	 * Minimun RTC port for ICE, DTLS, RTP, etc. Default 10000.
	 */
	RtcMinPort uint16 `json:"rtcMinPort,omitempty"`

	/**
	 * Maximum RTC port for ICE, DTLS, RTP, etc. Default 59999.
	 */
	RtcMaxPort uint16 `json:"rtcMaxPort,omitempty"`

	/**
	 * Path to the DTLS public certificate file in PEM format. If unset, a
	 * certificate is dynamically created.
	 */
	DtlsCertificateFile string `json:"dtlsCertificateFile,omitempty"`

	/**
	 * Path to the DTLS certificate private key file in PEM format. If unset, a
	 * certificate is dynamically created.
	 */
	DtlsPrivateKeyFile string `json:"dtlsPrivateKeyFile,omitempty"`

	/**
	 * Custom application data.
	 */
	AppData interface{} `json:"appData,omitempty"`

	/**
	 * Custom options.
	 */
	CustomOptions map[string]interface{}
}

func (WorkerSettings) Args

func (w WorkerSettings) Args() []string

func (WorkerSettings) Option

func (w WorkerSettings) Option() Option

type WorkerUpdateableSettings

type WorkerUpdateableSettings struct {
	/**
	 * Logging level for logs generated by the media worker subprocesses (check
	 * the Debugging documentation). Valid values are 'debug', 'warn', 'error' and
	 * 'none'. Default 'error'.
	 */
	LogLevel WorkerLogLevel `json:"logLevel,omitempty"`

	/**
	 * Log tags for debugging. Check the meaning of each available tag in the
	 * Debugging documentation.
	 */
	LogTags []WorkerLogTag `json:"logTags,omitempty"`
}

Directories

Path Synopsis
examples
app

Jump to

Keyboard shortcuts

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