webrtc

package module
v3.0.0-...-ad2a461 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 39 Imported by: 1

README

Pion WebRTC
Pion WebRTC

A pure Go implementation of the WebRTC API

Pion webrtc Sourcegraph Widget Slack Widget Twitter Widget
Build Status PkgGoDev Coverage Status Go Report Card Codacy Badge


Breaking Changes

Pion WebRTC v3.0.0 has started! See the release notes to learn about new features and breaking changes.

Until v3.0.0 has been tagged using v2 is suggested. The last v2 release is v2.2.17

Go Modules are mandatory for using Pion WebRTC. So make sure you set export GO111MODULE=on, and explicitly specify /v2 or /v3 when importing.

We are actively planning and would love your feedback! Please create GitHub issues or join the Slack channel to follow development and speak with the maintainers.


Pion WebRTC is a pure Go implementation of WebRTC. It has zero non-Go dependencies and no 3rd party Go dependencies. It is designed to follow WebRTC API, but may deviate when required. See DESIGN.md for the guiding principals/inspirations of the project.

Usage

example applications contains code samples of common things people build with Pion WebRTC.

example-webrtc-applications contains more full featured examples that use 3rd party libraries.

awesome-pion contains projects that have used Pion, and serve as real world examples of usage.

GoDoc is an auto generated API reference. All our Public APIs are commented.

FAQ has answers to common questions. If you have a question not covered please ask in Slack we are always looking to expand it.

Now go build something awesome! Here are some ideas to get your creative juices flowing:

  • Send a video file to multiple browser in real time for perfectly synchronized movie watching.
  • Send a webcam on an embedded device to your browser with no additional server required!
  • Securely send data between two servers, without using pub/sub.
  • Record your webcam and do special effects server side.
  • Build a conferencing application that processes audio/video and make decisions off of it.

WebAssembly

Pion WebRTC can be used when compiled to WebAssembly, also known as WASM. In this case the library will act as a wrapper around the JavaScript WebRTC API. This allows you to use WebRTC from Go in both server and browser side code with little to no changes. Check out the example applications for instructions on how to compile and run the WebAssembly examples. You can also visit the Wiki page on WebAssembly Development for more information.

Roadmap

The library is in active development, please refer to the roadmap to track our major milestones. We also maintain a list of Big Ideas these are things we want to build but don't have a clear plan or the resources yet. If you are looking to get involved this is a great place to get started! We would also love to hear your ideas! Even if you can't implement it yourself, it could inspire others.

Community

Pion has an active community on the Slack.

Follow the Pion Twitter for project updates and important WebRTC news.

We are always looking to support your projects. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at team@pion.ly

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible:

License

MIT License - see LICENSE for full text

Documentation

Overview

Package webrtc implements the WebRTC 1.0 as defined in W3C WebRTC specification document.

Index

Constants

View Source
const (
	// ICETransportStateNew indicates the ICETransport is waiting
	// for remote candidates to be supplied.
	ICETransportStateNew = iota + 1

	// ICETransportStateChecking indicates the ICETransport has
	// received at least one remote candidate, and a local and remote
	// ICECandidateComplete dictionary was not added as the last candidate.
	ICETransportStateChecking

	// ICETransportStateConnected indicates the ICETransport has
	// received a response to an outgoing connectivity check, or has
	// received incoming DTLS/media after a successful response to an
	// incoming connectivity check, but is still checking other candidate
	// pairs to see if there is a better connection.
	ICETransportStateConnected

	// ICETransportStateCompleted indicates the ICETransport tested
	// all appropriate candidate pairs and at least one functioning
	// candidate pair has been found.
	ICETransportStateCompleted

	// ICETransportStateFailed indicates the ICETransport the last
	// candidate was added and all appropriate candidate pairs have either
	// failed connectivity checks or have lost consent.
	ICETransportStateFailed

	// ICETransportStateDisconnected indicates the ICETransport has received
	// at least one local and remote candidate, but the final candidate was
	// received yet and all appropriate candidate pairs thus far have been
	// tested and failed.
	ICETransportStateDisconnected

	// ICETransportStateClosed indicates the ICETransport has shut down
	// and is no longer responding to STUN requests.
	ICETransportStateClosed
)
View Source
const (
	DefaultPayloadTypePCMU = 0
	DefaultPayloadTypePCMA = 8
	DefaultPayloadTypeG722 = 9
	DefaultPayloadTypeOpus = 111
	DefaultPayloadTypeVP8  = 96
	DefaultPayloadTypeVP9  = 98
	DefaultPayloadTypeH264 = 102
)

PayloadTypes for the default codecs

View Source
const (
	PCMU = "PCMU"
	PCMA = "PCMA"
	G722 = "G722"
	Opus = "opus"
	VP8  = "VP8"
	VP9  = "VP9"
	H264 = "H264"
)

Names for the default codecs supported by Pion WebRTC

View Source
const (
	//TypeRTCPFBTransportCC ..
	TypeRTCPFBTransportCC = "transport-cc"

	//TypeRTCPFBGoogREMB ..
	TypeRTCPFBGoogREMB = "goog-remb"

	//TypeRTCPFBACK ..
	TypeRTCPFBACK = "ack"

	//TypeRTCPFBCCM ..
	TypeRTCPFBCCM = "ccm"

	//TypeRTCPFBNACK ..
	TypeRTCPFBNACK = "nack"
)
View Source
const (
	SDPSectionGlobal = SDPSectionType("global")
	SDPSectionVideo  = SDPSectionType("video")
	SDPSectionAudio  = SDPSectionType("audio")
)

Common SDP sections

View Source
const (
	// Unknown defines default public constant to use for "enum" like struct
	// comparisons when no value was defined.
	Unknown = iota
)

Variables

View Source
var (
	// ErrUnknownType indicates an error with Unknown info.
	ErrUnknownType = errors.New("unknown")

	// ErrConnectionClosed indicates an operation executed after connection
	// has already been closed.
	ErrConnectionClosed = errors.New("connection closed")

	// ErrDataChannelNotOpen indicates an operation executed when the data
	// channel is not (yet) open.
	ErrDataChannelNotOpen = errors.New("data channel not open")

	// ErrCertificateExpired indicates that an x509 certificate has expired.
	ErrCertificateExpired = errors.New("x509Cert expired")

	// ErrNoTurnCredentials indicates that a TURN server URL was provided
	// without required credentials.
	ErrNoTurnCredentials = errors.New("turn server credentials required")

	// ErrTurnCredentials indicates that provided TURN credentials are partial
	// or malformed.
	ErrTurnCredentials = errors.New("invalid turn server credentials")

	// ErrExistingTrack indicates that a track already exists.
	ErrExistingTrack = errors.New("track already exists")

	// ErrPrivateKeyType indicates that a particular private key encryption
	// chosen to generate a certificate is not supported.
	ErrPrivateKeyType = errors.New("private key type not supported")

	// ErrModifyingPeerIdentity indicates that an attempt to modify
	// PeerIdentity was made after PeerConnection has been initialized.
	ErrModifyingPeerIdentity = errors.New("peerIdentity cannot be modified")

	// ErrModifyingCertificates indicates that an attempt to modify
	// Certificates was made after PeerConnection has been initialized.
	ErrModifyingCertificates = errors.New("certificates cannot be modified")

	// ErrModifyingBundlePolicy indicates that an attempt to modify
	// BundlePolicy was made after PeerConnection has been initialized.
	ErrModifyingBundlePolicy = errors.New("bundle policy cannot be modified")

	// ErrModifyingRTCPMuxPolicy indicates that an attempt to modify
	// RTCPMuxPolicy was made after PeerConnection has been initialized.
	ErrModifyingRTCPMuxPolicy = errors.New("rtcp mux policy cannot be modified")

	// ErrModifyingICECandidatePoolSize indicates that an attempt to modify
	// ICECandidatePoolSize was made after PeerConnection has been initialized.
	ErrModifyingICECandidatePoolSize = errors.New("ice candidate pool size cannot be modified")

	// ErrStringSizeLimit indicates that the character size limit of string is
	// exceeded. The limit is hardcoded to 65535 according to specifications.
	ErrStringSizeLimit = errors.New("data channel label exceeds size limit")

	// ErrMaxDataChannelID indicates that the maximum number ID that could be
	// specified for a data channel has been exceeded.
	ErrMaxDataChannelID = errors.New("maximum number ID for datachannel specified")

	// ErrNegotiatedWithoutID indicates that an attempt to create a data channel
	// was made while setting the negotiated option to true without providing
	// the negotiated channel ID.
	ErrNegotiatedWithoutID = errors.New("negotiated set without channel id")

	// ErrRetransmitsOrPacketLifeTime indicates that an attempt to create a data
	// channel was made with both options MaxPacketLifeTime and MaxRetransmits
	// set together. Such configuration is not supported by the specification
	// and is mutually exclusive.
	ErrRetransmitsOrPacketLifeTime = errors.New("both MaxPacketLifeTime and MaxRetransmits was set")

	// ErrCodecNotFound is returned when a codec search to the Media Engine fails
	ErrCodecNotFound = errors.New("codec not found")

	// ErrNoRemoteDescription indicates that an operation was rejected because
	// the remote description is not set
	ErrNoRemoteDescription = errors.New("remote description is not set")

	// ErrIncorrectSDPSemantics indicates that the PeerConnection was configured to
	// generate SDP Answers with different SDP Semantics than the received Offer
	ErrIncorrectSDPSemantics = errors.New("offer SDP semantics does not match configuration")

	// ErrProtocolTooLarge indicates that value given for a DataChannelInit protocol is
	//longer then 65535 bytes
	ErrProtocolTooLarge = errors.New("protocol is larger then 65535 bytes")

	// ErrSenderNotCreatedByConnection indicates RemoveTrack was called with a RtpSender not created
	// by this PeerConnection
	ErrSenderNotCreatedByConnection = errors.New("RtpSender not created by this PeerConnection")

	// ErrSessionDescriptionNoFingerprint indicates SetRemoteDescription was called with a SessionDescription that has no
	// fingerprint
	ErrSessionDescriptionNoFingerprint = errors.New("SetRemoteDescription called with no fingerprint")

	// ErrSessionDescriptionInvalidFingerprint indicates SetRemoteDescription was called with a SessionDescription that
	// has an invalid fingerprint
	ErrSessionDescriptionInvalidFingerprint = errors.New("SetRemoteDescription called with an invalid fingerprint")

	// ErrSessionDescriptionConflictingFingerprints indicates SetRemoteDescription was called with a SessionDescription that
	// has an conflicting fingerprints
	ErrSessionDescriptionConflictingFingerprints = errors.New("SetRemoteDescription called with multiple conflicting fingerprint")

	// ErrSessionDescriptionMissingIceUfrag indicates SetRemoteDescription was called with a SessionDescription that
	// is missing an ice-ufrag value
	ErrSessionDescriptionMissingIceUfrag = errors.New("SetRemoteDescription called with no ice-ufrag")

	// ErrSessionDescriptionMissingIcePwd indicates SetRemoteDescription was called with a SessionDescription that
	// is missing an ice-pwd value
	ErrSessionDescriptionMissingIcePwd = errors.New("SetRemoteDescription called with no ice-pwd")

	// ErrSessionDescriptionConflictingIceUfrag  indicates SetRemoteDescription was called with a SessionDescription that
	// contains multiple conflicting ice-ufrag values
	ErrSessionDescriptionConflictingIceUfrag = errors.New("SetRemoteDescription called with multiple conflicting ice-ufrag values")

	// ErrSessionDescriptionConflictingIcePwd indicates SetRemoteDescription was called with a SessionDescription that
	// contains multiple conflicting ice-pwd values
	ErrSessionDescriptionConflictingIcePwd = errors.New("SetRemoteDescription called with multiple conflicting ice-pwd values")

	// ErrNoSRTPProtectionProfile indicates that the DTLS handshake completed and no SRTP Protection Profile was chosen
	ErrNoSRTPProtectionProfile = errors.New("DTLS Handshake completed and no SRTP Protection Profile was chosen")
)

Functions

func GatheringCompletePromise

func GatheringCompletePromise(pc *PeerConnection) (gatherComplete <-chan struct{})

GatheringCompletePromise is a Pion specific helper function that returns a channel that is closed when gathering is complete. This function may be helpful in cases where you are unable to trickle your ICE Candidates.

It is better to not use this function, and instead trickle candidates. If you use this function you will see longer connection startup times. When the call is connected you will see no impact however.

func WithMediaEngine

func WithMediaEngine(m MediaEngine) func(a *API)

WithMediaEngine allows providing a MediaEngine to the API. Settings should not be changed after passing the engine to an API.

func WithSettingEngine

func WithSettingEngine(s SettingEngine) func(a *API)

WithSettingEngine allows providing a SettingEngine to the API. Settings should not be changed after passing the engine to an API.

Types

type API

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

API bundles the global funcions of the WebRTC and ORTC API. Some of these functions are also exported globally using the defaultAPI object. Note that the global version of the API may be phased out in the future.

func NewAPI

func NewAPI(options ...func(*API)) *API

NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects

func (*API) NewDTLSTransport

func (api *API) NewDTLSTransport(transport *ICETransport, certificates []Certificate) (*DTLSTransport, error)

NewDTLSTransport creates a new DTLSTransport. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.

func (*API) NewDataChannel

func (api *API) NewDataChannel(transport *SCTPTransport, params *DataChannelParameters) (*DataChannel, error)

NewDataChannel creates a new DataChannel. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.

func (*API) NewICEGatherer

func (api *API) NewICEGatherer(opts ICEGatherOptions) (*ICEGatherer, error)

NewICEGatherer creates a new NewICEGatherer. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.

func (*API) NewICETransport

func (api *API) NewICETransport(gatherer *ICEGatherer) *ICETransport

NewICETransport creates a new NewICETransport. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.

func (*API) NewPeerConnection

func (api *API) NewPeerConnection(configuration Configuration) (*PeerConnection, error)

NewPeerConnection creates a new PeerConnection with the provided configuration against the received API object

func (*API) NewRTPReceiver

func (api *API) NewRTPReceiver(kind RTPCodecType, transport *DTLSTransport) (*RTPReceiver, error)

NewRTPReceiver constructs a new RTPReceiver

func (*API) NewRTPSender

func (api *API) NewRTPSender(track *Track, transport *DTLSTransport) (*RTPSender, error)

NewRTPSender constructs a new RTPSender

func (*API) NewSCTPTransport

func (api *API) NewSCTPTransport(dtls *DTLSTransport) *SCTPTransport

NewSCTPTransport creates a new SCTPTransport. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.

type AnswerOptions

type AnswerOptions struct {
	OfferAnswerOptions
}

AnswerOptions structure describes the options used to control the answer creation process.

type AudioReceiverStats

type AudioReceiverStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// AudioLevel represents the output audio level of the track.
	//
	// The value is a value between 0..1 (linear), where 1.0 represents 0 dBov,
	// 0 represents silence, and 0.5 represents approximately 6 dBSPL change in
	// the sound pressure level from 0 dBov.
	//
	// If the track is sourced from an Receiver, does no audio processing, has a
	// constant level, and has a volume setting of 1.0, the audio level is expected
	// to be the same as the audio level of the source SSRC, while if the volume setting
	// is 0.5, the AudioLevel is expected to be half that value.
	//
	// For outgoing audio tracks, the AudioLevel is the level of the audio being sent.
	AudioLevel float64 `json:"audioLevel"`

	// TotalAudioEnergy is the total energy of all the audio samples sent/received
	// for this object, calculated by duration * Math.pow(energy/maxEnergy, 2) for
	// each audio sample seen.
	TotalAudioEnergy float64 `json:"totalAudioEnergy"`

	// VoiceActivityFlag represents whether the last RTP packet sent or played out
	// by this track contained voice activity or not based on the presence of the
	// V bit in the extension header, as defined in [RFC6464].
	//
	// This value indicates the voice activity in the latest RTP packet played out
	// from a given SSRC, and is defined in RTPSynchronizationSource.voiceActivityFlag.
	VoiceActivityFlag bool `json:"voiceActivityFlag"`

	// TotalSamplesDuration represents the total duration in seconds of all samples
	// that have sent or received (and thus counted by TotalSamplesSent or TotalSamplesReceived).
	// Can be used with TotalAudioEnergy to compute an average audio level over different intervals.
	TotalSamplesDuration float64 `json:"totalSamplesDuration"`

	// EstimatedPlayoutTimestamp is the estimated playout time of this receiver's
	// track. The playout time is the NTP timestamp of the last playable sample that
	// has a known timestamp (from an RTCP SR packet mapping RTP timestamps to NTP
	// timestamps), extrapolated with the time elapsed since it was ready to be played out.
	// This is the "current time" of the track in NTP clock time of the sender and
	// can be present even if there is no audio currently playing.
	//
	// This can be useful for estimating how much audio and video is out of
	// sync for two tracks from the same source:
	// 		AudioTrackStats.EstimatedPlayoutTimestamp - VideoTrackStats.EstimatedPlayoutTimestamp
	EstimatedPlayoutTimestamp StatsTimestamp `json:"estimatedPlayoutTimestamp"`

	// JitterBufferDelay is the sum of the time, in seconds, each sample takes from
	// the time it is received and to the time it exits the jitter buffer.
	// This increases upon samples exiting, having completed their time in the buffer
	// (incrementing JitterBufferEmittedCount). The average jitter buffer delay can
	// be calculated by dividing the JitterBufferDelay with the JitterBufferEmittedCount.
	JitterBufferDelay float64 `json:"jitterBufferDelay"`

	// JitterBufferEmittedCount is the total number of samples that have come out
	// of the jitter buffer (increasing JitterBufferDelay).
	JitterBufferEmittedCount uint64 `json:"jitterBufferEmittedCount"`

	// TotalSamplesReceived is the total number of samples that have been received
	// by this receiver. This includes ConcealedSamples.
	TotalSamplesReceived uint64 `json:"totalSamplesReceived"`

	// ConcealedSamples is the total number of samples that are concealed samples.
	// A concealed sample is a sample that is based on data that was synthesized
	// to conceal packet loss and does not represent incoming data.
	ConcealedSamples uint64 `json:"concealedSamples"`

	// ConcealmentEvents is the number of concealment events. This counter increases
	// every time a concealed sample is synthesized after a non-concealed sample.
	// That is, multiple consecutive concealed samples will increase the concealedSamples
	// count multiple times but is a single concealment event.
	ConcealmentEvents uint64 `json:"concealmentEvents"`
}

