Documentation ¶
Overview ¶
Package webrtc implements the WebRTC 1.0 as defined in W3C WebRTC specification document.
Index ¶
- Constants
- Variables
- func WithMediaEngine(m MediaEngine) func(a *API)
- func WithSettingEngine(s SettingEngine) func(a *API)
- type API
- 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 *Track, transport *DTLSTransport) (*RTPSender, error)
- func (api *API) NewSCTPTransport(dtls *DTLSTransport) *SCTPTransport
- type AnswerOptions
- type BundlePolicy
- type Certificate
- type Configuration
- type DTLSFingerprint
- type DTLSParameters
- type DTLSRole
- type DTLSTransport
- type DTLSTransportState
- type DataChannel
- 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) 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) OnMessage(f func(msg DataChannelMessage))
- func (d *DataChannel) OnOpen(f func())
- func (d *DataChannel) Ordered() bool
- func (d *DataChannel) Priority() PriorityType
- 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
- type DataChannelInit
- type DataChannelMessage
- type DataChannelParameters
- type DataChannelState
- type ICECandidate
- type ICECandidateInit
- type ICECandidatePair
- type ICECandidateType
- type ICEComponent
- type ICEConnectionState
- type ICECredentialType
- type ICEGatherOptions
- type ICEGatherer
- type ICEGathererState
- type ICEGatheringState
- type ICEParameters
- type ICEProtocol
- type ICERole
- type ICEServer
- type ICETransport
- func (t *ICETransport) AddRemoteCandidate(remoteCandidate ICECandidate) 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) Stop() error
- type ICETransportPolicy
- type ICETransportState
- type MediaEngine
- type NetworkType
- type OAuthCredential
- type OfferAnswerOptions
- type OfferOptions
- type PeerConnection
- func (pc *PeerConnection) AddICECandidate(candidate ICECandidateInit) error
- func (pc *PeerConnection) AddTrack(track *Track) (*RTPSender, error)
- func (pc *PeerConnection) AddTransceiver(trackOrKind RTPCodecType, init ...RtpTransceiverInit) (*RTPTransceiver, error)
- 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() []*RTPReceiver
- func (pc *PeerConnection) GetSenders() []*RTPSender
- func (pc *PeerConnection) GetTransceivers() []*RTPTransceiver
- func (pc *PeerConnection) ICEConnectionState() ICEConnectionState
- func (pc *PeerConnection) ICEGatheringState() ICEGatheringState
- func (pc *PeerConnection) LocalDescription() *SessionDescription
- func (pc *PeerConnection) NewTrack(payloadType uint8, ssrc uint32, id, label string) (*Track, error)
- 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())
- func (pc *PeerConnection) OnSignalingStateChange(f func(SignalingState))
- func (pc *PeerConnection) OnTrack(f func(*Track, *RTPReceiver))
- func (pc *PeerConnection) PendingLocalDescription() *SessionDescription
- func (pc *PeerConnection) PendingRemoteDescription() *SessionDescription
- func (pc *PeerConnection) RemoteDescription() *SessionDescription
- func (pc *PeerConnection) SetConfiguration(configuration Configuration) error
- func (pc *PeerConnection) SetIdentityProvider(provider 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
- type PeerConnectionState
- type PriorityType
- type RTCPFeedback
- type RTCPMuxPolicy
- type RTPCapabilities
- type RTPCodec
- func NewRTPCodec(codecType RTPCodecType, name string, clockrate uint32, channels uint16, ...) *RTPCodec
- func NewRTPG722Codec(payloadType uint8, clockrate uint32) *RTPCodec
- func NewRTPH264Codec(payloadType uint8, clockrate uint32) *RTPCodec
- func NewRTPOpusCodec(payloadType uint8, clockrate uint32) *RTPCodec
- func NewRTPVP8Codec(payloadType uint8, clockrate uint32) *RTPCodec
- func NewRTPVP9Codec(payloadType uint8, clockrate uint32) *RTPCodec
- type RTPCodecCapability
- type RTPCodecType
- type RTPCodingParameters
- type RTPDecodingParameters
- type RTPEncodingParameters
- type RTPHeaderExtensionCapability
- type RTPReceiveParameters
- type RTPReceiver
- func (r *RTPReceiver) Read(b []byte) (n int, err error)
- func (r *RTPReceiver) ReadRTCP() ([]rtcp.Packet, error)
- func (r *RTPReceiver) Receive(parameters RTPReceiveParameters) error
- func (r *RTPReceiver) Stop() error
- func (r *RTPReceiver) Track() *Track
- func (r *RTPReceiver) Transport() *DTLSTransport
- type RTPSendParameters
- type RTPSender
- type RTPTransceiver
- type RTPTransceiverDirection
- type RtpTransceiverInit
- type SCTPCapabilities
- type SCTPTransport
- func (r *SCTPTransport) GetCapabilities() SCTPCapabilities
- func (r *SCTPTransport) MaxChannels() uint16
- func (r *SCTPTransport) OnDataChannel(f func(*DataChannel))
- func (r *SCTPTransport) Start(remoteCaps SCTPCapabilities) error
- func (r *SCTPTransport) State() SCTPTransportState
- func (r *SCTPTransport) Stop() error
- func (r *SCTPTransport) Transport() *DTLSTransport
- type SCTPTransportState
- type SDPSemantics
- type SDPType
- type SessionDescription
- type SettingEngine
- type SignalingState
- type Track
- func (t *Track) Codec() *RTPCodec
- func (t *Track) ID() string
- func (t *Track) Kind() RTPCodecType
- func (t *Track) Label() string
- func (t *Track) PayloadType() uint8
- func (t *Track) Read(b []byte) (n int, err error)
- func (t *Track) ReadRTP() (*rtp.Packet, error)
- func (t *Track) SSRC() uint32
- func (t *Track) Write(b []byte) (n int, err error)
- func (t *Track) WriteRTP(p *rtp.Packet) error
- func (t *Track) WriteSample(s media.Sample) error
Constants ¶
const ( // ICETransportStateNew indicates the ICETransport is waiting // for remote candidates to be supplied. ICETransportStateNew = iota + 1 // ICETransportStateChecking indicates the ICETransport has // received at least one remote candidate, and a local and remote // ICECandidateComplete dictionary was not added as the last candidate. ICETransportStateChecking // ICETransportStateConnected indicates the ICETransport has // received a response to an outgoing connectivity check, or has // received incoming DTLS/media after a successful response to an // incoming connectivity check, but is still checking other candidate // pairs to see if there is a better connection. ICETransportStateConnected // ICETransportStateCompleted indicates the ICETransport tested // all appropriate candidate pairs and at least one functioning // candidate pair has been found. ICETransportStateCompleted // ICETransportStateFailed indicates the ICETransport the last // candidate was added and all appropriate candidate pairs have either // failed connectivity checks or have lost consent. ICETransportStateFailed // ICETransportStateDisconnected indicates the ICETransport has received // at least one local and remote candidate, but the final candidate was // received yet and all appropriate candidate pairs thus far have been // tested and failed. ICETransportStateDisconnected // ICETransportStateClosed indicates the ICETransport has shut down // and is no longer responding to STUN requests. ICETransportStateClosed )
const ( DefaultPayloadTypeG722 = 9 DefaultPayloadTypeOpus = 111 DefaultPayloadTypeVP8 = 96 DefaultPayloadTypeVP9 = 98 DefaultPayloadTypeH264 = 102 )
PayloadTypes for the default codecs
const ( G722 = "G722" Opus = "opus" VP8 = "VP8" VP9 = "VP9" H264 = "H264" )
Names for the default codecs supported by pion-webrtc
const ( // Unknown defines default public constant to use for "enum" like struct // comparisons when no value was defined. Unknown = iota )
Variables ¶
var ( // ErrUnknownType indicates an error with Unknown info. ErrUnknownType = errors.New("unknown") // ErrConnectionClosed indicates an operation executed after connection // has already been closed. ErrConnectionClosed = errors.New("connection closed") // ErrDataChannelNotOpen indicates an operation executed when the data // channel is not (yet) open. ErrDataChannelNotOpen = errors.New("data channel not open") // ErrCertificateExpired indicates that an x509 certificate has expired. ErrCertificateExpired = errors.New("x509Cert expired") // ErrNoTurnCredencials indicates that a TURN server URL was provided // without required credentials. ErrNoTurnCredencials = errors.New("turn server credentials required") // ErrTurnCredencials indicates that provided TURN credentials are partial // or malformed. ErrTurnCredencials = errors.New("invalid turn server credentials") // ErrExistingTrack indicates that a track already exists. ErrExistingTrack = errors.New("track already exists") // ErrPrivateKeyType indicates that a particular private key encryption // chosen to generate a certificate is not supported. ErrPrivateKeyType = errors.New("private key type not supported") // ErrModifyingPeerIdentity indicates that an attempt to modify // PeerIdentity was made after PeerConnection has been initialized. ErrModifyingPeerIdentity = errors.New("peerIdentity cannot be modified") // ErrModifyingCertificates indicates that an attempt to modify // Certificates was made after PeerConnection has been initialized. ErrModifyingCertificates = errors.New("certificates cannot be modified") // ErrModifyingBundlePolicy indicates that an attempt to modify // BundlePolicy was made after PeerConnection has been initialized. ErrModifyingBundlePolicy = errors.New("bundle policy cannot be modified") // ErrModifyingRTCPMuxPolicy indicates that an attempt to modify // RTCPMuxPolicy was made after PeerConnection has been initialized. ErrModifyingRTCPMuxPolicy = errors.New("rtcp mux policy cannot be modified") // ErrModifyingICECandidatePoolSize indicates that an attempt to modify // ICECandidatePoolSize was made after PeerConnection has been initialized. ErrModifyingICECandidatePoolSize = errors.New("ice candidate pool size cannot be modified") // ErrStringSizeLimit indicates that the character size limit of string is // exceeded. The limit is hardcoded to 65535 according to specifications. ErrStringSizeLimit = errors.New("data channel label exceeds size limit") // ErrMaxDataChannelID indicates that the maximum number ID that could be // specified for a data channel has been exceeded. ErrMaxDataChannelID = errors.New("maximum number ID for datachannel specified") // ErrNegotiatedWithoutID indicates that an attempt to create a data channel // was made while setting the negotiated option to true without providing // the negotiated channel ID. ErrNegotiatedWithoutID = errors.New("negotiated set without channel id") // ErrRetransmitsOrPacketLifeTime indicates that an attempt to create a data // channel was made with both options MaxPacketLifeTime and MaxRetransmits // set together. Such configuration is not supported by the specification // and is mutually exclusive. ErrRetransmitsOrPacketLifeTime = errors.New("both MaxPacketLifeTime and MaxRetransmits was set") // ErrCodecNotFound is returned when a codec search to the Media Engine fails ErrCodecNotFound = errors.New("codec not found") // ErrNoRemoteDescription indicates that an operation was rejected because // the remote description is not set ErrNoRemoteDescription = errors.New("remote description is not set") // ErrIncorrectSDPSemantics indicates that the PeerConnection was configured to // generate SDP Answers with different SDP Semantics than the received Offer ErrIncorrectSDPSemantics = errors.New("offer SDP semantics does not match configuration") )
Functions ¶
func WithMediaEngine ¶
func WithMediaEngine(m MediaEngine) func(a *API)
WithMediaEngine allows providing a MediaEngine to the API. Settings should not be changed after passing the engine to an API.
func WithSettingEngine ¶
func WithSettingEngine(s SettingEngine) func(a *API)
WithSettingEngine allows providing a SettingEngine to the API. Settings should not be changed after passing the engine to an API.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API bundles the global funcions of the WebRTC and ORTC API. Some of these functions are also exported globally using the defaultAPI object. Note that the global version of the API may be phased out in the future.
func (*API) NewDTLSTransport ¶
func (api *API) NewDTLSTransport(transport *ICETransport, certificates []Certificate) (*DTLSTransport, error)
NewDTLSTransport creates a new DTLSTransport. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
func (*API) NewDataChannel ¶
func (api *API) NewDataChannel(transport *SCTPTransport, params *DataChannelParameters) (*DataChannel, error)
NewDataChannel creates a new DataChannel. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
func (*API) NewICEGatherer ¶
func (api *API) NewICEGatherer(opts ICEGatherOptions) (*ICEGatherer, error)
NewICEGatherer creates a new NewICEGatherer. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
func (*API) NewICETransport ¶
func (api *API) NewICETransport(gatherer *ICEGatherer) *ICETransport
NewICETransport creates a new NewICETransport. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
func (*API) NewPeerConnection ¶
func (api *API) NewPeerConnection(configuration Configuration) (*PeerConnection, error)
NewPeerConnection creates a new PeerConnection with the provided configuration against the received API object
func (*API) NewRTPReceiver ¶
func (api *API) NewRTPReceiver(kind RTPCodecType, transport *DTLSTransport) (*RTPReceiver, error)
NewRTPReceiver constructs a new RTPReceiver
func (*API) NewRTPSender ¶
func (api *API) NewRTPSender(track *Track, transport *DTLSTransport) (*RTPSender, error)
NewRTPSender constructs a new RTPSender
func (*API) NewSCTPTransport ¶
func (api *API) NewSCTPTransport(dtls *DTLSTransport) *SCTPTransport
NewSCTPTransport creates a new SCTPTransport. This constructor is part of the ORTC API. It is not meant to be used together with the basic WebRTC API.
type AnswerOptions ¶
type AnswerOptions struct {
OfferAnswerOptions
}
AnswerOptions structure describes the options used to control the answer creation process.
type BundlePolicy ¶
type BundlePolicy int
BundlePolicy affects which media tracks are negotiated if the remote endpoint is not bundle-aware, and what ICE candidates are gathered. If the remote endpoint is bundle-aware, all media tracks and data channels are bundled onto the same transport.
const ( // BundlePolicyBalanced indicates to gather ICE candidates for each // media type in use (audio, video, and data). If the remote endpoint is // not bundle-aware, negotiate only one audio and video track on separate // transports. BundlePolicyBalanced BundlePolicy = iota + 1 // BundlePolicyMaxCompat indicates to gather ICE candidates for each // track. If the remote endpoint is not bundle-aware, negotiate all media // tracks on separate transports. BundlePolicyMaxCompat // BundlePolicyMaxBundle indicates to gather ICE candidates for only // one track. If the remote endpoint is not bundle-aware, negotiate only // one media track. BundlePolicyMaxBundle )
func (BundlePolicy) String ¶
func (t BundlePolicy) String() string
type Certificate ¶
type Certificate struct {
// contains filtered or unexported fields
}
Certificate represents a x509Cert used to authenticate WebRTC communications.
func GenerateCertificate ¶
func GenerateCertificate(secretKey crypto.PrivateKey) (*Certificate, error)
GenerateCertificate causes the creation of an X.509 certificate and corresponding private key.
func NewCertificate ¶
func NewCertificate(key crypto.PrivateKey, tpl x509.Certificate) (*Certificate, error)
NewCertificate generates a new x509 compliant Certificate to be used by DTLS for encrypting data sent over the wire. This method differs from GenerateCertificate by allowing to specify a template x509.Certificate to be used in order to define certificate parameters.
func (Certificate) Equals ¶
func (c Certificate) Equals(o Certificate) bool
Equals determines if two certificates are identical by comparing both the secretKeys and x509Certificates.
func (Certificate) Expires ¶
func (c Certificate) Expires() time.Time
Expires returns the timestamp after which this certificate is no longer valid.
func (Certificate) GetFingerprints ¶
func (c Certificate) GetFingerprints() ([]DTLSFingerprint, error)
GetFingerprints returns the list of certificate fingerprints, one of which is computed with the digest algorithm used in the certificate signature.
type Configuration ¶
type Configuration struct { // ICEServers defines a slice describing servers available to be used by // ICE, such as STUN and TURN servers. ICEServers []ICEServer // ICETransportPolicy indicates which candidates the ICEAgent is allowed // to use. ICETransportPolicy ICETransportPolicy // BundlePolicy indicates which media-bundling policy to use when gathering // ICE candidates. BundlePolicy BundlePolicy // RTCPMuxPolicy indicates which rtcp-mux policy to use when gathering ICE // candidates. RTCPMuxPolicy RTCPMuxPolicy // PeerIdentity sets the target peer identity for the PeerConnection. // The PeerConnection will not establish a connection to a remote peer // unless it can be successfully authenticated with the provided name. PeerIdentity string // Certificates describes a set of certificates that the PeerConnection // uses to authenticate. Valid values for this parameter are created // through calls to the GenerateCertificate function. Although any given // DTLS connection will use only one certificate, this attribute allows the // caller to provide multiple certificates that support different // algorithms. The final certificate will be selected based on the DTLS // handshake, which establishes which certificates are allowed. The // PeerConnection implementation selects which of the certificates is // used for a given connection; how certificates are selected is outside // the scope of this specification. If this value is absent, then a default // set of certificates is generated for each PeerConnection instance. Certificates []Certificate // ICECandidatePoolSize describes the size of the prefetched ICE pool. ICECandidatePoolSize uint8 // SDPSemantics controls the type of SDP offers accepted by and // SDP answers generated by the PeerConnection. SDPSemantics SDPSemantics }
Configuration defines a set of parameters to configure how the peer-to-peer communication via PeerConnection is established or re-established.
type DTLSFingerprint ¶
type DTLSFingerprint struct { // Algorithm specifies one of the the hash function algorithms defined in // the 'Hash function Textual Names' registry. Algorithm string `json:"algorithm"` // Value specifies the value of the certificate fingerprint in lowercase // hex string as expressed utilizing the syntax of 'fingerprint' in // https://tools.ietf.org/html/rfc4572#section-5. Value string `json:"value"` }
DTLSFingerprint specifies the hash function algorithm and certificate fingerprint as described in https://tools.ietf.org/html/rfc4572.
type DTLSParameters ¶
type DTLSParameters struct { Role DTLSRole `json:"role"` Fingerprints []DTLSFingerprint `json:"fingerprints"` }
DTLSParameters holds information relating to DTLS configuration.
type DTLSRole ¶
type DTLSRole byte
DTLSRole indicates the role of the DTLS transport.
const ( // DTLSRoleAuto defines the DLTS role is determined based on // the resolved ICE role: the ICE controlled role acts as the DTLS // client and the ICE controlling role acts as the DTLS server. DTLSRoleAuto DTLSRole = iota + 1 // DTLSRoleClient defines the DTLS client role. DTLSRoleClient // DTLSRoleServer defines the DTLS server role. DTLSRoleServer )
type DTLSTransport ¶
type DTLSTransport struct {
// contains filtered or unexported fields
}
DTLSTransport allows an application access to information about the DTLS transport over which RTP and RTCP packets are sent and received by RTPSender and RTPReceiver, as well other data such as SCTP packets sent and received by data channels.
func (*DTLSTransport) GetLocalParameters ¶
func (t *DTLSTransport) GetLocalParameters() (DTLSParameters, error)
GetLocalParameters returns the DTLS parameters of the local DTLSTransport upon construction.
func (*DTLSTransport) GetRemoteCertificate ¶
func (t *DTLSTransport) GetRemoteCertificate() []byte
GetRemoteCertificate returns the certificate chain in use by the remote side returns an empty list prior to selection of the remote certificate
func (*DTLSTransport) ICETransport ¶
func (t *DTLSTransport) ICETransport() *ICETransport
ICETransport returns the currently-configured *ICETransport or nil if one has not been configured
func (*DTLSTransport) Start ¶
func (t *DTLSTransport) Start(remoteParameters DTLSParameters) error
Start DTLS transport negotiation with the parameters of the remote DTLS transport
func (*DTLSTransport) Stop ¶
func (t *DTLSTransport) Stop() error
Stop stops and closes the DTLSTransport object.
type DTLSTransportState ¶
type DTLSTransportState int
DTLSTransportState indicates the dtsl transport establishment state.
const ( // DTLSTransportStateNew indicates that DTLS has not started negotiating // yet. DTLSTransportStateNew DTLSTransportState = iota + 1 // DTLSTransportStateConnecting indicates that DTLS is in the process of // negotiating a secure connection and verifying the remote fingerprint. DTLSTransportStateConnecting // DTLSTransportStateConnected indicates that DTLS has completed // negotiation of a secure connection and verified the remote fingerprint. DTLSTransportStateConnected // DTLSTransportStateClosed indicates that the transport has been closed // intentionally as the result of receipt of a close_notify alert, or // calling close(). DTLSTransportStateClosed // DTLSTransportStateFailed indicates that the transport has failed as // the result of an error (such as receipt of an error alert or failure to // validate the remote fingerprint). DTLSTransportStateFailed )
func (DTLSTransportState) String ¶
func (t DTLSTransportState) String() string
type DataChannel ¶
type DataChannel struct {
// contains filtered or unexported fields
}
DataChannel represents a WebRTC DataChannel The DataChannel interface represents a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data
func (*DataChannel) BufferedAmount ¶
func (d *DataChannel) BufferedAmount() uint64
BufferedAmount represents the number of bytes of application data (UTF-8 text and binary data) that have been queued using send(). Even though the data transmission can occur in parallel, the returned value MUST NOT be decreased before the current task yielded back to the event loop to prevent race conditions. The value does not include framing overhead incurred by the protocol, or buffering done by the operating system or network hardware. The value of BufferedAmount slot will only increase with each call to the send() method as long as the ReadyState is open; however, BufferedAmount does not reset to zero once the channel closes.
func (*DataChannel) BufferedAmountLowThreshold ¶
func (d *DataChannel) BufferedAmountLowThreshold() uint64
BufferedAmountLowThreshold represents the threshold at which the bufferedAmount is considered to be low. When the bufferedAmount decreases from above this threshold to equal or below it, the bufferedamountlow event fires. BufferedAmountLowThreshold is initially zero on each new DataChannel, but the application may change its value at any time. The threshold is set to 0 by default.
func (*DataChannel) Close ¶
func (d *DataChannel) Close() error
Close Closes the DataChannel. It may be called regardless of whether the DataChannel object was created by this peer or the remote peer.
func (*DataChannel) Detach ¶
func (d *DataChannel) Detach() (datachannel.ReadWriteCloser, error)
Detach allows you to detach the underlying datachannel. This provides an idiomatic API to work with, however it disables the OnMessage callback. Before calling Detach you have to enable this behavior by calling webrtc.DetachDataChannels(). Combining detached and normal data channels is not supported. Please reffer to the data-channels-detach example and the pion/datachannel documentation for the correct way to handle the resulting DataChannel object.
func (*DataChannel) ID ¶
func (d *DataChannel) ID() *uint16
ID represents the ID for this DataChannel. The value is initially null, which is what will be returned if the ID was not provided at channel creation time, and the DTLS role of the SCTP transport has not yet been negotiated. Otherwise, it will return the ID that was either selected by the script or generated. After the ID is set to a non-null value, it will not change.
func (*DataChannel) Label ¶
func (d *DataChannel) Label() string
Label represents a label that can be used to distinguish this DataChannel object from other DataChannel objects. Scripts are allowed to create multiple DataChannel objects with the same label.
func (*DataChannel) MaxPacketLifeTime ¶
func (d *DataChannel) MaxPacketLifeTime() *uint16
MaxPacketLifeTime represents the length of the time window (msec) during which transmissions and retransmissions may occur in unreliable mode.
func (*DataChannel) MaxRetransmits ¶
func (d *DataChannel) MaxRetransmits() *uint16
MaxRetransmits represents the maximum number of retransmissions that are attempted in unreliable mode.
func (*DataChannel) Negotiated ¶
func (d *DataChannel) Negotiated() bool
Negotiated represents whether this DataChannel was negotiated by the application (true), or not (false).
func (*DataChannel) OnBufferedAmountLow ¶
func (d *DataChannel) OnBufferedAmountLow(f func())
OnBufferedAmountLow sets an event handler which is invoked when the number of bytes of outgoing data becomes lower than the BufferedAmountLowThreshold.
func (*DataChannel) OnClose ¶
func (d *DataChannel) OnClose(f func())
OnClose sets an event handler which is invoked when the underlying data transport has been closed.
func (*DataChannel) OnMessage ¶
func (d *DataChannel) OnMessage(f func(msg DataChannelMessage))
OnMessage sets an event handler which is invoked on a binary message arrival over the sctp transport from a remote peer. OnMessage can currently receive messages up to 16384 bytes in size. Check out the detach API if you want to use larger message sizes. Note that browser support for larger messages is also limited.
func (*DataChannel) OnOpen ¶
func (d *DataChannel) OnOpen(f func())
OnOpen sets an event handler which is invoked when the underlying data transport has been established (or re-established).
func (*DataChannel) Ordered ¶
func (d *DataChannel) Ordered() bool
Ordered represents if the DataChannel is ordered, and false if out-of-order delivery is allowed.
func (*DataChannel) Priority ¶
func (d *DataChannel) Priority() PriorityType
Priority represents the priority for this DataChannel. The priority is assigned at channel creation time.
func (*DataChannel) Protocol ¶
func (d *DataChannel) Protocol() string
Protocol represents the name of the sub-protocol used with this DataChannel.
func (*DataChannel) ReadyState ¶
func (d *DataChannel) ReadyState() DataChannelState
ReadyState represents the state of the DataChannel object.
func (*DataChannel) Send ¶
func (d *DataChannel) Send(data []byte) error
Send sends the binary message to the DataChannel peer
func (*DataChannel) SendText ¶
func (d *DataChannel) SendText(s string) error
SendText sends the text message to the DataChannel peer
func (*DataChannel) SetBufferedAmountLowThreshold ¶
func (d *DataChannel) SetBufferedAmountLowThreshold(th uint64)
SetBufferedAmountLowThreshold is used to update the threshold. See BufferedAmountLowThreshold().
func (*DataChannel) Transport ¶
func (d *DataChannel) Transport() *SCTPTransport
Transport returns the SCTPTransport instance the DataChannel is sending over.
type DataChannelInit ¶
type DataChannelInit struct { // Ordered indicates if data is allowed to be delivered out of order. The // default value of true, guarantees that data will be delivered in order. Ordered *bool // MaxPacketLifeTime limits the time (in milliseconds) during which the // channel will transmit or retransmit data if not acknowledged. This value // may be clamped if it exceeds the maximum value supported. MaxPacketLifeTime *uint16 // MaxRetransmits limits the number of times a channel will retransmit data // if not successfully delivered. This value may be clamped if it exceeds // the maximum value supported. MaxRetransmits *uint16 // Protocol describes the subprotocol name used for this channel. Protocol *string // Negotiated describes if the data channel is created by the local peer or // the remote peer. The default value of false tells the user agent to // announce the channel in-band and instruct the other peer to dispatch a // corresponding DataChannel. If set to true, it is up to the application // to negotiate the channel and create an DataChannel with the same id // at the other peer. Negotiated *bool // ID overrides the default selection of ID for this channel. ID *uint16 // Priority describes the priority of this channel. Priority *PriorityType }
DataChannelInit can be used to configure properties of the underlying channel such as data reliability.
type DataChannelMessage ¶
DataChannelMessage represents a message received from the data channel. IsString will be set to true if the incoming message is of the string type. Otherwise the message is of a binary type.
type DataChannelParameters ¶
type DataChannelParameters struct { Label string `json:"label"` ID uint16 `json:"id"` Ordered bool `json:"ordered"` MaxPacketLifeTime *uint16 `json:"maxPacketLifeTime"` MaxRetransmits *uint16 `json:"maxRetransmits"` }
DataChannelParameters describes the configuration of the DataChannel.
type DataChannelState ¶
type DataChannelState int
DataChannelState indicates the state of a data channel.
const ( // DataChannelStateConnecting indicates that the data channel is being // established. This is the initial state of DataChannel, whether created // with CreateDataChannel, or dispatched as a part of an DataChannelEvent. DataChannelStateConnecting DataChannelState = iota + 1 // DataChannelStateOpen indicates that the underlying data transport is // established and communication is possible. DataChannelStateOpen // DataChannelStateClosing indicates that the procedure to close down the // underlying data transport has started. DataChannelStateClosing // DataChannelStateClosed indicates that the underlying data transport // has been closed or could not be established. DataChannelStateClosed )
func (DataChannelState) String ¶
func (t DataChannelState) String() string
type ICECandidate ¶
type ICECandidate struct { Foundation string `json:"foundation"` Priority uint32 `json:"priority"` IP string `json:"ip"` Protocol ICEProtocol `json:"protocol"` Port uint16 `json:"port"` Typ ICECandidateType `json:"type"` Component uint16 `json:"component"` RelatedAddress string `json:"relatedAddress"` RelatedPort uint16 `json:"relatedPort"` }
ICECandidate represents a ice candidate
func (ICECandidate) String ¶
func (c ICECandidate) String() string
type ICECandidateInit ¶
type ICECandidateInit struct { Candidate string `json:"candidate"` SDPMid *string `json:"sdpMid,omitempty"` SDPMLineIndex *uint16 `json:"sdpMLineIndex,omitempty"` UsernameFragment string `json:"usernameFragment"` }
ICECandidateInit is used to serialize ice candidates
type ICECandidatePair ¶
type ICECandidatePair struct { Local *ICECandidate Remote *ICECandidate }
ICECandidatePair represents an ICE Candidate pair
func NewICECandidatePair ¶
func NewICECandidatePair(local, remote *ICECandidate) *ICECandidatePair
NewICECandidatePair returns an initialized *ICECandidatePair for the given pair of ICECandidate instances
func (*ICECandidatePair) String ¶
func (p *ICECandidatePair) String() string
type ICECandidateType ¶
type ICECandidateType int
ICECandidateType represents the type of the ICE candidate used.
const ( // ICECandidateTypeHost indicates that the candidate is of Host type as // described in https://tools.ietf.org/html/rfc8445#section-5.1.1.1. A // candidate obtained by binding to a specific port from an IP address on // the host. This includes IP addresses on physical interfaces and logical // ones, such as ones obtained through VPNs. ICECandidateTypeHost ICECandidateType = iota + 1 // ICECandidateTypeSrflx indicates the the candidate is of Server // Reflexive type as described // https://tools.ietf.org/html/rfc8445#section-5.1.1.2. A candidate type // whose IP address and port are a binding allocated by a NAT for an ICE // agent after it sends a packet through the NAT to a server, such as a // STUN server. ICECandidateTypeSrflx // ICECandidateTypePrflx indicates that the candidate is of Peer // Reflexive type. A candidate type whose IP address and port are a binding // allocated by a NAT for an ICE agent after it sends a packet through the // NAT to its peer. ICECandidateTypePrflx // ICECandidateTypeRelay indicates the the candidate is of Relay type as // described in https://tools.ietf.org/html/rfc8445#section-5.1.1.2. A // candidate type obtained from a relay server, such as a TURN server. ICECandidateTypeRelay )
func (ICECandidateType) String ¶
func (t ICECandidateType) String() string
type ICEComponent ¶
type ICEComponent int
ICEComponent describes if the ice transport is used for RTP (or RTCP multiplexing).
const ( // ICEComponentRTP indicates that the ICE Transport is used for RTP (or // RTCP multiplexing), as defined in // https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols // multiplexed with RTP (e.g. data channel) share its component ID. This // represents the component-id value 1 when encoded in candidate-attribute. ICEComponentRTP ICEComponent = iota + 1 // ICEComponentRTCP indicates that the ICE Transport is used for RTCP as // defined by https://tools.ietf.org/html/rfc5245#section-4.1.1.1. This // represents the component-id value 2 when encoded in candidate-attribute. ICEComponentRTCP )
func (ICEComponent) String ¶
func (t ICEComponent) String() string
type ICEConnectionState ¶
type ICEConnectionState int
ICEConnectionState indicates signaling state of the ICE Connection.
const ( // ICEConnectionStateNew indicates that any of the ICETransports are // in the "new" state and none of them are in the "checking", "disconnected" // or "failed" state, or all ICETransports are in the "closed" state, or // there are no transports. ICEConnectionStateNew ICEConnectionState = iota + 1 // ICEConnectionStateChecking indicates that any of the ICETransports // are in the "checking" state and none of them are in the "disconnected" // or "failed" state. ICEConnectionStateChecking // ICEConnectionStateConnected indicates that all ICETransports are // in the "connected", "completed" or "closed" state and at least one of // them is in the "connected" state. ICEConnectionStateConnected // ICEConnectionStateCompleted indicates that all ICETransports are // in the "completed" or "closed" state and at least one of them is in the // "completed" state. ICEConnectionStateCompleted // ICEConnectionStateDisconnected indicates that any of the // ICETransports are in the "disconnected" state and none of them are // in the "failed" state. ICEConnectionStateDisconnected // ICEConnectionStateFailed indicates that any of the ICETransports // are in the "failed" state. ICEConnectionStateFailed // ICEConnectionStateClosed indicates that the PeerConnection's // isClosed is true. ICEConnectionStateClosed )
func (ICEConnectionState) String ¶
func (c ICEConnectionState) String() string
type ICECredentialType ¶
type ICECredentialType int
ICECredentialType indicates the type of credentials used to connect to an ICE server.
const ( // ICECredentialTypePassword describes username and pasword based // credentials as described in https://tools.ietf.org/html/rfc5389. ICECredentialTypePassword ICECredentialType = iota + 1 // ICECredentialTypeOauth describes token based credential as described // in https://tools.ietf.org/html/rfc7635. ICECredentialTypeOauth )
func (ICECredentialType) String ¶
func (t ICECredentialType) String() string
type ICEGatherOptions ¶
type ICEGatherOptions struct {
ICEServers []ICEServer
}
ICEGatherOptions provides options relating to the gathering of ICE candidates.
type ICEGatherer ¶
type ICEGatherer struct {
// contains filtered or unexported fields
}
The ICEGatherer gathers local host, server reflexive and relay candidates, as well as enabling the retrieval of local Interactive Connectivity Establishment (ICE) parameters which can be exchanged in signaling.
func (*ICEGatherer) Close ¶
func (g *ICEGatherer) Close() error
Close prunes all local candidates, and closes the ports.
func (*ICEGatherer) GetLocalCandidates ¶
func (g *ICEGatherer) GetLocalCandidates() ([]ICECandidate, error)
GetLocalCandidates returns the sequence of valid local candidates associated with the ICEGatherer.
func (*ICEGatherer) GetLocalParameters ¶
func (g *ICEGatherer) GetLocalParameters() (ICEParameters, error)
GetLocalParameters returns the ICE parameters of the ICEGatherer.
func (*ICEGatherer) State ¶
func (g *ICEGatherer) State() ICEGathererState
State indicates the current state of the ICE gatherer.
type ICEGathererState ¶
type ICEGathererState byte
ICEGathererState represents the current state of the ICE gatherer.
const ( // ICEGathererStateNew indicates object has been created but // gather() has not been called. ICEGathererStateNew ICEGathererState = iota + 1 // ICEGathererStateGathering indicates gather() has been called, // and the ICEGatherer is in the process of gathering candidates. ICEGathererStateGathering // ICEGathererStateComplete indicates the ICEGatherer has completed gathering. ICEGathererStateComplete // ICEGathererStateClosed indicates the closed state can only be entered // when the ICEGatherer has been closed intentionally by calling close(). ICEGathererStateClosed )
func (ICEGathererState) String ¶
func (s ICEGathererState) String() string
type ICEGatheringState ¶
type ICEGatheringState int
ICEGatheringState describes the state of the candidate gathering process.
const ( // ICEGatheringStateNew indicates that any of the ICETransports are // in the "new" gathering state and none of the transports are in the // "gathering" state, or there are no transports. ICEGatheringStateNew ICEGatheringState = iota + 1 // ICEGatheringStateGathering indicates that any of the ICETransports // are in the "gathering" state. ICEGatheringStateGathering // ICEGatheringStateComplete indicates that at least one ICETransport // exists, and all ICETransports are in the "completed" gathering state. ICEGatheringStateComplete )
func (ICEGatheringState) String ¶
func (t ICEGatheringState) String() string
type ICEParameters ¶
type ICEParameters struct { UsernameFragment string `json:"usernameFragment"` Password string `json:"password"` ICELite bool `json:"iceLite"` }
ICEParameters includes the ICE username fragment and password and other ICE-related parameters.
type ICEProtocol ¶
type ICEProtocol int
ICEProtocol indicates the transport protocol type that is used in the ice.URL structure.
const ( // ICEProtocolUDP indicates the URL uses a UDP transport. ICEProtocolUDP ICEProtocol = iota + 1 // ICEProtocolTCP indicates the URL uses a TCP transport. ICEProtocolTCP )
func (ICEProtocol) String ¶
func (t ICEProtocol) String() string
type ICERole ¶
type ICERole int
ICERole describes the role ice.Agent is playing in selecting the preferred the candidate pair.
const ( // ICERoleControlling indicates that the ICE agent that is responsible // for selecting the final choice of candidate pairs and signaling them // through STUN and an updated offer, if needed. In any session, one agent // is always controlling. The other is the controlled agent. ICERoleControlling ICERole = iota + 1 // ICERoleControlled indicates that an ICE agent that waits for the // controlling agent to select the final choice of candidate pairs. ICERoleControlled )
type ICEServer ¶
type ICEServer struct { URLs []string Username string Credential interface{} CredentialType ICECredentialType }
ICEServer describes a single STUN and TURN server that can be used by the ICEAgent to establish a connection with a peer.
type ICETransport ¶
type ICETransport struct {
// contains filtered or unexported fields
}
ICETransport allows an application access to information about the ICE transport over which packets are sent and received.
func (*ICETransport) AddRemoteCandidate ¶
func (t *ICETransport) AddRemoteCandidate(remoteCandidate ICECandidate) error
AddRemoteCandidate adds a candidate associated with the remote ICETransport.
func (*ICETransport) OnConnectionStateChange ¶
func (t *ICETransport) OnConnectionStateChange(f func(ICETransportState))
OnConnectionStateChange sets a handler that is fired when the ICE connection state changes.
func (*ICETransport) OnSelectedCandidatePairChange ¶
func (t *ICETransport) OnSelectedCandidatePairChange(f func(*ICECandidatePair))
OnSelectedCandidatePairChange sets a handler that is invoked when a new ICE candidate pair is selected
func (*ICETransport) Role ¶
func (t *ICETransport) Role() ICERole
Role indicates the current role of the ICE transport.
func (*ICETransport) SetRemoteCandidates ¶
func (t *ICETransport) SetRemoteCandidates(remoteCandidates []ICECandidate) error
SetRemoteCandidates sets the sequence of candidates associated with the remote ICETransport.
func (*ICETransport) Start ¶
func (t *ICETransport) Start(gatherer *ICEGatherer, params ICEParameters, role *ICERole) error
Start incoming connectivity checks based on its configured role.
func (*ICETransport) Stop ¶
func (t *ICETransport) Stop() error
Stop irreversibly stops the ICETransport.
type ICETransportPolicy ¶
type ICETransportPolicy int
ICETransportPolicy defines the ICE candidate policy surface the permitted candidates. Only these candidates are used for connectivity checks.
const ( // ICETransportPolicyRelay indicates only media relay candidates such // as candidates passing through a TURN server are used. ICETransportPolicyRelay ICETransportPolicy = iota + 1 // ICETransportPolicyAll indicates any type of candidate is used. ICETransportPolicyAll )
func (ICETransportPolicy) String ¶
func (t ICETransportPolicy) String() string
type ICETransportState ¶
type ICETransportState int
ICETransportState represents the current state of the ICE transport.
func (ICETransportState) String ¶
func (c ICETransportState) String() string
type MediaEngine ¶
type MediaEngine struct {
// contains filtered or unexported fields
}
MediaEngine defines the codecs supported by a PeerConnection
func (*MediaEngine) RegisterCodec ¶
func (m *MediaEngine) RegisterCodec(codec *RTPCodec) uint8
RegisterCodec registers a codec to a media engine
func (*MediaEngine) RegisterDefaultCodecs ¶
func (m *MediaEngine) RegisterDefaultCodecs()
RegisterDefaultCodecs is a helper that registers the default codecs supported by pion-webrtc
type NetworkType ¶
type NetworkType int
NetworkType represents the type of network
const ( // NetworkTypeUDP4 indicates UDP over IPv4. NetworkTypeUDP4 NetworkType = iota + 1 // NetworkTypeUDP6 indicates UDP over IPv6. NetworkTypeUDP6 // NetworkTypeTCP4 indicates TCP over IPv4. NetworkTypeTCP4 // NetworkTypeTCP6 indicates TCP over IPv6. NetworkTypeTCP6 )
func (NetworkType) String ¶
func (t NetworkType) String() string
type OAuthCredential ¶
type OAuthCredential struct { // MACKey is a base64-url encoded format. It is used in STUN message // integrity hash calculation. MACKey string // AccessToken is a base64-encoded format. This is an encrypted // self-contained token that is opaque to the application. AccessToken string }
OAuthCredential represents OAuth credential information which is used by the STUN/TURN client to connect to an ICE server as defined in https://tools.ietf.org/html/rfc7635. Note that the kid parameter is not located in OAuthCredential, but in ICEServer's username member.
type OfferAnswerOptions ¶
type OfferAnswerOptions struct { // VoiceActivityDetection allows the application to provide information // about whether it wishes voice detection feature to be enabled or disabled. VoiceActivityDetection bool }
OfferAnswerOptions is a base structure which describes the options that can be used to control the offer/answer creation process.
type OfferOptions ¶
type OfferOptions struct { OfferAnswerOptions // ICERestart forces the underlying ice gathering process to be restarted. // When this value is true, the generated description will have ICE // credentials that are different from the current credentials ICERestart bool }
OfferOptions structure describes the options used to control the offer creation process
type PeerConnection ¶
type PeerConnection struct {
// contains filtered or unexported fields
}
PeerConnection represents a WebRTC connection that establishes a peer-to-peer communications with another PeerConnection instance in a browser, or to another endpoint implementing the required protocols.
func NewPeerConnection ¶
func NewPeerConnection(configuration Configuration) (*PeerConnection, error)
NewPeerConnection creates a peerconnection with the default codecs. See API.NewRTCPeerConnection for details.
func (*PeerConnection) AddICECandidate ¶
func (pc *PeerConnection) AddICECandidate(candidate ICECandidateInit) error
AddICECandidate accepts an ICE candidate string and adds it to the existing set of candidates
func (*PeerConnection) AddTrack ¶
func (pc *PeerConnection) AddTrack(track *Track) (*RTPSender, error)
AddTrack adds a Track to the PeerConnection
func (*PeerConnection) AddTransceiver ¶
func (pc *PeerConnection) AddTransceiver(trackOrKind RTPCodecType, init ...RtpTransceiverInit) (*RTPTransceiver, error)
AddTransceiver Create a new RTCRtpTransceiver and add it to the set of transceivers.
func (*PeerConnection) Close ¶
func (pc *PeerConnection) Close() error
Close ends the PeerConnection
func (*PeerConnection) ConnectionState ¶
func (pc *PeerConnection) ConnectionState() PeerConnectionState
ConnectionState attribute returns the connection state of the PeerConnection instance.
func (*PeerConnection) CreateAnswer ¶
func (pc *PeerConnection) CreateAnswer(options *AnswerOptions) (SessionDescription, error)
CreateAnswer starts the PeerConnection and generates the localDescription
func (*PeerConnection) CreateDataChannel ¶
func (pc *PeerConnection) CreateDataChannel(label string, options *DataChannelInit) (*DataChannel, error)
CreateDataChannel creates a new DataChannel object with the given label and optional DataChannelInit used to configure properties of the underlying channel such as data reliability.
func (*PeerConnection) CreateOffer ¶
func (pc *PeerConnection) CreateOffer(options *OfferOptions) (SessionDescription, error)
CreateOffer starts the PeerConnection and generates the localDescription
func (*PeerConnection) CurrentLocalDescription ¶
func (pc *PeerConnection) CurrentLocalDescription() *SessionDescription
CurrentLocalDescription represents the local description that was successfully negotiated the last time the PeerConnection transitioned into the stable state plus any local candidates that have been generated by the ICEAgent since the offer or answer was created.
func (*PeerConnection) CurrentRemoteDescription ¶
func (pc *PeerConnection) CurrentRemoteDescription() *SessionDescription
CurrentRemoteDescription represents the last remote description that was successfully negotiated the last time the PeerConnection transitioned into the stable state plus any remote candidates that have been supplied via AddICECandidate() since the offer or answer was created.
func (*PeerConnection) GetConfiguration ¶
func (pc *PeerConnection) GetConfiguration() Configuration
GetConfiguration returns a Configuration object representing the current configuration of this PeerConnection object. The returned object is a copy and direct mutation on it will not take affect until SetConfiguration has been called with Configuration passed as its only argument. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-getconfiguration
func (*PeerConnection) GetReceivers ¶
func (pc *PeerConnection) GetReceivers() []*RTPReceiver
GetReceivers returns the RTPReceivers that are currently attached to this RTCPeerConnection
func (*PeerConnection) GetSenders ¶
func (pc *PeerConnection) GetSenders() []*RTPSender
GetSenders returns the RTPSender that are currently attached to this PeerConnection
func (*PeerConnection) GetTransceivers ¶
func (pc *PeerConnection) GetTransceivers() []*RTPTransceiver
GetTransceivers returns the RTCRtpTransceiver that are currently attached to this RTCPeerConnection
func (*PeerConnection) ICEConnectionState ¶
func (pc *PeerConnection) ICEConnectionState() ICEConnectionState
ICEConnectionState returns the ICE connection state of the PeerConnection instance.
func (*PeerConnection) ICEGatheringState ¶
func (pc *PeerConnection) ICEGatheringState() ICEGatheringState
ICEGatheringState attribute returns the ICE gathering state of the PeerConnection instance.
func (*PeerConnection) LocalDescription ¶
func (pc *PeerConnection) LocalDescription() *SessionDescription
LocalDescription returns pendingLocalDescription if it is not null and otherwise it returns currentLocalDescription. This property is used to determine if setLocalDescription has already been called. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-localdescription
func (*PeerConnection) NewTrack ¶
func (pc *PeerConnection) NewTrack(payloadType uint8, ssrc uint32, id, label string) (*Track, error)
NewTrack Creates a new Track
func (*PeerConnection) OnDataChannel ¶
func (pc *PeerConnection) OnDataChannel(f func(*DataChannel))
OnDataChannel sets an event handler which is invoked when a data channel message arrives from a remote peer.
func (*PeerConnection) OnICECandidate ¶
func (pc *PeerConnection) OnICECandidate(f func(*ICECandidate))
OnICECandidate sets an event handler which is invoked when a new ICE candidate is found. BUG: trickle ICE is not supported so this event is triggered immediately when SetLocalDescription is called. Typically, you only need to use this method if you want API compatibility with the JavaScript/Wasm bindings.
func (*PeerConnection) OnICEConnectionStateChange ¶
func (pc *PeerConnection) OnICEConnectionStateChange(f func(ICEConnectionState))
OnICEConnectionStateChange sets an event handler which is called when an ICE connection state is changed.
func (*PeerConnection) OnICEGatheringStateChange ¶
func (pc *PeerConnection) OnICEGatheringStateChange(f func())
OnICEGatheringStateChange sets an event handler which is invoked when the ICE candidate gathering state has changed. BUG: trickle ICE is not supported so this event is triggered immediately when SetLocalDescription is called. Typically, you only need to use this method if you want API compatibility with the JavaScript/Wasm bindings.
func (*PeerConnection) OnSignalingStateChange ¶
func (pc *PeerConnection) OnSignalingStateChange(f func(SignalingState))
OnSignalingStateChange sets an event handler which is invoked when the peer connection's signaling state changes
func (*PeerConnection) OnTrack ¶
func (pc *PeerConnection) OnTrack(f func(*Track, *RTPReceiver))
OnTrack sets an event handler which is called when remote track arrives from a remote peer.
func (*PeerConnection) PendingLocalDescription ¶
func (pc *PeerConnection) PendingLocalDescription() *SessionDescription
PendingLocalDescription represents a local description that is in the process of being negotiated plus any local candidates that have been generated by the ICEAgent since the offer or answer was created. If the PeerConnection is in the stable state, the value is null.
func (*PeerConnection) PendingRemoteDescription ¶
func (pc *PeerConnection) PendingRemoteDescription() *SessionDescription
PendingRemoteDescription represents a remote description that is in the process of being negotiated, complete with any remote candidates that have been supplied via AddICECandidate() since the offer or answer was created. If the PeerConnection is in the stable state, the value is null.
func (*PeerConnection) RemoteDescription ¶
func (pc *PeerConnection) RemoteDescription() *SessionDescription
RemoteDescription returns pendingRemoteDescription if it is not null and otherwise it returns currentRemoteDescription. This property is used to determine if setRemoteDescription has already been called. https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-remotedescription
func (*PeerConnection) SetConfiguration ¶
func (pc *PeerConnection) SetConfiguration(configuration Configuration) error
SetConfiguration updates the configuration of this PeerConnection object.
func (*PeerConnection) SetIdentityProvider ¶
func (pc *PeerConnection) SetIdentityProvider(provider string) error
SetIdentityProvider is used to configure an identity provider to generate identity assertions
func (*PeerConnection) SetLocalDescription ¶
func (pc *PeerConnection) SetLocalDescription(desc SessionDescription) error
SetLocalDescription sets the SessionDescription of the local peer
func (*PeerConnection) SetRemoteDescription ¶
func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error
SetRemoteDescription sets the SessionDescription of the remote peer
func (*PeerConnection) SignalingState ¶
func (pc *PeerConnection) SignalingState() SignalingState
SignalingState attribute returns the signaling state of the PeerConnection instance.
type PeerConnectionState ¶
type PeerConnectionState int
PeerConnectionState indicates the state of the PeerConnection.
const ( // PeerConnectionStateNew indicates that any of the ICETransports or // DTLSTransports are in the "new" state and none of the transports are // in the "connecting", "checking", "failed" or "disconnected" state, or // all transports are in the "closed" state, or there are no transports. PeerConnectionStateNew PeerConnectionState = iota + 1 // PeerConnectionStateConnecting indicates that any of the // ICETransports or DTLSTransports are in the "connecting" or // "checking" state and none of them is in the "failed" state. PeerConnectionStateConnecting // PeerConnectionStateConnected indicates that all ICETransports and // DTLSTransports are in the "connected", "completed" or "closed" state // and at least one of them is in the "connected" or "completed" state. PeerConnectionStateConnected // PeerConnectionStateDisconnected indicates that any of the // ICETransports or DTLSTransports are in the "disconnected" state // and none of them are in the "failed" or "connecting" or "checking" state. PeerConnectionStateDisconnected // PeerConnectionStateFailed indicates that any of the ICETransports // or DTLSTransports are in a "failed" state. PeerConnectionStateFailed // PeerConnectionStateClosed indicates the peer connection is closed // and the isClosed member variable of PeerConnection is true. PeerConnectionStateClosed )
func (PeerConnectionState) String ¶
func (t PeerConnectionState) String() string
type PriorityType ¶
type PriorityType int
PriorityType determines the priority type of a data channel.
const ( // PriorityTypeVeryLow corresponds to "below normal". PriorityTypeVeryLow PriorityType = iota + 1 // PriorityTypeLow corresponds to "normal". PriorityTypeLow // PriorityTypeMedium corresponds to "high". PriorityTypeMedium // PriorityTypeHigh corresponds to "extra high". PriorityTypeHigh )
func (PriorityType) String ¶
func (p PriorityType) String() string
type RTCPFeedback ¶
type RTCPFeedback struct { // Type is the type of feedback. // see: https://draft.ortc.org/#dom-rtcrtcpfeedback // valid: ack, ccm, nack, goog-remb, transport-cc Type string // The parameter value depends on the type. // For example, type="nack" parameter="pli" will send Picture Loss Indicator packets. Parameter string }
RTCPFeedback signals the connection to use additional RTCP packet types. https://draft.ortc.org/#dom-rtcrtcpfeedback
type RTCPMuxPolicy ¶
type RTCPMuxPolicy int
RTCPMuxPolicy affects what ICE candidates are gathered to support non-multiplexed RTCP.
const ( // RTCPMuxPolicyNegotiate indicates to gather ICE candidates for both // RTP and RTCP candidates. If the remote-endpoint is capable of // multiplexing RTCP, multiplex RTCP on the RTP candidates. If it is not, // use both the RTP and RTCP candidates separately. RTCPMuxPolicyNegotiate RTCPMuxPolicy = iota + 1 // RTCPMuxPolicyRequire indicates to gather ICE candidates only for // RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is // not capable of rtcp-mux, session negotiation will fail. RTCPMuxPolicyRequire )
func (RTCPMuxPolicy) String ¶
func (t RTCPMuxPolicy) String() string
type RTPCapabilities ¶
type RTPCapabilities struct { Codecs []RTPCodecCapability HeaderExtensions []RTPHeaderExtensionCapability }
RTPCapabilities represents the capabilities of a transceiver
type RTPCodec ¶
type RTPCodec struct { RTPCodecCapability Type RTPCodecType Name string PayloadType uint8 Payloader rtp.Payloader }
RTPCodec represents a codec supported by the PeerConnection
func NewRTPCodec ¶
func NewRTPCodec( codecType RTPCodecType, name string, clockrate uint32, channels uint16, fmtp string, payloadType uint8, payloader rtp.Payloader, ) *RTPCodec
NewRTPCodec is used to define a new codec
func NewRTPG722Codec ¶
NewRTPG722Codec is a helper to create a G722 codec
func NewRTPH264Codec ¶
NewRTPH264Codec is a helper to create an H264 codec
func NewRTPOpusCodec ¶
NewRTPOpusCodec is a helper to create an Opus codec
func NewRTPVP8Codec ¶
NewRTPVP8Codec is a helper to create an VP8 codec
func NewRTPVP9Codec ¶
NewRTPVP9Codec is a helper to create an VP9 codec
type RTPCodecCapability ¶
type RTPCodecCapability struct { MimeType string ClockRate uint32 Channels uint16 SDPFmtpLine string RTCPFeedback []RTCPFeedback }
RTPCodecCapability provides information about codec capabilities.
type RTPCodecType ¶
type RTPCodecType int
RTPCodecType determines the type of a codec
const ( // RTPCodecTypeAudio indicates this is an audio codec RTPCodecTypeAudio RTPCodecType = iota + 1 // RTPCodecTypeVideo indicates this is a video codec RTPCodecTypeVideo )
func NewRTPCodecType ¶
func NewRTPCodecType(r string) RTPCodecType
NewRTPCodecType creates a RTPCodecType from a string
func (RTPCodecType) String ¶
func (t RTPCodecType) String() string
type RTPCodingParameters ¶
type RTPCodingParameters struct { SSRC uint32 `json:"ssrc"` PayloadType uint8 `json:"payloadType"` }
RTPCodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement encoding/decoding itself http://draft.ortc.org/#dom-rtcrtpcodingparameters
type RTPDecodingParameters ¶
type RTPDecodingParameters struct {
RTPCodingParameters
}
RTPDecodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement decoding itself http://draft.ortc.org/#dom-rtcrtpdecodingparameters
type RTPEncodingParameters ¶
type RTPEncodingParameters struct {
RTPCodingParameters
}
RTPEncodingParameters provides information relating to both encoding and decoding. This is a subset of the RFC since Pion WebRTC doesn't implement encoding itself http://draft.ortc.org/#dom-rtcrtpencodingparameters
type RTPHeaderExtensionCapability ¶
type RTPHeaderExtensionCapability struct {
URI string
}
RTPHeaderExtensionCapability is used to define a RFC5285 RTP header extension supported by the codec.
type RTPReceiveParameters ¶
type RTPReceiveParameters struct {
Encodings RTPDecodingParameters
}
RTPReceiveParameters contains the RTP stack settings used by receivers
type RTPReceiver ¶
type RTPReceiver struct {
// contains filtered or unexported fields
}
RTPReceiver allows an application to inspect the receipt of a Track
func (*RTPReceiver) Read ¶
func (r *RTPReceiver) Read(b []byte) (n int, err error)
Read reads incoming RTCP for this RTPReceiver
func (*RTPReceiver) ReadRTCP ¶
func (r *RTPReceiver) ReadRTCP() ([]rtcp.Packet, error)
ReadRTCP is a convenience method that wraps Read and unmarshals for you
func (*RTPReceiver) Receive ¶
func (r *RTPReceiver) Receive(parameters RTPReceiveParameters) error
Receive initialize the track and starts all the transports
func (*RTPReceiver) Stop ¶
func (r *RTPReceiver) Stop() error
Stop irreversibly stops the RTPReceiver
func (*RTPReceiver) Track ¶
func (r *RTPReceiver) Track() *Track
Track returns the RTCRtpTransceiver track
func (*RTPReceiver) Transport ¶
func (r *RTPReceiver) Transport() *DTLSTransport
Transport returns the currently-configured *DTLSTransport or nil if one has not yet been configured
type RTPSendParameters ¶
type RTPSendParameters struct {
Encodings RTPEncodingParameters
}
RTPSendParameters contains the RTP stack settings used by receivers
type RTPSender ¶
type RTPSender struct {
// contains filtered or unexported fields
}
RTPSender allows an application to control how a given Track is encoded and transmitted to a remote peer
func (*RTPSender) ReadRTCP ¶
ReadRTCP is a convenience method that wraps Read and unmarshals for you
func (*RTPSender) Send ¶
func (r *RTPSender) Send(parameters RTPSendParameters) error
Send Attempts to set the parameters controlling the sending of media.
func (*RTPSender) Transport ¶
func (r *RTPSender) Transport() *DTLSTransport
Transport returns the currently-configured *DTLSTransport or nil if one has not yet been configured
type RTPTransceiver ¶
type RTPTransceiver struct { Mid string Sender *RTPSender Receiver *RTPReceiver Direction RTPTransceiverDirection // contains filtered or unexported fields }
RTPTransceiver represents a combination of an RTPSender and an RTPReceiver that share a common mid.
func (*RTPTransceiver) Stop ¶
func (t *RTPTransceiver) Stop() error
Stop irreversibly stops the RTPTransceiver
type RTPTransceiverDirection ¶
type RTPTransceiverDirection int
RTPTransceiverDirection indicates the direction of the RTPTransceiver.
const ( // RTPTransceiverDirectionSendrecv indicates the RTPSender will offer // to send RTP and RTPReceiver the will offer to receive RTP. RTPTransceiverDirectionSendrecv RTPTransceiverDirection = iota + 1 // RTPTransceiverDirectionSendonly indicates the RTPSender will offer // to send RTP. RTPTransceiverDirectionSendonly // RTPTransceiverDirectionRecvonly indicates the RTPReceiver the will // offer to receive RTP. RTPTransceiverDirectionRecvonly // RTPTransceiverDirectionInactive indicates the RTPSender won't offer // to send RTP and RTPReceiver the won't offer to receive RTP. RTPTransceiverDirectionInactive )
func NewRTPTransceiverDirection ¶
func NewRTPTransceiverDirection(raw string) RTPTransceiverDirection
NewRTPTransceiverDirection defines a procedure for creating a new RTPTransceiverDirection from a raw string naming the transceiver direction.
func (RTPTransceiverDirection) String ¶
func (t RTPTransceiverDirection) String() string
type RtpTransceiverInit ¶
type RtpTransceiverInit struct { Direction RTPTransceiverDirection SendEncodings []RTPEncodingParameters }
RtpTransceiverInit dictionary is used when calling the WebRTC function addTransceiver() to provide configuration options for the new transceiver.
type SCTPCapabilities ¶
type SCTPCapabilities struct {
MaxMessageSize uint32 `json:"maxMessageSize"`
}
SCTPCapabilities indicates the capabilities of the SCTPTransport.
type SCTPTransport ¶
type SCTPTransport struct {
// contains filtered or unexported fields
}
SCTPTransport provides details about the SCTP transport.
func (*SCTPTransport) GetCapabilities ¶
func (r *SCTPTransport) GetCapabilities() SCTPCapabilities
GetCapabilities returns the SCTPCapabilities of the SCTPTransport.
func (*SCTPTransport) MaxChannels ¶
func (r *SCTPTransport) MaxChannels() uint16
MaxChannels is the maximum number of RTCDataChannels that can be open simultaneously.
func (*SCTPTransport) OnDataChannel ¶
func (r *SCTPTransport) OnDataChannel(f func(*DataChannel))
OnDataChannel sets an event handler which is invoked when a data channel message arrives from a remote peer.
func (*SCTPTransport) Start ¶
func (r *SCTPTransport) Start(remoteCaps SCTPCapabilities) error
Start the SCTPTransport. Since both local and remote parties must mutually create an SCTPTransport, SCTP SO (Simultaneous Open) is used to establish a connection over SCTP.
func (*SCTPTransport) State ¶
func (r *SCTPTransport) State() SCTPTransportState
State returns the current state of the SCTPTransport
func (*SCTPTransport) Transport ¶
func (r *SCTPTransport) Transport() *DTLSTransport
Transport returns the DTLSTransport instance the SCTPTransport is sending over.
type SCTPTransportState ¶
type SCTPTransportState int
SCTPTransportState indicates the state of the SCTP transport.
const ( // SCTPTransportStateConnecting indicates the SCTPTransport is in the // process of negotiating an association. This is the initial state of the // SCTPTransportState when an SCTPTransport is created. SCTPTransportStateConnecting SCTPTransportState = iota + 1 // SCTPTransportStateConnected indicates the negotiation of an // association is completed. SCTPTransportStateConnected // SCTPTransportStateClosed indicates a SHUTDOWN or ABORT chunk is // received or when the SCTP association has been closed intentionally, // such as by closing the peer connection or applying a remote description // that rejects data or changes the SCTP port. SCTPTransportStateClosed )
func (SCTPTransportState) String ¶
func (s SCTPTransportState) String() string
type SDPSemantics ¶ added in v2.0.4
type SDPSemantics int
SDPSemantics determines which style of SDP offers and answers can be used
const ( // SDPSemanticsUnifiedPlan uses unified-plan offers and answers // (the default in Chrome since M72) // https://tools.ietf.org/html/draft-roach-mmusic-unified-plan-00 SDPSemanticsUnifiedPlan SDPSemantics = iota // SDPSemanticsPlanB uses plan-b offers and answers // NB: This format should be considered deprecated // https://tools.ietf.org/html/draft-uberti-rtcweb-plan-00 SDPSemanticsPlanB // SDPSemanticsUnifiedPlanWithFallback prefers unified-plan // offers and answers, but will respond to a plan-b offer // with a plan-b answer SDPSemanticsUnifiedPlanWithFallback )
func (SDPSemantics) String ¶ added in v2.0.4
func (s SDPSemantics) String() string
type SDPType ¶
type SDPType int
SDPType describes the type of an SessionDescription.
const ( // SDPTypeOffer indicates that a description MUST be treated as an SDP // offer. SDPTypeOffer SDPType = iota + 1 // SDPTypePranswer indicates that a description MUST be treated as an // SDP answer, but not a final answer. A description used as an SDP // pranswer may be applied as a response to an SDP offer, or an update to // a previously sent SDP pranswer. SDPTypePranswer // SDPTypeAnswer indicates that a description MUST be treated as an SDP // final answer, and the offer-answer exchange MUST be considered complete. // A description used as an SDP answer may be applied as a response to an // SDP offer or as an update to a previously sent SDP pranswer. SDPTypeAnswer // SDPTypeRollback indicates that a description MUST be treated as // canceling the current SDP negotiation and moving the SDP offer and // answer back to what it was in the previous stable state. Note the // local or remote SDP descriptions in the previous stable state could be // null if there has not yet been a successful offer-answer negotiation. SDPTypeRollback )
func (SDPType) MarshalJSON ¶
MarshalJSON enables JSON marshaling of a SDPType
func (*SDPType) UnmarshalJSON ¶
UnmarshalJSON enables JSON unmarshaling of a SDPType
type SessionDescription ¶
type SessionDescription struct { Type SDPType `json:"type"` SDP string `json:"sdp"` // contains filtered or unexported fields }
SessionDescription is used to expose local and remote session descriptions.
type SettingEngine ¶
type SettingEngine struct { LoggerFactory logging.LoggerFactory // contains filtered or unexported fields }
SettingEngine allows influencing behavior in ways that are not supported by the WebRTC API. This allows us to support additional use-cases without deviating from the WebRTC API elsewhere.
func (*SettingEngine) DetachDataChannels ¶
func (e *SettingEngine) DetachDataChannels()
DetachDataChannels enables detaching data channels. When enabled data channels have to be detached in the OnOpen callback using the DataChannel.Detach method.
func (*SettingEngine) SetConnectionTimeout ¶
func (e *SettingEngine) SetConnectionTimeout(connectionTimeout, keepAlive time.Duration)
SetConnectionTimeout sets the amount of silence needed on a given candidate pair before the ICE agent considers the pair timed out.
func (*SettingEngine) SetEphemeralUDPPortRange ¶
func (e *SettingEngine) SetEphemeralUDPPortRange(portMin, portMax uint16) error
SetEphemeralUDPPortRange limits the pool of ephemeral ports that ICE UDP connections can allocate from. This setting currently only affects host candidates, not server reflexive candidates.
func (*SettingEngine) SetNetworkTypes ¶
func (e *SettingEngine) SetNetworkTypes(candidateTypes []NetworkType)
SetNetworkTypes configures what types of candidate networks are supported during local and server reflexive gathering.
type SignalingState ¶
type SignalingState int
SignalingState indicates the signaling state of the offer/answer process.
const ( // SignalingStateStable indicates there is no offer/answer exchange in // progress. This is also the initial state, in which case the local and // remote descriptions are nil. SignalingStateStable SignalingState = iota + 1 // SignalingStateHaveLocalOffer indicates that a local description, of // type "offer", has been successfully applied. SignalingStateHaveLocalOffer // SignalingStateHaveRemoteOffer indicates that a remote description, of // type "offer", has been successfully applied. SignalingStateHaveRemoteOffer // SignalingStateHaveLocalPranswer indicates that a remote description // of type "offer" has been successfully applied and a local description // of type "pranswer" has been successfully applied. SignalingStateHaveLocalPranswer // SignalingStateHaveRemotePranswer indicates that a local description // of type "offer" has been successfully applied and a remote description // of type "pranswer" has been successfully applied. SignalingStateHaveRemotePranswer // SignalingStateClosed indicates The PeerConnection has been closed. SignalingStateClosed )
func (SignalingState) String ¶
func (t SignalingState) String() string
type Track ¶
type Track struct {
// contains filtered or unexported fields
}
Track represents a single media track
func (*Track) PayloadType ¶
PayloadType gets the PayloadType of the track
Source Files ¶
- api.go
- bundlepolicy.go
- certificate.go
- configuration.go
- constants.go
- datachannel.go
- datachannelinit.go
- datachannelmessage.go
- datachannelparameters.go
- datachannelstate.go
- dtlsfingerprint.go
- dtlsparameters.go
- dtlsrole.go
- dtlstransport.go
- dtlstransportstate.go
- errors.go
- icecandidate.go
- icecandidateinit.go
- icecandidatepair.go
- icecandidatetype.go
- icecomponent.go
- iceconnectionstate.go
- icecredentialtype.go
- icegatherer.go
- icegathererstate.go
- icegatheringstate.go
- icegatheroptions.go
- iceparameters.go
- iceprotocol.go
- icerole.go
- iceserver.go
- icetransport.go
- icetransportpolicy.go
- icetransportstate.go
- mediaengine.go
- networktype.go
- oauthcredential.go
- offeransweroptions.go
- peerconnection.go
- peerconnectionstate.go
- prioritytype.go
- rtcpfeedback.go
- rtcpmuxpolicy.go
- rtpcodingparameters.go
- rtpdecodingparameters.go
- rtpencodingparameters.go
- rtpreceiveparameters.go
- rtpreceiver.go
- rtpsender.go
- rtpsendparameters.go
- rtptransceiver.go
- rtptransceiverdirection.go
- rtptransceiverinit.go
- sctpcapabilities.go
- sctptransport.go
- sctptransportstate.go
- sdpsemantics.go
- sdptype.go
- sessiondescription.go
- settingengine.go
- signalingstate.go
- track.go
Directories ¶
Path | Synopsis |
---|---|
internal/signal
Package signal contains helpers to exchange the SDP session description between examples.
|
Package signal contains helpers to exchange the SDP session description between examples. |
internal
|
|
pkg
|
|
media/rtpdump
Package rtpdump implements the RTPDump file format documented at https://www.cs.columbia.edu/irt/software/rtptools/
|
Package rtpdump implements the RTPDump file format documented at https://www.cs.columbia.edu/irt/software/rtptools/ |
null
Package null is used to represent values where the 0 value is significant This pattern is common in ECMAScript, this allows us to maintain a matching API
|
Package null is used to represent values where the 0 value is significant This pattern is common in ECMAScript, this allows us to maintain a matching API |
rtcerr
Package rtcerr implements the error wrappers defined throughout the WebRTC 1.0 specifications.
|
Package rtcerr implements the error wrappers defined throughout the WebRTC 1.0 specifications. |