github.com/pion/webrtc/v4@v4.0.1/errors.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  package webrtc
     5  
     6  import (
     7  	"errors"
     8  )
     9  
    10  var (
    11  	// ErrUnknownType indicates an error with Unknown info.
    12  	ErrUnknownType = errors.New("unknown")
    13  
    14  	// ErrConnectionClosed indicates an operation executed after connection
    15  	// has already been closed.
    16  	ErrConnectionClosed = errors.New("connection closed")
    17  
    18  	// ErrDataChannelNotOpen indicates an operation executed when the data
    19  	// channel is not (yet) open.
    20  	ErrDataChannelNotOpen = errors.New("data channel not open")
    21  
    22  	// ErrCertificateExpired indicates that an x509 certificate has expired.
    23  	ErrCertificateExpired = errors.New("x509Cert expired")
    24  
    25  	// ErrNoTurnCredentials indicates that a TURN server URL was provided
    26  	// without required credentials.
    27  	ErrNoTurnCredentials = errors.New("turn server credentials required")
    28  
    29  	// ErrTurnCredentials indicates that provided TURN credentials are partial
    30  	// or malformed.
    31  	ErrTurnCredentials = errors.New("invalid turn server credentials")
    32  
    33  	// ErrExistingTrack indicates that a track already exists.
    34  	ErrExistingTrack = errors.New("track already exists")
    35  
    36  	// ErrPrivateKeyType indicates that a particular private key encryption
    37  	// chosen to generate a certificate is not supported.
    38  	ErrPrivateKeyType = errors.New("private key type not supported")
    39  
    40  	// ErrModifyingPeerIdentity indicates that an attempt to modify
    41  	// PeerIdentity was made after PeerConnection has been initialized.
    42  	ErrModifyingPeerIdentity = errors.New("peerIdentity cannot be modified")
    43  
    44  	// ErrModifyingCertificates indicates that an attempt to modify
    45  	// Certificates was made after PeerConnection has been initialized.
    46  	ErrModifyingCertificates = errors.New("certificates cannot be modified")
    47  
    48  	// ErrModifyingBundlePolicy indicates that an attempt to modify
    49  	// BundlePolicy was made after PeerConnection has been initialized.
    50  	ErrModifyingBundlePolicy = errors.New("bundle policy cannot be modified")
    51  
    52  	// ErrModifyingRTCPMuxPolicy indicates that an attempt to modify
    53  	// RTCPMuxPolicy was made after PeerConnection has been initialized.
    54  	ErrModifyingRTCPMuxPolicy = errors.New("rtcp mux policy cannot be modified")
    55  
    56  	// ErrModifyingICECandidatePoolSize indicates that an attempt to modify
    57  	// ICECandidatePoolSize was made after PeerConnection has been initialized.
    58  	ErrModifyingICECandidatePoolSize = errors.New("ice candidate pool size cannot be modified")
    59  
    60  	// ErrStringSizeLimit indicates that the character size limit of string is
    61  	// exceeded. The limit is hardcoded to 65535 according to specifications.
    62  	ErrStringSizeLimit = errors.New("data channel label exceeds size limit")
    63  
    64  	// ErrMaxDataChannelID indicates that the maximum number ID that could be
    65  	// specified for a data channel has been exceeded.
    66  	ErrMaxDataChannelID = errors.New("maximum number ID for datachannel specified")
    67  
    68  	// ErrNegotiatedWithoutID indicates that an attempt to create a data channel
    69  	// was made while setting the negotiated option to true without providing
    70  	// the negotiated channel ID.
    71  	ErrNegotiatedWithoutID = errors.New("negotiated set without channel id")
    72  
    73  	// ErrRetransmitsOrPacketLifeTime indicates that an attempt to create a data
    74  	// channel was made with both options MaxPacketLifeTime and MaxRetransmits
    75  	// set together. Such configuration is not supported by the specification
    76  	// and is mutually exclusive.
    77  	ErrRetransmitsOrPacketLifeTime = errors.New("both MaxPacketLifeTime and MaxRetransmits was set")
    78  
    79  	// ErrCodecNotFound is returned when a codec search to the Media Engine fails
    80  	ErrCodecNotFound = errors.New("codec not found")
    81  
    82  	// ErrNoRemoteDescription indicates that an operation was rejected because
    83  	// the remote description is not set
    84  	ErrNoRemoteDescription = errors.New("remote description is not set")
    85  
    86  	// ErrIncorrectSDPSemantics indicates that the PeerConnection was configured to
    87  	// generate SDP Answers with different SDP Semantics than the received Offer
    88  	ErrIncorrectSDPSemantics = errors.New("remote SessionDescription semantics does not match configuration")
    89  
    90  	// ErrIncorrectSignalingState indicates that the signaling state of PeerConnection is not correct
    91  	ErrIncorrectSignalingState = errors.New("operation can not be run in current signaling state")
    92  
    93  	// ErrProtocolTooLarge indicates that value given for a DataChannelInit protocol is
    94  	// longer then 65535 bytes
    95  	ErrProtocolTooLarge = errors.New("protocol is larger then 65535 bytes")
    96  
    97  	// ErrSenderNotCreatedByConnection indicates RemoveTrack was called with a RtpSender not created
    98  	// by this PeerConnection
    99  	ErrSenderNotCreatedByConnection = errors.New("RtpSender not created by this PeerConnection")
   100  
   101  	// ErrSessionDescriptionNoFingerprint indicates SetRemoteDescription was called with a SessionDescription that has no
   102  	// fingerprint
   103  	ErrSessionDescriptionNoFingerprint = errors.New("SetRemoteDescription called with no fingerprint")
   104  
   105  	// ErrSessionDescriptionInvalidFingerprint indicates SetRemoteDescription was called with a SessionDescription that
   106  	// has an invalid fingerprint
   107  	ErrSessionDescriptionInvalidFingerprint = errors.New("SetRemoteDescription called with an invalid fingerprint")
   108  
   109  	// ErrSessionDescriptionConflictingFingerprints indicates SetRemoteDescription was called with a SessionDescription that
   110  	// has an conflicting fingerprints
   111  	ErrSessionDescriptionConflictingFingerprints = errors.New("SetRemoteDescription called with multiple conflicting fingerprint")
   112  
   113  	// ErrSessionDescriptionMissingIceUfrag indicates SetRemoteDescription was called with a SessionDescription that
   114  	// is missing an ice-ufrag value
   115  	ErrSessionDescriptionMissingIceUfrag = errors.New("SetRemoteDescription called with no ice-ufrag")
   116  
   117  	// ErrSessionDescriptionMissingIcePwd indicates SetRemoteDescription was called with a SessionDescription that
   118  	// is missing an ice-pwd value
   119  	ErrSessionDescriptionMissingIcePwd = errors.New("SetRemoteDescription called with no ice-pwd")
   120  
   121  	// ErrSessionDescriptionConflictingIceUfrag  indicates SetRemoteDescription was called with a SessionDescription that
   122  	// contains multiple conflicting ice-ufrag values
   123  	ErrSessionDescriptionConflictingIceUfrag = errors.New("SetRemoteDescription called with multiple conflicting ice-ufrag values")
   124  
   125  	// ErrSessionDescriptionConflictingIcePwd indicates SetRemoteDescription was called with a SessionDescription that
   126  	// contains multiple conflicting ice-pwd values
   127  	ErrSessionDescriptionConflictingIcePwd = errors.New("SetRemoteDescription called with multiple conflicting ice-pwd values")
   128  
   129  	// ErrNoSRTPProtectionProfile indicates that the DTLS handshake completed and no SRTP Protection Profile was chosen
   130  	ErrNoSRTPProtectionProfile = errors.New("DTLS Handshake completed and no SRTP Protection Profile was chosen")
   131  
   132  	// ErrFailedToGenerateCertificateFingerprint indicates that we failed to generate the fingerprint used for comparing certificates
   133  	ErrFailedToGenerateCertificateFingerprint = errors.New("failed to generate certificate fingerprint")
   134  
   135  	// ErrNoCodecsAvailable indicates that operation isn't possible because the MediaEngine has no codecs available
   136  	ErrNoCodecsAvailable = errors.New("operation failed no codecs are available")
   137  
   138  	// ErrUnsupportedCodec indicates the remote peer doesn't support the requested codec
   139  	ErrUnsupportedCodec = errors.New("unable to start track, codec is not supported by remote")
   140  
   141  	// ErrSenderWithNoCodecs indicates that a RTPSender was created without any codecs. To send media the MediaEngine needs at
   142  	// least one configured codec.
   143  	ErrSenderWithNoCodecs = errors.New("unable to populate media section, RTPSender created with no codecs")
   144  
   145  	// ErrRTPSenderNewTrackHasIncorrectKind indicates that the new track is of a different kind than the previous/original
   146  	ErrRTPSenderNewTrackHasIncorrectKind = errors.New("new track must be of the same kind as previous")
   147  
   148  	// ErrRTPSenderNewTrackHasIncorrectEnvelope indicates that the new track has a different envelope than the previous/original
   149  	ErrRTPSenderNewTrackHasIncorrectEnvelope = errors.New("new track must have the same envelope as previous")
   150  
   151  	// ErrUnbindFailed indicates that a TrackLocal was not able to be unbind
   152  	ErrUnbindFailed = errors.New("failed to unbind TrackLocal from PeerConnection")
   153  
   154  	// ErrNoPayloaderForCodec indicates that the requested codec does not have a payloader
   155  	ErrNoPayloaderForCodec = errors.New("the requested codec does not have a payloader")
   156  
   157  	// ErrRegisterHeaderExtensionInvalidDirection indicates that a extension was registered with a direction besides `sendonly` or `recvonly`
   158  	ErrRegisterHeaderExtensionInvalidDirection = errors.New("a header extension must be registered as 'recvonly', 'sendonly' or both")
   159  
   160  	// ErrSimulcastProbeOverflow indicates that too many Simulcast probe streams are in flight and the requested SSRC was ignored
   161  	ErrSimulcastProbeOverflow = errors.New("simulcast probe limit has been reached, new SSRC has been discarded")
   162  
   163  	errDetachNotEnabled                 = errors.New("enable detaching by calling webrtc.DetachDataChannels()")
   164  	errDetachBeforeOpened               = errors.New("datachannel not opened yet, try calling Detach from OnOpen")
   165  	errDtlsTransportNotStarted          = errors.New("the DTLS transport has not started yet")
   166  	errDtlsKeyExtractionFailed          = errors.New("failed extracting keys from DTLS for SRTP")
   167  	errFailedToStartSRTP                = errors.New("failed to start SRTP")
   168  	errFailedToStartSRTCP               = errors.New("failed to start SRTCP")
   169  	errInvalidDTLSStart                 = errors.New("attempted to start DTLSTransport that is not in new state")
   170  	errNoRemoteCertificate              = errors.New("peer didn't provide certificate via DTLS")
   171  	errIdentityProviderNotImplemented   = errors.New("identity provider is not implemented")
   172  	errNoMatchingCertificateFingerprint = errors.New("remote certificate does not match any fingerprint")
   173  
   174  	errICEConnectionNotStarted        = errors.New("ICE connection not started")
   175  	errICECandidateTypeUnknown        = errors.New("unknown candidate type")
   176  	errICEInvalidConvertCandidateType = errors.New("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")
   177  	errICEAgentNotExist               = errors.New("ICEAgent does not exist")
   178  	errICECandiatesCoversionFailed    = errors.New("unable to convert ICE candidates to ICECandidates")
   179  	errICERoleUnknown                 = errors.New("unknown ICE Role")
   180  	errICEProtocolUnknown             = errors.New("unknown protocol")
   181  	errICEGathererNotStarted          = errors.New("gatherer not started")
   182  
   183  	errNetworkTypeUnknown = errors.New("unknown network type")
   184  
   185  	errSDPDoesNotMatchOffer                           = errors.New("new sdp does not match previous offer")
   186  	errSDPDoesNotMatchAnswer                          = errors.New("new sdp does not match previous answer")
   187  	errPeerConnSDPTypeInvalidValue                    = errors.New("provided value is not a valid enum value of type SDPType")
   188  	errPeerConnStateChangeInvalid                     = errors.New("invalid state change op")
   189  	errPeerConnStateChangeUnhandled                   = errors.New("unhandled state change op")
   190  	errPeerConnSDPTypeInvalidValueSetLocalDescription = errors.New("invalid SDP type supplied to SetLocalDescription()")
   191  	errPeerConnRemoteDescriptionWithoutMidValue       = errors.New("remoteDescription contained media section without mid value")
   192  	errPeerConnRemoteDescriptionNil                   = errors.New("remoteDescription has not been set yet")
   193  	errPeerConnSingleMediaSectionHasExplicitSSRC      = errors.New("single media section has an explicit SSRC")
   194  	errPeerConnRemoteSSRCAddTransceiver               = errors.New("could not add transceiver for remote SSRC")
   195  	errPeerConnSimulcastMidRTPExtensionRequired       = errors.New("mid RTP Extensions required for Simulcast")
   196  	errPeerConnSimulcastStreamIDRTPExtensionRequired  = errors.New("stream id RTP Extensions required for Simulcast")
   197  	errPeerConnSimulcastIncomingSSRCFailed            = errors.New("incoming SSRC failed Simulcast probing")
   198  	errPeerConnAddTransceiverFromKindOnlyAcceptsOne   = errors.New("AddTransceiverFromKind only accepts one RTPTransceiverInit")
   199  	errPeerConnAddTransceiverFromTrackOnlyAcceptsOne  = errors.New("AddTransceiverFromTrack only accepts one RTPTransceiverInit")
   200  	errPeerConnAddTransceiverFromKindSupport          = errors.New("AddTransceiverFromKind currently only supports recvonly")
   201  	errPeerConnAddTransceiverFromTrackSupport         = errors.New("AddTransceiverFromTrack currently only supports sendonly and sendrecv")
   202  	errPeerConnSetIdentityProviderNotImplemented      = errors.New("TODO SetIdentityProvider")
   203  	errPeerConnWriteRTCPOpenWriteStream               = errors.New("WriteRTCP failed to open WriteStream")
   204  	errPeerConnTranscieverMidNil                      = errors.New("cannot find transceiver with mid")
   205  
   206  	errRTPReceiverDTLSTransportNil            = errors.New("DTLSTransport must not be nil")
   207  	errRTPReceiverReceiveAlreadyCalled        = errors.New("Receive has already been called")
   208  	errRTPReceiverWithSSRCTrackStreamNotFound = errors.New("unable to find stream for Track with SSRC")
   209  	errRTPReceiverForRIDTrackStreamNotFound   = errors.New("no trackStreams found for RID")
   210  
   211  	errRTPSenderTrackNil             = errors.New("Track must not be nil")
   212  	errRTPSenderDTLSTransportNil     = errors.New("DTLSTransport must not be nil")
   213  	errRTPSenderSendAlreadyCalled    = errors.New("Send has already been called")
   214  	errRTPSenderStopped              = errors.New("Sender has already been stopped")
   215  	errRTPSenderTrackRemoved         = errors.New("Sender Track has been removed or replaced to nil")
   216  	errRTPSenderRidNil               = errors.New("Sender cannot add encoding as rid is empty")
   217  	errRTPSenderNoBaseEncoding       = errors.New("Sender cannot add encoding as there is no base track")
   218  	errRTPSenderBaseEncodingMismatch = errors.New("Sender cannot add encoding as provided track does not match base track")
   219  	errRTPSenderRIDCollision         = errors.New("Sender cannot encoding due to RID collision")
   220  	errRTPSenderNoTrackForRID        = errors.New("Sender does not have track for RID")
   221  
   222  	errRTPTransceiverCannotChangeMid        = errors.New("errRTPSenderTrackNil")
   223  	errRTPTransceiverSetSendingInvalidState = errors.New("invalid state change in RTPTransceiver.setSending")
   224  	errRTPTransceiverCodecUnsupported       = errors.New("unsupported codec type by this transceiver")
   225  
   226  	errSCTPTransportDTLS = errors.New("DTLS not established")
   227  
   228  	errSDPZeroTransceivers                 = errors.New("addTransceiverSDP() called with 0 transceivers")
   229  	errSDPMediaSectionMediaDataChanInvalid = errors.New("invalid Media Section. Media + DataChannel both enabled")
   230  	errSDPMediaSectionMultipleTrackInvalid = errors.New("invalid Media Section. Can not have multiple tracks in one MediaSection in UnifiedPlan")
   231  
   232  	errSettingEngineSetAnsweringDTLSRole = errors.New("SetAnsweringDTLSRole must DTLSRoleClient or DTLSRoleServer")
   233  
   234  	errSignalingStateCannotRollback            = errors.New("can't rollback from stable state")
   235  	errSignalingStateProposedTransitionInvalid = errors.New("invalid proposed signaling state transition")
   236  
   237  	errStatsICECandidateStateInvalid = errors.New("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")
   238  
   239  	errInvalidICECredentialTypeString = errors.New("invalid ICECredentialType")
   240  	errInvalidICEServer               = errors.New("invalid ICEServer")
   241  
   242  	errICETransportNotInNew = errors.New("ICETransport can only be called in ICETransportStateNew")
   243  	errICETransportClosed   = errors.New("ICETransport closed")
   244  
   245  	errCertificatePEMFormatError = errors.New("bad Certificate PEM format")
   246  
   247  	errRTPTooShort = errors.New("not long enough to be a RTP Packet")
   248  
   249  	errExcessiveRetries = errors.New("excessive retries in CreateOffer")
   250  )