AudioReceiverStats contains audio metrics related to a specific receiver.

type AudioSenderStats

type AudioSenderStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// TrackIdentifier represents the id property of the track.
	TrackIdentifier string `json:"trackIdentifier"`

	// RemoteSource is true if the source is remote, for instance if it is sourced
	// from another host via a PeerConnection. False otherwise. Only applicable for 'track' stats.
	RemoteSource bool `json:"remoteSource"`

	// Ended reflects the "ended" state of the track.
	Ended bool `json:"ended"`

	// Kind is either "audio" or "video". This reflects the "kind" attribute of the MediaStreamTrack.
	Kind string `json:"kind"`

	// AudioLevel represents the output audio level of the track.
	//
	// The value is a value between 0..1 (linear), where 1.0 represents 0 dBov,
	// 0 represents silence, and 0.5 represents approximately 6 dBSPL change in
	// the sound pressure level from 0 dBov.
	//
	// If the track is sourced from an Receiver, does no audio processing, has a
	// constant level, and has a volume setting of 1.0, the audio level is expected
	// to be the same as the audio level of the source SSRC, while if the volume setting
	// is 0.5, the AudioLevel is expected to be half that value.
	//
	// For outgoing audio tracks, the AudioLevel is the level of the audio being sent.
	AudioLevel float64 `json:"audioLevel"`

	// TotalAudioEnergy is the total energy of all the audio samples sent/received
	// for this object, calculated by duration * Math.pow(energy/maxEnergy, 2) for
	// each audio sample seen.
	TotalAudioEnergy float64 `json:"totalAudioEnergy"`

	// VoiceActivityFlag represents whether the last RTP packet sent or played out
	// by this track contained voice activity or not based on the presence of the
	// V bit in the extension header, as defined in [RFC6464].
	//
	// This value indicates the voice activity in the latest RTP packet played out
	// from a given SSRC, and is defined in RTPSynchronizationSource.voiceActivityFlag.
	VoiceActivityFlag bool `json:"voiceActivityFlag"`

	// TotalSamplesDuration represents the total duration in seconds of all samples
	// that have sent or received (and thus counted by TotalSamplesSent or TotalSamplesReceived).
	// Can be used with TotalAudioEnergy to compute an average audio level over different intervals.
	TotalSamplesDuration float64 `json:"totalSamplesDuration"`

	// EchoReturnLoss is only present while the sender is sending a track sourced from
	// a microphone where echo cancellation is applied. Calculated in decibels.
	EchoReturnLoss float64 `json:"echoReturnLoss"`

	// EchoReturnLossEnhancement is only present while the sender is sending a track
	// sourced from a microphone where echo cancellation is applied. Calculated in decibels.
	EchoReturnLossEnhancement float64 `json:"echoReturnLossEnhancement"`

	// TotalSamplesSent is the total number of samples that have been sent by this sender.
	TotalSamplesSent uint64 `json:"totalSamplesSent"`
}

AudioSenderStats represents the stats about one audio sender of a PeerConnection object for which one calls GetStats.

It appears in the stats as soon as the RTPSender is added by either AddTrack or AddTransceiver, or by media negotiation.

type BundlePolicy

type BundlePolicy int

BundlePolicy affects which media tracks are negotiated if the remote endpoint is not bundle-aware, and what ICE candidates are gathered. If the remote endpoint is bundle-aware, all media tracks and data channels are bundled onto the same transport.

const (
	// BundlePolicyBalanced indicates to gather ICE candidates for each
	// media type in use (audio, video, and data). If the remote endpoint is
	// not bundle-aware, negotiate only one audio and video track on separate
	// transports.
	BundlePolicyBalanced BundlePolicy = iota + 1

	// BundlePolicyMaxCompat indicates to gather ICE candidates for each
	// track. If the remote endpoint is not bundle-aware, negotiate all media
	// tracks on separate transports.
	BundlePolicyMaxCompat

	// BundlePolicyMaxBundle indicates to gather ICE candidates for only
	// one track. If the remote endpoint is not bundle-aware, negotiate only
	// one media track.
	BundlePolicyMaxBundle
)

func (BundlePolicy) String

func (t BundlePolicy) String() string

type Certificate

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

Certificate represents a x509Cert used to authenticate WebRTC communications.

func CertificateFromX509

func CertificateFromX509(privateKey crypto.PrivateKey, certificate *x509.Certificate) Certificate

CertificateFromX509 creates a new WebRTC Certificate from a given PrivateKey and Certificate

This can be used if you want to share a certificate across multiple PeerConnections

func GenerateCertificate

func GenerateCertificate(secretKey crypto.PrivateKey) (*Certificate, error)

GenerateCertificate causes the creation of an X.509 certificate and corresponding private key.

func NewCertificate

func NewCertificate(key crypto.PrivateKey, tpl x509.Certificate) (*Certificate, error)

NewCertificate generates a new x509 compliant Certificate to be used by DTLS for encrypting data sent over the wire. This method differs from GenerateCertificate by allowing to specify a template x509.Certificate to be used in order to define certificate parameters.

func (Certificate) Equals

func (c Certificate) Equals(o Certificate) bool

Equals determines if two certificates are identical by comparing both the secretKeys and x509Certificates.

func (Certificate) Expires

func (c Certificate) Expires() time.Time

Expires returns the timestamp after which this certificate is no longer valid.

func (Certificate) GetFingerprints

func (c Certificate) GetFingerprints() ([]DTLSFingerprint, error)

GetFingerprints returns the list of certificate fingerprints, one of which is computed with the digest algorithm used in the certificate signature.

type CertificateStats

type CertificateStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// Fingerprint is the fingerprint of the certificate.
	Fingerprint string `json:"fingerprint"`

	// FingerprintAlgorithm is the hash function used to compute the certificate fingerprint. For instance, "sha-256".
	FingerprintAlgorithm string `json:"fingerprintAlgorithm"`

	// Base64Certificate is the DER-encoded base-64 representation of the certificate.
	Base64Certificate string `json:"base64Certificate"`

	// IssuerCertificateID refers to the stats object that contains the next certificate
	// in the certificate chain. If the current certificate is at the end of the chain
	// (i.e. a self-signed certificate), this will not be set.
	IssuerCertificateID string `json:"issuerCertificateId"`
}

CertificateStats contains information about a certificate used by an ICETransport.

type CodecStats

type CodecStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// PayloadType as used in RTP encoding or decoding
	PayloadType uint32 `json:"payloadType"`

	// CodecType of this CodecStats
	CodecType CodecType `json:"codecType"`

	// TransportID is the unique identifier of the transport on which this codec is
	// being used, which can be used to look up the corresponding TransportStats object.
	TransportID string `json:"transportId"`

	// MimeType is the codec MIME media type/subtype. e.g., video/vp8 or equivalent.
	MimeType string `json:"mimeType"`

	// ClockRate represents the media sampling rate.
	ClockRate uint32 `json:"clockRate"`

	// Channels is 2 for stereo, missing for most other cases.
	Channels uint32 `json:"channels"`

	// SDPFmtpLine is the a=fmtp line in the SDP corresponding to the codec,
	// i.e., after the colon following the PT.
	SDPFmtpLine string `json:"sdpFmtpLine"`

	// Implementation identifies the implementation used. This is useful for diagnosing
	// interoperability issues.
	Implementation string `json:"implementation"`
}

CodecStats contains statistics for a codec that is currently being used by RTP streams being sent or received by this PeerConnection object.

type CodecType

type CodecType string

CodecType specifies whether a CodecStats objects represents a media format that is being encoded or decoded

const (
	// CodecTypeEncode means the attached CodecStats represents a media format that
	// is being encoded, or that the implementation is prepared to encode.
	CodecTypeEncode CodecType = "encode"

	// CodecTypeDecode means the attached CodecStats represents a media format
	// that the implementation is prepared to decode.
	CodecTypeDecode CodecType = "decode"
)

type Configuration

type Configuration struct {
	// ICEServers defines a slice describing servers available to be used by
	// ICE, such as STUN and TURN servers.
	ICEServers []ICEServer

	// ICETransportPolicy indicates which candidates the ICEAgent is allowed
	// to use.
	ICETransportPolicy ICETransportPolicy

	// BundlePolicy indicates which media-bundling policy to use when gathering
	// ICE candidates.
	BundlePolicy BundlePolicy

	// RTCPMuxPolicy indicates which rtcp-mux policy to use when gathering ICE
	// candidates.
	RTCPMuxPolicy RTCPMuxPolicy

	// PeerIdentity sets the target peer identity for the PeerConnection.
	// The PeerConnection will not establish a connection to a remote peer
	// unless it can be successfully authenticated with the provided name.
	PeerIdentity string

	// Certificates describes a set of certificates that the PeerConnection
	// uses to authenticate. Valid values for this parameter are created
	// through calls to the GenerateCertificate function. Although any given
	// DTLS connection will use only one certificate, this attribute allows the
	// caller to provide multiple certificates that support different
	// algorithms. The final certificate will be selected based on the DTLS
	// handshake, which establishes which certificates are allowed. The
	// PeerConnection implementation selects which of the certificates is
	// used for a given connection; how certificates are selected is outside
	// the scope of this specification. If this value is absent, then a default
	// set of certificates is generated for each PeerConnection instance.
	Certificates []Certificate

	// ICECandidatePoolSize describes the size of the prefetched ICE pool.
	ICECandidatePoolSize uint8

	// SDPSemantics controls the type of SDP offers accepted by and
	// SDP answers generated by the PeerConnection.
	SDPSemantics SDPSemantics
}

A Configuration defines how peer-to-peer communication via PeerConnection is established or re-established. Configurations may be set up once and reused across multiple connections. Configurations are treated as readonly. As long as they are unmodified, they are safe for concurrent use.

type DTLSFingerprint

type DTLSFingerprint struct {
	// Algorithm specifies one of the the hash function algorithms defined in
	// the 'Hash function Textual Names' registry.
	Algorithm string `json:"algorithm"`

	// Value specifies the value of the certificate fingerprint in lowercase
	// hex string as expressed utilizing the syntax of 'fingerprint' in
	// https://tools.ietf.org/html/rfc4572#section-5.
	Value string `json:"value"`
}

DTLSFingerprint specifies the hash function algorithm and certificate fingerprint as described in https://tools.ietf.org/html/rfc4572.

type DTLSParameters

type DTLSParameters struct {
	Role         DTLSRole          `json:"role"`
	Fingerprints []DTLSFingerprint `json:"fingerprints"`
}

DTLSParameters holds information relating to DTLS configuration.

type DTLSRole

type DTLSRole byte

DTLSRole indicates the role of the DTLS transport.

const (
	// DTLSRoleAuto defines the DTLS role is determined based on
	// the resolved ICE role: the ICE controlled role acts as the DTLS
	// client and the ICE controlling role acts as the DTLS server.
	DTLSRoleAuto DTLSRole = iota + 1

	// DTLSRoleClient defines the DTLS client role.
	DTLSRoleClient

	// DTLSRoleServer defines the DTLS server role.
	DTLSRoleServer
)

func (DTLSRole) String

func (r DTLSRole) String() string

type DTLSTransport

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

DTLSTransport allows an application access to information about the DTLS transport over which RTP and RTCP packets are sent and received by RTPSender and RTPReceiver, as well other data such as SCTP packets sent and received by data channels.

func (*DTLSTransport) GetLocalParameters

func (t *DTLSTransport) GetLocalParameters() (DTLSParameters, error)

GetLocalParameters returns the DTLS parameters of the local DTLSTransport upon construction.

func (*DTLSTransport) GetRemoteCertificate

func (t *DTLSTransport) GetRemoteCertificate() []byte

GetRemoteCertificate returns the certificate chain in use by the remote side returns an empty list prior to selection of the remote certificate

func (*DTLSTransport) ICETransport

func (t *DTLSTransport) ICETransport() *ICETransport

ICETransport returns the currently-configured *ICETransport or nil if one has not been configured

func (*DTLSTransport) OnStateChange

func (t *DTLSTransport) OnStateChange(f func(DTLSTransportState))

OnStateChange sets a handler that is fired when the DTLS connection state changes.

func (*DTLSTransport) Start

func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error

Start DTLS transport negotiation with the parameters of the remote DTLS transport

func (*DTLSTransport) State

func (t *DTLSTransport) State() DTLSTransportState

State returns the current dtls transport state.

func (*DTLSTransport) Stop

func (t *DTLSTransport) Stop() error

Stop stops and closes the DTLSTransport object.

type DTLSTransportState

type DTLSTransportState int

DTLSTransportState indicates the DTLS transport establishment state.

const (
	// DTLSTransportStateNew indicates that DTLS has not started negotiating
	// yet.
	DTLSTransportStateNew DTLSTransportState = iota + 1

	// DTLSTransportStateConnecting indicates that DTLS is in the process of
	// negotiating a secure connection and verifying the remote fingerprint.
	DTLSTransportStateConnecting

	// DTLSTransportStateConnected indicates that DTLS has completed
	// negotiation of a secure connection and verified the remote fingerprint.
	DTLSTransportStateConnected

	// DTLSTransportStateClosed indicates that the transport has been closed
	// intentionally as the result of receipt of a close_notify alert, or
	// calling close().
	DTLSTransportStateClosed

	// DTLSTransportStateFailed indicates that the transport has failed as
	// the result of an error (such as receipt of an error alert or failure to
	// validate the remote fingerprint).
	DTLSTransportStateFailed
)

func (DTLSTransportState) String

func (t DTLSTransportState) String() string

type DataChannel

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

DataChannel represents a WebRTC DataChannel The DataChannel interface represents a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data

func (*DataChannel) BufferedAmount

func (d *DataChannel) BufferedAmount() uint64

BufferedAmount represents the number of bytes of application data (UTF-8 text and binary data) that have been queued using send(). Even though the data transmission can occur in parallel, the returned value MUST NOT be decreased before the current task yielded back to the event loop to prevent race conditions. The value does not include framing overhead incurred by the protocol, or buffering done by the operating system or network hardware. The value of BufferedAmount slot will only increase with each call to the send() method as long as the ReadyState is open; however, BufferedAmount does not reset to zero once the channel closes.

func (*DataChannel) BufferedAmountLowThreshold

func (d *DataChannel) BufferedAmountLowThreshold() uint64

BufferedAmountLowThreshold represents the threshold at which the bufferedAmount is considered to be low. When the bufferedAmount decreases from above this threshold to equal or below it, the bufferedamountlow event fires. BufferedAmountLowThreshold is initially zero on each new DataChannel, but the application may change its value at any time. The threshold is set to 0 by default.

func (*DataChannel) Close

func (d *DataChannel) Close() error

Close Closes the DataChannel. It may be called regardless of whether the DataChannel object was created by this peer or the remote peer.

func (*DataChannel) Detach

Detach allows you to detach the underlying datachannel. This provides an idiomatic API to work with, however it disables the OnMessage callback. Before calling Detach you have to enable this behavior by calling webrtc.DetachDataChannels(). Combining detached and normal data channels is not supported. Please refer to the data-channels-detach example and the pion/datachannel documentation for the correct way to handle the resulting DataChannel object.

func (*DataChannel) ID

func (d *DataChannel) ID() *uint16

ID represents the ID for this DataChannel. The value is initially null, which is what will be returned if the ID was not provided at channel creation time, and the DTLS role of the SCTP transport has not yet been negotiated. Otherwise, it will return the ID that was either selected by the script or generated. After the ID is set to a non-null value, it will not change.

func (*DataChannel) Label

func (d *DataChannel) Label() string

Label represents a label that can be used to distinguish this DataChannel object from other DataChannel objects. Scripts are allowed to create multiple DataChannel objects with the same label.

func (*DataChannel) MaxPacketLifeTime

func (d *DataChannel) MaxPacketLifeTime() *uint16

MaxPacketLifeTime represents the length of the time window (msec) during which transmissions and retransmissions may occur in unreliable mode.

func (*DataChannel) MaxRetransmits

func (d *DataChannel) MaxRetransmits() *uint16

MaxRetransmits represents the maximum number of retransmissions that are attempted in unreliable mode.

func (*DataChannel) Negotiated

func (d *DataChannel) Negotiated() bool

Negotiated represents whether this DataChannel was negotiated by the application (true), or not (false).

func (*DataChannel) OnBufferedAmountLow

func (d *DataChannel) OnBufferedAmountLow(f func())

OnBufferedAmountLow sets an event handler which is invoked when the number of bytes of outgoing data becomes lower than the BufferedAmountLowThreshold.

func (*DataChannel) OnClose

func (d *DataChannel) OnClose(f func())

OnClose sets an event handler which is invoked when the underlying data transport has been closed.

func (*DataChannel) OnError

func (d *DataChannel) OnError(f func(err error))

OnError sets an event handler which is invoked when the underlying data transport cannot be read.

func (*DataChannel) OnMessage

func (d *DataChannel) OnMessage(f func(msg DataChannelMessage))

OnMessage sets an event handler which is invoked on a binary message arrival over the sctp transport from a remote peer. OnMessage can currently receive messages up to 16384 bytes in size. Check out the detach API if you want to use larger message sizes. Note that browser support for larger messages is also limited.

func (*DataChannel) OnOpen

func (d *DataChannel) OnOpen(f func())

OnOpen sets an event handler which is invoked when the underlying data transport has been established (or re-established).

func (*DataChannel) Ordered

func (d *DataChannel) Ordered() bool

Ordered represents if the DataChannel is ordered, and false if out-of-order delivery is allowed.

func (*DataChannel) Protocol

func (d *DataChannel) Protocol() string

Protocol represents the name of the sub-protocol used with this DataChannel.

func (*DataChannel) ReadyState

func (d *DataChannel) ReadyState() DataChannelState

ReadyState represents the state of the DataChannel object.

func (*DataChannel) Send

func (d *DataChannel) Send(data []byte) error

Send sends the binary message to the DataChannel peer

