webrtc package - github.com/pion/webrtc/v4 - Go Packages (original) (raw)
Package webrtc implements the WebRTC 1.0 as defined in W3C WebRTC specification document.
func ConfigureFlexFEC03(payloadType PayloadType, mediaEngine *MediaEngine, ...) error
func ConfigureNack(mediaEngine *MediaEngine, interceptorRegistry *interceptor.Registry) error
func ConfigureRTCPReports(interceptorRegistry *interceptor.Registry) error
func ConfigureSimulcastExtensionHeaders(mediaEngine *MediaEngine) error
func ConfigureStatsInterceptor(interceptorRegistry *interceptor.Registry) error
func ConfigureTWCCSender(mediaEngine *MediaEngine, interceptorRegistry *interceptor.Registry) error
func GatheringCompletePromise(pc *PeerConnection) (gatherComplete <-chan struct{})
func NewAudioPlayoutStatsProvider(id string) *defaultAudioPlayoutStatsProvider
func NewICEUDPMux(logger logging.LeveledLogger, udpConn net.PacketConn) ice.UDPMux
func WithInterceptorRegistry(ir *interceptor.Registry) func(a *API)
func WithPayloader(h func(RTPCodecCapability) (rtp.Payloader, error)) func(*TrackLocalStaticRTP)
func WithRTPTimestamp(timestamp uint32) func(*TrackLocalStaticRTP)
- func (api *API) NewDTLSTransport(transport *ICETransport, certificates []Certificate) (*DTLSTransport, error)
- func (api *API) NewDataChannel(transport *SCTPTransport, params *DataChannelParameters) (*DataChannel, error)
- func (api *API) NewICEGatherer(opts ICEGatherOptions) (*ICEGatherer, error)
- func (api *API) NewICETransport(gatherer *ICEGatherer) *ICETransport
- func (api *API) NewPeerConnection(configuration Configuration) (*PeerConnection, error)
- func (api *API) NewRTPReceiver(kind RTPCodecType, transport *DTLSTransport) (*RTPReceiver, error)
- func (api *API) NewRTPSender(track TrackLocal, transport *DTLSTransport) (*RTPSender, error)
- func (api *API) NewSCTPTransport(dtls *DTLSTransport) *SCTPTransport
- func CertificateFromPEM(pems string) (*Certificate, error)
- func CertificateFromX509(privateKey crypto.PrivateKey, certificate *x509.Certificate) Certificate
- func GenerateCertificate(secretKey crypto.PrivateKey) (*Certificate, error)
- func NewCertificate(key crypto.PrivateKey, tpl x509.Certificate) (*Certificate, error)
- func (t *DTLSTransport) GetLocalParameters() (DTLSParameters, error)
- func (t *DTLSTransport) GetRemoteCertificate() []byte
- func (t *DTLSTransport) ICETransport() *ICETransport
- func (t *DTLSTransport) OnStateChange(f func(DTLSTransportState))
- func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error
- func (t *DTLSTransport) State() DTLSTransportState
- func (t *DTLSTransport) Stop() error
- func (t *DTLSTransport) WriteRTCP(pkts []rtcp.Packet) (int, error)
- func (d *DataChannel) BufferedAmount() uint64
- func (d *DataChannel) BufferedAmountLowThreshold() uint64
- func (d *DataChannel) Close() error
- func (d *DataChannel) Detach() (datachannel.ReadWriteCloser, error)
- func (d *DataChannel) DetachWithDeadline() (datachannel.ReadWriteCloserDeadliner, error)
- func (d *DataChannel) GracefulClose() error
- func (d *DataChannel) ID() *uint16
- func (d *DataChannel) Label() string
- func (d *DataChannel) MaxPacketLifeTime() *uint16
- func (d *DataChannel) MaxRetransmits() *uint16
- func (d *DataChannel) Negotiated() bool
- func (d *DataChannel) OnBufferedAmountLow(f func())
- func (d *DataChannel) OnClose(f func())
- func (d *DataChannel) OnDial(f func())
- func (d *DataChannel) OnError(f func(err error))
- func (d *DataChannel) OnMessage(f func(msg DataChannelMessage))
- func (d *DataChannel) OnOpen(f func())
- func (d *DataChannel) Ordered() bool
- func (d *DataChannel) Protocol() string
- func (d *DataChannel) ReadyState() DataChannelState
- func (d *DataChannel) Send(data []byte) error
- func (d *DataChannel) SendText(s string) error
- func (d *DataChannel) SetBufferedAmountLowThreshold(th uint64)
- func (d *DataChannel) Transport() *SCTPTransport
- func (g *ICEGatherer) Close() error
- func (g *ICEGatherer) Gather() error
- func (g *ICEGatherer) GetLocalCandidates() ([]ICECandidate, error)
- func (g *ICEGatherer) GetLocalParameters() (ICEParameters, error)
- func (g *ICEGatherer) GracefulClose() error
- func (g *ICEGatherer) OnLocalCandidate(f func(*ICECandidate))
- func (g *ICEGatherer) OnStateChange(f func(ICEGathererState))
- func (g *ICEGatherer) State() ICEGathererState
- func (t *ICETransport) AddRemoteCandidate(remoteCandidate *ICECandidate) error
- func (t *ICETransport) GetLocalParameters() (ICEParameters, error)
- func (t *ICETransport) GetRemoteParameters() (ICEParameters, error)
- func (t *ICETransport) GetSelectedCandidatePair() (*ICECandidatePair, error)
- func (t *ICETransport) GetSelectedCandidatePairStats() (ICECandidatePairStats, bool)
- func (t *ICETransport) GracefulStop() error
- func (t *ICETransport) OnConnectionStateChange(f func(ICETransportState))
- func (t *ICETransport) OnSelectedCandidatePairChange(f func(*ICECandidatePair))
- func (t *ICETransport) Role() ICERole
- func (t *ICETransport) SetRemoteCandidates(remoteCandidates []ICECandidate) error
- func (t *ICETransport) Start(gatherer *ICEGatherer, params ICEParameters, role *ICERole) error
- func (t *ICETransport) State() ICETransportState
- func (t *ICETransport) Stop() error
- func (m *MediaEngine) RegisterCodec(codec RTPCodecParameters, typ RTPCodecType) error
- func (m *MediaEngine) RegisterDefaultCodecs() error
- func (m *MediaEngine) RegisterFeedback(feedback RTCPFeedback, typ RTPCodecType)
- func (m *MediaEngine) RegisterHeaderExtension(extension RTPHeaderExtensionCapability, typ RTPCodecType, ...) error
- func (pc *PeerConnection) AddICECandidate(candidate ICECandidateInit) error
- func (pc *PeerConnection) AddTrack(track TrackLocal) (*RTPSender, error)
- func (pc *PeerConnection) AddTransceiverFromKind(kind RTPCodecType, init ...RTPTransceiverInit) (t *RTPTransceiver, err error)
- func (pc *PeerConnection) AddTransceiverFromTrack(track TrackLocal, init ...RTPTransceiverInit) (t *RTPTransceiver, err error)
- func (pc *PeerConnection) CanTrickleICECandidates() ICETrickleCapability
- func (pc *PeerConnection) Close() error
- func (pc *PeerConnection) ConnectionState() PeerConnectionState
- func (pc *PeerConnection) CreateAnswer(options *AnswerOptions) (SessionDescription, error)
- func (pc *PeerConnection) CreateDataChannel(label string, options *DataChannelInit) (*DataChannel, error)
- func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription, error)
- func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription
- func (pc *PeerConnection) CurrentRemoteDescription() *SessionDescription
- func (pc *PeerConnection) GetConfiguration() Configuration
- func (pc *PeerConnection) GetReceivers() (receivers []*RTPReceiver)
- func (pc *PeerConnection) GetSenders() (result []*RTPSender)
- func (pc *PeerConnection) GetStats() StatsReport
- func (pc *PeerConnection) GetTransceivers() []*RTPTransceiver
- func (pc *PeerConnection) GracefulClose() error
- func (pc *PeerConnection) ICEConnectionState() ICEConnectionState
- func (pc *PeerConnection) ICEGatheringState() ICEGatheringState
- func (pc *PeerConnection) ID() string
- func (pc *PeerConnection) LocalDescription() *SessionDescription
- func (pc *PeerConnection) OnConnectionStateChange(f func(PeerConnectionState))
- func (pc *PeerConnection) OnDataChannel(f func(*DataChannel))
- func (pc *PeerConnection) OnICECandidate(f func(*ICECandidate))
- func (pc *PeerConnection) OnICEConnectionStateChange(f func(ICEConnectionState))
- func (pc *PeerConnection) OnICEGatheringStateChange(f func(ICEGatheringState))
- func (pc *PeerConnection) OnNegotiationNeeded(f func())
- func (pc *PeerConnection) OnSignalingStateChange(f func(SignalingState))
- func (pc *PeerConnection) OnTrack(f func(*TrackRemote, *RTPReceiver))
- func (pc *PeerConnection) PendingLocalDescription() *SessionDescription
- func (pc *PeerConnection) PendingRemoteDescription() *SessionDescription
- func (pc *PeerConnection) RemoteDescription() *SessionDescription
- func (pc *PeerConnection) RemoveTrack(sender *RTPSender) (err error)
- func (pc *PeerConnection) SCTP() *SCTPTransport
- func (pc *PeerConnection) SetConfiguration(configuration Configuration) error
- func (pc *PeerConnection) SetIdentityProvider(string) error
- func (pc *PeerConnection) SetLocalDescription(desc SessionDescription) error
- func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error
- func (pc *PeerConnection) SignalingState() SignalingState
- func (pc *PeerConnection) WriteRTCP(pkts []rtcp.Packet) error
- func (r *RTPReceiver) GetParameters() RTPParameters
- func (r *RTPReceiver) RTPTransceiver() *RTPTransceiver
- func (r *RTPReceiver) Read(b []byte) (n int, a interceptor.Attributes, err error)
- func (r *RTPReceiver) ReadRTCP() ([]rtcp.Packet, interceptor.Attributes, error)
- func (r *RTPReceiver) ReadSimulcast(b []byte, rid string) (n int, a interceptor.Attributes, err error)
- func (r *RTPReceiver) ReadSimulcastRTCP(rid string) ([]rtcp.Packet, interceptor.Attributes, error)
- func (r *RTPReceiver) Receive(parameters RTPReceiveParameters) error
- func (r *RTPReceiver) SetRTPParameters(params RTPParameters)
- func (r *RTPReceiver) SetReadDeadline(t time.Time) error
- func (r *RTPReceiver) SetReadDeadlineSimulcast(deadline time.Time, rid string) error
- func (r *RTPReceiver) Stop() error
- func (r *RTPReceiver) Track() *TrackRemote
- func (r *RTPReceiver) Tracks() []*TrackRemote
- func (r *RTPReceiver) Transport() *DTLSTransport
- func (r *RTPSender) AddEncoding(track TrackLocal) error
- func (r *RTPSender) GetParameters() RTPSendParameters
- func (r *RTPSender) Read(b []byte) (n int, a interceptor.Attributes, err error)
- func (r *RTPSender) ReadRTCP() ([]rtcp.Packet, interceptor.Attributes, error)
- func (r *RTPSender) ReadSimulcast(b []byte, rid string) (n int, a interceptor.Attributes, err error)
- func (r *RTPSender) ReadSimulcastRTCP(rid string) ([]rtcp.Packet, interceptor.Attributes, error)
- func (r *RTPSender) ReplaceTrack(track TrackLocal) error
- func (r *RTPSender) Send(parameters RTPSendParameters) error
- func (r *RTPSender) SetReadDeadline(t time.Time) error
- func (r *RTPSender) SetReadDeadlineSimulcast(deadline time.Time, rid string) error
- func (r *RTPSender) Stop() error
- func (r *RTPSender) Track() TrackLocal
- func (r *RTPSender) Transport() *DTLSTransport
- func (t *RTPTransceiver) Direction() RTPTransceiverDirection
- func (t *RTPTransceiver) Kind() RTPCodecType
- func (t *RTPTransceiver) Mid() string
- func (t *RTPTransceiver) Receiver() *RTPReceiver
- func (t *RTPTransceiver) Sender() *RTPSender
- func (t *RTPTransceiver) SetCodecPreferences(codecs []RTPCodecParameters) error
- func (t *RTPTransceiver) SetMid(mid string) error
- func (t *RTPTransceiver) SetSender(s *RTPSender, track TrackLocal) error
- func (t *RTPTransceiver) Stop() error
- func (r *SCTPTransport) BufferedAmount() int
- func (r *SCTPTransport) GetCapabilities() SCTPCapabilities
- func (r *SCTPTransport) MaxChannels() uint16
- func (r *SCTPTransport) OnClose(f func(err error))
- func (r *SCTPTransport) OnDataChannel(f func(*DataChannel))
- func (r *SCTPTransport) OnDataChannelOpened(f func(*DataChannel))
- func (r *SCTPTransport) OnError(f func(err error))
- func (r *SCTPTransport) Start(capabilities SCTPCapabilities) error
- func (r *SCTPTransport) State() SCTPTransportState
- func (r *SCTPTransport) Stop() error
- func (r *SCTPTransport) Transport() *DTLSTransport
- func (e *SettingEngine) DetachDataChannels()
- func (e *SettingEngine) DisableActiveTCP(isDisabled bool)
- func (e *SettingEngine) DisableCertificateFingerprintVerification(isDisabled bool)
- func (e *SettingEngine) DisableCloseByDTLS(isEnabled bool)
- func (e *SettingEngine) DisableMediaEngineCopy(isDisabled bool)
- func (e *SettingEngine) DisableMediaEngineMultipleCodecs(isDisabled bool)
- func (e *SettingEngine) DisableSRTCPReplayProtection(isDisabled bool)
- func (e *SettingEngine) DisableSRTPReplayProtection(isDisabled bool)
- func (e *SettingEngine) EnableDataChannelBlockWrite(nonblockWrite bool)
- func (e *SettingEngine) EnableSCTPZeroChecksum(isEnabled bool)
- func (e *SettingEngine) SetAnsweringDTLSRole(role DTLSRole) error
- func (e *SettingEngine) SetDTLSCertificateRequestMessageHook(hook func(handshake.MessageCertificateRequest) handshake.Message)
- func (e *SettingEngine) SetDTLSCipherSuites(cipherSuites ...dtls.CipherSuiteID)
- func (e *SettingEngine) SetDTLSClientAuth(clientAuth dtls.ClientAuthType)
- func (e *SettingEngine) SetDTLSClientCAs(clientCAs *x509.CertPool)
- func (e *SettingEngine) SetDTLSClientHelloMessageHook(hook func(handshake.MessageClientHello) handshake.Message)
- func (e *SettingEngine) SetDTLSConnectContextMaker(connectContextMaker func() (context.Context, func()))
- func (e *SettingEngine) SetDTLSCustomerCipherSuites(customCipherSuites func() []dtls.CipherSuite)
- func (e *SettingEngine) SetDTLSDisableInsecureSkipVerify(disable bool)
- func (e *SettingEngine) SetDTLSEllipticCurves(ellipticCurves ...dtlsElliptic.Curve)
- func (e *SettingEngine) SetDTLSExtendedMasterSecret(extendedMasterSecret dtls.ExtendedMasterSecretType)
- func (e *SettingEngine) SetDTLSInsecureSkipHelloVerify(skip bool)
- func (e *SettingEngine) SetDTLSKeyLogWriter(writer io.Writer)
- func (e *SettingEngine) SetDTLSReplayProtectionWindow(n uint)
- func (e *SettingEngine) SetDTLSRetransmissionInterval(interval time.Duration)
- func (e *SettingEngine) SetDTLSRootCAs(rootCAs *x509.CertPool)
- func (e *SettingEngine) SetDTLSServerHelloMessageHook(hook func(handshake.MessageServerHello) handshake.Message)
- func (e *SettingEngine) SetEphemeralUDPPortRange(portMin, portMax uint16) error
- func (e *SettingEngine) SetFireOnTrackBeforeFirstRTP(fireOnTrackBeforeFirstRTP bool)
- func (e *SettingEngine) SetHandleUndeclaredSSRCWithoutAnswer(handleUndeclaredSSRCWithoutAnswer bool)
- func (e *SettingEngine) SetHostAcceptanceMinWait(t time.Duration)
- func (e *SettingEngine) SetICEBindingRequestHandler(...)
- func (e *SettingEngine) SetICECredentials(usernameFragment, password string)
- func (e *SettingEngine) SetICEMaxBindingRequests(d uint16)
- func (e *SettingEngine) SetICEMulticastDNSMode(multicastDNSMode ice.MulticastDNSMode)
- func (e *SettingEngine) SetICEProxyDialer(d proxy.Dialer)
- func (e *SettingEngine) SetICETCPMux(tcpMux ice.TCPMux)
- func (e *SettingEngine) SetICETimeouts(disconnectedTimeout, failedTimeout, keepAliveInterval time.Duration)
- func (e *SettingEngine) SetICEUDPMux(udpMux ice.UDPMux)
- func (e *SettingEngine) SetIPFilter(filter func(net.IP) (keep bool))
- func (e *SettingEngine) SetIgnoreRidPauseForRecv(ignoreRidPauseForRecv bool)
- func (e *SettingEngine) SetIncludeLoopbackCandidate(include bool)
- func (e *SettingEngine) SetInterfaceFilter(filter func(string) (keep bool))
- func (e *SettingEngine) SetLite(lite bool)
- func (e *SettingEngine) SetMulticastDNSHostName(hostName string)
- func (e *SettingEngine) SetNAT1To1IPs(ips []string, candidateType ICECandidateType)
- func (e *SettingEngine) SetNet(net transport.Net)
- func (e *SettingEngine) SetNetworkTypes(candidateTypes []NetworkType)
- func (e *SettingEngine) SetPrflxAcceptanceMinWait(t time.Duration)
- func (e *SettingEngine) SetReceiveMTU(receiveMTU uint)
- func (e *SettingEngine) SetRelayAcceptanceMinWait(t time.Duration)
- func (e *SettingEngine) SetSCTPCwndCAStep(cwndCAStep uint32)
- func (e *SettingEngine) SetSCTPFastRtxWnd(fastRtxWnd uint32)
- func (e *SettingEngine) SetSCTPMaxMessageSize(maxMessageSize uint32)
- func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32)
- func (e *SettingEngine) SetSCTPMinCwnd(minCwnd uint32)
- func (e *SettingEngine) SetSCTPRTOMax(rtoMax time.Duration)
- func (e *SettingEngine) SetSDPMediaLevelFingerprints(sdpMediaLevelFingerprints bool)
- func (e *SettingEngine) SetSRTCPReplayProtectionWindow(n uint)
- func (e *SettingEngine) SetSRTPProtectionProfiles(profiles ...dtls.SRTPProtectionProfile)
- func (e *SettingEngine) SetSRTPReplayProtectionWindow(n uint)
- func (e *SettingEngine) SetSTUNGatherTimeout(t time.Duration)
- func (e *SettingEngine) SetSrflxAcceptanceMinWait(t time.Duration)
- func (r StatsReport) GetCertificateStats(c *Certificate) (CertificateStats, bool)
- func (r StatsReport) GetCodecStats(c *RTPCodecParameters) (CodecStats, bool)
- func (r StatsReport) GetConnectionStats(conn *PeerConnection) (PeerConnectionStats, bool)
- func (r StatsReport) GetDataChannelStats(dc *DataChannel) (DataChannelStats, bool)
- func (r StatsReport) GetICECandidatePairStats(c *ICECandidatePair) (ICECandidatePairStats, bool)
- func (r StatsReport) GetICECandidateStats(c *ICECandidate) (ICECandidateStats, bool)
- func (s *TrackLocalStaticRTP) Bind(trackContext TrackLocalContext) (RTPCodecParameters, error)
- func (s *TrackLocalStaticRTP) Codec() RTPCodecCapability
- func (s *TrackLocalStaticRTP) ID() string
- func (s *TrackLocalStaticRTP) Kind() RTPCodecType
- func (s *TrackLocalStaticRTP) RID() string
- func (s *TrackLocalStaticRTP) StreamID() string
- func (s *TrackLocalStaticRTP) Unbind(t TrackLocalContext) error
- func (s *TrackLocalStaticRTP) Write(b []byte) (n int, err error)
- func (s *TrackLocalStaticRTP) WriteRTP(p *rtp.Packet) error
- func (s *TrackLocalStaticSample) Bind(t TrackLocalContext) (RTPCodecParameters, error)
- func (s *TrackLocalStaticSample) Codec() RTPCodecCapability
- func (s *TrackLocalStaticSample) GeneratePadding(samples uint32) error
- func (s *TrackLocalStaticSample) ID() string
- func (s *TrackLocalStaticSample) Kind() RTPCodecType
- func (s *TrackLocalStaticSample) RID() string
- func (s *TrackLocalStaticSample) StreamID() string
- func (s *TrackLocalStaticSample) Unbind(t TrackLocalContext) error
- func (s *TrackLocalStaticSample) WriteSample(sample media.Sample) error
- func (t *TrackRemote) Codec() RTPCodecParameters
- func (t *TrackRemote) HasRTX() bool
- func (t *TrackRemote) ID() string
- func (t *TrackRemote) Kind() RTPCodecType
- func (t *TrackRemote) Msid() string
- func (t *TrackRemote) PayloadType() PayloadType
- func (t *TrackRemote) RID() string
- func (t *TrackRemote) Read(b []byte) (n int, attributes interceptor.Attributes, err error)
- func (t *TrackRemote) ReadRTP() (*rtp.Packet, interceptor.Attributes, error)
- func (t *TrackRemote) RtxSSRC() SSRC
- func (t *TrackRemote) SSRC() SSRC
- func (t *TrackRemote) SetReadDeadline(deadline time.Time) error
- func (t *TrackRemote) StreamID() string
const (
AttributeRtxPayloadType = "rtx_payload_type"
AttributeRtxSsrc = "rtx_ssrc"
AttributeRtxSequenceNumber = "rtx_sequence_number")
const (
MimeTypeH264 = "video/H264"
MimeTypeH265 = "video/H265"
MimeTypeOpus = "audio/opus"
MimeTypeVP8 = "video/VP8"
MimeTypeVP9 = "video/VP9"
MimeTypeAV1 = "video/AV1"
MimeTypeG722 = "audio/G722"
MimeTypePCMU = "audio/PCMU"
MimeTypePCMA = "audio/PCMA"
MimeTypeRTX = "video/rtx"
MimeTypeFlexFEC = "video/flexfec"
MimeTypeFlexFEC03 = "video/flexfec-03"
MimeTypeUlpFEC = "video/ulpfec")
const (
TypeRTCPFBTransportCC = "transport-cc"
TypeRTCPFBGoogREMB = "goog-remb"
TypeRTCPFBACK = "ack"
TypeRTCPFBCCM = "ccm"
TypeRTCPFBNACK = "nack")
var (
ErrUnknownType = [errors](/errors).[New](/errors#New)("unknown")
ErrConnectionClosed = [errors](/errors).[New](/errors#New)("connection closed")
ErrDataChannelNotOpen = [errors](/errors).[New](/errors#New)("data channel not open")
ErrCertificateExpired = [errors](/errors).[New](/errors#New)("x509Cert expired")
ErrNoTurnCredentials = [errors](/errors).[New](/errors#New)("turn server credentials required")
ErrTurnCredentials = [errors](/errors).[New](/errors#New)("invalid turn server credentials")
ErrExistingTrack = [errors](/errors).[New](/errors#New)("track already exists")
ErrPrivateKeyType = [errors](/errors).[New](/errors#New)("private key type not supported")
ErrModifyingPeerIdentity = [errors](/errors).[New](/errors#New)("peerIdentity cannot be modified")
ErrModifyingCertificates = [errors](/errors).[New](/errors#New)("certificates cannot be modified")
ErrModifyingBundlePolicy = [errors](/errors).[New](/errors#New)("bundle policy cannot be modified")
ErrModifyingRTCPMuxPolicy = [errors](/errors).[New](/errors#New)("rtcp mux policy cannot be modified")
ErrModifyingICECandidatePoolSize = [errors](/errors).[New](/errors#New)("ice candidate pool size cannot be modified")
ErrStringSizeLimit = [errors](/errors).[New](/errors#New)("data channel label exceeds size limit")
ErrMaxDataChannelID = [errors](/errors).[New](/errors#New)("maximum number ID for datachannel specified")
ErrNegotiatedWithoutID = [errors](/errors).[New](/errors#New)("negotiated set without channel id")
ErrRetransmitsOrPacketLifeTime = [errors](/errors).[New](/errors#New)("both MaxPacketLifeTime and MaxRetransmits was set")
ErrCodecNotFound = [errors](/errors).[New](/errors#New)("codec not found")
ErrNoRemoteDescription = [errors](/errors).[New](/errors#New)("remote description is not set")
ErrIncorrectSDPSemantics = [errors](/errors).[New](/errors#New)("remote SessionDescription semantics does not match configuration")
ErrIncorrectSignalingState = [errors](/errors).[New](/errors#New)("operation can not be run in current signaling state")
ErrProtocolTooLarge = [errors](/errors).[New](/errors#New)("protocol is larger then 65535 bytes")
ErrSenderNotCreatedByConnection = [errors](/errors).[New](/errors#New)("RtpSender not created by this PeerConnection")
ErrSessionDescriptionNoFingerprint = [errors](/errors).[New](/errors#New)("SetRemoteDescription called with no fingerprint")
ErrSessionDescriptionInvalidFingerprint = [errors](/errors).[New](/errors#New)("SetRemoteDescription called with an invalid fingerprint")
ErrSessionDescriptionConflictingFingerprints = [errors](/errors).[New](/errors#New)(
"SetRemoteDescription called with multiple conflicting fingerprint",
)
ErrSessionDescriptionMissingIceUfrag = [errors](/errors).[New](/errors#New)("SetRemoteDescription called with no ice-ufrag")
ErrSessionDescriptionMissingIcePwd = [errors](/errors).[New](/errors#New)("SetRemoteDescription called with no ice-pwd")
ErrSessionDescriptionConflictingIceUfrag = [errors](/errors).[New](/errors#New)(
"SetRemoteDescription called with multiple conflicting ice-ufrag values",
)
ErrSessionDescriptionConflictingIcePwd = [errors](/errors).[New](/errors#New)(
"SetRemoteDescription called with multiple conflicting ice-pwd values",
)
ErrNoSRTPProtectionProfile = [errors](/errors).[New](/errors#New)("DTLS Handshake completed and no SRTP Protection Profile was chosen")
ErrFailedToGenerateCertificateFingerprint = [errors](/errors).[New](/errors#New)("failed to generate certificate fingerprint")
ErrNoCodecsAvailable = [errors](/errors).[New](/errors#New)("operation failed no codecs are available")
ErrUnsupportedCodec = [errors](/errors).[New](/errors#New)("unable to start track, codec is not supported by remote")
ErrSenderWithNoCodecs = [errors](/errors).[New](/errors#New)("unable to populate media section, RTPSender created with no codecs")
ErrCodecAlreadyRegistered = [errors](/errors).[New](/errors#New)("codec already registered for same payload type")
ErrRTPSenderNewTrackHasIncorrectKind = [errors](/errors).[New](/errors#New)("new track must be of the same kind as previous")
ErrRTPSenderNewTrackHasIncorrectEnvelope = [errors](/errors).[New](/errors#New)("new track must have the same envelope as previous")
ErrUnbindFailed = [errors](/errors).[New](/errors#New)("failed to unbind TrackLocal from PeerConnection")
ErrNoPayloaderForCodec = [errors](/errors).[New](/errors#New)("the requested codec does not have a payloader")
ErrRegisterHeaderExtensionInvalidDirection = [errors](/errors).[New](/errors#New)(
"a header extension must be registered as 'recvonly', 'sendonly' or both",
)
ErrSimulcastProbeOverflow = [errors](/errors).[New](/errors#New)("simulcast probe limit has been reached, new SSRC has been discarded")
ErrSDPUnmarshalling = [errors](/errors).[New](/errors#New)("failed to unmarshal SDP"))
ConfigureFlexFEC03 registers flexfec-03 codec with provided payloadType in mediaEngine and adds corresponding interceptor to the registry. Note that this function should be called before any other interceptor that modifies RTP packets (i.e. TWCCHeaderExtensionSender) is added to the registry, so that packets generated by flexfec interceptor are not modified.
ConfigureNack will setup everything necessary for handling generating/responding to nack messages.
ConfigureRTCPReports will setup everything necessary for generating Sender and Receiver Reports.
func ConfigureSimulcastExtensionHeaders(mediaEngine *MediaEngine) error
ConfigureSimulcastExtensionHeaders enables the RTP Extension Headers needed for Simulcast.
ConfigureStatsInterceptor will setup everything necessary for generating RTP stream statistics.
ConfigureTWCCHeaderExtensionSender will setup everything necessary for adding a TWCC header extension to outgoing RTP packets. This will allow the remote peer to generate TWCC reports.
ConfigureTWCCSender will setup everything necessary for generating TWCC reports. This must be called after registering codecs with the MediaEngine.
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.
ExampleGatheringCompletePromise demonstrates how to implement non-trickle ICE in Pion, an older form of ICE that does not require an asynchronous side channel between peers: negotiation is just a single offer-answer exchange. It works by explicitly waiting for all local ICE candidates to have been gathered before sending an offer to the peer.
// create a peer connection pc, err := NewPeerConnection(Configuration{}) if err != nil { panic(err) } defer func() { closeErr := pc.Close() if closeErr != nil { panic(closeErr) } }()
// add at least one transceiver to the peer connection, or nothing // interesting will happen. This could use pc.AddTrack instead. _, err = pc.AddTransceiverFromKind(RTPCodecTypeVideo) if err != nil { panic(err) }
// create a first offer that does not contain any local candidates offer, err := pc.CreateOffer(nil) if err != nil { panic(err) }
// gatherComplete is a channel that will be closed when // the gathering of local candidates is complete. gatherComplete := GatheringCompletePromise(pc)
// apply the offer err = pc.SetLocalDescription(offer) if err != nil { panic(err) }
// wait for gathering of local candidates to complete <-gatherComplete
// compute the local offer again offer2 := pc.LocalDescription()
// this second offer contains all candidates, and may be sent to // the peer with no need for further communication. In this // example, we simply check that it contains at least one // candidate. hasCandidate := strings.Contains(offer2.SDP, "\na=candidate:") if hasCandidate { fmt.Println("Ok!") }
Output:
Ok!
func NewAudioPlayoutStatsProvider(id string) *defaultAudioPlayoutStatsProvider
NewAudioPlayoutStatsProvider constructs a default provider with the supplied stats ID.
NewICETCPMux creates a new instance of ice.TCPMuxDefault. It enables use of passive ICE TCP candidates.
NewICEUDPMux creates a new instance of ice.UDPMuxDefault. It allows many PeerConnections to be served by a single UDP Port.
RegisterDefaultInterceptors will register some useful interceptors. If you want to customize which interceptors are loaded, you should copy the code from this method and remove unwanted interceptors.
WithInterceptorRegistry allows providing Interceptors to the API. Settings should not be changed after passing the registry to an API.
func WithMediaEngine(m *MediaEngine) func(a *API)
WithMediaEngine allows providing a MediaEngine to the API. Settings can be changed after passing the engine to an API. When a PeerConnection is created the MediaEngine is copied and no more changes can be made.
WithPayloader allows the user to override the Payloader.
func WithRTPStreamID(rid string) func(*TrackLocalStaticRTP)
WithRTPStreamID sets the RTP stream ID for this TrackLocalStaticRTP.
func WithRTPTimestamp(timestamp uint32) func(*TrackLocalStaticRTP)
WithRTPTimestamp set the initial RTP timestamp for the track.
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.
API allows configuration of a PeerConnection with APIs that are available in the standard. This lets you set custom behavior via the SettingEngine, configure codecs via the MediaEngine and define custom media behaviors via Interceptors.
func NewAPI(options ...func(*API)) *API
NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects
It uses the default Codecs and Interceptors unless you customize them using WithMediaEngine and WithInterceptorRegistry respectively.
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 *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 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 *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 API) NewPeerConnection(configuration Configuration) (PeerConnection, error)
NewPeerConnection creates a new PeerConnection with the provided configuration against the received API object. This method will attach a default set of codecs and interceptors to the resulting PeerConnection. If this behavior is not desired, set the set of codecs and interceptors explicitly by usingWithMediaEngine and WithInterceptorRegistry when calling NewAPI.
func (api *API) NewRTPReceiver(kind RTPCodecType, transport DTLSTransport) (RTPReceiver, error)
NewRTPReceiver constructs a new RTPReceiver.
func (api *API) NewRTPSender(track TrackLocal, transport DTLSTransport) (RTPSender, error)
NewRTPSender constructs a new RTPSender.
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 struct { OfferAnswerOptions }
AnswerOptions structure describes the options used to control the answer creation process.
type AudioPlayoutStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
Kind [string](/builtin#string) `json:"kind"`
SynthesizedSamplesDuration [float64](/builtin#float64) `json:"synthesizedSamplesDuration"`
SynthesizedSamplesEvents [uint64](/builtin#uint64) `json:"synthesizedSamplesEvents"`
TotalSamplesDuration [float64](/builtin#float64) `json:"totalSamplesDuration"`
TotalPlayoutDelay [float64](/builtin#float64) `json:"totalPlayoutDelay"`
TotalSamplesCount [uint64](/builtin#uint64) `json:"totalSamplesCount"`}
AudioPlayoutStats represents one playout path - if the same playout stats object is referenced by multiple RTCInboundRtpStreamStats this is an indication that audio mixing is happening in which case sample counters in this stats object refer to the samples after mixing. Only applicable if the playout path represents an audio device.
type AudioPlayoutStatsProvider interface {
AddTrack(track *[TrackRemote](#TrackRemote)) [error](/builtin#error)
RemoveTrack(track *[TrackRemote](#TrackRemote))
Snapshot(now [time](/time).[Time](/time#Time)) ([AudioPlayoutStats](#AudioPlayoutStats), [bool](/builtin#bool))}
AudioPlayoutStatsProvider is an interface for getting audio playout metrics.
type AudioReceiverStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
Kind [string](/builtin#string) `json:"kind"`
AudioLevel [float64](/builtin#float64) `json:"audioLevel"`
TotalAudioEnergy [float64](/builtin#float64) `json:"totalAudioEnergy"`
VoiceActivityFlag [bool](/builtin#bool) `json:"voiceActivityFlag"`
TotalSamplesDuration [float64](/builtin#float64) `json:"totalSamplesDuration"`
EstimatedPlayoutTimestamp [StatsTimestamp](#StatsTimestamp) `json:"estimatedPlayoutTimestamp"`
JitterBufferDelay [float64](/builtin#float64) `json:"jitterBufferDelay"`
JitterBufferEmittedCount [uint64](/builtin#uint64) `json:"jitterBufferEmittedCount"`
TotalSamplesReceived [uint64](/builtin#uint64) `json:"totalSamplesReceived"`
ConcealedSamples [uint64](/builtin#uint64) `json:"concealedSamples"`
ConcealmentEvents [uint64](/builtin#uint64) `json:"concealmentEvents"`}
AudioReceiverStats contains audio metrics related to a specific receiver.
type AudioSenderStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
TrackIdentifier [string](/builtin#string) `json:"trackIdentifier"`
RemoteSource [bool](/builtin#bool) `json:"remoteSource"`
Ended [bool](/builtin#bool) `json:"ended"`
Kind [string](/builtin#string) `json:"kind"`
AudioLevel [float64](/builtin#float64) `json:"audioLevel"`
TotalAudioEnergy [float64](/builtin#float64) `json:"totalAudioEnergy"`
VoiceActivityFlag [bool](/builtin#bool) `json:"voiceActivityFlag"`
TotalSamplesDuration [float64](/builtin#float64) `json:"totalSamplesDuration"`
EchoReturnLoss [float64](/builtin#float64) `json:"echoReturnLoss"`
EchoReturnLossEnhancement [float64](/builtin#float64) `json:"echoReturnLossEnhancement"`
TotalSamplesSent [uint64](/builtin#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 AudioSourceStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
TrackIdentifier [string](/builtin#string) `json:"trackIdentifier"`
Kind [string](/builtin#string) `json:"kind"`
AudioLevel [float64](/builtin#float64) `json:"audioLevel"`
TotalAudioEnergy [float64](/builtin#float64) `json:"totalAudioEnergy"`
TotalSamplesDuration [float64](/builtin#float64) `json:"totalSamplesDuration"`
EchoReturnLoss [float64](/builtin#float64) `json:"echoReturnLoss"`
EchoReturnLossEnhancement [float64](/builtin#float64) `json:"echoReturnLossEnhancement"`
DroppedSamplesDuration [float64](/builtin#float64) `json:"droppedSamplesDuration"`
DroppedSamplesEvents [uint64](/builtin#uint64) `json:"droppedSamplesEvents"`
TotalCaptureDelay [float64](/builtin#float64) `json:"totalCaptureDelay"`
TotalSamplesCaptured [uint64](/builtin#uint64) `json:"totalSamplesCaptured"`}
AudioSourceStats represents an audio track that is attached to one or more senders.
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 (
BundlePolicyUnknown [BundlePolicy](#BundlePolicy) = [iota](/builtin#iota)
BundlePolicyBalanced
BundlePolicyMaxCompat
BundlePolicyMaxBundle)
MarshalJSON returns the JSON encoding.
UnmarshalJSON parses the JSON-encoded data and stores the result.
type Certificate struct {
}
Certificate represents a x509Cert used to authenticate WebRTC communications.
CertificateFromPEM creates a fresh certificate based on a string containing pem blocks fort the private key and x509 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.
GenerateCertificate causes the creation of an X.509 certificate and corresponding private key.
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.
Equals determines if two certificates are identical by comparing both the secretKeys and x509Certificates.
Expires returns the timestamp after which this certificate is no longer valid.
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.
PEM returns the certificate encoded as two pem block: once for the X509 certificate and the other for the private key.
type CertificateStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
Fingerprint [string](/builtin#string) `json:"fingerprint"`
FingerprintAlgorithm [string](/builtin#string) `json:"fingerprintAlgorithm"`
Base64Certificate [string](/builtin#string) `json:"base64Certificate"`
IssuerCertificateID [string](/builtin#string) `json:"issuerCertificateId"`}
CertificateStats contains information about a certificate used by an ICETransport.
type CodecStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
PayloadType [PayloadType](#PayloadType) `json:"payloadType"`
CodecType [CodecType](#CodecType) `json:"codecType"`
TransportID [string](/builtin#string) `json:"transportId"`
MimeType [string](/builtin#string) `json:"mimeType"`
ClockRate [uint32](/builtin#uint32) `json:"clockRate"`
Channels [uint8](/builtin#uint8) `json:"channels"`
SDPFmtpLine [string](/builtin#string) `json:"sdpFmtpLine"`
Implementation [string](/builtin#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.
CodecType specifies whether a CodecStats objects represents a media format that is being encoded or decoded.
const (
CodecTypeEncode [CodecType](#CodecType) = "encode"
CodecTypeDecode [CodecType](#CodecType) = "decode")
type Configuration struct {
ICEServers [][ICEServer](#ICEServer) `json:"iceServers,omitempty"`
ICETransportPolicy [ICETransportPolicy](#ICETransportPolicy) `json:"iceTransportPolicy,omitempty"`
BundlePolicy [BundlePolicy](#BundlePolicy) `json:"bundlePolicy,omitempty"`
RTCPMuxPolicy [RTCPMuxPolicy](#RTCPMuxPolicy) `json:"rtcpMuxPolicy,omitempty"`
PeerIdentity [string](/builtin#string) `json:"peerIdentity,omitempty"`
Certificates [][Certificate](#Certificate) `json:"certificates,omitempty"`
ICECandidatePoolSize [uint8](/builtin#uint8) `json:"iceCandidatePoolSize,omitempty"`
SDPSemantics [SDPSemantics](#SDPSemantics) `json:"sdpSemantics,omitempty"`}
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 DTLSParameters struct {
Role DTLSRole json:"role"
Fingerprints []DTLSFingerprint json:"fingerprints"
}
DTLSParameters holds information relating to DTLS configuration.
DTLSRole indicates the role of the DTLS transport.
const (
DTLSRoleUnknown [DTLSRole](#DTLSRole) = [iota](/builtin#iota)
DTLSRoleAuto
DTLSRoleClient
DTLSRoleServer)
type DTLSTransport struct {
}
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 (t *DTLSTransport) GetLocalParameters() (DTLSParameters, error)
GetLocalParameters returns the DTLS parameters of the local DTLSTransport upon construction.
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 (t *DTLSTransport) ICETransport() *ICETransport
ICETransport returns the currently-configured *ICETransport or nil if one has not been configured.
func (t *DTLSTransport) OnStateChange(f func(DTLSTransportState))
OnStateChange sets a handler that is fired when the DTLS connection state changes.
func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error
Start DTLS transport negotiation with the parameters of the remote DTLS transport.
func (t *DTLSTransport) State() DTLSTransportState
State returns the current dtls transport state.
Stop stops and closes the DTLSTransport object.
WriteRTCP sends a user provided RTCP packet to the connected peer. If no peer is connected the packet is discarded.
type DTLSTransportState int
DTLSTransportState indicates the DTLS transport establishment state.
const (
DTLSTransportStateUnknown [DTLSTransportState](#DTLSTransportState) = [iota](/builtin#iota)
DTLSTransportStateNew
DTLSTransportStateConnecting
DTLSTransportStateConnected
DTLSTransportStateClosed
DTLSTransportStateFailed)
MarshalText implements encoding.TextMarshaler.
UnmarshalText implements encoding.TextUnmarshaler.
type DataChannel struct {
}
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.
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 (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.
Close Closes the DataChannel. It may be called regardless of whether the DataChannel object was created by this peer or the remote peer.
Detach allows you to detach the underlying datachannel. This provides an idiomatic API to work with (`io.ReadWriteCloser` with its `.Read()` and `.Write()` methods, as opposed to `.Send()` and `.OnMessage`), 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.
DetachWithDeadline allows you to detach the underlying datachannel. It is the same as Detach but returns a ReadWriteCloserDeadliner.
func (d *DataChannel) GracefulClose() error
GracefulClose Closes the DataChannel. It may be called regardless of whether the DataChannel object was created by this peer or the remote peer. It also waits for any goroutines it started to complete. This is only safe to call outside of DataChannel callbacks or if in a callback, in its own goroutine.
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.
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 (d *DataChannel) MaxPacketLifeTime() *uint16
MaxPacketLifeTime represents the length of the time window (msec) during which transmissions and retransmissions may occur in unreliable mode.
MaxRetransmits represents the maximum number of retransmissions that are attempted in unreliable mode.
func (d *DataChannel) Negotiated() bool
Negotiated represents whether this DataChannel was negotiated by the application (true), or not (false).
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 or equal to the BufferedAmountLowThreshold.
func (d *DataChannel) OnClose(f func())
OnClose sets an event handler which is invoked when the underlying data transport has been closed. Note: Due to backwards compatibility, there is a chance that OnClose can be called, even if the GracefulClose is used. If this is the case for you, you can deregister OnClose prior to GracefulClose.
func (d *DataChannel) OnDial(f func())
OnDial sets an event handler which is invoked when the peer has been dialed, but before said peer has responded.
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 (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 (d *DataChannel) OnOpen(f func())
OnOpen sets an event handler which is invoked when the underlying data transport has been established (or re-established).
Ordered returns true if the DataChannel is ordered, and false if out-of-order delivery is allowed.
Protocol represents the name of the sub-protocol used with this DataChannel.
func (d *DataChannel) ReadyState() DataChannelState
ReadyState represents the state of the DataChannel object.
Send sends the binary message to the DataChannel peer.
SendText sends the text message to the DataChannel peer.
func (d *DataChannel) SetBufferedAmountLowThreshold(th uint64)
SetBufferedAmountLowThreshold is used to update the threshold. See BufferedAmountLowThreshold().
func (d *DataChannel) Transport() *SCTPTransport
Transport returns the SCTPTransport instance the DataChannel is sending over.
DataChannelInit can be used to configure properties of the underlying channel such as data reliability.
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 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 int
DataChannelState indicates the state of a data channel.
const (
DataChannelStateUnknown [DataChannelState](#DataChannelState) = [iota](/builtin#iota)
DataChannelStateConnecting
DataChannelStateOpen
DataChannelStateClosing
DataChannelStateClosed)
MarshalText implements encoding.TextMarshaler.
UnmarshalText implements encoding.TextUnmarshaler.
type DataChannelStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
Label [string](/builtin#string) `json:"label"`
Protocol [string](/builtin#string) `json:"protocol"`
DataChannelIdentifier [int32](/builtin#int32) `json:"dataChannelIdentifier"`
TransportID [string](/builtin#string) `json:"transportId"`
State [DataChannelState](#DataChannelState) `json:"state"`
MessagesSent [uint32](/builtin#uint32) `json:"messagesSent"`
BytesSent [uint64](/builtin#uint64) `json:"bytesSent"`
MessagesReceived [uint32](/builtin#uint32) `json:"messagesReceived"`
BytesReceived [uint64](/builtin#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"
SDPMid string json:"sdpMid"
SDPMLineIndex uint16 json:"sdpMLineIndex"
}
ICECandidate represents a ice candidate.
func (ICECandidate) ToICE ¶ added in v4.0.15
ToICE converts ICECandidate to ice.Candidate.
type ICECandidateInit ¶
type ICECandidateInit struct {
Candidate string json:"candidate"
SDPMid *string json:"sdpMid"
SDPMLineIndex *uint16 json:"sdpMLineIndex"
UsernameFragment *string json:"usernameFragment"
}
ICECandidateInit is used to serialize ice candidates.
type ICECandidatePair ¶
type ICECandidatePair struct { Local *ICECandidate Remote *ICECandidate
}
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 ¶
type ICECandidatePairStats ¶
type ICECandidatePairStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
TransportID [string](/builtin#string) `json:"transportId"`
LocalCandidateID [string](/builtin#string) `json:"localCandidateId"`
RemoteCandidateID [string](/builtin#string) `json:"remoteCandidateId"`
State [StatsICECandidatePairState](#StatsICECandidatePairState) `json:"state"`
Nominated [bool](/builtin#bool) `json:"nominated"`
PacketsSent [uint32](/builtin#uint32) `json:"packetsSent"`
PacketsReceived [uint32](/builtin#uint32) `json:"packetsReceived"`
BytesSent [uint64](/builtin#uint64) `json:"bytesSent"`
BytesReceived [uint64](/builtin#uint64) `json:"bytesReceived"`
LastPacketSentTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastPacketSentTimestamp"`
LastPacketReceivedTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastPacketReceivedTimestamp"`
FirstRequestTimestamp [StatsTimestamp](#StatsTimestamp) `json:"firstRequestTimestamp"`
LastRequestTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastRequestTimestamp"`
FirstResponseTimestamp [StatsTimestamp](#StatsTimestamp) `json:"firstResponseTimestamp"`
LastResponseTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastResponseTimestamp"`
FirstRequestReceivedTimestamp [StatsTimestamp](#StatsTimestamp) `json:"firstRequestReceivedTimestamp"`
LastRequestReceivedTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastRequestReceivedTimestamp"`
TotalRoundTripTime [float64](/builtin#float64) `json:"totalRoundTripTime"`
CurrentRoundTripTime [float64](/builtin#float64) `json:"currentRoundTripTime"`
AvailableOutgoingBitrate [float64](/builtin#float64) `json:"availableOutgoingBitrate"`
AvailableIncomingBitrate [float64](/builtin#float64) `json:"availableIncomingBitrate"`
CircuitBreakerTriggerCount [uint32](/builtin#uint32) `json:"circuitBreakerTriggerCount"`
RequestsReceived [uint64](/builtin#uint64) `json:"requestsReceived"`
RequestsSent [uint64](/builtin#uint64) `json:"requestsSent"`
ResponsesReceived [uint64](/builtin#uint64) `json:"responsesReceived"`
ResponsesSent [uint64](/builtin#uint64) `json:"responsesSent"`
RetransmissionsReceived [uint64](/builtin#uint64) `json:"retransmissionsReceived"`
RetransmissionsSent [uint64](/builtin#uint64) `json:"retransmissionsSent"`
ConsentRequestsSent [uint64](/builtin#uint64) `json:"consentRequestsSent"`
ConsentExpiredTimestamp [StatsTimestamp](#StatsTimestamp) `json:"consentExpiredTimestamp"`
PacketsDiscardedOnSend [uint32](/builtin#uint32) `json:"packetsDiscardedOnSend"`
BytesDiscardedOnSend [uint32](/builtin#uint32) `json:"bytesDiscardedOnSend"`}
ICECandidatePairStats contains ICE candidate pair statistics related to the ICETransport objects.
type ICECandidateStats ¶
type ICECandidateStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
TransportID [string](/builtin#string) `json:"transportId"`
NetworkType [string](/builtin#string) `json:"networkType,omitempty"`
IP [string](/builtin#string) `json:"ip"`
Port [int32](/builtin#int32) `json:"port"`
Protocol [string](/builtin#string) `json:"protocol"`
CandidateType [ICECandidateType](#ICECandidateType) `json:"candidateType"`
Priority [int32](/builtin#int32) `json:"priority"`
URL [string](/builtin#string) `json:"url"`
RelayProtocol [string](/builtin#string) `json:"relayProtocol"`
Deleted [bool](/builtin#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 (
ICECandidateTypeUnknown [ICECandidateType](#ICECandidateType) = [iota](/builtin#iota)
ICECandidateTypeHost
ICECandidateTypeSrflx
ICECandidateTypePrflx
ICECandidateTypeRelay)
func NewICECandidateType ¶
NewICECandidateType takes a string and converts it into ICECandidateType.
func (ICECandidateType) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (ICECandidateType) String ¶
func (*ICECandidateType) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
ICEComponent describes if the ice transport is used for RTP (or RTCP multiplexing).
const (
ICEComponentUnknown [ICEComponent](#ICEComponent) = [iota](/builtin#iota)
ICEComponentRTP
ICEComponentRTCP)
type ICEConnectionState int
ICEConnectionState indicates signaling state of the ICE Connection.
const (
ICEConnectionStateUnknown [ICEConnectionState](#ICEConnectionState) = [iota](/builtin#iota)
ICEConnectionStateNew
ICEConnectionStateChecking
ICEConnectionStateConnected
ICEConnectionStateCompleted
ICEConnectionStateDisconnected
ICEConnectionStateFailed
ICEConnectionStateClosed)
func NewICEConnectionState(raw string) ICEConnectionState
NewICEConnectionState takes a string and converts it to ICEConnectionState.
type ICECredentialType int
ICECredentialType indicates the type of credentials used to connect to an ICE server.
const (
ICECredentialTypePassword [ICECredentialType](#ICECredentialType) = [iota](/builtin#iota)
ICECredentialTypeOauth)
MarshalJSON returns the JSON encoding.
UnmarshalJSON parses the JSON-encoded data and stores the result.
type ICEGatherOptions struct { ICEServers []ICEServer ICEGatherPolicy ICETransportPolicy }
ICEGatherOptions provides options relating to the gathering of ICE candidates.
type ICEGatherPolicy = ICETransportPolicy
ICEGatherPolicy is the ORTC equivalent of ICETransportPolicy.
type ICEGatherer struct {
}
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.
Close prunes all local candidates, and closes the ports.
func (*ICEGatherer) GetLocalCandidates ¶
func (g *ICEGatherer) GetLocalCandidates() ([]ICECandidate, error)
GetLocalCandidates returns the sequence of valid local candidates associated with the ICEGatherer.
func (g *ICEGatherer) GetLocalParameters() (ICEParameters, error)
GetLocalParameters returns the ICE parameters of the ICEGatherer.
func (g *ICEGatherer) GracefulClose() error
GracefulClose prunes all local candidates, and closes the ports. It also waits for any goroutines it started to complete. This is only safe to call outside of ICEGatherer callbacks or if in a callback, in its own goroutine.
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 will be called with a nil pointer when gathering is finished.
func (g *ICEGatherer) OnStateChange(f func(ICEGathererState))
OnStateChange fires any time the ICEGatherer changes.
func (g *ICEGatherer) State() ICEGathererState
State indicates the current state of the ICE gatherer.
ICEGathererState represents the current state of the ICE gatherer.
const (
ICEGathererStateUnknown [ICEGathererState](#ICEGathererState) = [iota](/builtin#iota)
ICEGathererStateNew
ICEGathererStateGathering
ICEGathererStateComplete
ICEGathererStateClosed)
type ICEGatheringState int
ICEGatheringState describes the state of the candidate gathering process.
const (
ICEGatheringStateUnknown [ICEGatheringState](#ICEGatheringState) = [iota](/builtin#iota)
ICEGatheringStateNew
ICEGatheringStateGathering
ICEGatheringStateComplete)
NewICEGatheringState takes a string and converts it to ICEGatheringState.
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.
ICEProtocol indicates the transport protocol type that is used in the ice.URL structure.
const (
ICEProtocolUnknown [ICEProtocol](#ICEProtocol) = [iota](/builtin#iota)
ICEProtocolUDP
ICEProtocolTCP)
NewICEProtocol takes a string and converts it to ICEProtocol.
ICERole describes the role ice.Agent is playing in selecting the preferred the candidate pair.
const (
ICERoleUnknown [ICERole](#ICERole) = [iota](/builtin#iota)
ICERoleControlling
ICERoleControlled)
MarshalText implements encoding.TextMarshaler.
UnmarshalText implements encoding.TextUnmarshaler.
type ICEServer struct {
URLs []string json:"urls"
Username string json:"username,omitempty"
Credential any json:"credential,omitempty"
CredentialType ICECredentialType json:"credentialType,omitempty"
}
ICEServer describes a single STUN and TURN server that can be used by the ICEAgent to establish a connection with a peer.
MarshalJSON returns the JSON encoding.
UnmarshalJSON parses the JSON-encoded data and stores the result.
type ICETransport struct {
}
ICETransport allows an application access to information about the ICE transport over which packets are sent and received.
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 (t *ICETransport) GetLocalParameters() (ICEParameters, error)
GetLocalParameters returns an IceParameters object which provides information uniquely identifying the local peer for the duration of the ICE session.
func (t *ICETransport) GetRemoteParameters() (ICEParameters, error)
GetRemoteParameters returns an IceParameters object which provides information uniquely identifying the remote peer for the duration of the ICE session.
func (*ICETransport) GetSelectedCandidatePair ¶
func (t ICETransport) GetSelectedCandidatePair() (ICECandidatePair, error)
GetSelectedCandidatePair returns the selected candidate pair on which packets are sent if there is no selected pair nil is returned.
func (*ICETransport) GetSelectedCandidatePairStats ¶
func (t *ICETransport) GetSelectedCandidatePairStats() (ICECandidatePairStats, bool)
GetSelectedCandidatePairStats returns the selected candidate pair stats on which packets are sent if there is no selected pair empty stats, false is returned to indicate stats not available.
func (t *ICETransport) GracefulStop() error
GracefulStop irreversibly stops the ICETransport. It also waits for any goroutines it started to complete. This is only safe to call outside of ICETransport callbacks or if in a callback, in its own goroutine.
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 (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 (t *ICETransport) Start(gatherer *ICEGatherer, params ICEParameters, role *ICERole) error
Start incoming connectivity checks based on its configured role.
func (t *ICETransport) State() ICETransportState
State returns the current ice transport state.
Stop irreversibly stops the ICETransport.
type ICETransportPolicy int
ICETransportPolicy defines the ICE candidate policy surface the permitted candidates. Only these candidates are used for connectivity checks.
const (
ICETransportPolicyAll [ICETransportPolicy](#ICETransportPolicy) = [iota](/builtin#iota)
ICETransportPolicyRelay)
func NewICETransportPolicy(raw string) ICETransportPolicy
NewICETransportPolicy takes a string and converts it to ICETransportPolicy.
MarshalJSON returns the JSON encoding.
UnmarshalJSON parses the JSON-encoded data and stores the result.
type ICETransportState int
ICETransportState represents the current state of the ICE transport.
const (
ICETransportStateUnknown [ICETransportState](#ICETransportState) = [iota](/builtin#iota)
ICETransportStateNew
ICETransportStateChecking
ICETransportStateConnected
ICETransportStateCompleted
ICETransportStateFailed
ICETransportStateDisconnected
ICETransportStateClosed)
MarshalText implements encoding.TextMarshaler.
UnmarshalText implements encoding.TextUnmarshaler.
type ICETrickleCapability int
ICETrickleCapability represents whether the remote endpoint accepts trickled ICE candidates.
const (
ICETrickleCapabilityUnknown [ICETrickleCapability](#ICETrickleCapability) = [iota](/builtin#iota)
ICETrickleCapabilitySupported
ICETrickleCapabilityUnsupported)
String returns the string representation of ICETrickleCapability.
type InboundRTPStreamStats struct {
Mid [string](/builtin#string) `json:"mid"`
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
SSRC [SSRC](#SSRC) `json:"ssrc"`
Kind [string](/builtin#string) `json:"kind"`
TransportID [string](/builtin#string) `json:"transportId"`
CodecID [string](/builtin#string) `json:"codecId"`
FIRCount [uint32](/builtin#uint32) `json:"firCount"`
PLICount [uint32](/builtin#uint32) `json:"pliCount"`
TotalProcessingDelay [float64](/builtin#float64) `json:"totalProcessingDelay"`
NACKCount [uint32](/builtin#uint32) `json:"nackCount"`
JitterBufferDelay [float64](/builtin#float64) `json:"jitterBufferDelay"`
JitterBufferTargetDelay [float64](/builtin#float64) `json:"jitterBufferTargetDelay"`
JitterBufferEmittedCount [uint64](/builtin#uint64) `json:"jitterBufferEmittedCount"`
JitterBufferMinimumDelay [float64](/builtin#float64) `json:"jitterBufferMinimumDelay"`
TotalSamplesReceived [uint64](/builtin#uint64) `json:"totalSamplesReceived"`
ConcealedSamples [uint64](/builtin#uint64) `json:"concealedSamples"`
SilentConcealedSamples [uint64](/builtin#uint64) `json:"silentConcealedSamples"`
ConcealmentEvents [uint64](/builtin#uint64) `json:"concealmentEvents"`
InsertedSamplesForDeceleration [uint64](/builtin#uint64) `json:"insertedSamplesForDeceleration"`
RemovedSamplesForAcceleration [uint64](/builtin#uint64) `json:"removedSamplesForAcceleration"`
AudioLevel [float64](/builtin#float64) `json:"audioLevel"`
TotalAudioEnergy [float64](/builtin#float64) `json:"totalAudioEnergy"`
TotalSamplesDuration [float64](/builtin#float64) `json:"totalSamplesDuration"`
SLICount [uint32](/builtin#uint32) `json:"sliCount"`
QPSum [uint64](/builtin#uint64) `json:"qpSum"`
TotalDecodeTime [float64](/builtin#float64) `json:"totalDecodeTime"`
TotalInterFrameDelay [float64](/builtin#float64) `json:"totalInterFrameDelay"`
TotalSquaredInterFrameDelay [float64](/builtin#float64) `json:"totalSquaredInterFrameDelay"`
PacketsReceived [uint32](/builtin#uint32) `json:"packetsReceived"`
PacketsLost [int32](/builtin#int32) `json:"packetsLost"`
Jitter [float64](/builtin#float64) `json:"jitter"`
PacketsDiscarded [uint32](/builtin#uint32) `json:"packetsDiscarded"`
PacketsRepaired [uint32](/builtin#uint32) `json:"packetsRepaired"`
BurstPacketsLost [uint32](/builtin#uint32) `json:"burstPacketsLost"`
BurstPacketsDiscarded [uint32](/builtin#uint32) `json:"burstPacketsDiscarded"`
BurstLossCount [uint32](/builtin#uint32) `json:"burstLossCount"`
BurstDiscardCount [uint32](/builtin#uint32) `json:"burstDiscardCount"`
BurstLossRate [float64](/builtin#float64) `json:"burstLossRate"`
BurstDiscardRate [float64](/builtin#float64) `json:"burstDiscardRate"`
GapLossRate [float64](/builtin#float64) `json:"gapLossRate"`
GapDiscardRate [float64](/builtin#float64) `json:"gapDiscardRate"`
TrackID [string](/builtin#string) `json:"trackId"`
ReceiverID [string](/builtin#string) `json:"receiverId"`
RemoteID [string](/builtin#string) `json:"remoteId"`
FramesDecoded [uint32](/builtin#uint32) `json:"framesDecoded"`
KeyFramesDecoded [uint32](/builtin#uint32) `json:"keyFramesDecoded"`
FramesRendered [uint32](/builtin#uint32) `json:"framesRendered"`
FramesDropped [uint32](/builtin#uint32) `json:"framesDropped"`
FrameWidth [uint32](/builtin#uint32) `json:"frameWidth"`
FrameHeight [uint32](/builtin#uint32) `json:"frameHeight"`
LastPacketReceivedTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastPacketReceivedTimestamp"`
HeaderBytesReceived [uint64](/builtin#uint64) `json:"headerBytesReceived"`
AverageRTCPInterval [float64](/builtin#float64) `json:"averageRtcpInterval"`
FECPacketsReceived [uint32](/builtin#uint32) `json:"fecPacketsReceived"`
FECPacketsDiscarded [uint64](/builtin#uint64) `json:"fecPacketsDiscarded"`
BytesReceived [uint64](/builtin#uint64) `json:"bytesReceived"`
FramesReceived [uint32](/builtin#uint32) `json:"framesReceived"`
PacketsFailedDecryption [uint32](/builtin#uint32) `json:"packetsFailedDecryption"`
PacketsDuplicated [uint32](/builtin#uint32) `json:"packetsDuplicated"`
PerDSCPPacketsReceived map[[string](/builtin#string)][uint32](/builtin#uint32) `json:"perDscpPacketsReceived"`
DecoderImplementation [string](/builtin#string) `json:"decoderImplementation"`
PauseCount [uint32](/builtin#uint32) `json:"pauseCount"`
TotalPausesDuration [float64](/builtin#float64) `json:"totalPausesDuration"`
FreezeCount [uint32](/builtin#uint32) `json:"freezeCount"`
TotalFreezesDuration [float64](/builtin#float64) `json:"totalFreezesDuration"`
PowerEfficientDecoder [bool](/builtin#bool) `json:"powerEfficientDecoder"`}
InboundRTPStreamStats contains statistics for an inbound RTP stream that is currently received with this PeerConnection object.
type MediaEngine struct {
}
A MediaEngine defines the codecs supported by a PeerConnection, and the configuration of those codecs.
RegisterCodec adds codec to the MediaEngine These are the list of codecs supported by this PeerConnection.
func (m *MediaEngine) RegisterDefaultCodecs() error
RegisterDefaultCodecs registers the default codecs supported by Pion WebRTC. RegisterDefaultCodecs is not safe for concurrent use.
func (m *MediaEngine) RegisterFeedback(feedback RTCPFeedback, typ RTPCodecType)
RegisterFeedback adds feedback mechanism to already registered codecs.
func (m *MediaEngine) RegisterHeaderExtension( extension RTPHeaderExtensionCapability, typ RTPCodecType, allowedDirections ...RTPTransceiverDirection, ) error
RegisterHeaderExtension adds a header extension to the MediaEngine To determine the negotiated value use `GetHeaderExtensionID` after signaling is complete.
MediaKind indicates the kind of media (audio or video).
const (
MediaKindAudio [MediaKind](#MediaKind) = "audio"
MediaKindVideo [MediaKind](#MediaKind) = "video")
type MediaStreamStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
StreamIdentifier [string](/builtin#string) `json:"streamIdentifier"`
TrackIDs [][string](/builtin#string) `json:"trackIds"`}
MediaStreamStats contains statistics related to a specific MediaStream.
NetworkType represents the type of network.
const (
NetworkTypeUnknown [NetworkType](#NetworkType) = [iota](/builtin#iota)
NetworkTypeUDP4
NetworkTypeUDP6
NetworkTypeTCP4
NetworkTypeTCP6)
NewNetworkType allows create network type from string It will be useful for getting custom network types from external config.
Protocol returns udp or tcp.
type OAuthCredential struct {
MACKey [string](/builtin#string)
AccessToken [string](/builtin#string)}
OAuthCredential represents OAuth credential information which is used by the STUN/TURN client to connect to an ICE server as defined inhttps://tools.ietf.org/html/rfc7635. Note that the kid parameter is not located in OAuthCredential, but in ICEServer's username member.
type OfferAnswerOptions struct {
VoiceActivityDetection [bool](/builtin#bool)
ICETricklingSupported [bool](/builtin#bool)}
OfferAnswerOptions is a base structure which describes the options that can be used to control the offer/answer creation process.
type OfferOptions struct { OfferAnswerOptions
ICERestart [bool](/builtin#bool)}
OfferOptions structure describes the options used to control the offer creation process.
type OutboundRTPStreamStats struct {
Mid [string](/builtin#string) `json:"mid"`
Rid [string](/builtin#string) `json:"rid"`
MediaSourceID [string](/builtin#string) `json:"mediaSourceId"`
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
SSRC [SSRC](#SSRC) `json:"ssrc"`
Kind [string](/builtin#string) `json:"kind"`
TransportID [string](/builtin#string) `json:"transportId"`
CodecID [string](/builtin#string) `json:"codecId"`
HeaderBytesSent [uint64](/builtin#uint64) `json:"headerBytesSent"`
RetransmittedPacketsSent [uint64](/builtin#uint64) `json:"retransmittedPacketsSent"`
RetransmittedBytesSent [uint64](/builtin#uint64) `json:"retransmittedBytesSent"`
FIRCount [uint32](/builtin#uint32) `json:"firCount"`
PLICount [uint32](/builtin#uint32) `json:"pliCount"`
NACKCount [uint32](/builtin#uint32) `json:"nackCount"`
SLICount [uint32](/builtin#uint32) `json:"sliCount"`
QPSum [uint64](/builtin#uint64) `json:"qpSum"`
PacketsSent [uint32](/builtin#uint32) `json:"packetsSent"`
PacketsDiscardedOnSend [uint32](/builtin#uint32) `json:"packetsDiscardedOnSend"`
FECPacketsSent [uint32](/builtin#uint32) `json:"fecPacketsSent"`
BytesSent [uint64](/builtin#uint64) `json:"bytesSent"`
BytesDiscardedOnSend [uint64](/builtin#uint64) `json:"bytesDiscardedOnSend"`
TrackID [string](/builtin#string) `json:"trackId"`
SenderID [string](/builtin#string) `json:"senderId"`
RemoteID [string](/builtin#string) `json:"remoteId"`
LastPacketSentTimestamp [StatsTimestamp](#StatsTimestamp) `json:"lastPacketSentTimestamp"`
TargetBitrate [float64](/builtin#float64) `json:"targetBitrate"`
TotalEncodedBytesTarget [uint64](/builtin#uint64) `json:"totalEncodedBytesTarget"`
FrameWidth [uint32](/builtin#uint32) `json:"frameWidth"`
FrameHeight [uint32](/builtin#uint32) `json:"frameHeight"`
FramesPerSecond [float64](/builtin#float64) `json:"framesPerSecond"`
FramesSent [uint32](/builtin#uint32) `json:"framesSent"`
HugeFramesSent [uint32](/builtin#uint32) `json:"hugeFramesSent"`
FramesEncoded [uint32](/builtin#uint32) `json:"framesEncoded"`
KeyFramesEncoded [uint32](/builtin#uint32) `json:"keyFramesEncoded"`
TotalEncodeTime [float64](/builtin#float64) `json:"totalEncodeTime"`
TotalPacketSendDelay [float64](/builtin#float64) `json:"totalPacketSendDelay"`
AverageRTCPInterval [float64](/builtin#float64) `json:"averageRtcpInterval"`
QualityLimitationReason [QualityLimitationReason](#QualityLimitationReason) `json:"qualityLimitationReason"`
QualityLimitationDurations map[[string](/builtin#string)][float64](/builtin#float64) `json:"qualityLimitationDurations"`
QualityLimitationResolutionChanges [uint32](/builtin#uint32) `json:"qualityLimitationResolutionChanges"`
PerDSCPPacketsSent map[[string](/builtin#string)][uint32](/builtin#uint32) `json:"perDscpPacketsSent"`
Active [bool](/builtin#bool) `json:"active"`
EncoderImplementation [string](/builtin#string) `json:"encoderImplementation"`
PowerEfficientEncoder [bool](/builtin#bool) `json:"powerEfficientEncoder"`
ScalabilityMode [string](/builtin#string) `json:"scalabilityMode"`}
OutboundRTPStreamStats contains statistics for an outbound RTP stream that is currently sent with this PeerConnection object.
type PeerConnection struct {
}
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(configuration Configuration) (*PeerConnection, error)
NewPeerConnection creates a PeerConnection with the default codecs and interceptors.
If you wish to customize the set of available codecs and/or the set of active interceptors, create an API with a custom MediaEngine and/or interceptor.Registry, then call [(*API).NewPeerConnection] instead of this function.
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.
AddTrack adds a Track to the PeerConnection.
func (pc *PeerConnection) AddTransceiverFromKind( kind RTPCodecType, init ...RTPTransceiverInit, ) (t *RTPTransceiver, err error)
AddTransceiverFromKind Create a new RtpTransceiver and adds it to the set of transceivers.
func (pc *PeerConnection) AddTransceiverFromTrack( track TrackLocal, init ...RTPTransceiverInit, ) (t *RTPTransceiver, err error)
AddTransceiverFromTrack Create a new RtpTransceiver(SendRecv or SendOnly) and add it to the set of transceivers.
func (*PeerConnection) CanTrickleICECandidates ¶ added in v4.1.7
func (pc *PeerConnection) CanTrickleICECandidates() ICETrickleCapability
CanTrickleICECandidates reports whether the remote endpoint indicated support for receiving trickled ICE candidates.
Close ends the PeerConnection.
func (pc *PeerConnection) ConnectionState() PeerConnectionState
ConnectionState attribute returns the connection state of the PeerConnection instance.
CreateAnswer starts the PeerConnection and generates the localDescription.
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 (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 (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 (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 (pc PeerConnection) GetReceivers() (receivers []RTPReceiver)
GetReceivers returns the RTPReceivers that are currently attached to this PeerConnection.
func (pc PeerConnection) GetSenders() (result []RTPSender)
GetSenders returns the RTPSender that are currently attached to this PeerConnection.
func (pc *PeerConnection) GetStats() StatsReport
GetStats return data providing statistics about the overall connection.
func (pc PeerConnection) GetTransceivers() []RTPTransceiver
GetTransceivers returns the RtpTransceiver that are currently attached to this PeerConnection.
func (pc *PeerConnection) GracefulClose() error
GracefulClose ends the PeerConnection. It also waits for any goroutines it started to complete. This is only safe to call outside of PeerConnection callbacks or if in a callback, in its own goroutine.
func (pc *PeerConnection) ICEConnectionState() ICEConnectionState
ICEConnectionState returns the ICE connection state of the PeerConnection instance.
func (pc *PeerConnection) ICEGatheringState() ICEGatheringState
ICEGatheringState attribute returns the ICE gathering state of the PeerConnection instance.
func (pc *PeerConnection) OnConnectionStateChange(f func(PeerConnectionState))
OnConnectionStateChange sets an event handler which is called when the PeerConnectionState has changed.
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. ICE candidate gathering only begins when SetLocalDescription or SetRemoteDescription is called. Take note that the handler will be called with a nil pointer when gathering is finished.
func (pc *PeerConnection) OnICEConnectionStateChange(f func(ICEConnectionState))
OnICEConnectionStateChange sets an event handler which is called when an ICE connection state is changed.
func (pc *PeerConnection) OnICEGatheringStateChange(f func(ICEGatheringState))
OnICEGatheringStateChange sets an event handler which is invoked when the ICE candidate gathering state has changed.
func (pc *PeerConnection) OnNegotiationNeeded(f func())
OnNegotiationNeeded sets an event handler which is invoked when a change has occurred which requires session negotiation.
func (pc *PeerConnection) OnSignalingStateChange(f func(SignalingState))
OnSignalingStateChange sets an event handler which is invoked when the peer connection's signaling state changes.
func (pc PeerConnection) OnTrack(f func(TrackRemote, *RTPReceiver))
OnTrack sets an event handler which is called when remote track arrives from a remote peer.
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 (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 (pc *PeerConnection) RemoveTrack(sender *RTPSender) (err error)
RemoveTrack removes a Track from the PeerConnection.
func (pc *PeerConnection) SCTP() *SCTPTransport
SCTP returns the SCTPTransport for this PeerConnection
The SCTP transport over which SCTP data is sent and received. If SCTP has not been negotiated, the value is nil.https://www.w3.org/TR/webrtc/#attributes-15
func (pc *PeerConnection) SetConfiguration(configuration Configuration) error
SetConfiguration updates the configuration of this PeerConnection object.
SetIdentityProvider is used to configure an identity provider to generate identity assertions.
func (pc *PeerConnection) SetLocalDescription(desc SessionDescription) error
SetLocalDescription sets the SessionDescription of the local peer
func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error
SetRemoteDescription sets the SessionDescription of the remote peer
func (pc *PeerConnection) SignalingState() SignalingState
SignalingState attribute returns the signaling state of the PeerConnection instance.
WriteRTCP sends a user provided RTCP packet to the connected peer. If no peer is connected the packet is discarded. It also runs any configured interceptors.
type PeerConnectionState int
PeerConnectionState indicates the state of the PeerConnection.
const (
PeerConnectionStateUnknown [PeerConnectionState](#PeerConnectionState) = [iota](/builtin#iota)
PeerConnectionStateNew
PeerConnectionStateConnecting
PeerConnectionStateConnected
PeerConnectionStateDisconnected
PeerConnectionStateFailed
PeerConnectionStateClosed)
type PeerConnectionStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
DataChannelsOpened [uint32](/builtin#uint32) `json:"dataChannelsOpened"`
DataChannelsClosed [uint32](/builtin#uint32) `json:"dataChannelsClosed"`
DataChannelsRequested [uint32](/builtin#uint32) `json:"dataChannelsRequested"`
DataChannelsAccepted [uint32](/builtin#uint32) `json:"dataChannelsAccepted"`}
PeerConnectionStats contains statistics related to the PeerConnection object.
type QualityLimitationReason string
QualityLimitationReason lists the reason for limiting the resolution and/or framerate. Only valid for video.
const (
QualityLimitationReasonNone [QualityLimitationReason](#QualityLimitationReason) = "none"
QualityLimitationReasonCPU [QualityLimitationReason](#QualityLimitationReason) = "cpu"
QualityLimitationReasonBandwidth [QualityLimitationReason](#QualityLimitationReason) = "bandwidth"
QualityLimitationReasonOther [QualityLimitationReason](#QualityLimitationReason) = "other")
RTCPMuxPolicy affects what ICE candidates are gathered to support non-multiplexed RTCP.
const (
RTCPMuxPolicyUnknown [RTCPMuxPolicy](#RTCPMuxPolicy) = [iota](/builtin#iota)
RTCPMuxPolicyNegotiate
RTCPMuxPolicyRequire)
MarshalJSON returns the JSON encoding.
UnmarshalJSON parses the JSON-encoded data and stores the result.
type RTPCodecParameters struct { RTPCodecCapability PayloadType PayloadType
}
RTPCodecParameters is a sequence containing the media codecs that an RtpSender will choose from, as well as entries for RTX, RED and FEC mechanisms. This also includes the PayloadType that has been negotiated
https://w3c.github.io/webrtc-pc/#rtcrtpcodecparameters
RTPCodecType determines the type of a codec.
const (
RTPCodecTypeUnknown [RTPCodecType](#RTPCodecType) = [iota](/builtin#iota)
RTPCodecTypeAudio
RTPCodecTypeVideo)
NewRTPCodecType creates a RTPCodecType from a string.
type RTPCodingParameters struct {
RID string json:"rid"
SSRC SSRC json:"ssrc"
PayloadType PayloadType json:"payloadType"
RTX RTPRtxParameters json:"rtx"
FEC RTPFecParameters json:"fec"
}
RTPCodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement encoding/decoding itselfhttp://draft.ortc.org/#dom-rtcrtpcodingparameters
type RTPContributingSourceStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
ContributorSSRC [SSRC](#SSRC) `json:"contributorSsrc"`
InboundRTPStreamID [string](/builtin#string) `json:"inboundRtpStreamId"`
PacketsContributedTo [uint32](/builtin#uint32) `json:"packetsContributedTo"`
AudioLevel [float64](/builtin#float64) `json:"audioLevel"`}
RTPContributingSourceStats contains statistics for a contributing source (CSRC) that contributed to an inbound RTP stream.
type RTPReceiveParameters struct { Encodings []RTPDecodingParameters }
RTPReceiveParameters contains the RTP stack settings used by receivers.
type RTPReceiver struct {
}
RTPReceiver allows an application to inspect the receipt of a TrackRemote.
func (r *RTPReceiver) GetParameters() RTPParameters
GetParameters describes the current configuration for the encoding and transmission of media on the receiver's track.
func (r *RTPReceiver) RTPTransceiver() *RTPTransceiver
RTPTransceiver returns the RTPTransceiver this RTPReceiver belongs too, or nil if none.
Read reads incoming RTCP for this RTPReceiver.
ReadRTCP is a convenience method that wraps Read and unmarshal for you. It also runs any configured interceptors.
ReadSimulcast reads incoming RTCP for this RTPReceiver for given rid.
ReadSimulcastRTCP is a convenience method that wraps ReadSimulcast and unmarshal for you.
Receive initialize the track and starts all the transports.
func (r *RTPReceiver) SetRTPParameters(params RTPParameters)
SetRTPParameters applies provided RTPParameters the RTPReceiver's tracks.
This method is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
The amount of provided codecs must match the number of tracks on the receiver.
SetReadDeadline sets the max amount of time the RTCP stream will block before returning. 0 is forever.
SetReadDeadlineSimulcast sets the max amount of time the RTCP stream for a given rid will block before returning. 0 is forever.
Stop irreversibly stops the RTPReceiver.
func (r *RTPReceiver) Track() *TrackRemote
Track returns the RtpTransceiver TrackRemote.
func (r RTPReceiver) Tracks() []TrackRemote
Tracks returns the RtpTransceiver tracks A RTPReceiver to support Simulcast may now have multiple tracks.
func (r *RTPReceiver) Transport() *DTLSTransport
Transport returns the currently-configured *DTLSTransport or nil if one has not yet been configured.
type RTPSendParameters struct { RTPParameters Encodings []RTPEncodingParameters }
RTPSendParameters contains the RTP stack settings used by receivers.
type RTPSender struct {
}
RTPSender allows an application to control how a given Track is encoded and transmitted to a remote peer.
func (r *RTPSender) AddEncoding(track TrackLocal) error
AddEncoding adds an encoding to RTPSender. Used by simulcast senders.
func (r *RTPSender) GetParameters() RTPSendParameters
GetParameters describes the current configuration for the encoding and transmission of media on the sender's track.
Read reads incoming RTCP for this RTPSender.
ReadRTCP is a convenience method that wraps Read and unmarshals for you.
ReadSimulcast reads incoming RTCP for this RTPSender for given rid.
ReadSimulcastRTCP is a convenience method that wraps ReadSimulcast and unmarshal for you.
func (r *RTPSender) ReplaceTrack(track TrackLocal) error
ReplaceTrack replaces the track currently being used as the sender's source with a new TrackLocal. The new track must be of the same media kind (audio, video, etc) and switching the track should not require negotiation.
Send Attempts to set the parameters controlling the sending of media.
SetReadDeadline sets the deadline for the Read operation. Setting to zero means no deadline.
SetReadDeadlineSimulcast sets the max amount of time the RTCP stream for a given rid will block before returning. 0 is forever.
Stop irreversibly stops the RTPSender.
func (r *RTPSender) Track() TrackLocal
Track returns the RTCRtpTransceiver track, or nil.
func (r *RTPSender) Transport() *DTLSTransport
Transport returns the currently-configured *DTLSTransport or nil if one has not yet been configured.
type RTPTransceiver struct {
}
RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid.
func (t *RTPTransceiver) Direction() RTPTransceiverDirection
Direction returns the RTPTransceiver's current direction.
func (t *RTPTransceiver) Kind() RTPCodecType
Kind returns RTPTransceiver's kind.
Mid gets the Transceiver's mid value. When not already set, this value will be set in CreateOffer or CreateAnswer.
func (t *RTPTransceiver) Receiver() *RTPReceiver
Receiver returns the RTPTransceiver's RTPReceiver if it has one.
func (t *RTPTransceiver) Sender() *RTPSender
Sender returns the RTPTransceiver's RTPSender if it has one.
func (t *RTPTransceiver) SetCodecPreferences(codecs []RTPCodecParameters) error
SetCodecPreferences sets preferred list of supported codecs if codecs is empty or nil we reset to default from MediaEngine.
SetMid sets the RTPTransceiver's mid. If it was already set, will return an error.
SetSender sets the RTPSender and Track to current transceiver.
Stop irreversibly stops the RTPTransceiver.
type RTPTransceiverDirection int
RTPTransceiverDirection indicates the direction of the RTPTransceiver.
const (
RTPTransceiverDirectionUnknown [RTPTransceiverDirection](#RTPTransceiverDirection) = [iota](/builtin#iota)
RTPTransceiverDirectionSendrecv
RTPTransceiverDirectionSendonly
RTPTransceiverDirectionRecvonly
RTPTransceiverDirectionInactive)
func NewRTPTransceiverDirection(raw string) RTPTransceiverDirection
NewRTPTransceiverDirection defines a procedure for creating a new RTPTransceiverDirection from a raw string naming the transceiver direction.
Revers indicate the opposite direction.
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 RemoteInboundRTPStreamStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
SSRC [SSRC](#SSRC) `json:"ssrc"`
Kind [string](/builtin#string) `json:"kind"`
TransportID [string](/builtin#string) `json:"transportId"`
CodecID [string](/builtin#string) `json:"codecId"`
FIRCount [uint32](/builtin#uint32) `json:"firCount"`
PLICount [uint32](/builtin#uint32) `json:"pliCount"`
NACKCount [uint32](/builtin#uint32) `json:"nackCount"`
SLICount [uint32](/builtin#uint32) `json:"sliCount"`
QPSum [uint64](/builtin#uint64) `json:"qpSum"`
PacketsReceived [uint32](/builtin#uint32) `json:"packetsReceived"`
PacketsLost [int32](/builtin#int32) `json:"packetsLost"`
Jitter [float64](/builtin#float64) `json:"jitter"`
PacketsDiscarded [uint32](/builtin#uint32) `json:"packetsDiscarded"`
PacketsRepaired [uint32](/builtin#uint32) `json:"packetsRepaired"`
BurstPacketsLost [uint32](/builtin#uint32) `json:"burstPacketsLost"`
BurstPacketsDiscarded [uint32](/builtin#uint32) `json:"burstPacketsDiscarded"`
BurstLossCount [uint32](/builtin#uint32) `json:"burstLossCount"`
BurstDiscardCount [uint32](/builtin#uint32) `json:"burstDiscardCount"`
BurstLossRate [float64](/builtin#float64) `json:"burstLossRate"`
BurstDiscardRate [float64](/builtin#float64) `json:"burstDiscardRate"`
GapLossRate [float64](/builtin#float64) `json:"gapLossRate"`
GapDiscardRate [float64](/builtin#float64) `json:"gapDiscardRate"`
LocalID [string](/builtin#string) `json:"localId"`
RoundTripTime [float64](/builtin#float64) `json:"roundTripTime"`
TotalRoundTripTime [float64](/builtin#float64) `json:"totalRoundTripTime"`
FractionLost [float64](/builtin#float64) `json:"fractionLost"`
RoundTripTimeMeasurements [uint64](/builtin#uint64) `json:"roundTripTimeMeasurements"`}
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 struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
SSRC [SSRC](#SSRC) `json:"ssrc"`
Kind [string](/builtin#string) `json:"kind"`
TransportID [string](/builtin#string) `json:"transportId"`
CodecID [string](/builtin#string) `json:"codecId"`
FIRCount [uint32](/builtin#uint32) `json:"firCount"`
PLICount [uint32](/builtin#uint32) `json:"pliCount"`
NACKCount [uint32](/builtin#uint32) `json:"nackCount"`
SLICount [uint32](/builtin#uint32) `json:"sliCount"`
QPSum [uint64](/builtin#uint64) `json:"qpSum"`
PacketsSent [uint32](/builtin#uint32) `json:"packetsSent"`
PacketsDiscardedOnSend [uint32](/builtin#uint32) `json:"packetsDiscardedOnSend"`
FECPacketsSent [uint32](/builtin#uint32) `json:"fecPacketsSent"`
BytesSent [uint64](/builtin#uint64) `json:"bytesSent"`
BytesDiscardedOnSend [uint64](/builtin#uint64) `json:"bytesDiscardedOnSend"`
LocalID [string](/builtin#string) `json:"localId"`
RemoteTimestamp [StatsTimestamp](#StatsTimestamp) `json:"remoteTimestamp"`
ReportsSent [uint64](/builtin#uint64) `json:"reportsSent"`
RoundTripTime [float64](/builtin#float64) `json:"roundTripTime"`
TotalRoundTripTime [float64](/builtin#float64) `json:"totalRoundTripTime"`
RoundTripTimeMeasurements [uint64](/builtin#uint64) `json:"roundTripTimeMeasurements"`}
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 SCTPCapabilities struct {
MaxMessageSize uint32 json:"maxMessageSize"
}
SCTPCapabilities indicates the capabilities of the SCTPTransport.
type SCTPTransport struct {
}
SCTPTransport provides details about the SCTP transport.
func (r *SCTPTransport) BufferedAmount() int
BufferedAmount returns total amount (in bytes) of currently buffered user data.
func (r *SCTPTransport) GetCapabilities() SCTPCapabilities
GetCapabilities returns the SCTPCapabilities of the SCTPTransport.
MaxChannels is the maximum number of RTCDataChannels that can be open simultaneously.
func (r *SCTPTransport) OnClose(f func(err error))
OnClose sets an event handler which is invoked when the SCTP Association closes.
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 (r SCTPTransport) OnDataChannelOpened(f func(DataChannel))
OnDataChannelOpened sets an event handler which is invoked when a data channel is opened.
func (r *SCTPTransport) OnError(f func(err error))
OnError sets an event handler which is invoked when the SCTP Association errors.
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 (r *SCTPTransport) State() SCTPTransportState
State returns the current state of the SCTPTransport.
Stop stops the SCTPTransport.
func (r *SCTPTransport) Transport() *DTLSTransport
Transport returns the DTLSTransport instance the SCTPTransport is sending over.
type SCTPTransportState int
SCTPTransportState indicates the state of the SCTP transport.
const (
SCTPTransportStateUnknown [SCTPTransportState](#SCTPTransportState) = [iota](/builtin#iota)
SCTPTransportStateConnecting
SCTPTransportStateConnected
SCTPTransportStateClosed)
type SCTPTransportStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
TransportID [string](/builtin#string) `json:"transportId"`
SmoothedRoundTripTime [float64](/builtin#float64) `json:"smoothedRoundTripTime"`
CongestionWindow [uint32](/builtin#uint32) `json:"congestionWindow"`
ReceiverWindow [uint32](/builtin#uint32) `json:"receiverWindow"`
MTU [uint32](/builtin#uint32) `json:"mtu"`
UNACKData [uint32](/builtin#uint32) `json:"unackData"`
BytesSent [uint64](/builtin#uint64) `json:"bytesSent"`
BytesReceived [uint64](/builtin#uint64) `json:"bytesReceived"`}
SCTPTransportStats contains information about a certificate used by an SCTPTransport.
SDPSemantics determines which style of SDP offers and answers can be used.
const (
SDPSemanticsUnifiedPlan [SDPSemantics](#SDPSemantics) = [iota](/builtin#iota)
SDPSemanticsPlanB
SDPSemanticsUnifiedPlanWithFallback)
MarshalJSON returns the JSON encoding.
UnmarshalJSON parses the JSON-encoded data and stores the result.
SDPType describes the type of an SessionDescription.
const (
SDPTypeUnknown [SDPType](#SDPType) = [iota](/builtin#iota)
SDPTypeOffer
SDPTypePranswer
SDPTypeAnswer
SDPTypeRollback)
NewSDPType creates an SDPType from a string.
MarshalJSON enables JSON marshaling of a SDPType.
UnmarshalJSON enables JSON unmarshaling of a SDPType.
SSRC represents a synchronization source A synchronization source is a randomly chosen value meant to be globally unique within a particular RTP session. Used to identify a single stream of media.
https://tools.ietf.org/html/rfc3550#section-3
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 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 struct {
Type SDPType json:"type"
SDP string json:"sdp"
}
SessionDescription is used to expose local and remote session descriptions.
Unmarshal is a helper to deserialize the sdp.
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 (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 (e *SettingEngine) DisableActiveTCP(isDisabled bool)
DisableActiveTCP disables using active TCP for ICE. Active TCP is enabled by default.
func (e *SettingEngine) DisableCertificateFingerprintVerification(isDisabled bool)
DisableCertificateFingerprintVerification disables fingerprint verification after DTLS Handshake has finished.
func (e *SettingEngine) DisableCloseByDTLS(isEnabled bool)
DisableCloseByDTLS sets if the connection should be closed when dtls transport is closed. Setting this to true will keep the connection open when dtls transport is closed and relies on the ice failed state to detect the connection is interrupted.
func (e *SettingEngine) DisableMediaEngineCopy(isDisabled bool)
DisableMediaEngineCopy stops the MediaEngine from being copied. This allows a user to modify the MediaEngine after the PeerConnection has been constructed. This is useful if you wish to modify codecs after signaling. Make sure not to share MediaEngines between PeerConnections.
func (e *SettingEngine) DisableMediaEngineMultipleCodecs(isDisabled bool)
DisableMediaEngineMultipleCodecs disables the MediaEngine negotiating different codecs. With the default value multiple media sections in the SDP can each negotiate different codecs. This is the new default behvior, because it makes Pion more spec compliant. The value of this setting will get copied to every copy of the MediaEngine generated for new PeerConnections (assuming DisableMediaEngineCopy is set to false). Note: this setting is targeted to be removed in release 4.2.0 (or later).
func (e *SettingEngine) DisableSRTCPReplayProtection(isDisabled bool)
DisableSRTCPReplayProtection disables SRTCP replay protection.
func (e *SettingEngine) DisableSRTPReplayProtection(isDisabled bool)
DisableSRTPReplayProtection disables SRTP replay protection.
func (e *SettingEngine) EnableDataChannelBlockWrite(nonblockWrite bool)
EnableDataChannelBlockWrite allows data channels to block on write, it only works if DetachDataChannels is enabled.
func (e *SettingEngine) EnableSCTPZeroChecksum(isEnabled bool)
EnableSCTPZeroChecksum controls the zero checksum feature in SCTP. This removes the need to checksum every incoming/outgoing packet and will reduce latency and CPU usage. This feature is not backwards compatible so is disabled by default.
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
SetDTLSCertificateRequestMessageHook if not nil, is called when a DTLS Certificate Request message is sent from a client. The returned handshake message replaces the original message.
SetDTLSCipherSuites allows the user to specify a list of DTLS CipherSuites. This allow to control which ciphers implemented by pion/dtls are used during the DTLS handshake. It can be used for DTLS connection hardening.
SetDTLSClientAuth sets the client auth type for DTLS.
SetDTLSClientCAs sets the client CA certificate pool for DTLS certificate verification.
SetDTLSClientHelloMessageHook if not nil, is called when a DTLS Client Hello message is sent from a client. The returned handshake message replaces the original message.
func (e *SettingEngine) SetDTLSConnectContextMaker(connectContextMaker func() (context.Context, func()))
SetDTLSConnectContextMaker sets the context used during the DTLS Handshake. It can be used to extend or reduce the timeout on the DTLS Handshake. If nil, the default dtls.ConnectContextMaker is used. It can be implemented as following.
func ConnectContextMaker() (context.Context, func()) { return context.WithTimeout(context.Background(), 30*time.Second) }
func (e *SettingEngine) SetDTLSCustomerCipherSuites(customCipherSuites func() []dtls.CipherSuite)
SetDTLSCustomerCipherSuites allows the user to specify a list of custom DTLS CipherSuites. It allows to use custom/private DTLS CipherSuites in addition to the ones implemented by pion/dtls.
func (e *SettingEngine) SetDTLSDisableInsecureSkipVerify(disable bool)
SetDTLSDisableInsecureSkipVerify sets the disable skip insecure verify flag for DTLS. This controls whether a client verifies the server's certificate chain and host name.
SetDTLSEllipticCurves sets the elliptic curves for DTLS.
SetDTLSExtendedMasterSecret sets the extended master secret type for DTLS.
func (e *SettingEngine) SetDTLSInsecureSkipHelloVerify(skip bool)
SetDTLSInsecureSkipHelloVerify sets the skip HelloVerify flag for DTLS. If true and when acting as DTLS server, will allow client to skip hello verify phase and receive ServerHello after initial ClientHello. This will mean faster connect times, but will have lower DoS attack resistance.
func (e *SettingEngine) SetDTLSKeyLogWriter(writer io.Writer)
SetDTLSKeyLogWriter sets the destination of the TLS key material for debugging. Logging key material compromises security and should only be use for debugging.
func (e *SettingEngine) SetDTLSReplayProtectionWindow(n uint)
SetDTLSReplayProtectionWindow sets a replay attack protection window size of DTLS connection.
SetDTLSRetransmissionInterval sets the retranmission interval for DTLS.
SetDTLSRootCAs sets the root CA certificate pool for DTLS certificate verification.
SetDTLSServerHelloMessageHook if not nil, is called when a DTLS Server Hello message is sent from a client. The returned handshake message replaces the original message.
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.
When portMin and portMax are left to the 0 default value, pion/ice candidate gatherer replaces them and uses 1 for portMin and 65535 for portMax.
func (e *SettingEngine) SetFireOnTrackBeforeFirstRTP(fireOnTrackBeforeFirstRTP bool)
SetFireOnTrackBeforeFirstRTP sets if firing the OnTrack event should happen before any RTP packets are received. Setting this to true will have the Track's Codec and PayloadTypes be initially set to their zero values in the OnTrack handler. Note: This does not yet affect simulcast tracks.
func (*SettingEngine) SetHandleUndeclaredSSRCWithoutAnswer ¶ added in v4.1.4
func (e *SettingEngine) SetHandleUndeclaredSSRCWithoutAnswer(handleUndeclaredSSRCWithoutAnswer bool)
SetHandleUndeclaredSSRCWithoutAnswer controls if an SDP answer is required for processing early media of non-simulcast tracks.
SetHostAcceptanceMinWait sets the ICEHostAcceptanceMinWait.
func (*SettingEngine) SetICEBindingRequestHandler ¶
SetICEBindingRequestHandler sets a callback that is fired on a STUN BindingRequest This allows users to do things like - Log incoming Binding Requests for debugging - Implement draft-thatcher-ice-renomination - Implement custom CandidatePair switching logic.
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 (e *SettingEngine) SetICEMaxBindingRequests(d uint16)
SetICEMaxBindingRequests sets the maximum amount of binding requests that can be sent on a candidate before it is considered invalid.
SetICEMulticastDNSMode controls if pion/ice queries and generates mDNS ICE Candidates.
SetICEProxyDialer sets the proxy dialer interface based on golang.org/x/net/proxy.
SetICETCPMux enables ICE-TCP when set to a non-nil value. Make sure that NetworkTypeTCP4 or NetworkTypeTCP6 is enabled as well.
func (e *SettingEngine) SetICETimeouts(disconnectedTimeout, failedTimeout, keepAliveInterval time.Duration)
SetICETimeouts sets the behavior around ICE Timeouts
disconnectedTimeout:
Duration without network activity before an Agent is considered disconnected. Default is 5 Seconds
failedTimeout:
Duration without network activity before an Agent is considered failed after disconnected. Default is 25 Seconds
keepAliveInterval:
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.
SetICEUDPMux allows ICE traffic to come through a single UDP port, drastically simplifying deployments where ports will need to be opened/forwarded. UDPMux should be started prior to creating PeerConnections.
func (e *SettingEngine) SetIPFilter(filter func(net.IP) (keep bool))
SetIPFilter sets the filtering functions when gathering ICE candidates This can be used to exclude certain ip from ICE. Which may be useful if you know a certain ip will never succeed, or if you wish to reduce the amount of information you wish to expose to the remote peer.
func (e *SettingEngine) SetIgnoreRidPauseForRecv(ignoreRidPauseForRecv bool)
SetIgnoreRidPauseForRecv controls if SDP `a=simulcast:recv` will include the paused attribute of a RID (simulcast layer).
func (*SettingEngine) SetIncludeLoopbackCandidate ¶
func (e *SettingEngine) SetIncludeLoopbackCandidate(include bool)
SetIncludeLoopbackCandidate enable pion to gather loopback candidates, it is useful for some VM have public IP mapped to loopback interface.
func (e *SettingEngine) SetInterfaceFilter(filter func(string) (keep 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 (e *SettingEngine) SetLite(lite bool)
SetLite configures whether or not the ice agent should be a lite agent.
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 (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 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.
SetNet sets the Net instance that is passed to pion/ice
Net is an network interface layer for Pion, allowing users to replace Pions network stack with a custom implementation.
func (e *SettingEngine) SetNetworkTypes(candidateTypes []NetworkType)
SetNetworkTypes configures what types of candidate networks are supported during local and server reflexive gathering.
SetPrflxAcceptanceMinWait sets the ICEPrflxAcceptanceMinWait.
func (e *SettingEngine) SetReceiveMTU(receiveMTU uint)
SetReceiveMTU sets the size of read buffer that copies incoming packets. This is optional. Leave this 0 for the default receiveMTU.
SetRelayAcceptanceMinWait sets the ICERelayAcceptanceMinWait.
func (e *SettingEngine) SetSCTPCwndCAStep(cwndCAStep uint32)
SetSCTPCwndCAStep sets congestion window adjustment step size during congestion avoidance.
func (e *SettingEngine) SetSCTPFastRtxWnd(fastRtxWnd uint32)
SetSCTPFastRtxWnd sets the fast retransmission window size.
func (e *SettingEngine) SetSCTPMaxMessageSize(maxMessageSize uint32)
SetSCTPMaxMessageSize sets the largest message we are willing to accept. Leave this 0 for the default max message size.
func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32)
SetSCTPMaxReceiveBufferSize sets the maximum receive buffer size. Leave this 0 for the default maxReceiveBufferSize.
func (e *SettingEngine) SetSCTPMinCwnd(minCwnd uint32)
SetSCTPMinCwnd sets the minimum congestion window size. The congestion window will not be smaller than this value during congestion control.
SetSCTPRTOMax sets the maximum retransmission timeout. Leave this 0 for the default timeout.
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 (e *SettingEngine) SetSRTCPReplayProtectionWindow(n uint)
SetSRTCPReplayProtectionWindow sets a replay attack protection window size of SRTCP session.
SetSRTPProtectionProfiles allows the user to override the default SRTP Protection Profiles The default srtp protection profiles are provided by the function `defaultSrtpProtectionProfiles`.
func (e *SettingEngine) SetSRTPReplayProtectionWindow(n uint)
SetSRTPReplayProtectionWindow sets a replay attack protection window size of SRTP session.
SetSTUNGatherTimeout sets the ICESTUNGatherTimeout.
SetSrflxAcceptanceMinWait sets the ICESrflxAcceptanceMinWait.
type SignalingState int32
SignalingState indicates the signaling state of the offer/answer process.
const (
SignalingStateUnknown [SignalingState](#SignalingState) = [iota](/builtin#iota)
SignalingStateStable
SignalingStateHaveLocalOffer
SignalingStateHaveRemoteOffer
SignalingStateHaveLocalPranswer
SignalingStateHaveRemotePranswer
SignalingStateClosed)
func (t *SignalingState) Get() SignalingState
Get thread safe read value.
func (t *SignalingState) Set(state SignalingState)
Set thread safe write value.
A Stats object contains a set of statistics copies out of a monitored component of the WebRTC stack at a specific time.
UnmarshalStatsJSON unmarshals a Stats object from JSON.
type StatsICECandidatePairState ¶
type StatsICECandidatePairState string
StatsICECandidatePairState is the state of an ICE candidate pair used in the ICECandidatePairStats object.
const (
StatsICECandidatePairStateFrozen [StatsICECandidatePairState](#StatsICECandidatePairState) = "frozen"
StatsICECandidatePairStateWaiting [StatsICECandidatePairState](#StatsICECandidatePairState) = "waiting"
StatsICECandidatePairStateInProgress [StatsICECandidatePairState](#StatsICECandidatePairState) = "in-progress"
StatsICECandidatePairStateFailed [StatsICECandidatePairState](#StatsICECandidatePairState) = "failed"
StatsICECandidatePairStateSucceeded [StatsICECandidatePairState](#StatsICECandidatePairState) = "succeeded")
StatsReport collects Stats objects indexed by their ID.
func (r StatsReport) GetCertificateStats(c *Certificate) (CertificateStats, bool)
GetCertificateStats is a helper method to return the associated stats for a given Certificate.
GetCodecStats is a helper method to return the associated stats for a given Codec.
func (r StatsReport) GetConnectionStats(conn *PeerConnection) (PeerConnectionStats, bool)
GetConnectionStats is a helper method to return the associated stats for a given PeerConnection.
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.
StatsTimestamp is a timestamp represented by the floating point number of milliseconds since the epoch.
Time returns the time.Time represented by this timestamp.
StatsType indicates the type of the object that a Stats object represents.
const (
StatsTypeCodec [StatsType](#StatsType) = "codec"
StatsTypeInboundRTP [StatsType](#StatsType) = "inbound-rtp"
StatsTypeOutboundRTP [StatsType](#StatsType) = "outbound-rtp"
StatsTypeRemoteInboundRTP [StatsType](#StatsType) = "remote-inbound-rtp"
StatsTypeRemoteOutboundRTP [StatsType](#StatsType) = "remote-outbound-rtp"
StatsTypeCSRC [StatsType](#StatsType) = "csrc"
StatsTypeMediaSource = "media-source"
StatsTypeMediaPlayout [StatsType](#StatsType) = "media-playout"
StatsTypePeerConnection [StatsType](#StatsType) = "peer-connection"
StatsTypeDataChannel [StatsType](#StatsType) = "data-channel"
StatsTypeStream [StatsType](#StatsType) = "stream"
StatsTypeTrack [StatsType](#StatsType) = "track"
StatsTypeSender [StatsType](#StatsType) = "sender"
StatsTypeReceiver [StatsType](#StatsType) = "receiver"
StatsTypeTransport [StatsType](#StatsType) = "transport"
StatsTypeCandidatePair [StatsType](#StatsType) = "candidate-pair"
StatsTypeLocalCandidate [StatsType](#StatsType) = "local-candidate"
StatsTypeRemoteCandidate [StatsType](#StatsType) = "remote-candidate"
StatsTypeCertificate [StatsType](#StatsType) = "certificate"
StatsTypeSCTPTransport [StatsType](#StatsType) = "sctp-transport")
TrackLocal is an interface that controls how the user can send media The user can provide their own TrackLocal implementations, or use the implementations in pkg/media.
type TrackLocalContext interface {
CodecParameters() [][RTPCodecParameters](#RTPCodecParameters)
HeaderExtensions() [][RTPHeaderExtensionParameter](#RTPHeaderExtensionParameter)
SSRC() [SSRC](#SSRC)
SSRCRetransmission() [SSRC](#SSRC)
SSRCForwardErrorCorrection() [SSRC](#SSRC)
WriteStream() [TrackLocalWriter](#TrackLocalWriter)
ID() [string](/builtin#string)
RTCPReader() [interceptor](/github.com/pion/interceptor).[RTCPReader](/github.com/pion/interceptor#RTCPReader)}
TrackLocalContext is the Context passed when a TrackLocal has been Binded/Unbinded from a PeerConnection, and used in Interceptors.
type TrackLocalStaticRTP struct {
}
TrackLocalStaticRTP is a TrackLocal that has a pre-set codec and accepts RTP Packets. If you wish to send a media.Sample use TrackLocalStaticSample.
func NewTrackLocalStaticRTP( c RTPCodecCapability, id, streamID string, options ...func(TrackLocalStaticRTP), ) (TrackLocalStaticRTP, error)
NewTrackLocalStaticRTP returns a TrackLocalStaticRTP.
Bind is called by the PeerConnection after negotiation is complete This asserts that the code requested is supported by the remote peer. If so it sets up all the state (SSRC and PayloadType) to have a call.
func (s *TrackLocalStaticRTP) Codec() RTPCodecCapability
Codec gets the Codec of the track.
ID is the unique identifier for this Track. This should be unique for the stream, but doesn't have to globally unique. A common example would be 'audio' or 'video' and StreamID would be 'desktop' or 'webcam'.
func (s *TrackLocalStaticRTP) Kind() RTPCodecType
Kind controls if this TrackLocal is audio or video.
RID is the RTP stream identifier.
StreamID is the group this track belongs too. This must be unique.
Unbind implements the teardown logic when the track is no longer needed. This happens because a track has been stopped.
Write writes a RTP Packet as a buffer to the TrackLocalStaticRTP If one PeerConnection fails the packets will still be sent to all PeerConnections. The error message will contain the ID of the failed PeerConnections so you can remove them.
WriteRTP writes a RTP Packet to the TrackLocalStaticRTP If one PeerConnection fails the packets will still be sent to all PeerConnections. The error message will contain the ID of the failed PeerConnections so you can remove them.
type TrackLocalStaticSample struct {
}
TrackLocalStaticSample is a TrackLocal that has a pre-set codec and accepts Samples. If you wish to send a RTP Packet use TrackLocalStaticRTP.
func NewTrackLocalStaticSample( c RTPCodecCapability, id, streamID string, options ...func(TrackLocalStaticRTP), ) (TrackLocalStaticSample, error)
NewTrackLocalStaticSample returns a TrackLocalStaticSample.
Bind is called by the PeerConnection after negotiation is complete This asserts that the code requested is supported by the remote peer. If so it setups all the state (SSRC and PayloadType) to have a call.
Codec gets the Codec of the track.
GeneratePadding writes padding-only samples to the TrackLocalStaticSample If one PeerConnection fails the packets will still be sent to all PeerConnections. The error message will contain the ID of the failed PeerConnections so you can remove them.
ID is the unique identifier for this Track. This should be unique for the stream, but doesn't have to globally unique. A common example would be 'audio' or 'video' and StreamID would be 'desktop' or 'webcam'.
func (s *TrackLocalStaticSample) Kind() RTPCodecType
Kind controls if this TrackLocal is audio or video.
RID is the RTP stream identifier.
StreamID is the group this track belongs too. This must be unique.
Unbind implements the teardown logic when the track is no longer needed. This happens because a track has been stopped.
WriteSample writes a Sample to the TrackLocalStaticSample If one PeerConnection fails the packets will still be sent to all PeerConnections. The error message will contain the ID of the failed PeerConnections so you can remove them.
TrackLocalWriter is the Writer for outbound RTP Packets.
type TrackRemote struct {
}
TrackRemote represents a single inbound source of media.
func (t *TrackRemote) Codec() RTPCodecParameters
Codec gets the Codec of the track.
HasRTX returns true if the track has a separate RTX stream.
ID is the unique identifier for this Track. This should be unique for the stream, but doesn't have to globally unique. A common example would be 'audio' or 'video' and StreamID would be 'desktop' or 'webcam'.
func (t *TrackRemote) Kind() RTPCodecType
Kind gets the Kind of the track.
Msid gets the Msid of the track.
func (t *TrackRemote) PayloadType() PayloadType
PayloadType gets the PayloadType of the track.
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 TrackRemote will not have an RID, so it is important to assert it is non-zero.
Read reads data from the track.
ReadRTP is a convenience method that wraps Read and unmarshals for you.
func (t *TrackRemote) RtxSSRC() SSRC
RtxSSRC returns the RTX SSRC for a track, or 0 if track does not have a separate RTX stream.
func (t *TrackRemote) SSRC() SSRC
SSRC gets the SSRC of the track.
SetReadDeadline sets the max amount of time the RTP stream will block before returning. 0 is forever.
StreamID is the group this track belongs too. This must be unique.
type TransportStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
PacketsSent [uint32](/builtin#uint32) `json:"packetsSent"`
PacketsReceived [uint32](/builtin#uint32) `json:"packetsReceived"`
BytesSent [uint64](/builtin#uint64) `json:"bytesSent"`
BytesReceived [uint64](/builtin#uint64) `json:"bytesReceived"`
RTCPTransportStatsID [string](/builtin#string) `json:"rtcpTransportStatsId"`
ICERole [ICERole](#ICERole) `json:"iceRole"`
DTLSState [DTLSTransportState](#DTLSTransportState) `json:"dtlsState"`
ICEState [ICETransportState](#ICETransportState) `json:"iceState"`
SelectedCandidatePairID [string](/builtin#string) `json:"selectedCandidatePairId"`
LocalCertificateID [string](/builtin#string) `json:"localCertificateId"`
RemoteCertificateID [string](/builtin#string) `json:"remoteCertificateId"`
DTLSCipher [string](/builtin#string) `json:"dtlsCipher"`
SRTPCipher [string](/builtin#string) `json:"srtpCipher"`}
TransportStats contains transport statistics related to the PeerConnection object.
type VideoReceiverStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
Kind [string](/builtin#string) `json:"kind"`
FrameWidth [uint32](/builtin#uint32) `json:"frameWidth"`
FrameHeight [uint32](/builtin#uint32) `json:"frameHeight"`
FramesPerSecond [float64](/builtin#float64) `json:"framesPerSecond"`
EstimatedPlayoutTimestamp [StatsTimestamp](#StatsTimestamp) `json:"estimatedPlayoutTimestamp"`
JitterBufferDelay [float64](/builtin#float64) `json:"jitterBufferDelay"`
JitterBufferEmittedCount [uint64](/builtin#uint64) `json:"jitterBufferEmittedCount"`
FramesReceived [uint32](/builtin#uint32) `json:"framesReceived"`
KeyFramesReceived [uint32](/builtin#uint32) `json:"keyFramesReceived"`
FramesDecoded [uint32](/builtin#uint32) `json:"framesDecoded"`
FramesDropped [uint32](/builtin#uint32) `json:"framesDropped"`
PartialFramesLost [uint32](/builtin#uint32) `json:"partialFramesLost"`
FullFramesLost [uint32](/builtin#uint32) `json:"fullFramesLost"`}
VideoReceiverStats contains video metrics related to a specific receiver.
type VideoSenderStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
Kind [string](/builtin#string) `json:"kind"`
FramesCaptured [uint32](/builtin#uint32) `json:"framesCaptured"`
FramesSent [uint32](/builtin#uint32) `json:"framesSent"`
HugeFramesSent [uint32](/builtin#uint32) `json:"hugeFramesSent"`
KeyFramesSent [uint32](/builtin#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.
type VideoSourceStats struct {
Timestamp [StatsTimestamp](#StatsTimestamp) `json:"timestamp"`
Type [StatsType](#StatsType) `json:"type"`
ID [string](/builtin#string) `json:"id"`
TrackIdentifier [string](/builtin#string) `json:"trackIdentifier"`
Kind [string](/builtin#string) `json:"kind"`
Width [uint32](/builtin#uint32) `json:"width"`
Height [uint32](/builtin#uint32) `json:"height"`
Frames [uint32](/builtin#uint32) `json:"frames"`
FramesPerSecond [float64](/builtin#float64) `json:"framesPerSecond"`}
VideoSourceStats represents a video track that is attached to one or more senders.