errors.go 15 KB

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