func (*DataChannel) SendText

func (d *DataChannel) SendText(s string) error

SendText sends the text message to the DataChannel peer

func (*DataChannel) SetBufferedAmountLowThreshold

func (d *DataChannel) SetBufferedAmountLowThreshold(th uint64)

SetBufferedAmountLowThreshold is used to update the threshold. See BufferedAmountLowThreshold().

func (*DataChannel) Transport

func (d *DataChannel) Transport() *SCTPTransport

Transport returns the SCTPTransport instance the DataChannel is sending over.

type DataChannelInit

type DataChannelInit struct {
	// Ordered indicates if data is allowed to be delivered out of order. The
	// default value of true, guarantees that data will be delivered in order.
	Ordered *bool

	// MaxPacketLifeTime limits the time (in milliseconds) during which the
	// channel will transmit or retransmit data if not acknowledged. This value
	// may be clamped if it exceeds the maximum value supported.
	MaxPacketLifeTime *uint16

	// MaxRetransmits limits the number of times a channel will retransmit data
	// if not successfully delivered. This value may be clamped if it exceeds
	// the maximum value supported.
	MaxRetransmits *uint16

	// Protocol describes the subprotocol name used for this channel.
	Protocol *string

	// Negotiated describes if the data channel is created by the local peer or
	// the remote peer. The default value of false tells the user agent to
	// announce the channel in-band and instruct the other peer to dispatch a
	// corresponding DataChannel. If set to true, it is up to the application
	// to negotiate the channel and create an DataChannel with the same id
	// at the other peer.
	Negotiated *bool

	// ID overrides the default selection of ID for this channel.
	ID *uint16
}

DataChannelInit can be used to configure properties of the underlying channel such as data reliability.

type DataChannelMessage

type DataChannelMessage struct {
	IsString bool
	Data     []byte
}

DataChannelMessage represents a message received from the data channel. IsString will be set to true if the incoming message is of the string type. Otherwise the message is of a binary type.

type DataChannelParameters

type DataChannelParameters struct {
	Label             string  `json:"label"`
	Protocol          string  `json:"protocol"`
	ID                *uint16 `json:"id"`
	Ordered           bool    `json:"ordered"`
	MaxPacketLifeTime *uint16 `json:"maxPacketLifeTime"`
	MaxRetransmits    *uint16 `json:"maxRetransmits"`
	Negotiated        bool    `json:"negotiated"`
}

DataChannelParameters describes the configuration of the DataChannel.

type DataChannelState

type DataChannelState int

DataChannelState indicates the state of a data channel.

const (
	// DataChannelStateConnecting indicates that the data channel is being
	// established. This is the initial state of DataChannel, whether created
	// with CreateDataChannel, or dispatched as a part of an DataChannelEvent.
	DataChannelStateConnecting DataChannelState = iota + 1

	// DataChannelStateOpen indicates that the underlying data transport is
	// established and communication is possible.
	DataChannelStateOpen

	// DataChannelStateClosing indicates that the procedure to close down the
	// underlying data transport has started.
	DataChannelStateClosing

	// DataChannelStateClosed indicates that the underlying data transport
	// has been closed or could not be established.
	DataChannelStateClosed
)

func (DataChannelState) String

func (t DataChannelState) String() string

type DataChannelStats

type DataChannelStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// Label is the "label" value of the DataChannel object.
	Label string `json:"label"`

	// Protocol is the "protocol" value of the DataChannel object.
	Protocol string `json:"protocol"`

	// DataChannelIdentifier is the "id" attribute of the DataChannel object.
	DataChannelIdentifier int32 `json:"dataChannelIdentifier"`

	// TransportID the ID of the TransportStats object for transport used to carry this datachannel.
	TransportID string `json:"transportId"`

	// State is the "readyState" value of the DataChannel object.
	State DataChannelState `json:"state"`

	// MessagesSent represents the total number of API "message" events sent.
	MessagesSent uint32 `json:"messagesSent"`

	// BytesSent represents the total number of payload bytes sent on this
	// datachannel not including headers or padding.
	BytesSent uint64 `json:"bytesSent"`

	// MessagesReceived represents the total number of API "message" events received.
	MessagesReceived uint32 `json:"messagesReceived"`

	// BytesReceived represents the total number of bytes received on this
	// datachannel not including headers or padding.
	BytesReceived uint64 `json:"bytesReceived"`
}

DataChannelStats contains statistics related to each DataChannel ID.

type ICECandidate

type ICECandidate struct {
	Foundation     string           `json:"foundation"`
	Priority       uint32           `json:"priority"`
	Address        string           `json:"address"`
	Protocol       ICEProtocol      `json:"protocol"`
	Port           uint16           `json:"port"`
	Typ            ICECandidateType `json:"type"`
	Component      uint16           `json:"component"`
	RelatedAddress string           `json:"relatedAddress"`
	RelatedPort    uint16           `json:"relatedPort"`
	TCPType        string           `json:"tcpType"`
	// contains filtered or unexported fields
}

ICECandidate represents a ice candidate

func (ICECandidate) String

func (c ICECandidate) String() string

func (ICECandidate) ToJSON

func (c ICECandidate) ToJSON() ICECandidateInit

ToJSON returns an ICECandidateInit as indicated by the spec https://w3c.github.io/webrtc-pc/#dom-rtcicecandidate-tojson

type ICECandidateInit

type ICECandidateInit struct {
	Candidate        string  `json:"candidate"`
	SDPMid           *string `json:"sdpMid,omitempty"`
	SDPMLineIndex    *uint16 `json:"sdpMLineIndex,omitempty"`
	UsernameFragment string  `json:"usernameFragment"`
}

ICECandidateInit is used to serialize ice candidates

type ICECandidatePair

type ICECandidatePair struct {
	Local  *ICECandidate
	Remote *ICECandidate
	// contains filtered or unexported fields
}

ICECandidatePair represents an ICE Candidate pair

func NewICECandidatePair

func NewICECandidatePair(local, remote *ICECandidate) *ICECandidatePair

NewICECandidatePair returns an initialized *ICECandidatePair for the given pair of ICECandidate instances

func (*ICECandidatePair) String

func (p *ICECandidatePair) String() string

type ICECandidatePairStats

type ICECandidatePairStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// TransportID is a unique identifier that is associated to the object that
	// was inspected to produce the TransportStats associated with this candidate pair.
	TransportID string `json:"transportId"`

	// LocalCandidateID is a unique identifier that is associated to the object
	// that was inspected to produce the ICECandidateStats for the local candidate
	// associated with this candidate pair.
	LocalCandidateID string `json:"localCandidateId"`

	// RemoteCandidateID is a unique identifier that is associated to the object
	// that was inspected to produce the ICECandidateStats for the remote candidate
	// associated with this candidate pair.
	RemoteCandidateID string `json:"remoteCandidateId"`

	// State represents the state of the checklist for the local and remote
	// candidates in a pair.
	State StatsICECandidatePairState `json:"state"`

	// Nominated is true when this valid pair that should be used for media
	// if it is the highest-priority one amongst those whose nominated flag is set
	Nominated bool `json:"nominated"`

	// PacketsSent represents the total number of packets sent on this candidate pair.
	PacketsSent uint32 `json:"packetsSent"`

	// PacketsReceived represents the total number of packets received on this candidate pair.
	PacketsReceived uint32 `json:"packetsReceived"`

	// BytesSent represents the total number of payload bytes sent on this candidate pair
	// not including headers or padding.
	BytesSent uint64 `json:"bytesSent"`

	// BytesReceived represents the total number of payload bytes received on this candidate pair
	// not including headers or padding.
	BytesReceived uint64 `json:"bytesReceived"`

	// LastPacketSentTimestamp represents the timestamp at which the last packet was
	// sent on this particular candidate pair, excluding STUN packets.
	LastPacketSentTimestamp StatsTimestamp `json:"lastPacketSentTimestamp"`

	// LastPacketReceivedTimestamp represents the timestamp at which the last packet
	// was received on this particular candidate pair, excluding STUN packets.
	LastPacketReceivedTimestamp StatsTimestamp `json:"lastPacketReceivedTimestamp"`

	// FirstRequestTimestamp represents the timestamp at which the first STUN request
	// was sent on this particular candidate pair.
	FirstRequestTimestamp StatsTimestamp `json:"firstRequestTimestamp"`

	// LastRequestTimestamp represents the timestamp at which the last STUN request
	// was sent on this particular candidate pair. The average interval between two
	// consecutive connectivity checks sent can be calculated with
	// (LastRequestTimestamp - FirstRequestTimestamp) / RequestsSent.
	LastRequestTimestamp StatsTimestamp `json:"lastRequestTimestamp"`

	// LastResponseTimestamp represents the timestamp at which the last STUN response
	// was received on this particular candidate pair.
	LastResponseTimestamp StatsTimestamp `json:"lastResponseTimestamp"`

	// TotalRoundTripTime represents the sum of all round trip time measurements
	// in seconds since the beginning of the session, based on STUN connectivity
	// check responses (ResponsesReceived), including those that reply to requests
	// that are sent in order to verify consent. The average round trip time can
	// be computed from TotalRoundTripTime by dividing it by ResponsesReceived.
	TotalRoundTripTime float64 `json:"totalRoundTripTime"`

	// CurrentRoundTripTime represents the latest round trip time measured in seconds,
	// computed from both STUN connectivity checks, including those that are sent
	// for consent verification.
	CurrentRoundTripTime float64 `json:"currentRoundTripTime"`

	// AvailableOutgoingBitrate is calculated by the underlying congestion control
	// by combining the available bitrate for all the outgoing RTP streams using
	// this candidate pair. The bitrate measurement does not count the size of the
	// IP or other transport layers like TCP or UDP. It is similar to the TIAS defined
	// in RFC 3890, i.e., it is measured in bits per second and the bitrate is calculated
	// over a 1 second window.
	AvailableOutgoingBitrate float64 `json:"availableOutgoingBitrate"`

	// AvailableIncomingBitrate is calculated by the underlying congestion control
	// by combining the available bitrate for all the incoming RTP streams using
	// this candidate pair. The bitrate measurement does not count the size of the
	// IP or other transport layers like TCP or UDP. It is similar to the TIAS defined
	// in  RFC 3890, i.e., it is measured in bits per second and the bitrate is
	// calculated over a 1 second window.
	AvailableIncomingBitrate float64 `json:"availableIncomingBitrate"`

	// CircuitBreakerTriggerCount represents the number of times the circuit breaker
	// is triggered for this particular 5-tuple, ceasing transmission.
	CircuitBreakerTriggerCount uint32 `json:"circuitBreakerTriggerCount"`

	// RequestsReceived represents the total number of connectivity check requests
	// received (including retransmissions). It is impossible for the receiver to
	// tell whether the request was sent in order to check connectivity or check
	// consent, so all connectivity checks requests are counted here.
	RequestsReceived uint64 `json:"requestsReceived"`

	// RequestsSent represents the total number of connectivity check requests
	// sent (not including retransmissions).
	RequestsSent uint64 `json:"requestsSent"`

	// ResponsesReceived represents the total number of connectivity check responses received.
	ResponsesReceived uint64 `json:"responsesReceived"`

	// ResponsesSent represents the total number of connectivity check responses sent.
	// Since we cannot distinguish connectivity check requests and consent requests,
	// all responses are counted.
	ResponsesSent uint64 `json:"responsesSent"`

	// RetransmissionsReceived represents the total number of connectivity check
	// request retransmissions received.
	RetransmissionsReceived uint64 `json:"retransmissionsReceived"`

	// RetransmissionsSent represents the total number of connectivity check
	// request retransmissions sent.
	RetransmissionsSent uint64 `json:"retransmissionsSent"`

	// ConsentRequestsSent represents the total number of consent requests sent.
	ConsentRequestsSent uint64 `json:"consentRequestsSent"`

	// ConsentExpiredTimestamp represents the timestamp at which the latest valid
	// STUN binding response expired.
	ConsentExpiredTimestamp StatsTimestamp `json:"consentExpiredTimestamp"`
}

ICECandidatePairStats contains ICE candidate pair statistics related to the ICETransport objects.

type ICECandidateStats

type ICECandidateStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// TransportID is a unique identifier that is associated to the object that
	// was inspected to produce the TransportStats associated with this candidate.
	TransportID string `json:"transportId"`

	// NetworkType represents the type of network interface used by the base of a
	// local candidate (the address the ICE agent sends from). Only present for
	// local candidates; it's not possible to know what type of network interface
	// a remote candidate is using.
	//
	// Note:
	// This stat only tells you about the network interface used by the first "hop";
	// it's possible that a connection will be bottlenecked by another type of network.
	// For example, when using Wi-Fi tethering, the networkType of the relevant candidate
	// would be "wifi", even when the next hop is over a cellular connection.
	NetworkType NetworkType `json:"networkType"`

	// IP is the IP address of the candidate, allowing for IPv4 addresses and
	// IPv6 addresses, but fully qualified domain names (FQDNs) are not allowed.
	IP string `json:"ip"`

	// Port is the port number of the candidate.
	Port int32 `json:"port"`

	// Protocol is one of udp and tcp.
	Protocol string `json:"protocol"`

	// CandidateType is the "Type" field of the ICECandidate.
	CandidateType ICECandidateType `json:"candidateType"`

	// Priority is the "Priority" field of the ICECandidate.
	Priority int32 `json:"priority"`

	// URL is the URL of the TURN or STUN server indicated in the that translated
	// this IP address. It is the URL address surfaced in an PeerConnectionICEEvent.
	URL string `json:"url"`

	// RelayProtocol is the protocol used by the endpoint to communicate with the
	// TURN server. This is only present for local candidates. Valid values for
	// the TURN URL protocol is one of udp, tcp, or tls.
	RelayProtocol string `json:"relayProtocol"`

	// Deleted is true if the candidate has been deleted/freed. For host candidates,
	// this means that any network resources (typically a socket) associated with the
	// candidate have been released. For TURN candidates, this means the TURN allocation
	// is no longer active.
	//
	// Only defined for local candidates. For remote candidates, this property is not applicable.
	Deleted bool `json:"deleted"`
}

ICECandidateStats contains ICE candidate statistics related to the ICETransport objects.

type ICECandidateType

type ICECandidateType int

ICECandidateType represents the type of the ICE candidate used.

const (
	// ICECandidateTypeHost indicates that the candidate is of Host type as
	// described in https://tools.ietf.org/html/rfc8445#section-5.1.1.1. A
	// candidate obtained by binding to a specific port from an IP address on
	// the host. This includes IP addresses on physical interfaces and logical
	// ones, such as ones obtained through VPNs.
	ICECandidateTypeHost ICECandidateType = iota + 1

	// ICECandidateTypeSrflx indicates the the candidate is of Server
	// Reflexive type as described
	// https://tools.ietf.org/html/rfc8445#section-5.1.1.2. A candidate type
	// whose IP address and port are a binding allocated by a NAT for an ICE
	// agent after it sends a packet through the NAT to a server, such as a
	// STUN server.
	ICECandidateTypeSrflx

	// ICECandidateTypePrflx indicates that the candidate is of Peer
	// Reflexive type. A candidate type whose IP address and port are a binding
	// allocated by a NAT for an ICE agent after it sends a packet through the
	// NAT to its peer.
	ICECandidateTypePrflx

	// ICECandidateTypeRelay indicates the the candidate is of Relay type as
	// described in https://tools.ietf.org/html/rfc8445#section-5.1.1.2. A
	// candidate type obtained from a relay server, such as a TURN server.
	ICECandidateTypeRelay
)

func NewICECandidateType

func NewICECandidateType(raw string) (ICECandidateType, error)

NewICECandidateType takes a string and converts it into ICECandidateType

func (ICECandidateType) String

func (t ICECandidateType) String() string

type ICEComponent

type ICEComponent int

ICEComponent describes if the ice transport is used for RTP (or RTCP multiplexing).

const (
	// ICEComponentRTP indicates that the ICE Transport is used for RTP (or
	// RTCP multiplexing), as defined in
	// https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols
	// multiplexed with RTP (e.g. data channel) share its component ID. This
	// represents the component-id value 1 when encoded in candidate-attribute.
	ICEComponentRTP ICEComponent = iota + 1

	// ICEComponentRTCP indicates that the ICE Transport is used for RTCP as
	// defined by https://tools.ietf.org/html/rfc5245#section-4.1.1.1. This
	// represents the component-id value 2 when encoded in candidate-attribute.
	ICEComponentRTCP
)

func (ICEComponent) String

func (t ICEComponent) String() string

type ICEConnectionState

type ICEConnectionState int

ICEConnectionState indicates signaling state of the ICE Connection.

const (
	// ICEConnectionStateNew indicates that any of the ICETransports are
	// in the "new" state and none of them are in the "checking", "disconnected"
	// or "failed" state, or all ICETransports are in the "closed" state, or
	// there are no transports.
	ICEConnectionStateNew ICEConnectionState = iota + 1

	// ICEConnectionStateChecking indicates that any of the ICETransports
	// are in the "checking" state and none of them are in the "disconnected"
	// or "failed" state.
	ICEConnectionStateChecking

	// ICEConnectionStateConnected indicates that all ICETransports are
	// in the "connected", "completed" or "closed" state and at least one of
	// them is in the "connected" state.
	ICEConnectionStateConnected

	// ICEConnectionStateCompleted indicates that all ICETransports are
	// in the "completed" or "closed" state and at least one of them is in the
	// "completed" state.
	ICEConnectionStateCompleted

	// ICEConnectionStateDisconnected indicates that any of the
	// ICETransports are in the "disconnected" state and none of them are
	// in the "failed" state.
	ICEConnectionStateDisconnected

	// ICEConnectionStateFailed indicates that any of the ICETransports
	// are in the "failed" state.
	ICEConnectionStateFailed

	// ICEConnectionStateClosed indicates that the PeerConnection's
	// isClosed is true.
	ICEConnectionStateClosed
)

func NewICEConnectionState

func NewICEConnectionState(raw string) ICEConnectionState

NewICEConnectionState takes a string and converts it to ICEConnectionState

func (ICEConnectionState) String

func (c ICEConnectionState) String() string

type ICECredentialType

type ICECredentialType int

