errors.go 15 KB

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