ICECredentialType indicates the type of credentials used to connect to an ICE server.

const (
	// ICECredentialTypePassword describes username and pasword based
	// credentials as described in https://tools.ietf.org/html/rfc5389.
	ICECredentialTypePassword ICECredentialType = iota

	// ICECredentialTypeOauth describes token based credential as described
	// in https://tools.ietf.org/html/rfc7635.
	ICECredentialTypeOauth
)

func (ICECredentialType) String

func (t ICECredentialType) String() string

type ICEGatherOptions

type ICEGatherOptions struct {
	ICEServers      []ICEServer
	ICEGatherPolicy ICETransportPolicy
}

ICEGatherOptions provides options relating to the gathering of ICE candidates.

type ICEGatherPolicy

type ICEGatherPolicy = ICETransportPolicy

ICEGatherPolicy is the ORTC equivalent of ICETransportPolicy

type ICEGatherer

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

ICEGatherer gathers local host, server reflexive and relay candidates, as well as enabling the retrieval of local Interactive Connectivity Establishment (ICE) parameters which can be exchanged in signaling.

func (*ICEGatherer) Close

func (g *ICEGatherer) Close() error

Close prunes all local candidates, and closes the ports.

func (*ICEGatherer) Gather

func (g *ICEGatherer) Gather() error

Gather ICE candidates.

func (*ICEGatherer) GetLocalCandidates

func (g *ICEGatherer) GetLocalCandidates() ([]ICECandidate, error)

GetLocalCandidates returns the sequence of valid local candidates associated with the ICEGatherer.

func (*ICEGatherer) GetLocalParameters

func (g *ICEGatherer) GetLocalParameters() (ICEParameters, error)

GetLocalParameters returns the ICE parameters of the ICEGatherer.

func (*ICEGatherer) OnLocalCandidate

func (g *ICEGatherer) OnLocalCandidate(f func(*ICECandidate))

OnLocalCandidate sets an event handler which fires when a new local ICE candidate is available Take note that the handler is gonna be called with a nil pointer when gathering is finished.

func (*ICEGatherer) OnStateChange

func (g *ICEGatherer) OnStateChange(f func(ICEGathererState))

OnStateChange fires any time the ICEGatherer changes

func (*ICEGatherer) State

func (g *ICEGatherer) State() ICEGathererState

State indicates the current state of the ICE gatherer.

type ICEGathererState

type ICEGathererState uint32

ICEGathererState represents the current state of the ICE gatherer.

const (
	// ICEGathererStateNew indicates object has been created but
	// gather() has not been called.
	ICEGathererStateNew ICEGathererState = iota + 1

	// ICEGathererStateGathering indicates gather() has been called,
	// and the ICEGatherer is in the process of gathering candidates.
	ICEGathererStateGathering

	// ICEGathererStateComplete indicates the ICEGatherer has completed gathering.
	ICEGathererStateComplete

	// ICEGathererStateClosed indicates the closed state can only be entered
	// when the ICEGatherer has been closed intentionally by calling close().
	ICEGathererStateClosed
)

func (ICEGathererState) String

func (s ICEGathererState) String() string

type ICEGatheringState

type ICEGatheringState int

ICEGatheringState describes the state of the candidate gathering process.

const (
	// ICEGatheringStateNew indicates that any of the ICETransports are
	// in the "new" gathering state and none of the transports are in the
	// "gathering" state, or there are no transports.
	ICEGatheringStateNew ICEGatheringState = iota + 1

	// ICEGatheringStateGathering indicates that any of the ICETransports
	// are in the "gathering" state.
	ICEGatheringStateGathering

	// ICEGatheringStateComplete indicates that at least one ICETransport
	// exists, and all ICETransports are in the "completed" gathering state.
	ICEGatheringStateComplete
)

func NewICEGatheringState

func NewICEGatheringState(raw string) ICEGatheringState

NewICEGatheringState takes a string and converts it to ICEGatheringState

func (ICEGatheringState) String

func (t ICEGatheringState) String() string

type ICEParameters

type ICEParameters struct {
	UsernameFragment string `json:"usernameFragment"`
	Password         string `json:"password"`
	ICELite          bool   `json:"iceLite"`
}

ICEParameters includes the ICE username fragment and password and other ICE-related parameters.

type ICEProtocol

type ICEProtocol int

ICEProtocol indicates the transport protocol type that is used in the ice.URL structure.

const (
	// ICEProtocolUDP indicates the URL uses a UDP transport.
	ICEProtocolUDP ICEProtocol = iota + 1

	// ICEProtocolTCP indicates the URL uses a TCP transport.
	ICEProtocolTCP
)

func NewICEProtocol

func NewICEProtocol(raw string) (ICEProtocol, error)

NewICEProtocol takes a string and converts it to ICEProtocol

func (ICEProtocol) String

func (t ICEProtocol) String() string

type ICERole

type ICERole int

ICERole describes the role ice.Agent is playing in selecting the preferred the candidate pair.

const (
	// ICERoleControlling indicates that the ICE agent that is responsible
	// for selecting the final choice of candidate pairs and signaling them
	// through STUN and an updated offer, if needed. In any session, one agent
	// is always controlling. The other is the controlled agent.
	ICERoleControlling ICERole = iota + 1

	// ICERoleControlled indicates that an ICE agent that waits for the
	// controlling agent to select the final choice of candidate pairs.
	ICERoleControlled
)

func (ICERole) String

func (t ICERole) String() string

type ICEServer

type ICEServer struct {
	URLs           []string
	Username       string
	Credential     interface{}
	CredentialType ICECredentialType
}

ICEServer describes a single STUN and TURN server that can be used by the ICEAgent to establish a connection with a peer.

type ICETransport

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

ICETransport allows an application access to information about the ICE transport over which packets are sent and received.

func NewICETransport

func NewICETransport(gatherer *ICEGatherer, loggerFactory logging.LoggerFactory) *ICETransport

NewICETransport creates a new NewICETransport.

func (*ICETransport) AddRemoteCandidate

func (t *ICETransport) AddRemoteCandidate(remoteCandidate ICECandidate) error

AddRemoteCandidate adds a candidate associated with the remote ICETransport.

func (*ICETransport) NewEndpoint

func (t *ICETransport) NewEndpoint(f mux.MatchFunc) *mux.Endpoint

NewEndpoint registers a new endpoint on the underlying mux.

func (*ICETransport) OnConnectionStateChange

func (t *ICETransport) OnConnectionStateChange(f func(ICETransportState))

OnConnectionStateChange sets a handler that is fired when the ICE connection state changes.

func (*ICETransport) OnSelectedCandidatePairChange

func (t *ICETransport) OnSelectedCandidatePairChange(f func(*ICECandidatePair))

OnSelectedCandidatePairChange sets a handler that is invoked when a new ICE candidate pair is selected

func (*ICETransport) Role

func (t *ICETransport) Role() ICERole

Role indicates the current role of the ICE transport.

func (*ICETransport) SetRemoteCandidates

func (t *ICETransport) SetRemoteCandidates(remoteCandidates []ICECandidate) error

SetRemoteCandidates sets the sequence of candidates associated with the remote ICETransport.

func (*ICETransport) Start

func (t *ICETransport) Start(gatherer *ICEGatherer, params ICEParameters, role *ICERole) error

Start incoming connectivity checks based on its configured role.

func (*ICETransport) State

func (t *ICETransport) State() ICETransportState

State returns the current ice transport state.

func (*ICETransport) Stop

func (t *ICETransport) Stop() error

Stop irreversibly stops the ICETransport.

type ICETransportPolicy

type ICETransportPolicy int

ICETransportPolicy defines the ICE candidate policy surface the permitted candidates. Only these candidates are used for connectivity checks.

const (
	// ICETransportPolicyAll indicates any type of candidate is used.
	ICETransportPolicyAll ICETransportPolicy = iota

	// ICETransportPolicyRelay indicates only media relay candidates such
	// as candidates passing through a TURN server are used.
	ICETransportPolicyRelay
)

func NewICETransportPolicy

func NewICETransportPolicy(raw string) ICETransportPolicy

NewICETransportPolicy takes a string and converts it to ICETransportPolicy

func (ICETransportPolicy) String

func (t ICETransportPolicy) String() string

type ICETransportState

type ICETransportState int

ICETransportState represents the current state of the ICE transport.

func (ICETransportState) String

func (c ICETransportState) String() string

type InboundRTPStreamStats

type InboundRTPStreamStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// SSRC is the 32-bit unsigned integer value used to identify the source of the
	// stream of RTP packets that this stats object concerns.
	SSRC uint32 `json:"ssrc"`

	// Kind is either "audio" or "video"
	Kind string `json:"kind"`

	// It is a unique identifier that is associated to the object that was inspected
	// to produce the TransportStats associated with this RTP stream.
	TransportID string `json:"transportId"`

	// CodecID is a unique identifier that is associated to the object that was inspected
	// to produce the CodecStats associated with this RTP stream.
	CodecID string `json:"codecId"`

	// FIRCount counts the total number of Full Intra Request (FIR) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	FIRCount uint32 `json:"firCount"`

	// PLICount counts the total number of Picture Loss Indication (PLI) packets
	// received by the sender. This metric is only valid for video and is sent by receiver.
	PLICount uint32 `json:"pliCount"`

	// NACKCount counts the total number of Negative ACKnowledgement (NACK) packets
	// received by the sender and is sent by receiver.
	NACKCount uint32 `json:"nackCount"`

	// SLICount counts the total number of Slice Loss Indication (SLI) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	SLICount uint32 `json:"sliCount"`

	// QPSum is the sum of the QP values of frames passed. The count of frames is
	// in FramesDecoded for inbound stream stats, and in FramesEncoded for outbound stream stats.
	QPSum uint64 `json:"qpSum"`

	// PacketsReceived is the total number of RTP packets received for this SSRC.
	PacketsReceived uint32 `json:"packetsReceived"`

	// PacketsLost is the total number of RTP packets lost for this SSRC. Note that
	// because of how this is estimated, it can be negative if more packets are received than sent.
	PacketsLost int32 `json:"packetsLost"`

	// Jitter is the packet jitter measured in seconds for this SSRC
	Jitter float64 `json:"jitter"`

	// PacketsDiscarded is the cumulative number of RTP packets discarded by the jitter
	// buffer due to late or early-arrival, i.e., these packets are not played out.
	// RTP packets discarded due to packet duplication are not reported in this metric.
	PacketsDiscarded uint32 `json:"packetsDiscarded"`

	// PacketsRepaired is the cumulative number of lost RTP packets repaired after applying
	// an error-resilience mechanism. It is measured for the primary source RTP packets
	// and only counted for RTP packets that have no further chance of repair.
	PacketsRepaired uint32 `json:"packetsRepaired"`

	// BurstPacketsLost is the cumulative number of RTP packets lost during loss bursts.
	BurstPacketsLost uint32 `json:"burstPacketsLost"`

	// BurstPacketsDiscarded is the cumulative number of RTP packets discarded during discard bursts.
	BurstPacketsDiscarded uint32 `json:"burstPacketsDiscarded"`

	// BurstLossCount is the cumulative number of bursts of lost RTP packets.
	BurstLossCount uint32 `json:"burstLossCount"`

	// BurstDiscardCount is the cumulative number of bursts of discarded RTP packets.
	BurstDiscardCount uint32 `json:"burstDiscardCount"`

	// BurstLossRate is the fraction of RTP packets lost during bursts to the
	// total number of RTP packets expected in the bursts.
	BurstLossRate float64 `json:"burstLossRate"`

	// BurstDiscardRate is the fraction of RTP packets discarded during bursts to
	// the total number of RTP packets expected in bursts.
	BurstDiscardRate float64 `json:"burstDiscardRate"`

	// GapLossRate is the fraction of RTP packets lost during the gap periods.
	GapLossRate float64 `json:"gapLossRate"`

	// GapDiscardRate is the fraction of RTP packets discarded during the gap periods.
	GapDiscardRate float64 `json:"gapDiscardRate"`

	// TrackID is the identifier of the stats object representing the receiving track,
	// a ReceiverAudioTrackAttachmentStats or ReceiverVideoTrackAttachmentStats.
	TrackID string `json:"trackId"`

	// ReceiverID is the stats ID used to look up the AudioReceiverStats or VideoReceiverStats
	// object receiving this stream.
	ReceiverID string `json:"receiverId"`

	// RemoteID is used for looking up the remote RemoteOutboundRTPStreamStats object
	// for the same SSRC.
	RemoteID string `json:"remoteId"`

	// FramesDecoded represents the total number of frames correctly decoded for this SSRC,
	// i.e., frames that would be displayed if no frames are dropped. Only valid for video.
	FramesDecoded uint32 `json:"framesDecoded"`

	// LastPacketReceivedTimestamp represents the timestamp at which the last packet was
	// received for this SSRC. This differs from Timestamp, which represents the time
	// at which the statistics were generated by the local endpoint.
	LastPacketReceivedTimestamp StatsTimestamp `json:"lastPacketReceivedTimestamp"`

	// AverageRTCPInterval is the average RTCP interval between two consecutive compound RTCP packets.
	// This is calculated by the sending endpoint when sending compound RTCP reports.
	// Compound packets must contain at least a RTCP RR or SR packet and an SDES packet
	// with the CNAME item.
	AverageRTCPInterval float64 `json:"averageRtcpInterval"`

	// FECPacketsReceived is the total number of RTP FEC packets received for this SSRC.
	// This counter can also be incremented when receiving FEC packets in-band with media packets (e.g., with Opus).
	FECPacketsReceived uint32 `json:"fecPacketsReceived"`

	// BytesReceived is the total number of bytes received for this SSRC.
	BytesReceived uint64 `json:"bytesReceived"`

	// PacketsFailedDecryption is the cumulative number of RTP packets that failed
	// to be decrypted. These packets are not counted by PacketsDiscarded.
	PacketsFailedDecryption uint32 `json:"packetsFailedDecryption"`

	// PacketsDuplicated is the cumulative number of packets discarded because they
	// are duplicated. Duplicate packets are not counted in PacketsDiscarded.
	//
	// Duplicated packets have the same RTP sequence number and content as a previously
	// received packet. If multiple duplicates of a packet are received, all of them are counted.
	// An improved estimate of lost packets can be calculated by adding PacketsDuplicated to PacketsLost.
	PacketsDuplicated uint32 `json:"packetsDuplicated"`

	// PerDSCPPacketsReceived is the total number of packets received for this SSRC,
	// per Differentiated Services code point (DSCP) [RFC2474]. DSCPs are identified
	// as decimal integers in string form. Note that due to network remapping and bleaching,
	// these numbers are not expected to match the numbers seen on sending. Not all
	// OSes make this information available.
	PerDSCPPacketsReceived map[string]uint32 `json:"perDscpPacketsReceived"`
}

InboundRTPStreamStats contains statistics for an inbound RTP stream that is currently received with this PeerConnection object.

type MediaEngine

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

A MediaEngine defines the codecs supported by a PeerConnection. MediaEngines populated using RegisterCodec (and RegisterDefaultCodecs) may be set up once and reused, including concurrently, as long as no other codecs are added subsequently. MediaEngines populated using PopulateFromSDP should be used only for that session.

func (*MediaEngine) GetCodecsByKind

func (m *MediaEngine) GetCodecsByKind(kind RTPCodecType) []*RTPCodec

GetCodecsByKind returns all codecs of kind kind that are supported by m. The returned codecs should not be modified.

func (*MediaEngine) GetCodecsByName

func (m *MediaEngine) GetCodecsByName(codecName string) []*RTPCodec

GetCodecsByName returns all codecs by name that are supported by m. The returned codecs should not be modified.

func (*MediaEngine) PopulateFromSDP

func (m *MediaEngine) PopulateFromSDP(sd SessionDescription) error

PopulateFromSDP finds all codecs in sd and adds them to m, using the dynamic payload types and parameters from sd. PopulateFromSDP is intended for use when answering a request. The offerer sets the PayloadTypes for the connection. PopulateFromSDP allows an answerer to properly match the PayloadTypes from the offerer. A MediaEngine populated by PopulateFromSDP should be used only for a single session.

func (*MediaEngine) RegisterCodec

func (m *MediaEngine) RegisterCodec(codec *RTPCodec) uint8

RegisterCodec adds codec to m. RegisterCodec is not safe for concurrent use.

func (*MediaEngine) RegisterDefaultCodecs

func (m *MediaEngine) RegisterDefaultCodecs()

RegisterDefaultCodecs registers the default codecs supported by Pion WebRTC. RegisterDefaultCodecs is not safe for concurrent use.

type MediaStreamStats

type MediaStreamStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// StreamIdentifier is the "id" property of the MediaStream
	StreamIdentifier string `json:"streamIdentifier"`

	// TrackIDs is a list of the identifiers of the stats object representing the
	// stream's tracks, either ReceiverAudioTrackAttachmentStats or ReceiverVideoTrackAttachmentStats.
	TrackIDs []string `json:"trackIds"`
}

MediaStreamStats contains statistics related to a specific MediaStream.

type NetworkType

type NetworkType int

NetworkType represents the type of network

const (
	// NetworkTypeUDP4 indicates UDP over IPv4.
	NetworkTypeUDP4 NetworkType = iota + 1

	// NetworkTypeUDP6 indicates UDP over IPv6.
	NetworkTypeUDP6

	// NetworkTypeTCP4 indicates TCP over IPv4.
	NetworkTypeTCP4

	// NetworkTypeTCP6 indicates TCP over IPv6.
	NetworkTypeTCP6
)

func NewNetworkType

func NewNetworkType(raw string) (NetworkType, error)

NewNetworkType allows create network type from string It will be useful for getting custom network types from external config.

func (NetworkType) Protocol

func (t NetworkType) Protocol() string

Protocol returns udp or tcp

func (NetworkType) String

func (t NetworkType) String() string

type OAuthCredential

type OAuthCredential struct {
	// MACKey is a base64-url encoded format. It is used in STUN message
	// integrity hash calculation.
	MACKey string

	// AccessToken is a base64-encoded format. This is an encrypted
	// self-contained token that is opaque to the application.
	AccessToken string
}

OAuthCredential represents OAuth credential information which is used by the STUN/TURN client to connect to an ICE server as defined in https://tools.ietf.org/html/rfc7635. Note that the kid parameter is not located in OAuthCredential, but in ICEServer's username member.

type OfferAnswerOptions

type OfferAnswerOptions struct {
	// VoiceActivityDetection allows the application to provide information
	// about whether it wishes voice detection feature to be enabled or disabled.
	VoiceActivityDetection bool
}

OfferAnswerOptions is a base structure which describes the options that can be used to control the offer/answer creation process.

type OfferOptions

type OfferOptions struct {
	OfferAnswerOptions

	// ICERestart forces the underlying ice gathering process to be restarted.
	// When this value is true, the generated description will have ICE
	// credentials that are different from the current credentials
	ICERestart bool
}

OfferOptions structure describes the options used to control the offer creation process

type OutboundRTPStreamStats

type OutboundRTPStreamStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// SSRC is the 32-bit unsigned integer value used to identify the source of the
	// stream of RTP packets that this stats object concerns.
	SSRC uint32 `json:"ssrc"`

	// Kind is either "audio" or "video"
	Kind string `json:"kind"`

	// It is a unique identifier that is associated to the object that was inspected
	// to produce the TransportStats associated with this RTP stream.
	TransportID string `json:"transportId"`

	// CodecID is a unique identifier that is associated to the object that was inspected
	// to produce the CodecStats associated with this RTP stream.
	CodecID string `json:"codecId"`

	// FIRCount counts the total number of Full Intra Request (FIR) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	FIRCount uint32 `json:"firCount"`

	// PLICount counts the total number of Picture Loss Indication (PLI) packets
	// received by the sender. This metric is only valid for video and is sent by receiver.
	PLICount uint32 `json:"pliCount"`

	// NACKCount counts the total number of Negative ACKnowledgement (NACK) packets
	// received by the sender and is sent by receiver.
	NACKCount uint32 `json:"nackCount"`

	// SLICount counts the total number of Slice Loss Indication (SLI) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	SLICount uint32 `json:"sliCount"`

	// QPSum is the sum of the QP values of frames passed. The count of frames is
	// in FramesDecoded for inbound stream stats, and in FramesEncoded for outbound stream stats.
	QPSum uint64 `json:"qpSum"`

	// PacketsSent is the total number of RTP packets sent for this SSRC.
	PacketsSent uint32 `json:"packetsSent"`

	// PacketsDiscardedOnSend is the total number of RTP packets for this SSRC that
	// have been discarded due to socket errors, i.e. a socket error occurred when handing
	// the packets to the socket. This might happen due to various reasons, including
	// full buffer or no available memory.
	PacketsDiscardedOnSend uint32 `json:"packetsDiscardedOnSend"`

	// FECPacketsSent is the total number of RTP FEC packets sent for this SSRC.
	// This counter can also be incremented when sending FEC packets in-band with
	// media packets (e.g., with Opus).
	FECPacketsSent uint32 `json:"fecPacketsSent"`

	// BytesSent is the total number of bytes sent for this SSRC.
	BytesSent uint64 `json:"bytesSent"`

	// BytesDiscardedOnSend is the total number of bytes for this SSRC that have
	// been discarded due to socket errors, i.e. a socket error occurred when handing
	// the packets containing the bytes to the socket. This might happen due to various
	// reasons, including full buffer or no available memory.
	BytesDiscardedOnSend uint64 `json:"bytesDiscardedOnSend"`

	// TrackID is the identifier of the stats object representing the current track
	// attachment to the sender of this stream, a SenderAudioTrackAttachmentStats
	// or SenderVideoTrackAttachmentStats.
	TrackID string `json:"trackId"`

	// SenderID is the stats ID used to look up the AudioSenderStats or VideoSenderStats
	// object sending this stream.
	SenderID string `json:"senderId"`

	// RemoteID is used for looking up the remote RemoteInboundRTPStreamStats object
	// for the same SSRC.
	RemoteID string `json:"remoteId"`

	// LastPacketSentTimestamp represents the timestamp at which the last packet was
	// sent for this SSRC. This differs from timestamp, which represents the time at
	// which the statistics were generated by the local endpoint.
	LastPacketSentTimestamp StatsTimestamp `json:"lastPacketSentTimestamp"`

	// TargetBitrate is the current target bitrate configured for this particular SSRC
	// and is the Transport Independent Application Specific (TIAS) bitrate [RFC3890].
	// Typically, the target bitrate is a configuration parameter provided to the codec's
	// encoder and does not count the size of the IP or other transport layers like TCP or UDP.
	// It is measured in bits per second and the bitrate is calculated over a 1 second window.
	TargetBitrate float64 `json:"targetBitrate"`

	// FramesEncoded represents the total number of frames successfully encoded for this RTP media stream.
	// Only valid for video.
	FramesEncoded uint32 `json:"framesEncoded"`

	// TotalEncodeTime is the total number of seconds that has been spent encoding the
	// framesEncoded frames of this stream. The average encode time can be calculated by
	// dividing this value with FramesEncoded. The time it takes to encode one frame is the
	// time passed between feeding the encoder a frame and the encoder returning encoded data
	// for that frame. This does not include any additional time it may take to packetize the resulting data.
	TotalEncodeTime float64 `json:"totalEncodeTime"`

	// AverageRTCPInterval is the average RTCP interval between two consecutive compound RTCP
	// packets. This is calculated by the sending endpoint when sending compound RTCP reports.
	// Compound packets must contain at least a RTCP RR or SR packet and an SDES packet with the CNAME item.
	AverageRTCPInterval float64 `json:"averageRtcpInterval"`

	// QualityLimitationReason is the current reason for limiting the resolution and/or framerate,
	// or "none" if not limited. Only valid for video.
	QualityLimitationReason QualityLimitationReason `json:"qualityLimitationReason"`

	// QualityLimitationDurations is record of the total time, in seconds, that this
	// stream has spent in each quality limitation state. The record includes a mapping
	// for all QualityLimitationReason types, including "none". Only valid for video.
	QualityLimitationDurations map[string]float64 `json:"qualityLimitationDurations"`

	// PerDSCPPacketsSent is the total number of packets sent for this SSRC, per DSCP.
	// DSCPs are identified as decimal integers in string form.
	PerDSCPPacketsSent map[string]uint32 `json:"perDscpPacketsSent"`
}

OutboundRTPStreamStats contains statistics for an outbound RTP stream that is currently sent with this PeerConnection object.

type PeerConnection

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

PeerConnection represents a WebRTC connection that establishes a peer-to-peer communications with another PeerConnection instance in a browser, or to another endpoint implementing the required protocols.

func NewPeerConnection

func NewPeerConnection(configuration Configuration) (*PeerConnection, error)

NewPeerConnection creates a peerconnection with the default codecs. See API.NewRTCPeerConnection for details.

func (*PeerConnection) AddICECandidate

func (pc *PeerConnection) AddICECandidate(candidate ICECandidateInit) error

AddICECandidate accepts an ICE candidate string and adds it to the existing set of candidates

func (*PeerConnection) AddTrack

func (pc *PeerConnection) AddTrack(track *Track) (*RTPSender, error)

AddTrack adds a Track to the PeerConnection

func (*PeerConnection) AddTransceiver

func (pc *PeerConnection) AddTransceiver(trackOrKind RTPCodecType, init ...RtpTransceiverInit) (*RTPTransceiver, error)

AddTransceiver Create a new RTCRtpTransceiver and add it to the set of transceivers. Deprecated: Use AddTrack, AddTransceiverFromKind or AddTransceiverFromTrack

func (*PeerConnection) AddTransceiverFromKind

func (pc *PeerConnection) AddTransceiverFromKind(kind RTPCodecType, init ...RtpTransceiverInit) (*RTPTransceiver, error)

AddTransceiverFromKind Create a new RTCRtpTransceiver(SendRecv or RecvOnly) and add it to the set of transceivers.

func (*PeerConnection) AddTransceiverFromTrack

func (pc *PeerConnection) AddTransceiverFromTrack(track *Track, init ...RtpTransceiverInit) (*RTPTransceiver, error)

AddTransceiverFromTrack Creates a new send only transceiver and add it to the set of

func (*PeerConnection) Close

func (pc *PeerConnection) Close() error

Close ends the PeerConnection

func (*PeerConnection) ConnectionState

func (pc *PeerConnection) ConnectionState() PeerConnectionState

ConnectionState attribute returns the connection state of the PeerConnection instance.

func (*PeerConnection) CreateAnswer

func (pc *PeerConnection) CreateAnswer(options *AnswerOptions) (SessionDescription, error)

CreateAnswer starts the PeerConnection and generates the localDescription

func (*PeerConnection) CreateDataChannel

func (pc *PeerConnection) CreateDataChannel(label string, options *DataChannelInit) (*DataChannel, error)

CreateDataChannel creates a new DataChannel object with the given label and optional DataChannelInit used to configure properties of the underlying channel such as data reliability.

func (*PeerConnection) CreateOffer

func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription, error)

CreateOffer starts the PeerConnection and generates the localDescription

func (*PeerConnection) CurrentLocalDescription

func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription

CurrentLocalDescription represents the local description that was successfully negotiated the last time the PeerConnection transitioned into the stable state plus any local candidates that have been generated by the ICEAgent since the offer or answer was created.

func (*PeerConnection) CurrentRemoteDescription

func (pc *PeerConnection) CurrentRemoteDescription() *SessionDescription

CurrentRemoteDescription represents the last remote description that was successfully negotiated the last time the PeerConnection transitioned into the stable state plus any remote candidates that have been supplied via AddICECandidate() since the offer or answer was created.

func (*PeerConnection) GetConfiguration

func (pc *PeerConnection) GetConfiguration() Configuration

GetConfiguration returns a Configuration object representing the current configuration of this PeerConnection object. The returned object is a copy and direct mutation on it will not take affect until SetConfiguration has been called with Configuration passed as its only argument. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-getconfiguration

func (*PeerConnection) GetReceivers

func (pc *PeerConnection) GetReceivers() []*RTPReceiver

GetReceivers returns the RTPReceivers that are currently attached to this RTCPeerConnection

func (*PeerConnection) GetRegisteredRTPCodecs

func (pc *PeerConnection) GetRegisteredRTPCodecs(kind RTPCodecType) []*RTPCodec

GetRegisteredRTPCodecs gets a list of registered RTPCodec from the underlying constructed MediaEngine

func (*PeerConnection) GetSenders

func (pc *PeerConnection) GetSenders() []*RTPSender

GetSenders returns the RTPSender that are currently attached to this PeerConnection

func (*PeerConnection) GetStats

func (pc *PeerConnection) GetStats() StatsReport

GetStats return data providing statistics about the overall connection

func (*PeerConnection) GetTransceivers

func (pc *PeerConnection) GetTransceivers() []*RTPTransceiver

GetTransceivers returns the RTCRtpTransceiver that are currently attached to this RTCPeerConnection

func (*PeerConnection) ICEConnectionState

func (pc *PeerConnection) ICEConnectionState() ICEConnectionState

ICEConnectionState returns the ICE connection state of the PeerConnection instance.

func (*PeerConnection) ICEGatheringState

func (pc *PeerConnection) ICEGatheringState() ICEGatheringState

ICEGatheringState attribute returns the ICE gathering state of the PeerConnection instance.

func (*PeerConnection) LocalDescription

func (pc *PeerConnection) LocalDescription() *SessionDescription

LocalDescription returns PendingLocalDescription if it is not null and otherwise it returns CurrentLocalDescription. This property is used to determine if SetLocalDescription has already been called. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-localdescription

func (*PeerConnection) NewTrack

func (pc *PeerConnection) NewTrack(payloadType uint8, ssrc uint32, id, label string) (*Track, error)

NewTrack Creates a new Track

func (*PeerConnection) OnConnectionStateChange

func (pc *PeerConnection) OnConnectionStateChange(f func(PeerConnectionState))

OnConnectionStateChange sets an event handler which is called when the PeerConnectionState has changed

func (*PeerConnection) OnDataChannel

func (pc *PeerConnection) OnDataChannel(f func(*DataChannel))

OnDataChannel sets an event handler which is invoked when a data channel message arrives from a remote peer.

func (*PeerConnection) OnICECandidate

func (pc *PeerConnection) OnICECandidate(f func(*ICECandidate))

OnICECandidate sets an event handler which is invoked when a new ICE candidate is found. Take note that the handler is gonna be called with a nil pointer when gathering is finished.

func (*PeerConnection) OnICEConnectionStateChange

func (pc *PeerConnection) OnICEConnectionStateChange(f func(ICEConnectionState))

OnICEConnectionStateChange sets an event handler which is called when an ICE connection state is changed.

func (*PeerConnection) OnICEGatheringStateChange

func (pc *PeerConnection) OnICEGatheringStateChange(f func(ICEGathererState))

OnICEGatheringStateChange sets an event handler which is invoked when the ICE candidate gathering state has changed.

func (*PeerConnection) OnSignalingStateChange

func (pc *PeerConnection) OnSignalingStateChange(f func(SignalingState))

OnSignalingStateChange sets an event handler which is invoked when the peer connection's signaling state changes

func (*PeerConnection) OnTrack

func (pc *PeerConnection) OnTrack(f func(*Track, *RTPReceiver))

OnTrack sets an event handler which is called when remote track arrives from a remote peer.

func (*PeerConnection) PendingLocalDescription

func (pc *PeerConnection) PendingLocalDescription() *SessionDescription

PendingLocalDescription represents a local description that is in the process of being negotiated plus any local candidates that have been generated by the ICEAgent since the offer or answer was created. If the PeerConnection is in the stable state, the value is null.

func (*PeerConnection) PendingRemoteDescription

func (pc *PeerConnection) PendingRemoteDescription() *SessionDescription

PendingRemoteDescription represents a remote description that is in the process of being negotiated, complete with any remote candidates that have been supplied via AddICECandidate() since the offer or answer was created. If the PeerConnection is in the stable state, the value is null.

func (*PeerConnection) RemoteDescription

func (pc *PeerConnection) RemoteDescription() *SessionDescription

RemoteDescription returns pendingRemoteDescription if it is not null and otherwise it returns currentRemoteDescription. This property is used to determine if setRemoteDescription has already been called. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-remotedescription

func (*PeerConnection) RemoveTrack

func (pc *PeerConnection) RemoveTrack(sender *RTPSender) error

RemoveTrack removes a Track from the PeerConnection

func (*PeerConnection) SetConfiguration

func (pc *PeerConnection) SetConfiguration(configuration Configuration) error

SetConfiguration updates the configuration of this PeerConnection object.

func (*PeerConnection) SetIdentityProvider

func (pc *PeerConnection) SetIdentityProvider(provider string) error

SetIdentityProvider is used to configure an identity provider to generate identity assertions

func (*PeerConnection) SetLocalDescription

func (pc *PeerConnection) SetLocalDescription(desc SessionDescription) error

SetLocalDescription sets the SessionDescription of the local peer

func (*PeerConnection) SetRemoteDescription

func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error

SetRemoteDescription sets the SessionDescription of the remote peer nolint: gocyclo

func (*PeerConnection) SignalingState

func (pc *PeerConnection) SignalingState() SignalingState

SignalingState attribute returns the signaling state of the PeerConnection instance.

func (*PeerConnection) WriteRTCP

func (pc *PeerConnection) WriteRTCP(pkts []rtcp.Packet) error

WriteRTCP sends a user provided RTCP packet to the connected peer If no peer is connected the packet is discarded

type PeerConnectionState

type PeerConnectionState int

PeerConnectionState indicates the state of the PeerConnection.

const (
	// PeerConnectionStateNew indicates that any of the ICETransports or
	// DTLSTransports are in the "new" state and none of the transports are
	// in the "connecting", "checking", "failed" or "disconnected" state, or
	// all transports are in the "closed" state, or there are no transports.
	PeerConnectionStateNew PeerConnectionState = iota + 1

	// PeerConnectionStateConnecting indicates that any of the
	// ICETransports or DTLSTransports are in the "connecting" or
	// "checking" state and none of them is in the "failed" state.
	PeerConnectionStateConnecting

	// PeerConnectionStateConnected indicates that all ICETransports and
	// DTLSTransports are in the "connected", "completed" or "closed" state
	// and at least one of them is in the "connected" or "completed" state.
	PeerConnectionStateConnected

	// PeerConnectionStateDisconnected indicates that any of the
	// ICETransports or DTLSTransports are in the "disconnected" state
	// and none of them are in the "failed" or "connecting" or "checking" state.
	PeerConnectionStateDisconnected

	// PeerConnectionStateFailed indicates that any of the ICETransports
	// or DTLSTransports are in a "failed" state.
	PeerConnectionStateFailed

	// PeerConnectionStateClosed indicates the peer connection is closed
	// and the isClosed member variable of PeerConnection is true.
	PeerConnectionStateClosed
)

func (PeerConnectionState) String

func (t PeerConnectionState) String() string

type PeerConnectionStats

type PeerConnectionStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// DataChannelsOpened represents the number of unique DataChannels that have
	// entered the "open" state during their lifetime.
	DataChannelsOpened uint32 `json:"dataChannelsOpened"`

	// DataChannelsClosed represents the number of unique DataChannels that have
	// left the "open" state during their lifetime (due to being closed by either
	// end or the underlying transport being closed). DataChannels that transition
	// from "connecting" to "closing" or "closed" without ever being "open"
	// are not counted in this number.
	DataChannelsClosed uint32 `json:"dataChannelsClosed"`

	// DataChannelsRequested Represents the number of unique DataChannels returned
	// from a successful createDataChannel() call on the PeerConnection. If the
	// underlying data transport is not established, these may be in the "connecting" state.
	DataChannelsRequested uint32 `json:"dataChannelsRequested"`

	// DataChannelsAccepted represents the number of unique DataChannels signaled
	// in a "datachannel" event on the PeerConnection.
	DataChannelsAccepted uint32 `json:"dataChannelsAccepted"`
}

PeerConnectionStats contains statistics related to the PeerConnection object.

type QualityLimitationReason

type QualityLimitationReason string

QualityLimitationReason lists the reason for limiting the resolution and/or framerate. Only valid for video.

const (
	// QualityLimitationReasonNone means the resolution and/or framerate is not limited.
	QualityLimitationReasonNone QualityLimitationReason = "none"

	// QualityLimitationReasonCPU means the resolution and/or framerate is primarily limited due to CPU load.
	QualityLimitationReasonCPU QualityLimitationReason = "cpu"

	// QualityLimitationReasonBandwidth means the resolution and/or framerate is primarily limited due to congestion cues during bandwidth estimation. Typical, congestion control algorithms use inter-arrival time, round-trip time, packet or other congestion cues to perform bandwidth estimation.
	QualityLimitationReasonBandwidth QualityLimitationReason = "bandwidth"

	// QualityLimitationReasonOther means the resolution and/or framerate is primarily limited for a reason other than the above.
	QualityLimitationReasonOther QualityLimitationReason = "other"
)

type RTCPFeedback

type RTCPFeedback struct {
	// Type is the type of feedback.
	// see: https://draft.ortc.org/#dom-rtcrtcpfeedback
	// valid: ack, ccm, nack, goog-remb, transport-cc
	Type string

	// The parameter value depends on the type.
	// For example, type="nack" parameter="pli" will send Picture Loss Indicator packets.
	Parameter string
}

RTCPFeedback signals the connection to use additional RTCP packet types. https://draft.ortc.org/#dom-rtcrtcpfeedback

type RTCPMuxPolicy

type RTCPMuxPolicy int

RTCPMuxPolicy affects what ICE candidates are gathered to support non-multiplexed RTCP.

const (
	// RTCPMuxPolicyNegotiate indicates to gather ICE candidates for both
	// RTP and RTCP candidates. If the remote-endpoint is capable of
	// multiplexing RTCP, multiplex RTCP on the RTP candidates. If it is not,
	// use both the RTP and RTCP candidates separately.
	RTCPMuxPolicyNegotiate RTCPMuxPolicy = iota + 1

	// RTCPMuxPolicyRequire indicates to gather ICE candidates only for
	// RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is
	// not capable of rtcp-mux, session negotiation will fail.
	RTCPMuxPolicyRequire
)

func (RTCPMuxPolicy) String

func (t RTCPMuxPolicy) String() string

type RTPCapabilities

type RTPCapabilities struct {
	Codecs           []RTPCodecCapability
	HeaderExtensions []RTPHeaderExtensionCapability
}

RTPCapabilities represents the capabilities of a transceiver

type RTPCodec

type RTPCodec struct {
	RTPCodecCapability
	Type        RTPCodecType
	Name        string
	PayloadType uint8
	Payloader   rtp.Payloader
}

RTPCodec represents a codec supported by the PeerConnection

func NewRTPCodec

func NewRTPCodec(
	codecType RTPCodecType,
	name string,
	clockrate uint32,
	channels uint16,
	fmtp string,
	payloadType uint8,
	payloader rtp.Payloader,
) *RTPCodec

NewRTPCodec is used to define a new codec

func NewRTPCodecExt

func NewRTPCodecExt(
	codecType RTPCodecType,
	name string,
	clockrate uint32,
	channels uint16,
	fmtp string,
	payloadType uint8,
	rtcpfb []RTCPFeedback,
	payloader rtp.Payloader,
) *RTPCodec

NewRTPCodecExt is used to define a new codec

func NewRTPG722Codec

func NewRTPG722Codec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPG722Codec is a helper to create a G722 codec

func NewRTPH264Codec

func NewRTPH264Codec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPH264Codec is a helper to create an H264 codec

func NewRTPH264CodecExt

func NewRTPH264CodecExt(payloadType uint8, clockrate uint32, rtcpfb []RTCPFeedback, fmtp string) *RTPCodec

NewRTPH264CodecExt is a helper to create an H264 codec

func NewRTPOpusCodec

func NewRTPOpusCodec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPOpusCodec is a helper to create an Opus codec

func NewRTPPCMACodec

func NewRTPPCMACodec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPPCMACodec is a helper to create a PCMA codec

func NewRTPPCMUCodec

func NewRTPPCMUCodec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPPCMUCodec is a helper to create a PCMU codec

func NewRTPVP8Codec

func NewRTPVP8Codec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPVP8Codec is a helper to create an VP8 codec

func NewRTPVP8CodecExt

func NewRTPVP8CodecExt(payloadType uint8, clockrate uint32, rtcpfb []RTCPFeedback, fmtp string) *RTPCodec

NewRTPVP8CodecExt is a helper to create an VP8 codec

func NewRTPVP9Codec

func NewRTPVP9Codec(payloadType uint8, clockrate uint32) *RTPCodec

NewRTPVP9Codec is a helper to create an VP9 codec

func NewRTPVP9CodecExt

func NewRTPVP9CodecExt(payloadType uint8, clockrate uint32, rtcpfb []RTCPFeedback, fmtp string) *RTPCodec

NewRTPVP9CodecExt is a helper to create an VP8 codec

type RTPCodecCapability

type RTPCodecCapability struct {
	MimeType     string
	ClockRate    uint32
	Channels     uint16
	SDPFmtpLine  string
	RTCPFeedback []RTCPFeedback
}

RTPCodecCapability provides information about codec capabilities.

type RTPCodecType

type RTPCodecType int

RTPCodecType determines the type of a codec

const (

	// RTPCodecTypeAudio indicates this is an audio codec
	RTPCodecTypeAudio RTPCodecType = iota + 1

	// RTPCodecTypeVideo indicates this is a video codec
	RTPCodecTypeVideo
)

func NewRTPCodecType

func NewRTPCodecType(r string) RTPCodecType

NewRTPCodecType creates a RTPCodecType from a string

func (RTPCodecType) String

func (t RTPCodecType) String() string

type RTPCodingParameters

type RTPCodingParameters struct {
	RID         string `json:"rid"`
	SSRC        uint32 `json:"ssrc"`
	PayloadType uint8  `json:"payloadType"`
}

RTPCodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement encoding/decoding itself http://draft.ortc.org/#dom-rtcrtpcodingparameters

type RTPContributingSourceStats

type RTPContributingSourceStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// ContributorSSRC is the SSRC identifier of the contributing source represented
	// by this stats object. It is a 32-bit unsigned integer that appears in the CSRC
	// list of any packets the relevant source contributed to.
	ContributorSSRC uint32 `json:"contributorSsrc"`

	// InboundRTPStreamID is the ID of the InboundRTPStreamStats object representing
	// the inbound RTP stream that this contributing source is contributing to.
	InboundRTPStreamID string `json:"inboundRtpStreamId"`

	// PacketsContributedTo is the total number of RTP packets that this contributing
	// source contributed to. This value is incremented each time a packet is counted
	// by InboundRTPStreamStats.packetsReceived, and the packet's CSRC list contains
	// the SSRC identifier of this contributing source, ContributorSSRC.
	PacketsContributedTo uint32 `json:"packetsContributedTo"`

	// AudioLevel is present if the last received RTP packet that this source contributed
	// to contained an [RFC6465] mixer-to-client audio level header extension. The value
	// of audioLevel is between 0..1 (linear), where 1.0 represents 0 dBov, 0 represents
	// silence, and 0.5 represents approximately 6 dBSPL change in the sound pressure level from 0 dBov.
	AudioLevel float64 `json:"audioLevel"`
}

RTPContributingSourceStats contains statistics for a contributing source (CSRC) that contributed to an inbound RTP stream.

type RTPDecodingParameters

type RTPDecodingParameters struct {
	RTPCodingParameters
}

RTPDecodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement decoding itself http://draft.ortc.org/#dom-rtcrtpdecodingparameters

type RTPEncodingParameters

type RTPEncodingParameters struct {
	RTPCodingParameters
}

RTPEncodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement encoding itself http://draft.ortc.org/#dom-rtcrtpencodingparameters

type RTPHeaderExtensionCapability

type RTPHeaderExtensionCapability struct {
	URI string
}

RTPHeaderExtensionCapability is used to define a RFC5285 RTP header extension supported by the codec.

type RTPReceiveParameters

type RTPReceiveParameters struct {
	Encodings []RTPDecodingParameters
}

RTPReceiveParameters contains the RTP stack settings used by receivers

type RTPReceiver

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

RTPReceiver allows an application to inspect the receipt of a Track

func (*RTPReceiver) Read

func (r *RTPReceiver) Read(b []byte) (n int, err error)

Read reads incoming RTCP for this RTPReceiver

func (*RTPReceiver) ReadRTCP

func (r *RTPReceiver) ReadRTCP() ([]rtcp.Packet, error)

ReadRTCP is a convenience method that wraps Read and unmarshals for you

func (*RTPReceiver) Receive

func (r *RTPReceiver) Receive(parameters RTPReceiveParameters) error

Receive initialize the track and starts all the transports

func (*RTPReceiver) Stop

func (r *RTPReceiver) Stop() error

Stop irreversibly stops the RTPReceiver

func (*RTPReceiver) Track

func (r *RTPReceiver) Track() *Track

Track returns the RtpTransceiver track

func (*RTPReceiver) Tracks

func (r *RTPReceiver) Tracks() []*Track

Tracks returns the RtpTransceiver tracks A RTPReceiver to support Simulcast may now have multiple tracks

func (*RTPReceiver) Transport

func (r *RTPReceiver) Transport() *DTLSTransport

Transport returns the currently-configured *DTLSTransport or nil if one has not yet been configured

type RTPSendParameters

type RTPSendParameters struct {
	Encodings RTPEncodingParameters
}

RTPSendParameters contains the RTP stack settings used by receivers

type RTPSender

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

RTPSender allows an application to control how a given Track is encoded and transmitted to a remote peer

func (*RTPSender) Read

func (r *RTPSender) Read(b []byte) (n int, err error)

Read reads incoming RTCP for this RTPReceiver

func (*RTPSender) ReadRTCP

func (r *RTPSender) ReadRTCP() ([]rtcp.Packet, error)

ReadRTCP is a convenience method that wraps Read and unmarshals for you

func (*RTPSender) Send

func (r *RTPSender) Send(parameters RTPSendParameters) error

Send Attempts to set the parameters controlling the sending of media.

func (*RTPSender) SendRTP

func (r *RTPSender) SendRTP(header *rtp.Header, payload []byte) (int, error)

SendRTP sends a RTP packet on this RTPSender

You should use Track instead to send packets. This is exposed because pion/webrtc currently provides no way for users to send RTP packets directly. This is makes users unable to send retransmissions to a single RTPSender. in /v3 this will go away, only use this API if you really need it.

func (*RTPSender) Stop

func (r *RTPSender) Stop() error

Stop irreversibly stops the RTPSender

func (*RTPSender) Track

func (r *RTPSender) Track() *Track

Track returns the RTCRtpTransceiver track, or nil

func (*RTPSender) Transport

func (r *RTPSender) Transport() *DTLSTransport

Transport returns the currently-configured *DTLSTransport or nil if one has not yet been configured

type RTPTransceiver

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

RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid.

func (*RTPTransceiver) Direction

func (t *RTPTransceiver) Direction() RTPTransceiverDirection

Direction returns the RTPTransceiver's current direction

func (*RTPTransceiver) Kind

func (t *RTPTransceiver) Kind() RTPCodecType

Kind returns RTPTransceiver's kind.

func (*RTPTransceiver) Mid

func (t *RTPTransceiver) Mid() string

Mid gets the Transceiver's mid value. When not already set, this value will be set in CreateOffer or CreateAnswer.

func (*RTPTransceiver) Receiver

func (t *RTPTransceiver) Receiver() *RTPReceiver

Receiver returns the RTPTransceiver's RTPReceiver if it has one

func (*RTPTransceiver) Sender

func (t *RTPTransceiver) Sender() *RTPSender

Sender returns the RTPTransceiver's RTPSender if it has one

func (*RTPTransceiver) Stop

func (t *RTPTransceiver) Stop() error

Stop irreversibly stops the RTPTransceiver

type RTPTransceiverDirection

type RTPTransceiverDirection int

RTPTransceiverDirection indicates the direction of the RTPTransceiver.

const (
	// RTPTransceiverDirectionSendrecv indicates the RTPSender will offer
	// to send RTP and RTPReceiver the will offer to receive RTP.
	RTPTransceiverDirectionSendrecv RTPTransceiverDirection = iota + 1

	// RTPTransceiverDirectionSendonly indicates the RTPSender will offer
	// to send RTP.
	RTPTransceiverDirectionSendonly

	// RTPTransceiverDirectionRecvonly indicates the RTPReceiver the will
	// offer to receive RTP.
	RTPTransceiverDirectionRecvonly

	// RTPTransceiverDirectionInactive indicates the RTPSender won't offer
	// to send RTP and RTPReceiver the won't offer to receive RTP.
	RTPTransceiverDirectionInactive
)

func NewRTPTransceiverDirection

func NewRTPTransceiverDirection(raw string) RTPTransceiverDirection

NewRTPTransceiverDirection defines a procedure for creating a new RTPTransceiverDirection from a raw string naming the transceiver direction.

func (RTPTransceiverDirection) String

func (t RTPTransceiverDirection) String() string

type RemoteInboundRTPStreamStats

type RemoteInboundRTPStreamStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// SSRC is the 32-bit unsigned integer value used to identify the source of the
	// stream of RTP packets that this stats object concerns.
	SSRC uint32 `json:"ssrc"`

	// Kind is either "audio" or "video"
	Kind string `json:"kind"`

	// It is a unique identifier that is associated to the object that was inspected
	// to produce the TransportStats associated with this RTP stream.
	TransportID string `json:"transportId"`

	// CodecID is a unique identifier that is associated to the object that was inspected
	// to produce the CodecStats associated with this RTP stream.
	CodecID string `json:"codecId"`

	// FIRCount counts the total number of Full Intra Request (FIR) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	FIRCount uint32 `json:"firCount"`

	// PLICount counts the total number of Picture Loss Indication (PLI) packets
	// received by the sender. This metric is only valid for video and is sent by receiver.
	PLICount uint32 `json:"pliCount"`

	// NACKCount counts the total number of Negative ACKnowledgement (NACK) packets
	// received by the sender and is sent by receiver.
	NACKCount uint32 `json:"nackCount"`

	// SLICount counts the total number of Slice Loss Indication (SLI) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	SLICount uint32 `json:"sliCount"`

	// QPSum is the sum of the QP values of frames passed. The count of frames is
	// in FramesDecoded for inbound stream stats, and in FramesEncoded for outbound stream stats.
	QPSum uint64 `json:"qpSum"`

	// PacketsReceived is the total number of RTP packets received for this SSRC.
	PacketsReceived uint32 `json:"packetsReceived"`

	// PacketsLost is the total number of RTP packets lost for this SSRC. Note that
	// because of how this is estimated, it can be negative if more packets are received than sent.
	PacketsLost int32 `json:"packetsLost"`

	// Jitter is the packet jitter measured in seconds for this SSRC
	Jitter float64 `json:"jitter"`

	// PacketsDiscarded is the cumulative number of RTP packets discarded by the jitter
	// buffer due to late or early-arrival, i.e., these packets are not played out.
	// RTP packets discarded due to packet duplication are not reported in this metric.
	PacketsDiscarded uint32 `json:"packetsDiscarded"`

	// PacketsRepaired is the cumulative number of lost RTP packets repaired after applying
	// an error-resilience mechanism. It is measured for the primary source RTP packets
	// and only counted for RTP packets that have no further chance of repair.
	PacketsRepaired uint32 `json:"packetsRepaired"`

	// BurstPacketsLost is the cumulative number of RTP packets lost during loss bursts.
	BurstPacketsLost uint32 `json:"burstPacketsLost"`

	// BurstPacketsDiscarded is the cumulative number of RTP packets discarded during discard bursts.
	BurstPacketsDiscarded uint32 `json:"burstPacketsDiscarded"`

	// BurstLossCount is the cumulative number of bursts of lost RTP packets.
	BurstLossCount uint32 `json:"burstLossCount"`

	// BurstDiscardCount is the cumulative number of bursts of discarded RTP packets.
	BurstDiscardCount uint32 `json:"burstDiscardCount"`

	// BurstLossRate is the fraction of RTP packets lost during bursts to the
	// total number of RTP packets expected in the bursts.
	BurstLossRate float64 `json:"burstLossRate"`

	// BurstDiscardRate is the fraction of RTP packets discarded during bursts to
	// the total number of RTP packets expected in bursts.
	BurstDiscardRate float64 `json:"burstDiscardRate"`

	// GapLossRate is the fraction of RTP packets lost during the gap periods.
	GapLossRate float64 `json:"gapLossRate"`

	// GapDiscardRate is the fraction of RTP packets discarded during the gap periods.
	GapDiscardRate float64 `json:"gapDiscardRate"`

	// LocalID is used for looking up the local OutboundRTPStreamStats object for the same SSRC.
	LocalID string `json:"localId"`

	// RoundTripTime is the estimated round trip time for this SSRC based on the
	// RTCP timestamps in the RTCP Receiver Report (RR) and measured in seconds.
	RoundTripTime float64 `json:"roundTripTime"`

	// FractionLost is the the fraction packet loss reported for this SSRC.
	FractionLost float64 `json:"fractionLost"`
}

RemoteInboundRTPStreamStats contains statistics for the remote endpoint's inbound RTP stream corresponding to an outbound stream that is currently sent with this PeerConnection object. It is measured at the remote endpoint and reported in an RTCP Receiver Report (RR) or RTCP Extended Report (XR).

type RemoteOutboundRTPStreamStats

type RemoteOutboundRTPStreamStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// SSRC is the 32-bit unsigned integer value used to identify the source of the
	// stream of RTP packets that this stats object concerns.
	SSRC uint32 `json:"ssrc"`

	// Kind is either "audio" or "video"
	Kind string `json:"kind"`

	// It is a unique identifier that is associated to the object that was inspected
	// to produce the TransportStats associated with this RTP stream.
	TransportID string `json:"transportId"`

	// CodecID is a unique identifier that is associated to the object that was inspected
	// to produce the CodecStats associated with this RTP stream.
	CodecID string `json:"codecId"`

	// FIRCount counts the total number of Full Intra Request (FIR) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	FIRCount uint32 `json:"firCount"`

	// PLICount counts the total number of Picture Loss Indication (PLI) packets
	// received by the sender. This metric is only valid for video and is sent by receiver.
	PLICount uint32 `json:"pliCount"`

	// NACKCount counts the total number of Negative ACKnowledgement (NACK) packets
	// received by the sender and is sent by receiver.
	NACKCount uint32 `json:"nackCount"`

	// SLICount counts the total number of Slice Loss Indication (SLI) packets received
	// by the sender. This metric is only valid for video and is sent by receiver.
	SLICount uint32 `json:"sliCount"`

	// QPSum is the sum of the QP values of frames passed. The count of frames is
	// in FramesDecoded for inbound stream stats, and in FramesEncoded for outbound stream stats.
	QPSum uint64 `json:"qpSum"`

	// PacketsSent is the total number of RTP packets sent for this SSRC.
	PacketsSent uint32 `json:"packetsSent"`

	// PacketsDiscardedOnSend is the total number of RTP packets for this SSRC that
	// have been discarded due to socket errors, i.e. a socket error occurred when handing
	// the packets to the socket. This might happen due to various reasons, including
	// full buffer or no available memory.
	PacketsDiscardedOnSend uint32 `json:"packetsDiscardedOnSend"`

	// FECPacketsSent is the total number of RTP FEC packets sent for this SSRC.
	// This counter can also be incremented when sending FEC packets in-band with
	// media packets (e.g., with Opus).
	FECPacketsSent uint32 `json:"fecPacketsSent"`

	// BytesSent is the total number of bytes sent for this SSRC.
	BytesSent uint64 `json:"bytesSent"`

	// BytesDiscardedOnSend is the total number of bytes for this SSRC that have
	// been discarded due to socket errors, i.e. a socket error occurred when handing
	// the packets containing the bytes to the socket. This might happen due to various
	// reasons, including full buffer or no available memory.
	BytesDiscardedOnSend uint64 `json:"bytesDiscardedOnSend"`

	// LocalID is used for looking up the local InboundRTPStreamStats object for the same SSRC.
	LocalID string `json:"localId"`

	// RemoteTimestamp represents the remote timestamp at which these statistics were
	// sent by the remote endpoint. This differs from timestamp, which represents the
	// time at which the statistics were generated or received by the local endpoint.
	// The RemoteTimestamp, if present, is derived from the NTP timestamp in an RTCP
	// Sender Report (SR) packet, which reflects the remote endpoint's clock.
	// That clock may not be synchronized with the local clock.
	RemoteTimestamp StatsTimestamp `json:"remoteTimestamp"`
}

RemoteOutboundRTPStreamStats contains statistics for the remote endpoint's outbound RTP stream corresponding to an inbound stream that is currently received with this PeerConnection object. It is measured at the remote endpoint and reported in an RTCP Sender Report (SR).

type RtpTransceiverInit

type RtpTransceiverInit struct {
	Direction     RTPTransceiverDirection
	SendEncodings []RTPEncodingParameters
}

RtpTransceiverInit dictionary is used when calling the WebRTC function addTransceiver() to provide configuration options for the new transceiver.

type SCTPCapabilities

type SCTPCapabilities struct {
	MaxMessageSize uint32 `json:"maxMessageSize"`
}

SCTPCapabilities indicates the capabilities of the SCTPTransport.

type SCTPTransport

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

SCTPTransport provides details about the SCTP transport.

func (*SCTPTransport) GetCapabilities

func (r *SCTPTransport) GetCapabilities() SCTPCapabilities

GetCapabilities returns the SCTPCapabilities of the SCTPTransport.

func (*SCTPTransport) MaxChannels

func (r *SCTPTransport) MaxChannels() uint16

MaxChannels is the maximum number of RTCDataChannels that can be open simultaneously.

func (*SCTPTransport) OnDataChannel

func (r *SCTPTransport) OnDataChannel(f func(*DataChannel))

OnDataChannel sets an event handler which is invoked when a data channel message arrives from a remote peer.

func (*SCTPTransport) OnDataChannelOpened

func (r *SCTPTransport) OnDataChannelOpened(f func(*DataChannel))

OnDataChannelOpened sets an event handler which is invoked when a data channel is opened

func (*SCTPTransport) OnError

func (r *SCTPTransport) OnError(f func(err error))

OnError sets an event handler which is invoked when the SCTP connection error occurs.

func (*SCTPTransport) Start

func (r *SCTPTransport) Start(remoteCaps SCTPCapabilities) error

Start the SCTPTransport. Since both local and remote parties must mutually create an SCTPTransport, SCTP SO (Simultaneous Open) is used to establish a connection over SCTP.

func (*SCTPTransport) State

func (r *SCTPTransport) State() SCTPTransportState

State returns the current state of the SCTPTransport

func (*SCTPTransport) Stop

func (r *SCTPTransport) Stop() error

Stop stops the SCTPTransport

func (*SCTPTransport) Transport

func (r *SCTPTransport) Transport() *DTLSTransport

Transport returns the DTLSTransport instance the SCTPTransport is sending over.

type SCTPTransportState

type SCTPTransportState int

SCTPTransportState indicates the state of the SCTP transport.

const (
	// SCTPTransportStateConnecting indicates the SCTPTransport is in the
	// process of negotiating an association. This is the initial state of the
	// SCTPTransportState when an SCTPTransport is created.
	SCTPTransportStateConnecting SCTPTransportState = iota + 1

	// SCTPTransportStateConnected indicates the negotiation of an
	// association is completed.
	SCTPTransportStateConnected

	// SCTPTransportStateClosed indicates a SHUTDOWN or ABORT chunk is
	// received or when the SCTP association has been closed intentionally,
	// such as by closing the peer connection or applying a remote description
	// that rejects data or changes the SCTP port.
	SCTPTransportStateClosed
)

func (SCTPTransportState) String

func (s SCTPTransportState) String() string

type SDPSectionType

type SDPSectionType string

SDPSectionType specifies media type sections

type SDPSemantics

type SDPSemantics int

SDPSemantics determines which style of SDP offers and answers can be used

const (
	// SDPSemanticsUnifiedPlan uses unified-plan offers and answers
	// (the default in Chrome since M72)
	// https://tools.ietf.org/html/draft-roach-mmusic-unified-plan-00
	SDPSemanticsUnifiedPlan SDPSemantics = iota

	// SDPSemanticsPlanB uses plan-b offers and answers
	// NB: This format should be considered deprecated
	// https://tools.ietf.org/html/draft-uberti-rtcweb-plan-00
	SDPSemanticsPlanB

	// SDPSemanticsUnifiedPlanWithFallback prefers unified-plan
	// offers and answers, but will respond to a plan-b offer
	// with a plan-b answer
	SDPSemanticsUnifiedPlanWithFallback
)

func (SDPSemantics) String

func (s SDPSemantics) String() string

type SDPType

type SDPType int

SDPType describes the type of an SessionDescription.

const (
	// SDPTypeOffer indicates that a description MUST be treated as an SDP
	// offer.
	SDPTypeOffer SDPType = iota + 1

	// SDPTypePranswer indicates that a description MUST be treated as an
	// SDP answer, but not a final answer. A description used as an SDP
	// pranswer may be applied as a response to an SDP offer, or an update to
	// a previously sent SDP pranswer.
	SDPTypePranswer

	// SDPTypeAnswer indicates that a description MUST be treated as an SDP
	// final answer, and the offer-answer exchange MUST be considered complete.
	// A description used as an SDP answer may be applied as a response to an
	// SDP offer or as an update to a previously sent SDP pranswer.
	SDPTypeAnswer

	// SDPTypeRollback indicates that a description MUST be treated as
	// canceling the current SDP negotiation and moving the SDP offer and
	// answer back to what it was in the previous stable state. Note the
	// local or remote SDP descriptions in the previous stable state could be
	// null if there has not yet been a successful offer-answer negotiation.
	SDPTypeRollback
)

func (SDPType) MarshalJSON

func (t SDPType) MarshalJSON() ([]byte, error)

MarshalJSON enables JSON marshaling of a SDPType

func (SDPType) String

func (t SDPType) String() string

func (*SDPType) UnmarshalJSON

func (t *SDPType) UnmarshalJSON(b []byte) error

UnmarshalJSON enables JSON unmarshaling of a SDPType

type SenderAudioTrackAttachmentStats

type SenderAudioTrackAttachmentStats AudioSenderStats

SenderAudioTrackAttachmentStats object represents the stats about one attachment of an audio MediaStreamTrack to the PeerConnection object for which one calls GetStats.

It appears in the stats as soon as it is attached (via AddTrack, via AddTransceiver, via ReplaceTrack on an RTPSender object).

If an audio track is attached twice (via AddTransceiver or ReplaceTrack), there will be two SenderAudioTrackAttachmentStats objects, one for each attachment. They will have the same "TrackIdentifier" attribute, but different "ID" attributes.

If the track is detached from the PeerConnection (via removeTrack or via replaceTrack), it continues to appear, but with the "ObjectDeleted" member set to true.

type SenderVideoTrackAttachmentStats

type SenderVideoTrackAttachmentStats VideoSenderStats

SenderVideoTrackAttachmentStats represents the stats about one attachment of a video MediaStreamTrack to the PeerConnection object for which one calls GetStats.

It appears in the stats as soon as it is attached (via AddTrack, via AddTransceiver, via ReplaceTrack on an RTPSender object).

If a video track is attached twice (via AddTransceiver or ReplaceTrack), there will be two SenderVideoTrackAttachmentStats objects, one for each attachment. They will have the same "TrackIdentifier" attribute, but different "ID" attributes.

If the track is detached from the PeerConnection (via RemoveTrack or via ReplaceTrack), it continues to appear, but with the "ObjectDeleted" member set to true.

type SessionDescription

type SessionDescription struct {
	Type SDPType `json:"type"`
	SDP  string  `json:"sdp"`
	// contains filtered or unexported fields
}

SessionDescription is used to expose local and remote session descriptions.

type SettingEngine

type SettingEngine struct {
	LoggerFactory logging.LoggerFactory
	// contains filtered or unexported fields
}

SettingEngine allows influencing behavior in ways that are not supported by the WebRTC API. This allows us to support additional use-cases without deviating from the WebRTC API elsewhere.

func (*SettingEngine) AddSDPExtensions

func (e *SettingEngine) AddSDPExtensions(mediaType SDPSectionType, exts []sdp.ExtMap)

AddSDPExtensions adds available and offered extensions for media type.

Ext IDs are optional and generated if you do not provide them SDP answers will only include extensions supported by both sides

func (*SettingEngine) DetachDataChannels

func (e *SettingEngine) DetachDataChannels()

DetachDataChannels enables detaching data channels. When enabled data channels have to be detached in the OnOpen callback using the DataChannel.Detach method.

func (*SettingEngine) DisableCertificateFingerprintVerification

func (e *SettingEngine) DisableCertificateFingerprintVerification(isDisabled bool)

DisableCertificateFingerprintVerification disables fingerprint verification after DTLS Handshake has finished

func (*SettingEngine) DisableSRTCPReplayProtection

func (e *SettingEngine) DisableSRTCPReplayProtection(isDisabled bool)

DisableSRTCPReplayProtection disables SRTCP replay protection.

func (*SettingEngine) DisableSRTPReplayProtection

func (e *SettingEngine) DisableSRTPReplayProtection(isDisabled bool)

DisableSRTPReplayProtection disables SRTP replay protection.

func (*SettingEngine) GenerateMulticastDNSCandidates

func (e *SettingEngine) GenerateMulticastDNSCandidates(generateMulticastDNSCandidates bool)

GenerateMulticastDNSCandidates instructs pion/ice to generate host candidates with mDNS hostnames instead of IP Addresses

func (*SettingEngine) SetAnsweringDTLSRole

func (e *SettingEngine) SetAnsweringDTLSRole(role DTLSRole) error

SetAnsweringDTLSRole sets the DTLS role that is selected when offering The DTLS role controls if the WebRTC Client as a client or server. This may be useful when interacting with non-compliant clients or debugging issues.

DTLSRoleActive:

Act as DTLS Client, send the ClientHello and starts the handshake

DTLSRolePassive:

Act as DTLS Server, wait for ClientHello

func (*SettingEngine) SetDTLSReplayProtectionWindow

func (e *SettingEngine) SetDTLSReplayProtectionWindow(n uint)

SetDTLSReplayProtectionWindow sets a replay attack protection window size of DTLS connection.

func (*SettingEngine) SetEphemeralUDPPortRange

func (e *SettingEngine) SetEphemeralUDPPortRange(portMin, portMax uint16) error

SetEphemeralUDPPortRange limits the pool of ephemeral ports that ICE UDP connections can allocate from. This affects both host candidates, and the local address of server reflexive candidates.

func (*SettingEngine) SetHostAcceptanceMinWait

func (e *SettingEngine) SetHostAcceptanceMinWait(t time.Duration)

SetHostAcceptanceMinWait sets the ICEHostAcceptanceMinWait

func (*SettingEngine) SetICECredentials

func (e *SettingEngine) SetICECredentials(usernameFragment, password string)

SetICECredentials sets a staic uFrag/uPwd to be used by pion/ice

This is useful if you want to do signalless WebRTC session, or having a reproducible environment with static credentials

func (*SettingEngine) SetICETCPPort

func (e *SettingEngine) SetICETCPPort(port int)

SetICETCPPort to a non-zero value enables ICE-TCP listener. This API is experimental and is likely to change in the future.

func (*SettingEngine) SetICETimeouts

func (e *SettingEngine) SetICETimeouts(disconnectedTimeout, failedTimeout, keepAliveInterval time.Duration)

SetICETimeouts sets the behavior around ICE Timeouts * disconnectedTimeout is the duration without network activity before a Agent is considered disconnected. Default is 5 Seconds * failedTimeout is the duration without network activity before a Agent is considered failed after disconnected. Default is 25 Seconds * keepAliveInterval is how often the ICE Agent sends extra traffic if there is no activity, if media is flowing no traffic will be sent. Default is 2 seconds

func (*SettingEngine) SetInterfaceFilter

func (e *SettingEngine) SetInterfaceFilter(filter func(string) bool)

SetInterfaceFilter sets the filtering functions when gathering ICE candidates This can be used to exclude certain network interfaces from ICE. Which may be useful if you know a certain interface will never succeed, or if you wish to reduce the amount of information you wish to expose to the remote peer

func (*SettingEngine) SetLite

func (e *SettingEngine) SetLite(lite bool)

SetLite configures whether or not the ice agent should be a lite agent

func (*SettingEngine) SetMulticastDNSHostName

func (e *SettingEngine) SetMulticastDNSHostName(hostName string)

SetMulticastDNSHostName sets a static HostName to be used by pion/ice instead of generating one on startup

This should only be used for a single PeerConnection. Having multiple PeerConnections with the same HostName will cause undefined behavior

func (*SettingEngine) SetNAT1To1IPs

func (e *SettingEngine) SetNAT1To1IPs(ips []string, candidateType ICECandidateType)

SetNAT1To1IPs sets a list of external IP addresses of 1:1 (D)NAT and a candidate type for which the external IP address is used. This is useful when you are host a server using Pion on an AWS EC2 instance which has a private address, behind a 1:1 DNAT with a public IP (e.g. Elastic IP). In this case, you can give the public IP address so that Pion will use the public IP address in its candidate instead of the private IP address. The second argument, candidateType, is used to tell Pion which type of candidate should use the given public IP address. Two types of candidates are supported:

ICECandidateTypeHost:

The public IP address will be used for the host candidate in the SDP.

ICECandidateTypeSrflx:

A server reflexive candidate with the given public IP address will be added

to the SDP.

Please note that if you choose ICECandidateTypeHost, then the private IP address won't be advertised with the peer. Also, this option cannot be used along with mDNS.

If you choose ICECandidateTypeSrflx, it simply adds a server reflexive candidate with the public IP. The host candidate is still available along with mDNS capabilities unaffected. Also, you cannot give STUN server URL at the same time. It will result in an error otherwise.

func (*SettingEngine) SetNetworkTypes

func (e *SettingEngine) SetNetworkTypes(candidateTypes []NetworkType)

SetNetworkTypes configures what types of candidate networks are supported during local and server reflexive gathering.

func (*SettingEngine) SetPrflxAcceptanceMinWait

func (e *SettingEngine) SetPrflxAcceptanceMinWait(t time.Duration)

SetPrflxAcceptanceMinWait sets the ICEPrflxAcceptanceMinWait

func (*SettingEngine) SetRelayAcceptanceMinWait

func (e *SettingEngine) SetRelayAcceptanceMinWait(t time.Duration)

SetRelayAcceptanceMinWait sets the ICERelayAcceptanceMinWait

func (*SettingEngine) SetSDPMediaLevelFingerprints

func (e *SettingEngine) SetSDPMediaLevelFingerprints(sdpMediaLevelFingerprints bool)

SetSDPMediaLevelFingerprints configures the logic for DTLS Fingerprint insertion If true, fingerprints will be inserted in the sdp at the fingerprint level, instead of the session level. This helps with compatibility with some webrtc implementations.

func (*SettingEngine) SetSRTCPReplayProtectionWindow

func (e *SettingEngine) SetSRTCPReplayProtectionWindow(n uint)

SetSRTCPReplayProtectionWindow sets a replay attack protection window size of SRTCP session.

func (*SettingEngine) SetSRTPReplayProtectionWindow

func (e *SettingEngine) SetSRTPReplayProtectionWindow(n uint)

SetSRTPReplayProtectionWindow sets a replay attack protection window size of SRTP session.

func (*SettingEngine) SetSrflxAcceptanceMinWait

func (e *SettingEngine) SetSrflxAcceptanceMinWait(t time.Duration)

SetSrflxAcceptanceMinWait sets the ICESrflxAcceptanceMinWait

func (*SettingEngine) SetVNet

func (e *SettingEngine) SetVNet(vnet *vnet.Net)

SetVNet sets the VNet instance that is passed to pion/ice

VNet is a virtual network layer for Pion, allowing users to simulate different topologies, latency, loss and jitter. This can be useful for learning WebRTC concepts or testing your application in a lab environment

type SignalingState

type SignalingState int

SignalingState indicates the signaling state of the offer/answer process.

const (
	// SignalingStateStable indicates there is no offer/answer exchange in
	// progress. This is also the initial state, in which case the local and
	// remote descriptions are nil.
	SignalingStateStable SignalingState = iota + 1

	// SignalingStateHaveLocalOffer indicates that a local description, of
	// type "offer", has been successfully applied.
	SignalingStateHaveLocalOffer

	// SignalingStateHaveRemoteOffer indicates that a remote description, of
	// type "offer", has been successfully applied.
	SignalingStateHaveRemoteOffer

	// SignalingStateHaveLocalPranswer indicates that a remote description
	// of type "offer" has been successfully applied and a local description
	// of type "pranswer" has been successfully applied.
	SignalingStateHaveLocalPranswer

	// SignalingStateHaveRemotePranswer indicates that a local description
	// of type "offer" has been successfully applied and a remote description
	// of type "pranswer" has been successfully applied.
	SignalingStateHaveRemotePranswer

	// SignalingStateClosed indicates The PeerConnection has been closed.
	SignalingStateClosed
)

func (SignalingState) String

func (t SignalingState) String() string

type Stats

type Stats interface{}

A Stats object contains a set of statistics copies out of a monitored component of the WebRTC stack at a specific time.

type StatsICECandidatePairState

type StatsICECandidatePairState string

StatsICECandidatePairState is the state of an ICE candidate pair used in the ICECandidatePairStats object.

const (
	// StatsICECandidatePairStateFrozen means a check for this pair hasn't been
	// performed, and it can't yet be performed until some other check succeeds,
	// allowing this pair to unfreeze and move into the Waiting state.
	StatsICECandidatePairStateFrozen StatsICECandidatePairState = "frozen"

	// StatsICECandidatePairStateWaiting means a check has not been performed for
	// this pair, and can be performed as soon as it is the highest-priority Waiting
	// pair on the check list.
	StatsICECandidatePairStateWaiting StatsICECandidatePairState = "waiting"

	// StatsICECandidatePairStateInProgress means a check has been sent for this pair,
	// but the transaction is in progress.
	StatsICECandidatePairStateInProgress StatsICECandidatePairState = "in-progress"

	// StatsICECandidatePairStateFailed means a check for this pair was already done
	// and failed, either never producing any response or producing an unrecoverable
	// failure response.
	StatsICECandidatePairStateFailed StatsICECandidatePairState = "failed"

	// StatsICECandidatePairStateSucceeded means a check for this pair was already
	// done and produced a successful result.
	StatsICECandidatePairStateSucceeded StatsICECandidatePairState = "succeeded"
)

type StatsReport

type StatsReport map[string]Stats

StatsReport collects Stats objects indexed by their ID.

func (StatsReport) GetConnectionStats

func (r StatsReport) GetConnectionStats(conn *PeerConnection) (PeerConnectionStats, bool)

GetConnectionStats is a helper method to return the associated stats for a given PeerConnection

func (StatsReport) GetDataChannelStats

func (r StatsReport) GetDataChannelStats(dc *DataChannel) (DataChannelStats, bool)

GetDataChannelStats is a helper method to return the associated stats for a given DataChannel

func (StatsReport) GetICECandidatePairStats

func (r StatsReport) GetICECandidatePairStats(c *ICECandidatePair) (ICECandidatePairStats, bool)

GetICECandidatePairStats is a helper method to return the associated stats for a given ICECandidatePair

func (StatsReport) GetICECandidateStats

func (r StatsReport) GetICECandidateStats(c *ICECandidate) (ICECandidateStats, bool)

GetICECandidateStats is a helper method to return the associated stats for a given ICECandidate

type StatsTimestamp

type StatsTimestamp float64

StatsTimestamp is a timestamp represented by the floating point number of milliseconds since the epoch.

func (StatsTimestamp) Time

func (s StatsTimestamp) Time() time.Time

Time returns the time.Time represented by this timestamp.

type StatsType

type StatsType string

StatsType indicates the type of the object that a Stats object represents.

const (
	// StatsTypeCodec is used by CodecStats.
	StatsTypeCodec StatsType = "codec"

	// StatsTypeInboundRTP is used by InboundRTPStreamStats.
	StatsTypeInboundRTP StatsType = "inbound-rtp"

	// StatsTypeOutboundRTP is used by OutboundRTPStreamStats.
	StatsTypeOutboundRTP StatsType = "outbound-rtp"

	// StatsTypeRemoteInboundRTP is used by RemoteInboundRTPStreamStats.
	StatsTypeRemoteInboundRTP StatsType = "remote-inbound-rtp"

	// StatsTypeRemoteOutboundRTP is used by RemoteOutboundRTPStreamStats.
	StatsTypeRemoteOutboundRTP StatsType = "remote-outbound-rtp"

	// StatsTypeCSRC is used by RTPContributingSourceStats.
	StatsTypeCSRC StatsType = "csrc"

	// StatsTypePeerConnection used by PeerConnectionStats.
	StatsTypePeerConnection StatsType = "peer-connection"

	// StatsTypeDataChannel is used by DataChannelStats.
	StatsTypeDataChannel StatsType = "data-channel"

	// StatsTypeStream is used by MediaStreamStats.
	StatsTypeStream StatsType = "stream"

	// StatsTypeTrack is used by SenderVideoTrackAttachmentStats and SenderAudioTrackAttachmentStats.
	StatsTypeTrack StatsType = "track"

	// StatsTypeSender is used by by the AudioSenderStats or VideoSenderStats depending on kind.
	StatsTypeSender StatsType = "sender"

	// StatsTypeReceiver is used by the AudioReceiverStats or VideoReceiverStats depending on kind.
	StatsTypeReceiver StatsType = "receiver"

	// StatsTypeTransport is used by TransportStats.
	StatsTypeTransport StatsType = "transport"

	// StatsTypeCandidatePair is used by ICECandidatePairStats.
	StatsTypeCandidatePair StatsType = "candidate-pair"

	// StatsTypeLocalCandidate is used by ICECandidateStats for the local candidate.
	StatsTypeLocalCandidate StatsType = "local-candidate"

	// StatsTypeRemoteCandidate is used by ICECandidateStats for the remote candidate.
	StatsTypeRemoteCandidate StatsType = "remote-candidate"

	// StatsTypeCertificate is used by CertificateStats.
	StatsTypeCertificate StatsType = "certificate"
)

type Track

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

Track represents a single media track

func NewTrack

func NewTrack(payloadType uint8, ssrc uint32, id, label string, codec *RTPCodec) (*Track, error)

NewTrack initializes a new *Track

func (*Track) Codec

func (t *Track) Codec() *RTPCodec

Codec gets the Codec of the track

func (*Track) FirstRtpPacket

func (t *Track) FirstRtpPacket() *rtp.Packet

FirstRtpPacket got the first pakcet

func (*Track) ID

func (t *Track) ID() string

ID gets the ID of the track

func (*Track) Kind

func (t *Track) Kind() RTPCodecType

Kind gets the Kind of the track

func (*Track) Label

func (t *Track) Label() string

Label gets the Label of the track

func (*Track) Packetizer

func (t *Track) Packetizer() rtp.Packetizer

Packetizer gets the Packetizer of the track

func (*Track) PayloadType

func (t *Track) PayloadType() uint8

PayloadType gets the PayloadType of the track

func (*Track) RID

func (t *Track) RID() string

RID gets the RTP Stream ID of this Track With Simulcast you will have multiple tracks with the same ID, but different RID values. In many cases a Track will not have an RID, so it is important to assert it is non-zero

func (*Track) Read

func (t *Track) Read(b []byte) (n int, err error)

Read reads data from the track. If this is a local track this will error

func (*Track) ReadRTP

func (t *Track) ReadRTP() (*rtp.Packet, error)

ReadRTP is a convenience method that wraps Read and unmarshals for you

func (*Track) SSRC

func (t *Track) SSRC() uint32

SSRC gets the SSRC of the track

func (*Track) Write

func (t *Track) Write(b []byte) (n int, err error)

Write writes data to the track. If this is a remote track this will error

func (*Track) WriteRTP

func (t *Track) WriteRTP(p *rtp.Packet) error

WriteRTP writes RTP packets to the track

func (*Track) WriteSample

func (t *Track) WriteSample(s media.Sample) error

WriteSample packetizes and writes to the track

type TransportStats

type TransportStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// PacketsSent represents the total number of packets sent over this transport.
	PacketsSent uint32 `json:"packetsSent"`

	// PacketsReceived represents the total number of packets received on this transport.
	PacketsReceived uint32 `json:"packetsReceived"`

	// BytesSent represents the total number of payload bytes sent on this PeerConnection
	// not including headers or padding.
	BytesSent uint64 `json:"bytesSent"`

	// BytesReceived represents the total number of bytes received on this PeerConnection
	// not including headers or padding.
	BytesReceived uint64 `json:"bytesReceived"`

	// RTCPTransportStatsID is the ID of the transport that gives stats for the RTCP
	// component If RTP and RTCP are not multiplexed and this record has only
	// the RTP component stats.
	RTCPTransportStatsID string `json:"rtcpTransportStatsId"`

	// ICERole is set to the current value of the "role" attribute of the underlying
	// DTLSTransport's "transport".
	ICERole ICERole `json:"iceRole"`

	// DTLSState is set to the current value of the "state" attribute of the underlying DTLSTransport.
	DTLSState DTLSTransportState `json:"dtlsState"`

	// SelectedCandidatePairID is a unique identifier that is associated to the object
	// that was inspected to produce the ICECandidatePairStats associated with this transport.
	SelectedCandidatePairID string `json:"selectedCandidatePairId"`

	// LocalCertificateID is the ID of the CertificateStats for the local certificate.
	// Present only if DTLS is negotiated.
	LocalCertificateID string `json:"localCertificateId"`

	// LocalCertificateID is the ID of the CertificateStats for the remote certificate.
	// Present only if DTLS is negotiated.
	RemoteCertificateID string `json:"remoteCertificateId"`

	// DTLSCipher is the descriptive name of the cipher suite used for the DTLS transport,
	// as defined in the "Description" column of the IANA cipher suite registry.
	DTLSCipher string `json:"dtlsCipher"`

	// SRTPCipher is the descriptive name of the protection profile used for the SRTP
	// transport, as defined in the "Profile" column of the IANA DTLS-SRTP protection
	// profile registry.
	SRTPCipher string `json:"srtpCipher"`
}

TransportStats contains transport statistics related to the PeerConnection object.

type VideoReceiverStats

type VideoReceiverStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// FrameWidth represents the width of the last processed frame for this track.
	// Before the first frame is processed this attribute is missing.
	FrameWidth uint32 `json:"frameWidth"`

	// FrameHeight represents the height of the last processed frame for this track.
	// Before the first frame is processed this attribute is missing.
	FrameHeight uint32 `json:"frameHeight"`

	// FramesPerSecond represents the nominal FPS value before the degradation preference
	// is applied. It is the number of complete frames in the last second. For sending
	// tracks it is the current captured FPS and for the receiving tracks it is the
	// current decoding framerate.
	FramesPerSecond float64 `json:"framesPerSecond"`

	// EstimatedPlayoutTimestamp is the estimated playout time of this receiver's
	// track. The playout time is the NTP timestamp of the last playable sample that
	// has a known timestamp (from an RTCP SR packet mapping RTP timestamps to NTP
	// timestamps), extrapolated with the time elapsed since it was ready to be played out.
	// This is the "current time" of the track in NTP clock time of the sender and
	// can be present even if there is no audio currently playing.
	//
	// This can be useful for estimating how much audio and video is out of
	// sync for two tracks from the same source:
	// 		AudioTrackStats.EstimatedPlayoutTimestamp - VideoTrackStats.EstimatedPlayoutTimestamp
	EstimatedPlayoutTimestamp StatsTimestamp `json:"estimatedPlayoutTimestamp"`

	// JitterBufferDelay is the sum of the time, in seconds, each sample takes from
	// the time it is received and to the time it exits the jitter buffer.
	// This increases upon samples exiting, having completed their time in the buffer
	// (incrementing JitterBufferEmittedCount). The average jitter buffer delay can
	// be calculated by dividing the JitterBufferDelay with the JitterBufferEmittedCount.
	JitterBufferDelay float64 `json:"jitterBufferDelay"`

	// JitterBufferEmittedCount is the total number of samples that have come out
	// of the jitter buffer (increasing JitterBufferDelay).
	JitterBufferEmittedCount uint64 `json:"jitterBufferEmittedCount"`

	// FramesReceived Represents the total number of complete frames received for
	// this receiver. This metric is incremented when the complete frame is received.
	FramesReceived uint32 `json:"framesReceived"`

	// KeyFramesReceived represents the total number of complete key frames received
	// for this MediaStreamTrack, such as Infra-frames in VP8 [RFC6386] or I-frames
	// in H.264 [RFC6184]. This is a subset of framesReceived. `framesReceived - keyFramesReceived`
	// gives you the number of delta frames received. This metric is incremented when
	// the complete key frame is received. It is not incremented if a partial key
	// frames is received and sent for decoding, i.e., the frame could not be recovered
	// via retransmission or FEC.
	KeyFramesReceived uint32 `json:"keyFramesReceived"`

	// FramesDecoded represents the total number of frames correctly decoded for this
	// SSRC, i.e., frames that would be displayed if no frames are dropped.
	FramesDecoded uint32 `json:"framesDecoded"`

	// FramesDropped is the total number of frames dropped predecode or dropped
	// because the frame missed its display deadline for this receiver's track.
	FramesDropped uint32 `json:"framesDropped"`

	// The cumulative number of partial frames lost. This metric is incremented when
	// the frame is sent to the decoder. If the partial frame is received and recovered
	// via retransmission or FEC before decoding, the FramesReceived counter is incremented.
	PartialFramesLost uint32 `json:"partialFramesLost"`

	// FullFramesLost is the cumulative number of full frames lost.
	FullFramesLost uint32 `json:"fullFramesLost"`
}

VideoReceiverStats contains video metrics related to a specific receiver.

type VideoSenderStats

type VideoSenderStats struct {
	// Timestamp is the timestamp associated with this object.
	Timestamp StatsTimestamp `json:"timestamp"`

	// Type is the object's StatsType
	Type StatsType `json:"type"`

	// ID is a unique id that is associated with the component inspected to produce
	// this Stats object. Two Stats objects will have the same ID if they were produced
	// by inspecting the same underlying object.
	ID string `json:"id"`

	// FramesCaptured represents the total number of frames captured, before encoding,
	// for this RTPSender (or for this MediaStreamTrack, if type is "track"). For example,
	// if type is "sender" and this sender's track represents a camera, then this is the
	// number of frames produced by the camera for this track while being sent by this sender,
	// combined with the number of frames produced by all tracks previously attached to this
	// sender while being sent by this sender. Framerates can vary due to hardware limitations
	// or environmental factors such as lighting conditions.
	FramesCaptured uint32 `json:"framesCaptured"`

	// FramesSent represents the total number of frames sent by this RTPSender
	// (or for this MediaStreamTrack, if type is "track").
	FramesSent uint32 `json:"framesSent"`

	// HugeFramesSent represents the total number of huge frames sent by this RTPSender
	// (or for this MediaStreamTrack, if type is "track"). Huge frames, by definition,
	// are frames that have an encoded size at least 2.5 times the average size of the frames.
	// The average size of the frames is defined as the target bitrate per second divided
	// by the target fps at the time the frame was encoded. These are usually complex
	// to encode frames with a lot of changes in the picture. This can be used to estimate,
	// e.g slide changes in the streamed presentation. If a huge frame is also a key frame,
	// then both counters HugeFramesSent and KeyFramesSent are incremented.
	HugeFramesSent uint32 `json:"hugeFramesSent"`

	// KeyFramesSent represents the total number of key frames sent by this RTPSender
	// (or for this MediaStreamTrack, if type is "track"), such as Infra-frames in
	// VP8 [RFC6386] or I-frames in H.264 [RFC6184]. This is a subset of FramesSent.
	// FramesSent - KeyFramesSent gives you the number of delta frames sent.
	KeyFramesSent uint32 `json:"keyFramesSent"`
}

VideoSenderStats represents the stats about one video sender of a PeerConnection object for which one calls GetStats.

It appears in the stats as soon as the sender is added by either AddTrack or AddTransceiver, or by media negotiation.

Directories

Path Synopsis
internal/signal
Package signal contains helpers to exchange the SDP session description between examples.
Package signal contains helpers to exchange the SDP session description between examples.
pkg
media
Package media provides media writer and filters
Package media provides media writer and filters
media/h264writer
Package h264writer implements H264 media container writer
Package h264writer implements H264 media container writer
media/ivfreader
Package ivfreader implements IVF media container reader
Package ivfreader implements IVF media container reader
media/ivfwriter
Package ivfwriter implements IVF media container writer
Package ivfwriter implements IVF media container writer
media/oggreader
Package oggreader implements the Ogg media container reader
Package oggreader implements the Ogg media container reader
media/oggwriter
Package oggwriter implements OGG media container writer
Package oggwriter implements OGG media container writer
media/rtpdump
Package rtpdump implements the RTPDump file format documented at https://www.cs.columbia.edu/irt/software/rtptools/
Package rtpdump implements the RTPDump file format documented at https://www.cs.columbia.edu/irt/software/rtptools/
media/samplebuilder
Package samplebuilder provides functionality to reconstruct media frames from RTP packets.
Package samplebuilder provides functionality to reconstruct media frames from RTP packets.
mux
Package mux multiplexes packets on a single socket (RFC7983)
Package mux multiplexes packets on a single socket (RFC7983)
null
Package null is used to represent values where the 0 value is significant This pattern is common in ECMAScript, this allows us to maintain a matching API
Package null is used to represent values where the 0 value is significant This pattern is common in ECMAScript, this allows us to maintain a matching API
rtcerr
Package rtcerr implements the error wrappers defined throughout the WebRTC 1.0 specifications.
Package rtcerr implements the error wrappers defined throughout the WebRTC 1.0 specifications.
util
Package util provides auxiliary functions internally used in webrtc package
Package util provides auxiliary functions internally used in webrtc package

Jump to

Keyboard shortcuts

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