1#![allow(dead_code)]
2
3use std::io;
4use std::net;
5use std::net::SocketAddr;
6use std::num::ParseIntError;
7use std::string::FromUtf8Error;
8use std::time::SystemTimeError;
9use substring::Substring;
10use thiserror::Error;
11
12pub type Result<T> = std::result::Result<T, Error>;
13
14#[derive(Error, Debug, PartialEq)]
15#[non_exhaustive]
16pub enum Error {
17 #[error("buffer: full")]
18 ErrBufferFull,
19 #[error("buffer: closed")]
20 ErrBufferClosed,
21 #[error("buffer: short")]
22 ErrBufferShort,
23 #[error("packet too big")]
24 ErrPacketTooBig,
25 #[error("i/o timeout")]
26 ErrTimeout,
27 #[error("udp: listener closed")]
28 ErrClosedListener,
29 #[error("udp: listen queue exceeded")]
30 ErrListenQueueExceeded,
31 #[error("udp: listener accept ch closed")]
32 ErrClosedListenerAcceptCh,
33 #[error("obs cannot be nil")]
34 ErrObsCannotBeNil,
35 #[error("se of closed network connection")]
36 ErrUseClosedNetworkConn,
37 #[error("addr is not a net.UDPAddr")]
38 ErrAddrNotUdpAddr,
39 #[error("something went wrong with locAddr")]
40 ErrLocAddr,
41 #[error("already closed")]
42 ErrAlreadyClosed,
43 #[error("no remAddr defined")]
44 ErrNoRemAddr,
45 #[error("address already in use")]
46 ErrAddressAlreadyInUse,
47 #[error("no such UDPConn")]
48 ErrNoSuchUdpConn,
49 #[error("cannot remove unspecified IP by the specified IP")]
50 ErrCannotRemoveUnspecifiedIp,
51 #[error("no address assigned")]
52 ErrNoAddressAssigned,
53 #[error("1:1 NAT requires more than one mapping")]
54 ErrNatRequriesMapping,
55 #[error("length mismtach between mappedIPs and localIPs")]
56 ErrMismatchLengthIp,
57 #[error("non-udp translation is not supported yet")]
58 ErrNonUdpTranslationNotSupported,
59 #[error("no associated local address")]
60 ErrNoAssociatedLocalAddress,
61 #[error("no NAT binding found")]
62 ErrNoNatBindingFound,
63 #[error("has no permission")]
64 ErrHasNoPermission,
65 #[error("host name must not be empty")]
66 ErrHostnameEmpty,
67 #[error("failed to parse IP address")]
68 ErrFailedToParseIpaddr,
69 #[error("no interface is available")]
70 ErrNoInterface,
71 #[error("not found")]
72 ErrNotFound,
73 #[error("unexpected network")]
74 ErrUnexpectedNetwork,
75 #[error("can't assign requested address")]
76 ErrCantAssignRequestedAddr,
77 #[error("unknown network")]
78 ErrUnknownNetwork,
79 #[error("no router linked")]
80 ErrNoRouterLinked,
81 #[error("invalid port number")]
82 ErrInvalidPortNumber,
83 #[error("unexpected type-switch failure")]
84 ErrUnexpectedTypeSwitchFailure,
85 #[error("bind failed")]
86 ErrBindFailed,
87 #[error("end port is less than the start")]
88 ErrEndPortLessThanStart,
89 #[error("port space exhausted")]
90 ErrPortSpaceExhausted,
91 #[error("vnet is not enabled")]
92 ErrVnetDisabled,
93 #[error("invalid local IP in static_ips")]
94 ErrInvalidLocalIpInStaticIps,
95 #[error("mapped in static_ips is beyond subnet")]
96 ErrLocalIpBeyondStaticIpsSubset,
97 #[error("all static_ips must have associated local IPs")]
98 ErrLocalIpNoStaticsIpsAssociated,
99 #[error("router already started")]
100 ErrRouterAlreadyStarted,
101 #[error("router already stopped")]
102 ErrRouterAlreadyStopped,
103 #[error("static IP is beyond subnet")]
104 ErrStaticIpIsBeyondSubnet,
105 #[error("address space exhausted")]
106 ErrAddressSpaceExhausted,
107 #[error("no IP address is assigned for eth0")]
108 ErrNoIpaddrEth0,
109 #[error("Invalid mask")]
110 ErrInvalidMask,
111
112 #[error("tls handshake is in progress")]
114 HandshakeInProgress,
115 #[error("context is not supported for export_keying_material")]
116 ContextUnsupported,
117 #[error("export_keying_material can not be used with a reserved label")]
118 ReservedExportKeyingMaterial,
119 #[error("no cipher suite for export_keying_material")]
120 CipherSuiteUnset,
121 #[error("export_keying_material hash: {0}")]
122 Hash(String),
123 #[error("mutex poison: {0}")]
124 PoisonError(String),
125
126 #[error("Wrong marshal size")]
129 WrongMarshalSize,
130 #[error("Invalid total lost count")]
133 InvalidTotalLost,
134 #[error("Invalid header")]
136 InvalidHeader,
137 #[error("Empty compound packet")]
139 EmptyCompound,
140 #[error("First packet in compound must be SR or RR")]
143 BadFirstPacket,
144 #[error("Compound missing SourceDescription with CNAME")]
146 MissingCname,
147 #[error("Feedback packet seen before CNAME")]
149 PacketBeforeCname,
150 #[error("Too many reports")]
152 TooManyReports,
153 #[error("Too many chunks")]
155 TooManyChunks,
156 #[error("too many sources")]
158 TooManySources,
159 #[error("Packet too short to be read")]
161 PacketTooShort,
162 #[error("Buffer too short to be written")]
164 BufferTooShort,
165 #[error("Wrong packet type")]
167 WrongType,
168 #[error("SDES must be < 255 octets long")]
170 SdesTextTooLong,
171 #[error("SDES item missing type")]
173 SdesMissingType,
174 #[error("Reason must be < 255 octets long")]
176 ReasonTooLong,
177 #[error("Invalid packet version")]
179 BadVersion,
180 #[error("Invalid padding value")]
182 WrongPadding,
183 #[error("Wrong feedback message type")]
185 WrongFeedbackType,
186 #[error("Wrong payload type")]
188 WrongPayloadType,
189 #[error("Header length is too small")]
191 HeaderTooSmall,
192 #[error("Media SSRC must be 0")]
194 SsrcMustBeZero,
195 #[error("Missing REMB identifier")]
197 MissingRembIdentifier,
198 #[error("SSRC num and length do not match")]
200 SsrcNumAndLengthMismatch,
201 #[error("Invalid size or startIndex")]
203 InvalidSizeOrStartIndex,
204 #[error("Delta exceed limit")]
206 DeltaExceedLimit,
207 #[error("Packet status chunk must be 2 bytes")]
209 PacketStatusChunkLength,
210 #[error("Invalid bitrate")]
211 InvalidBitrate,
212 #[error("Wrong chunk type")]
213 WrongChunkType,
214 #[error("Struct contains unexpected member type")]
215 BadStructMemberType,
216 #[error("Cannot read into non-pointer")]
217 BadReadParameter,
218 #[error("Invalid block size")]
219 InvalidBlockSize,
220
221 #[error("RTP header size insufficient")]
223 ErrHeaderSizeInsufficient,
224 #[error("RTP header size insufficient for extension")]
225 ErrHeaderSizeInsufficientForExtension,
226 #[error("buffer too small")]
227 ErrBufferTooSmall,
228 #[error("extension not enabled")]
229 ErrHeaderExtensionsNotEnabled,
230 #[error("extension not found")]
231 ErrHeaderExtensionNotFound,
232
233 #[error("header extension id must be between 1 and 14 for RFC 5285 extensions")]
234 ErrRfc8285oneByteHeaderIdrange,
235 #[error("header extension payload must be 16bytes or less for RFC 5285 one byte extensions")]
236 ErrRfc8285oneByteHeaderSize,
237
238 #[error("header extension id must be between 1 and 255 for RFC 5285 extensions")]
239 ErrRfc8285twoByteHeaderIdrange,
240 #[error("header extension payload must be 255bytes or less for RFC 5285 two byte extensions")]
241 ErrRfc8285twoByteHeaderSize,
242
243 #[error("header extension id must be 0 for none RFC 5285 extensions")]
244 ErrRfc3550headerIdrange,
245
246 #[error("packet is not large enough")]
247 ErrShortPacket,
248 #[error("invalid nil packet")]
249 ErrNilPacket,
250 #[error("too many PDiff")]
251 ErrTooManyPDiff,
252 #[error("too many spatial layers")]
253 ErrTooManySpatialLayers,
254 #[error("NALU Type is unhandled")]
255 ErrUnhandledNaluType,
256
257 #[error("corrupted h265 packet")]
258 ErrH265CorruptedPacket,
259 #[error("invalid h265 packet type")]
260 ErrInvalidH265PacketType,
261
262 #[error("payload is too small for OBU extension header")]
263 ErrPayloadTooSmallForObuExtensionHeader,
264 #[error("payload is too small for OBU payload size")]
265 ErrPayloadTooSmallForObuPayloadSize,
266
267 #[error("extension_payload must be in 32-bit words")]
268 HeaderExtensionPayloadNot32BitWords,
269 #[error("audio level overflow")]
270 AudioLevelOverflow,
271 #[error("playout delay overflow")]
272 PlayoutDelayOverflow,
273 #[error("payload is not large enough")]
274 PayloadIsNotLargeEnough,
275 #[error("STAP-A declared size({0}) is larger than buffer({1})")]
276 StapASizeLargerThanBuffer(usize, usize),
277 #[error("nalu type {0} is currently not handled")]
278 NaluTypeIsNotHandled(u8),
279
280 #[error("duplicated packet")]
282 ErrDuplicated,
283 #[error("SRTP master key is not long enough")]
284 ErrShortSrtpMasterKey,
285 #[error("SRTP master salt is not long enough")]
286 ErrShortSrtpMasterSalt,
287 #[error("no such SRTP Profile")]
288 ErrNoSuchSrtpProfile,
289 #[error("indexOverKdr > 0 is not supported yet")]
290 ErrNonZeroKdrNotSupported,
291 #[error("exporter called with wrong label")]
292 ErrExporterWrongLabel,
293 #[error("no config provided")]
294 ErrNoConfig,
295 #[error("no conn provided")]
296 ErrNoConn,
297 #[error("failed to verify auth tag")]
298 ErrFailedToVerifyAuthTag,
299 #[error("packet is too short to be RTP packet")]
300 ErrTooShortRtp,
301 #[error("packet is too short to be RTCP packet")]
302 ErrTooShortRtcp,
303 #[error("payload differs")]
304 ErrPayloadDiffers,
305 #[error("started channel used incorrectly, should only be closed")]
306 ErrStartedChannelUsedIncorrectly,
307 #[error("stream has not been inited, unable to close")]
308 ErrStreamNotInited,
309 #[error("stream is already closed")]
310 ErrStreamAlreadyClosed,
311 #[error("stream is already inited")]
312 ErrStreamAlreadyInited,
313 #[error("failed to cast child")]
314 ErrFailedTypeAssertion,
315 #[error("exceeded the maximum number of packets")]
316 ErrExceededMaxPackets,
317
318 #[error("index_over_kdr > 0 is not supported yet")]
319 UnsupportedIndexOverKdr,
320 #[error("invalid master key length for aes_256_cm")]
321 InvalidMasterKeyLength,
322 #[error("invalid master salt length for aes_256_cm")]
323 InvalidMasterSaltLength,
324 #[error("out_len > 32 is not supported for aes_256_cm")]
325 UnsupportedOutLength,
326 #[error("SRTP Master Key must be len {0}, got {1}")]
327 SrtpMasterKeyLength(usize, usize),
328 #[error("SRTP Salt must be len {0}, got {1}")]
329 SrtpSaltLength(usize, usize),
330 #[error("SyntaxError: {0}")]
331 ExtMapParse(String),
332 #[error("ssrc {0} not exist in srtp_ssrc_state")]
333 SsrcMissingFromSrtp(u32),
334 #[error("srtp ssrc={0} index={1}: duplicated")]
335 SrtpSsrcDuplicated(u32, u16),
336 #[error("srtcp ssrc={0} index={1}: duplicated")]
337 SrtcpSsrcDuplicated(u32, usize),
338 #[error("ssrc {0} not exist in srtcp_ssrc_state")]
339 SsrcMissingFromSrtcp(u32),
340 #[error("Stream with ssrc {0} exists")]
341 StreamWithSsrcExists(u32),
342 #[error("Session RTP/RTCP type must be same as input buffer")]
343 SessionRtpRtcpTypeMismatch,
344 #[error("Session EOF")]
345 SessionEof,
346 #[error("too short SRTP packet: only {0} bytes, expected > {1} bytes")]
347 SrtpTooSmall(usize, usize),
348 #[error("too short SRTCP packet: only {0} bytes, expected > {1} bytes")]
349 SrtcpTooSmall(usize, usize),
350 #[error("failed to verify rtp auth tag")]
351 RtpFailedToVerifyAuthTag,
352 #[error("too short auth tag: only {0} bytes, expected > {1} bytes")]
353 RtcpInvalidLengthAuthTag(usize, usize),
354 #[error("failed to verify rtcp auth tag")]
355 RtcpFailedToVerifyAuthTag,
356 #[error("SessionSRTP has been closed")]
357 SessionSrtpAlreadyClosed,
358 #[error("this stream is not a RTPStream")]
359 InvalidRtpStream,
360 #[error("this stream is not a RTCPStream")]
361 InvalidRtcpStream,
362
363 #[error("attribute not found")]
365 ErrAttributeNotFound,
366 #[error("transaction is stopped")]
367 ErrTransactionStopped,
368 #[error("transaction not exists")]
369 ErrTransactionNotExists,
370 #[error("transaction exists with same id")]
371 ErrTransactionExists,
372 #[error("agent is closed")]
373 ErrAgentClosed,
374 #[error("transaction is timed out")]
375 ErrTransactionTimeOut,
376 #[error("no default reason for ErrorCode")]
377 ErrNoDefaultReason,
378 #[error("unexpected EOF")]
379 ErrUnexpectedEof,
380 #[error("attribute size is invalid")]
381 ErrAttributeSizeInvalid,
382 #[error("attribute size overflow")]
383 ErrAttributeSizeOverflow,
384 #[error("attempt to decode to nil message")]
385 ErrDecodeToNil,
386 #[error("unexpected EOF: not enough bytes to read header")]
387 ErrUnexpectedHeaderEof,
388 #[error("integrity check failed")]
389 ErrIntegrityMismatch,
390 #[error("fingerprint check failed")]
391 ErrFingerprintMismatch,
392 #[error("FINGERPRINT before MESSAGE-INTEGRITY attribute")]
393 ErrFingerprintBeforeIntegrity,
394 #[error("bad UNKNOWN-ATTRIBUTES size")]
395 ErrBadUnknownAttrsSize,
396 #[error("invalid length of IP value")]
397 ErrBadIpLength,
398 #[error("no connection provided")]
399 ErrNoConnection,
400 #[error("client is closed")]
401 ErrClientClosed,
402 #[error("no agent is set")]
403 ErrNoAgent,
404 #[error("collector is closed")]
405 ErrCollectorClosed,
406 #[error("unsupported network")]
407 ErrUnsupportedNetwork,
408 #[error("invalid url")]
409 ErrInvalidUrl,
410 #[error("unknown scheme type")]
411 ErrSchemeType,
412 #[error("invalid hostname")]
413 ErrHost,
414
415 #[error("turn: RelayAddress must be valid IP to use RelayAddressGeneratorStatic")]
417 ErrRelayAddressInvalid,
418 #[error("turn: PacketConnConfigs and ConnConfigs are empty, unable to proceed")]
419 ErrNoAvailableConns,
420 #[error("turn: PacketConnConfig must have a non-nil Conn")]
421 ErrConnUnset,
422 #[error("turn: ListenerConfig must have a non-nil Listener")]
423 ErrListenerUnset,
424 #[error("turn: RelayAddressGenerator has invalid ListeningAddress")]
425 ErrListeningAddressInvalid,
426 #[error("turn: RelayAddressGenerator in RelayConfig is unset")]
427 ErrRelayAddressGeneratorUnset,
428 #[error("turn: max retries exceeded")]
429 ErrMaxRetriesExceeded,
430 #[error("turn: MaxPort must be not 0")]
431 ErrMaxPortNotZero,
432 #[error("turn: MaxPort must be not 0")]
433 ErrMinPortNotZero,
434 #[error("turn: MaxPort less than MinPort")]
435 ErrMaxPortLessThanMinPort,
436 #[error("turn: relay_conn cannot not be nil")]
437 ErrNilConn,
438 #[error("turn: TODO")]
439 ErrTodo,
440 #[error("turn: already listening")]
441 ErrAlreadyListening,
442 #[error("turn: Server failed to close")]
443 ErrFailedToClose,
444 #[error("turn: failed to retransmit transaction")]
445 ErrFailedToRetransmitTransaction,
446 #[error("all retransmissions failed")]
447 ErrAllRetransmissionsFailed,
448 #[error("no binding found for channel")]
449 ErrChannelBindNotFound,
450 #[error("STUN server address is not set for the client")]
451 ErrStunserverAddressNotSet,
452 #[error("only one Allocate() caller is allowed")]
453 ErrOneAllocateOnly,
454 #[error("already allocated")]
455 ErrAlreadyAllocated,
456 #[error("non-STUN message from STUN server")]
457 ErrNonStunmessage,
458 #[error("failed to decode STUN message")]
459 ErrFailedToDecodeStun,
460 #[error("unexpected STUN request message")]
461 ErrUnexpectedStunrequestMessage,
462 #[error("channel number not in [0x4000, 0x7FFF]")]
463 ErrInvalidChannelNumber,
464 #[error("channelData length != len(Data)")]
465 ErrBadChannelDataLength,
466 #[error("invalid value for requested family attribute")]
467 ErrInvalidRequestedFamilyValue,
468 #[error("fake error")]
469 ErrFakeErr,
470 #[error("use of closed network connection")]
471 ErrClosed,
472 #[error("addr is not a net.UDPAddr")]
473 ErrUdpaddrCast,
474 #[error("try-lock is already locked")]
475 ErrDoubleLock,
476 #[error("transaction closed")]
477 ErrTransactionClosed,
478 #[error("wait_for_result called on non-result transaction")]
479 ErrWaitForResultOnNonResultTransaction,
480 #[error("failed to build refresh request")]
481 ErrFailedToBuildRefreshRequest,
482 #[error("failed to refresh allocation")]
483 ErrFailedToRefreshAllocation,
484 #[error("failed to get lifetime from refresh response")]
485 ErrFailedToGetLifetime,
486 #[error("too short buffer")]
487 ErrShortBuffer,
488 #[error("unexpected response type")]
489 ErrUnexpectedResponse,
490 #[error("AllocatePacketConn must be set")]
491 ErrAllocatePacketConnMustBeSet,
492 #[error("AllocateConn must be set")]
493 ErrAllocateConnMustBeSet,
494 #[error("LeveledLogger must be set")]
495 ErrLeveledLoggerMustBeSet,
496 #[error("you cannot use the same channel number with different peer")]
497 ErrSameChannelDifferentPeer,
498 #[error("allocations must not be created with nil FivTuple")]
499 ErrNilFiveTuple,
500 #[error("allocations must not be created with nil FiveTuple.src_addr")]
501 ErrNilFiveTupleSrcAddr,
502 #[error("allocations must not be created with nil FiveTuple.dst_addr")]
503 ErrNilFiveTupleDstAddr,
504 #[error("allocations must not be created with nil turnSocket")]
505 ErrNilTurnSocket,
506 #[error("allocations must not be created with a lifetime of 0")]
507 ErrLifetimeZero,
508 #[error("allocation attempt created with duplicate FiveTuple")]
509 ErrDupeFiveTuple,
510 #[error("failed to cast net.Addr to *net.UDPAddr")]
511 ErrFailedToCastUdpaddr,
512 #[error("failed to generate nonce")]
513 ErrFailedToGenerateNonce,
514 #[error("failed to send error message")]
515 ErrFailedToSendError,
516 #[error("duplicated Nonce generated, discarding request")]
517 ErrDuplicatedNonce,
518 #[error("no such user exists")]
519 ErrNoSuchUser,
520 #[error("unexpected class")]
521 ErrUnexpectedClass,
522 #[error("unexpected method")]
523 ErrUnexpectedMethod,
524 #[error("failed to handle")]
525 ErrFailedToHandle,
526 #[error("unhandled STUN packet")]
527 ErrUnhandledStunpacket,
528 #[error("unable to handle ChannelData")]
529 ErrUnableToHandleChannelData,
530 #[error("failed to create stun message from packet")]
531 ErrFailedToCreateStunpacket,
532 #[error("failed to create channel data from packet")]
533 ErrFailedToCreateChannelData,
534 #[error("relay already allocated for 5-TUPLE")]
535 ErrRelayAlreadyAllocatedForFiveTuple,
536 #[error("RequestedTransport must be UDP")]
537 ErrRequestedTransportMustBeUdp,
538 #[error("no support for DONT-FRAGMENT")]
539 ErrNoDontFragmentSupport,
540 #[error("Request must not contain RESERVATION-TOKEN and EVEN-PORT")]
541 ErrRequestWithReservationTokenAndEvenPort,
542 #[error("no allocation found")]
543 ErrNoAllocationFound,
544 #[error("unable to handle send-indication, no permission added")]
545 ErrNoPermission,
546 #[error("packet write smaller than packet")]
547 ErrShortWrite,
548 #[error("no such channel bind")]
549 ErrNoSuchChannelBind,
550 #[error("failed writing to socket")]
551 ErrFailedWriteSocket,
552
553 #[error("Unknown type")]
556 ErrUnknownType,
557
558 #[error("queries not supported in stun address")]
560 ErrStunQuery,
561
562 #[error("invalid query")]
564 ErrInvalidQuery,
565
566 #[error("url parse: invalid port number")]
568 ErrPort,
569
570 #[error("local username fragment is less than 24 bits long")]
573 ErrLocalUfragInsufficientBits,
574
575 #[error("local password is less than 128 bits long")]
578 ErrLocalPwdInsufficientBits,
579
580 #[error("invalid transport protocol type")]
582 ErrProtoType,
583
584 #[error("no candidate pairs available")]
586 ErrNoCandidatePairs,
587
588 #[error("connecting canceled by caller")]
590 ErrCanceledByCaller,
591
592 #[error("attempted to start agent twice")]
594 ErrMultipleStart,
595
596 #[error("remote ufrag is empty")]
598 ErrRemoteUfragEmpty,
599
600 #[error("remote pwd is empty")]
602 ErrRemotePwdEmpty,
603
604 #[error("no on_candidate provided")]
606 ErrNoOnCandidateHandler,
607
608 #[error("attempting to gather candidates during gathering state")]
610 ErrMultipleGatherAttempted,
611
612 #[error("username is empty")]
614 ErrUsernameEmpty,
615
616 #[error("password is empty")]
618 ErrPasswordEmpty,
619
620 #[error("failed to parse address")]
622 ErrAddressParseFailed,
623
624 #[error("lite agents must only use host candidates")]
626 ErrLiteUsingNonHostCandidates,
627
628 #[error("lite support only")]
630 ErrLiteSupportOnly,
631
632 #[error("agent does not need URL with selected candidate types")]
634 ErrUselessUrlsProvided,
635
636 #[error("unsupported 1:1 NAT IP candidate type")]
638 ErrUnsupportedNat1to1IpCandidateType,
639
640 #[error("invalid 1:1 NAT IP mapping")]
642 ErrInvalidNat1to1IpMapping,
643
644 #[error("external mapped IP not found")]
646 ErrExternalMappedIpNotFound,
647
648 #[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
651 ErrMulticastDnsWithNat1to1IpMapping,
652
653 #[error("1:1 NAT IP mapping for host candidate ineffective")]
656 ErrIneffectiveNat1to1IpMappingHost,
657
658 #[error("1:1 NAT IP mapping for srflx candidate ineffective")]
661 ErrIneffectiveNat1to1IpMappingSrflx,
662
663 #[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
665 ErrInvalidMulticastDnshostName,
666
667 #[error("mdns is not supported")]
669 ErrMulticastDnsNotSupported,
670
671 #[error("ICE Agent can not be restarted when gathering")]
673 ErrRestartWhenGathering,
674
675 #[error("run was canceled by done")]
677 ErrRunCanceled,
678
679 #[error("TCPMux is not initialized")]
681 ErrTcpMuxNotInitialized,
682
683 #[error("conn with same remote addr already exists")]
685 ErrTcpRemoteAddrAlreadyExists,
686
687 #[error("failed to send packet")]
688 ErrSendPacket,
689 #[error("attribute not long enough to be ICE candidate")]
690 ErrAttributeTooShortIceCandidate,
691 #[error("could not parse component")]
692 ErrParseComponent,
693 #[error("could not parse priority")]
694 ErrParsePriority,
695 #[error("could not parse port")]
696 ErrParsePort,
697 #[error("could not parse related addresses")]
698 ErrParseRelatedAddr,
699 #[error("could not parse type")]
700 ErrParseType,
701 #[error("unknown candidate type")]
702 ErrUnknownCandidateType,
703 #[error("failed to get XOR-MAPPED-ADDRESS response")]
704 ErrGetXorMappedAddrResponse,
705 #[error("connection with same remote address already exists")]
706 ErrConnectionAddrAlreadyExist,
707 #[error("error reading streaming packet")]
708 ErrReadingStreamingPacket,
709 #[error("error writing to")]
710 ErrWriting,
711 #[error("error closing connection")]
712 ErrClosingConnection,
713 #[error("unable to determine networkType")]
714 ErrDetermineNetworkType,
715 #[error("missing protocol scheme")]
716 ErrMissingProtocolScheme,
717 #[error("too many colons in address")]
718 ErrTooManyColonsAddr,
719 #[error("unexpected error trying to read")]
720 ErrRead,
721 #[error("unknown role")]
722 ErrUnknownRole,
723 #[error("username mismatch")]
724 ErrMismatchUsername,
725 #[error("the ICE conn can't write STUN messages")]
726 ErrIceWriteStunMessage,
727 #[error("url parse: relative URL without a base")]
728 ErrUrlParse,
729 #[error("Candidate IP could not be found")]
730 ErrCandidateIpNotFound,
731
732 #[error("conn is closed")]
734 ErrConnClosed,
735 #[error("read/write timeout")]
736 ErrDeadlineExceeded,
737 #[error("context is not supported for export_keying_material")]
738 ErrContextUnsupported,
739 #[error("packet is too short")]
740 ErrDtlspacketInvalidLength,
741 #[error("handshake is in progress")]
742 ErrHandshakeInProgress,
743 #[error("invalid content type")]
744 ErrInvalidContentType,
745 #[error("invalid mac")]
746 ErrInvalidMac,
747 #[error("packet length and declared length do not match")]
748 ErrInvalidPacketLength,
749 #[error("export_keying_material can not be used with a reserved label")]
750 ErrReservedExportKeyingMaterial,
751 #[error("client sent certificate verify but we have no certificate to verify")]
752 ErrCertificateVerifyNoCertificate,
753 #[error("client+server do not support any shared cipher suites")]
754 ErrCipherSuiteNoIntersection,
755 #[error("server hello can not be created without a cipher suite")]
756 ErrCipherSuiteUnset,
757 #[error("client sent certificate but did not verify it")]
758 ErrClientCertificateNotVerified,
759 #[error("server required client verification, but got none")]
760 ErrClientCertificateRequired,
761 #[error("server responded with SRTP Profile we do not support")]
762 ErrClientNoMatchingSrtpProfile,
763 #[error("client required Extended Master Secret extension, but server does not support it")]
764 ErrClientRequiredButNoServerEms,
765 #[error("server hello can not be created without a compression method")]
766 ErrCompressionMethodUnset,
767 #[error("client+server cookie does not match")]
768 ErrCookieMismatch,
769 #[error("cookie must not be longer then 255 bytes")]
770 ErrCookieTooLong,
771 #[error("PSK Identity Hint provided but PSK is nil")]
772 ErrIdentityNoPsk,
773 #[error("no certificate provided")]
774 ErrInvalidCertificate,
775 #[error("cipher spec invalid")]
776 ErrInvalidCipherSpec,
777 #[error("invalid or unknown cipher suite")]
778 ErrInvalidCipherSuite,
779 #[error("unable to determine if ClientKeyExchange is a public key or PSK Identity")]
780 ErrInvalidClientKeyExchange,
781 #[error("invalid or unknown compression method")]
782 ErrInvalidCompressionMethod,
783 #[error("ECDSA signature contained zero or negative values")]
784 ErrInvalidEcdsasignature,
785 #[error("invalid or unknown elliptic curve type")]
786 ErrInvalidEllipticCurveType,
787 #[error("invalid extension type")]
788 ErrInvalidExtensionType,
789 #[error("invalid hash algorithm")]
790 ErrInvalidHashAlgorithm,
791 #[error("invalid named curve")]
792 ErrInvalidNamedCurve,
793 #[error("invalid private key type")]
794 ErrInvalidPrivateKey,
795 #[error("named curve and private key type does not match")]
796 ErrNamedCurveAndPrivateKeyMismatch,
797 #[error("invalid server name format")]
798 ErrInvalidSniFormat,
799 #[error("invalid signature algorithm")]
800 ErrInvalidSignatureAlgorithm,
801 #[error("expected and actual key signature do not match")]
802 ErrKeySignatureMismatch,
803 #[error("Conn can not be created with a nil nextConn")]
804 ErrNilNextConn,
805 #[error("connection can not be created, no CipherSuites satisfy this Config")]
806 ErrNoAvailableCipherSuites,
807 #[error("connection can not be created, no SignatureScheme satisfy this Config")]
808 ErrNoAvailableSignatureSchemes,
809 #[error("no certificates configured")]
810 ErrNoCertificates,
811 #[error("no config provided")]
812 ErrNoConfigProvided,
813 #[error("client requested zero or more elliptic curves that are not supported by the server")]
814 ErrNoSupportedEllipticCurves,
815 #[error("unsupported protocol version")]
816 ErrUnsupportedProtocolVersion,
817 #[error("Certificate and PSK provided")]
818 ErrPskAndCertificate,
819 #[error("PSK and PSK Identity Hint must both be set for client")]
820 ErrPskAndIdentityMustBeSetForClient,
821 #[error("SRTP support was requested but server did not respond with use_srtp extension")]
822 ErrRequestedButNoSrtpExtension,
823 #[error("Certificate is mandatory for server")]
824 ErrServerMustHaveCertificate,
825 #[error("client requested SRTP but we have no matching profiles")]
826 ErrServerNoMatchingSrtpProfile,
827 #[error(
828 "server requires the Extended Master Secret extension, but the client does not support it"
829 )]
830 ErrServerRequiredButNoClientEms,
831 #[error("expected and actual verify data does not match")]
832 ErrVerifyDataMismatch,
833 #[error("handshake message unset, unable to marshal")]
834 ErrHandshakeMessageUnset,
835 #[error("invalid flight number")]
836 ErrInvalidFlight,
837 #[error("unable to generate key signature, unimplemented")]
838 ErrKeySignatureGenerateUnimplemented,
839 #[error("unable to verify key signature, unimplemented")]
840 ErrKeySignatureVerifyUnimplemented,
841 #[error("data length and declared length do not match")]
842 ErrLengthMismatch,
843 #[error("buffer not long enough to contain nonce")]
844 ErrNotEnoughRoomForNonce,
845 #[error("feature has not been implemented yet")]
846 ErrNotImplemented,
847 #[error("sequence number overflow")]
848 ErrSequenceNumberOverflow,
849 #[error("unable to marshal fragmented handshakes")]
850 ErrUnableToMarshalFragmented,
851 #[error("invalid state machine transition")]
852 ErrInvalidFsmTransition,
853 #[error("ApplicationData with epoch of 0")]
854 ErrApplicationDataEpochZero,
855 #[error("unhandled contentType")]
856 ErrUnhandledContextType,
857 #[error("context canceled")]
858 ErrContextCanceled,
859 #[error("empty fragment")]
860 ErrEmptyFragment,
861 #[error("Alert is Fatal or Close Notify")]
862 ErrAlertFatalOrClose,
863 #[error(
864 "Fragment buffer overflow. New size {new_size} is greater than specified max {max_size}"
865 )]
866 ErrFragmentBufferOverflow { new_size: usize, max_size: usize },
867 #[error("Client transport is not set yet")]
868 ErrClientTransportNotSet,
869
870 #[error("endpoint stopping")]
874 EndpointStopping,
875 #[error("too many connections")]
879 TooManyConnections,
880 #[error("invalid DNS name: {0}")]
882 InvalidDnsName(String),
883 #[error("invalid remote address: {0}")]
887 InvalidRemoteAddress(SocketAddr),
888 #[error("no client config")]
890 NoClientConfig,
891 #[error("no server config")]
893 NoServerConfig,
894
895 #[error("raw is too small for a SCTP chunk")]
897 ErrChunkHeaderTooSmall,
898 #[error("not enough data left in SCTP packet to satisfy requested length")]
899 ErrChunkHeaderNotEnoughSpace,
900 #[error("chunk PADDING is non-zero at offset")]
901 ErrChunkHeaderPaddingNonZero,
902 #[error("chunk has invalid length")]
903 ErrChunkHeaderInvalidLength,
904
905 #[error("ChunkType is not of type ABORT")]
906 ErrChunkTypeNotAbort,
907 #[error("failed build Abort Chunk")]
908 ErrBuildAbortChunkFailed,
909 #[error("ChunkType is not of type COOKIEACK")]
910 ErrChunkTypeNotCookieAck,
911 #[error("ChunkType is not of type COOKIEECHO")]
912 ErrChunkTypeNotCookieEcho,
913 #[error("ChunkType is not of type ctError")]
914 ErrChunkTypeNotCt,
915 #[error("failed build Error Chunk")]
916 ErrBuildErrorChunkFailed,
917 #[error("failed to marshal stream")]
918 ErrMarshalStreamFailed,
919 #[error("chunk too short")]
920 ErrChunkTooShort,
921 #[error("ChunkType is not of type ForwardTsn")]
922 ErrChunkTypeNotForwardTsn,
923 #[error("ChunkType is not of type HEARTBEAT")]
924 ErrChunkTypeNotHeartbeat,
925 #[error("ChunkType is not of type HEARTBEATACK")]
926 ErrChunkTypeNotHeartbeatAck,
927 #[error("heartbeat is not long enough to contain Heartbeat Info")]
928 ErrHeartbeatNotLongEnoughInfo,
929 #[error("failed to parse param type")]
930 ErrParseParamTypeFailed,
931 #[error("heartbeat should only have HEARTBEAT param")]
932 ErrHeartbeatParam,
933 #[error("failed unmarshalling param in Heartbeat Chunk")]
934 ErrHeartbeatChunkUnmarshal,
935 #[error("unimplemented")]
936 ErrUnimplemented,
937 #[error("heartbeat Ack must have one param")]
938 ErrHeartbeatAckParams,
939 #[error("heartbeat Ack must have one param, and it should be a HeartbeatInfo")]
940 ErrHeartbeatAckNotHeartbeatInfo,
941 #[error("unable to marshal parameter for Heartbeat Ack")]
942 ErrHeartbeatAckMarshalParam,
943
944 #[error("raw is too small for error cause")]
945 ErrErrorCauseTooSmall,
946
947 #[error("unhandled ParamType: {typ}")]
948 ErrParamTypeUnhandled { typ: u16 },
949
950 #[error("unexpected ParamType")]
951 ErrParamTypeUnexpected,
952
953 #[error("param header too short")]
954 ErrParamHeaderTooShort,
955 #[error("param self reported length is shorter than header length")]
956 ErrParamHeaderSelfReportedLengthShorter,
957 #[error("param self reported length is longer than header length")]
958 ErrParamHeaderSelfReportedLengthLonger,
959 #[error("failed to parse param type")]
960 ErrParamHeaderParseFailed,
961
962 #[error("packet to short")]
963 ErrParamPacketTooShort,
964 #[error("outgoing SSN reset request parameter too short")]
965 ErrSsnResetRequestParamTooShort,
966 #[error("reconfig response parameter too short")]
967 ErrReconfigRespParamTooShort,
968 #[error("invalid algorithm type")]
969 ErrInvalidAlgorithmType,
970
971 #[error("failed to parse param type")]
972 ErrInitChunkParseParamTypeFailed,
973 #[error("failed unmarshalling param in Init Chunk")]
974 ErrInitChunkUnmarshalParam,
975 #[error("unable to marshal parameter for INIT/INITACK")]
976 ErrInitAckMarshalParam,
977
978 #[error("ChunkType is not of type INIT")]
979 ErrChunkTypeNotTypeInit,
980 #[error("chunk Value isn't long enough for mandatory parameters exp")]
981 ErrChunkValueNotLongEnough,
982 #[error("ChunkType of type INIT flags must be all 0")]
983 ErrChunkTypeInitFlagZero,
984 #[error("failed to unmarshal INIT body")]
985 ErrChunkTypeInitUnmarshalFailed,
986 #[error("failed marshaling INIT common data")]
987 ErrChunkTypeInitMarshalFailed,
988 #[error("ChunkType of type INIT ACK InitiateTag must not be 0")]
989 ErrChunkTypeInitInitiateTagZero,
990 #[error("INIT ACK inbound stream request must be > 0")]
991 ErrInitInboundStreamRequestZero,
992 #[error("INIT ACK outbound stream request must be > 0")]
993 ErrInitOutboundStreamRequestZero,
994 #[error("INIT ACK Advertised Receiver Window Credit (a_rwnd) must be >= 1500")]
995 ErrInitAdvertisedReceiver1500,
996
997 #[error("packet is smaller than the header size")]
998 ErrChunkPayloadSmall,
999 #[error("ChunkType is not of type PayloadData")]
1000 ErrChunkTypeNotPayloadData,
1001 #[error("ChunkType is not of type Reconfig")]
1002 ErrChunkTypeNotReconfig,
1003 #[error("ChunkReconfig has invalid ParamA")]
1004 ErrChunkReconfigInvalidParamA,
1005
1006 #[error("failed to parse param type")]
1007 ErrChunkParseParamTypeFailed,
1008 #[error("unable to marshal parameter A for reconfig")]
1009 ErrChunkMarshalParamAReconfigFailed,
1010 #[error("unable to marshal parameter B for reconfig")]
1011 ErrChunkMarshalParamBReconfigFailed,
1012
1013 #[error("ChunkType is not of type SACK")]
1014 ErrChunkTypeNotSack,
1015 #[error("SACK Chunk size is not large enough to contain header")]
1016 ErrSackSizeNotLargeEnoughInfo,
1017
1018 #[error("invalid chunk size")]
1019 ErrInvalidChunkSize,
1020 #[error("ChunkType is not of type SHUTDOWN")]
1021 ErrChunkTypeNotShutdown,
1022
1023 #[error("ChunkType is not of type SHUTDOWN-ACK")]
1024 ErrChunkTypeNotShutdownAck,
1025 #[error("ChunkType is not of type SHUTDOWN-COMPLETE")]
1026 ErrChunkTypeNotShutdownComplete,
1027
1028 #[error("raw is smaller than the minimum length for a SCTP packet")]
1029 ErrPacketRawTooSmall,
1030 #[error("unable to parse SCTP chunk, not enough data for complete header")]
1031 ErrParseSctpChunkNotEnoughData,
1032 #[error("failed to unmarshal, contains unknown chunk type")]
1033 ErrUnmarshalUnknownChunkType,
1034 #[error("checksum mismatch theirs")]
1035 ErrChecksumMismatch,
1036
1037 #[error("unexpected chunk popped (unordered)")]
1038 ErrUnexpectedChuckPoppedUnordered,
1039 #[error("unexpected chunk popped (ordered)")]
1040 ErrUnexpectedChuckPoppedOrdered,
1041 #[error("unexpected q state (should've been selected)")]
1042 ErrUnexpectedQState,
1043 #[error("try again")]
1044 ErrTryAgain,
1045
1046 #[error("abort chunk, with following errors: {0}")]
1047 ErrAbortChunk(String),
1048 #[error("shutdown called in non-Established state")]
1049 ErrShutdownNonEstablished,
1050 #[error("association closed before connecting")]
1051 ErrAssociationClosedBeforeConn,
1052 #[error("association init failed")]
1053 ErrAssociationInitFailed,
1054 #[error("association handshake closed")]
1055 ErrAssociationHandshakeClosed,
1056 #[error("silently discard")]
1057 ErrSilentlyDiscard,
1058 #[error("the init not stored to send")]
1059 ErrInitNotStoredToSend,
1060 #[error("cookieEcho not stored to send")]
1061 ErrCookieEchoNotStoredToSend,
1062 #[error("sctp packet must not have a source port of 0")]
1063 ErrSctpPacketSourcePortZero,
1064 #[error("sctp packet must not have a destination port of 0")]
1065 ErrSctpPacketDestinationPortZero,
1066 #[error("init chunk must not be bundled with any other chunk")]
1067 ErrInitChunkBundled,
1068 #[error("init chunk expects a verification tag of 0 on the packet when out-of-the-blue")]
1069 ErrInitChunkVerifyTagNotZero,
1070 #[error("todo: handle Init when in state")]
1071 ErrHandleInitState,
1072 #[error("no cookie in InitAck")]
1073 ErrInitAckNoCookie,
1074 #[error("there already exists a stream with identifier")]
1075 ErrStreamAlreadyExist,
1076 #[error("Failed to create a stream with identifier")]
1077 ErrStreamCreateFailed,
1078 #[error("unable to be popped from inflight queue TSN")]
1079 ErrInflightQueueTsnPop,
1080 #[error("requested non-existent TSN")]
1081 ErrTsnRequestNotExist,
1082 #[error("sending reset packet in non-Established state")]
1083 ErrResetPacketInStateNotExist,
1084 #[error("unexpected parameter type")]
1085 ErrParameterType,
1086 #[error("sending payload data in non-Established state")]
1087 ErrPayloadDataStateNotExist,
1088 #[error("unhandled chunk type")]
1089 ErrChunkTypeUnhandled,
1090 #[error("handshake failed (INIT ACK)")]
1091 ErrHandshakeInitAck,
1092 #[error("handshake failed (COOKIE ECHO)")]
1093 ErrHandshakeCookieEcho,
1094
1095 #[error("outbound packet larger than maximum message size")]
1096 ErrOutboundPacketTooLarge,
1097 #[error("Stream closed")]
1098 ErrStreamClosed,
1099 #[error("Stream not existed")]
1100 ErrStreamNotExisted,
1101 #[error("Association not existed")]
1102 ErrAssociationNotExisted,
1103 #[error("Transport not existed")]
1104 ErrTransportNoExisted,
1105 #[error("Io EOF")]
1106 ErrEof,
1107 #[error("Invalid SystemTime")]
1108 ErrInvalidSystemTime,
1109 #[error("Net Conn read error")]
1110 ErrNetConnRead,
1111 #[error("Max Data Channel ID")]
1112 ErrMaxDataChannelID,
1113
1114 #[error(
1116 "DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
1117 )]
1118 UnexpectedEndOfBuffer { expected: usize, actual: usize },
1119 #[error("Unknown MessageType {0}")]
1120 InvalidMessageType(u8),
1121 #[error("Unknown ChannelType {0}")]
1122 InvalidChannelType(u8),
1123 #[error("Unknown PayloadProtocolIdentifier {0}")]
1124 InvalidPayloadProtocolIdentifier(u8),
1125 #[error("Unknow Protocol")]
1126 UnknownProtocol,
1127
1128 #[error("stream is nil")]
1130 ErrNilStream,
1131 #[error("incomplete frame header")]
1132 ErrIncompleteFrameHeader,
1133 #[error("incomplete frame data")]
1134 ErrIncompleteFrameData,
1135 #[error("incomplete file header")]
1136 ErrIncompleteFileHeader,
1137 #[error("IVF signature mismatch")]
1138 ErrSignatureMismatch,
1139 #[error("IVF version unknown, parser may not parse correctly")]
1140 ErrUnknownIVFVersion,
1141
1142 #[error("file not opened")]
1143 ErrFileNotOpened,
1144 #[error("invalid nil packet")]
1145 ErrInvalidNilPacket,
1146
1147 #[error("bad header signature")]
1148 ErrBadIDPageSignature,
1149 #[error("wrong header, expected beginning of stream")]
1150 ErrBadIDPageType,
1151 #[error("payload for id page must be 19 bytes")]
1152 ErrBadIDPageLength,
1153 #[error("bad payload signature")]
1154 ErrBadIDPagePayloadSignature,
1155 #[error("not enough data for payload header")]
1156 ErrShortPageHeader,
1157
1158 #[error("data is not a H264 bitstream")]
1159 ErrDataIsNotH264Stream,
1160 #[error("data is not a H265 bitstream")]
1161 ErrDataIsNotH265Stream,
1162 #[error("Io EOF")]
1163 ErrIoEOF,
1164
1165 #[error("connection closed")]
1169 ErrConnectionClosed,
1170
1171 #[error("data channel closed")]
1174 ErrDataChannelClosed,
1175
1176 #[error("data channel not existed")]
1179 ErrDataChannelNotExisted,
1180
1181 #[error("x509Cert expired")]
1183 ErrCertificateExpired,
1184
1185 #[error("turn server credentials required")]
1188 ErrNoTurnCredentials,
1189
1190 #[error("invalid turn server credentials")]
1193 ErrTurnCredentials,
1194
1195 #[error("track already exists")]
1197 ErrExistingTrack,
1198
1199 #[error("track not existed")]
1201 ErrTrackNotExisted,
1202
1203 #[error("private key type not supported")]
1206 ErrPrivateKeyType,
1207
1208 #[error("peerIdentity cannot be modified")]
1211 ErrModifyingPeerIdentity,
1212
1213 #[error("certificates cannot be modified")]
1216 ErrModifyingCertificates,
1217
1218 #[error("no certificate")]
1220 ErrNonCertificate,
1221
1222 #[error("bundle policy cannot be modified")]
1225 ErrModifyingBundlePolicy,
1226
1227 #[error("rtcp mux policy cannot be modified")]
1230 ErrModifyingRTCPMuxPolicy,
1231
1232 #[error("ice candidate pool size cannot be modified")]
1235 ErrModifyingICECandidatePoolSize,
1236
1237 #[error("data channel label exceeds size limit")]
1240 ErrStringSizeLimit,
1241
1242 #[error("negotiated set without channel id")]
1246 ErrNegotiatedWithoutID,
1247
1248 #[error("both max_packet_life_time and max_retransmits was set")]
1253 ErrRetransmitsOrPacketLifeTime,
1254
1255 #[error("codec not found")]
1257 ErrCodecNotFound,
1258
1259 #[error("remote description is not set")]
1262 ErrNoRemoteDescription,
1263
1264 #[error("offer SDP semantics does not match configuration")]
1267 ErrIncorrectSDPSemantics,
1268
1269 #[error("operation can not be run in current signaling state")]
1271 ErrIncorrectSignalingState,
1272
1273 #[error("protocol is larger then 65535 bytes")]
1276 ErrProtocolTooLarge,
1277
1278 #[error("RtpSender not created by this PeerConnection")]
1281 ErrSenderNotCreatedByConnection,
1282
1283 #[error("RtpSender's initial_track_id has already been set")]
1286 ErrSenderInitialTrackIdAlreadySet,
1287
1288 #[error("set_remote_description called with no fingerprint")]
1291 ErrSessionDescriptionNoFingerprint,
1292
1293 #[error("set_remote_description called with an invalid fingerprint")]
1296 ErrSessionDescriptionInvalidFingerprint,
1297
1298 #[error("set_remote_description called with multiple conflicting fingerprint")]
1301 ErrSessionDescriptionConflictingFingerprints,
1302
1303 #[error("set_remote_description called with no ice-ufrag")]
1306 ErrSessionDescriptionMissingIceUfrag,
1307
1308 #[error("set_remote_description called with no ice-pwd")]
1311 ErrSessionDescriptionMissingIcePwd,
1312
1313 #[error("set_remote_description called with multiple conflicting ice-ufrag values")]
1316 ErrSessionDescriptionConflictingIceUfrag,
1317
1318 #[error("set_remote_description called with multiple conflicting ice-pwd values")]
1321 ErrSessionDescriptionConflictingIcePwd,
1322
1323 #[error("DTLS Handshake completed and no SRTP Protection Profile was chosen")]
1325 ErrNoSRTPProtectionProfile,
1326
1327 #[error("failed to generate certificate fingerprint")]
1329 ErrFailedToGenerateCertificateFingerprint,
1330
1331 #[error("operation failed no codecs are available")]
1333 ErrNoCodecsAvailable,
1334
1335 #[error("unable to start track, codec is not supported by remote")]
1337 ErrUnsupportedCodec,
1338
1339 #[error("Invalid state error")]
1340 InvalidStateError,
1341
1342 #[error("Invalid modification error")]
1343 InvalidModificationError,
1344
1345 #[error("Range error {0}")]
1346 RangeError(String),
1347
1348 #[error("unable to populate media section, RTPSender created with no codecs")]
1351 ErrSenderWithNoCodecs,
1352
1353 #[error("new track must be of the same kind as previous")]
1355 ErrRTPSenderNewTrackHasIncorrectKind,
1356
1357 #[error("new track has incorrect envelope")]
1358 ErrRTPSenderNewTrackHasIncorrectEnvelope,
1359
1360 #[error("Sequence number transformer must be enabled before sending data")]
1362 ErrRTPSenderDataSent,
1363
1364 #[error("Sequence number transformer has been already enabled")]
1366 ErrRTPSenderSeqTransEnabled,
1367
1368 #[error("failed to unbind TrackLocal from PeerConnection")]
1370 ErrUnbindFailed,
1371
1372 #[error("the requested codec does not have a payloader")]
1374 ErrNoPayloaderForCodec,
1375
1376 #[error("a header extension must be registered with the same direction each time")]
1379 ErrRegisterHeaderExtensionInvalidDirection,
1380
1381 #[error("invalid direction")]
1382 ErrInvalidDirection,
1383
1384 #[error(
1387 "no header extension ID was free to use(this means the maximum of 15 extensions have been registered)"
1388 )]
1389 ErrRegisterHeaderExtensionNoFreeID,
1390
1391 #[error("simulcast probe limit has been reached, new SSRC has been discarded")]
1393 ErrSimulcastProbeOverflow,
1394
1395 #[error("enable detaching by calling webrtc.DetachDataChannels()")]
1396 ErrDetachNotEnabled,
1397 #[error("datachannel not opened yet, try calling Detach from OnOpen")]
1398 ErrDetachBeforeOpened,
1399 #[error("the DTLS transport has not started yet")]
1400 ErrDtlsTransportNotStarted,
1401 #[error("failed extracting keys from DTLS for SRTP")]
1402 ErrDtlsKeyExtractionFailed,
1403 #[error("failed to start SRTP")]
1404 ErrFailedToStartSRTP,
1405 #[error("failed to start SRTCP")]
1406 ErrFailedToStartSRTCP,
1407 #[error("attempted to start DTLSTransport that is not in new state")]
1408 ErrInvalidDTLSStart,
1409 #[error("peer didn't provide certificate via DTLS")]
1410 ErrNoRemoteCertificate,
1411 #[error("identity provider is not implemented")]
1412 ErrIdentityProviderNotImplemented,
1413 #[error("remote certificate does not match any fingerprint")]
1414 ErrNoMatchingCertificateFingerprint,
1415 #[error("unsupported fingerprint algorithm")]
1416 ErrUnsupportedFingerprintAlgorithm,
1417 #[error("ICE connection not started")]
1418 ErrICEConnectionNotStarted,
1419 #[error("unknown candidate type")]
1420 ErrICECandidateTypeUnknown,
1421 #[error("cannot convert ice.CandidateType into webrtc.ICECandidateType, invalid type")]
1422 ErrICEInvalidConvertCandidateType,
1423 #[error("ICEAgent does not exist")]
1424 ErrICEAgentNotExist,
1425 #[error("unable to convert ICE candidates to ICECandidates")]
1426 ErrICECandidatesConversionFailed,
1427 #[error("unknown ICE Role")]
1428 ErrICERoleUnknown,
1429 #[error("unknown protocol")]
1430 ErrICEProtocolUnknown,
1431 #[error("gatherer not started")]
1432 ErrICEGathererNotStarted,
1433 #[error("unknown network type")]
1434 ErrNetworkTypeUnknown,
1435 #[error("new sdp does not match previous offer")]
1436 ErrSDPDoesNotMatchOffer,
1437 #[error("new sdp does not match previous answer")]
1438 ErrSDPDoesNotMatchAnswer,
1439 #[error("provided value is not a valid enum value of type SDPType")]
1440 ErrPeerConnSDPTypeInvalidValue,
1441 #[error("invalid state change op")]
1442 ErrPeerConnStateChangeInvalid,
1443 #[error("unhandled state change op")]
1444 ErrPeerConnStateChangeUnhandled,
1445 #[error("invalid SDP type supplied to SetLocalDescription()")]
1446 ErrPeerConnSDPTypeInvalidValueSetLocalDescription,
1447 #[error("remoteDescription contained media section without mid value")]
1448 ErrPeerConnRemoteDescriptionWithoutMidValue,
1449 #[error("remoteDescription has not been set yet")]
1450 ErrPeerConnRemoteDescriptionNil,
1451 #[error("localDescription has not been set yet")]
1452 ErrPeerConnLocalDescriptionNil,
1453 #[error("single media section has an explicit SSRC")]
1454 ErrPeerConnSingleMediaSectionHasExplicitSSRC,
1455 #[error("could not add transceiver for remote SSRC")]
1456 ErrPeerConnRemoteSSRCAddTransceiver,
1457 #[error("mid RTP Extensions required for Simulcast")]
1458 ErrPeerConnSimulcastMidRTPExtensionRequired,
1459 #[error("stream id RTP Extensions required for Simulcast")]
1460 ErrPeerConnSimulcastStreamIDRTPExtensionRequired,
1461 #[error("incoming SSRC failed Simulcast probing")]
1462 ErrPeerConnSimulcastIncomingSSRCFailed,
1463 #[error("failed collecting stats")]
1464 ErrPeerConnStatsCollectionFailed,
1465 #[error("add_transceiver_from_kind only accepts one RTPTransceiverInit")]
1466 ErrPeerConnAddTransceiverFromKindOnlyAcceptsOne,
1467 #[error("add_transceiver_from_track only accepts one RTPTransceiverInit")]
1468 ErrPeerConnAddTransceiverFromTrackOnlyAcceptsOne,
1469 #[error("add_transceiver_from_kind currently only supports recvonly")]
1470 ErrPeerConnAddTransceiverFromKindSupport,
1471 #[error("add_transceiver_from_track currently only supports sendonly and sendrecv")]
1472 ErrPeerConnAddTransceiverFromTrackSupport,
1473 #[error("TODO set_identity_provider")]
1474 ErrPeerConnSetIdentityProviderNotImplemented,
1475 #[error("write_rtcp failed to open write_stream")]
1476 ErrPeerConnWriteRTCPOpenWriteStream,
1477 #[error("cannot find transceiver with mid")]
1478 ErrPeerConnTransceiverMidNil,
1479 #[error("DTLSTransport must not be nil")]
1480 ErrRTPReceiverDTLSTransportNil,
1481 #[error("Receive has already been called")]
1482 ErrRTPReceiverReceiveAlreadyCalled,
1483 #[error("unable to find stream for Track with SSRC")]
1484 ErrRTPReceiverWithSSRCTrackStreamNotFound,
1485 #[error("no trackStreams found for SSRC")]
1486 ErrRTPReceiverForSSRCTrackStreamNotFound,
1487 #[error("no trackStreams found for RID")]
1488 ErrRTPReceiverForRIDTrackStreamNotFound,
1489 #[error("invalid RTP Receiver transition")]
1490 ErrRTPReceiverStateChangeInvalid,
1491 #[error("Track must not be nil")]
1492 ErrRTPSenderTrackNil,
1493 #[error("RTPSender not existed")]
1494 ErrRTPSenderNotExisted,
1495 #[error("Sender cannot add encoding as rid is empty")]
1496 ErrRTPSenderRidNil,
1497 #[error("Sender cannot add encoding as there is no base track")]
1498 ErrRTPSenderNoBaseEncoding,
1499 #[error("Sender cannot add encoding as provided track does not match base track")]
1500 ErrRTPSenderBaseEncodingMismatch,
1501 #[error("Sender cannot encoding due to RID collision")]
1502 ErrRTPSenderRIDCollision,
1503 #[error("Sender does not have track for RID")]
1504 ErrRTPSenderNoTrackForRID,
1505 #[error("RTPReceiver not existed")]
1506 ErrRTPReceiverNotExisted,
1507 #[error("DTLSTransport must not be nil")]
1508 ErrRTPSenderDTLSTransportNil,
1509 #[error("Send has already been called")]
1510 ErrRTPSenderSendAlreadyCalled,
1511 #[error("errRTPSenderTrackNil")]
1512 ErrRTPTransceiverCannotChangeMid,
1513 #[error("invalid state change in RTPTransceiver.setSending")]
1514 ErrRTPTransceiverSetSendingInvalidState,
1515 #[error("unsupported codec type by this transceiver")]
1516 ErrRTPTransceiverCodecUnsupported,
1517 #[error("DTLS not established")]
1518 ErrSCTPTransportDTLS,
1519 #[error("add_transceiver_sdp() called with 0 transceivers")]
1520 ErrSDPZeroTransceivers,
1521 #[error("invalid Media Section. Media + DataChannel both enabled")]
1522 ErrSDPMediaSectionMediaDataChanInvalid,
1523 #[error("invalid Media Section Track Index")]
1524 ErrSDPMediaSectionTrackInvalid,
1525 #[error("set_answering_dtlsrole must DTLSRoleClient or DTLSRoleServer")]
1526 ErrSettingEngineSetAnsweringDTLSRole,
1527 #[error("can't rollback from stable state")]
1528 ErrSignalingStateCannotRollback,
1529 #[error("invalid proposed signaling state transition: {0}")]
1530 ErrSignalingStateProposedTransitionInvalid(String),
1531 #[error("cannot convert to StatsICECandidatePairStateSucceeded invalid ice candidate state")]
1532 ErrStatsICECandidateStateInvalid,
1533 #[error("ICETransport can only be called in ICETransportStateNew")]
1534 ErrICETransportNotInNew,
1535 #[error("bad Certificate PEM format")]
1536 ErrCertificatePEMFormatError,
1537 #[error("SCTP is not established")]
1538 ErrSCTPNotEstablished,
1539
1540 #[error("DataChannel is not opened")]
1541 ErrClosedPipe,
1542 #[error("Interceptor is not bind")]
1543 ErrInterceptorNotBind,
1544 #[error("excessive retries in CreateOffer")]
1545 ErrExcessiveRetries,
1546
1547 #[error("not long enough to be a RTP Packet")]
1548 ErrRTPTooShort,
1549
1550 #[error("RFC8851 mandates rid-syntax = %s\"a=rid:\" rid-id SP rid-dir")]
1552 SimulcastRidParseErrorSyntaxIdDirSplit,
1553 #[error("RFC8851 mandates rid-dir = %s\"send\" / %s\"recv\"")]
1555 SimulcastRidParseErrorUnknownDirection,
1556
1557 #[error("codec not found")]
1559 CodecNotFound,
1560 #[error("missing whitespace")]
1561 MissingWhitespace,
1562 #[error("missing colon")]
1563 MissingColon,
1564 #[error("payload type not found")]
1565 PayloadTypeNotFound,
1566 #[error("SdpInvalidSyntax: {0}")]
1567 SdpInvalidSyntax(String),
1568 #[error("SdpInvalidValue: {0}")]
1569 SdpInvalidValue(String),
1570 #[error("sdp: empty time_descriptions")]
1571 SdpEmptyTimeDescription,
1572 #[error("parse extmap: {0}")]
1573 ParseExtMap(String),
1574 #[error("{} --> {} <-- {}", .s.substring(0,*.p), .s.substring(*.p, *.p+1), .s.substring(*.p+1, .s.len())
1575 )]
1576 SyntaxError { s: String, p: usize },
1577
1578 #[error("{0}")]
1580 Sec1(#[source] sec1::Error),
1581 #[error("{0}")]
1582 P256(#[source] P256Error),
1583 #[error("{0}")]
1584 RcGen(#[from] rcgen::Error),
1585 #[error("invalid PEM: {0}")]
1586 InvalidPEM(String),
1587 #[error("aes gcm: {0}")]
1588 AesGcm(#[from] aes_gcm::Error),
1589 #[error("parse ip: {0}")]
1590 ParseIp(#[from] net::AddrParseError),
1591 #[error("parse int: {0}")]
1592 ParseInt(#[from] ParseIntError),
1593 #[error("{0}")]
1594 Io(#[source] IoError),
1595 #[error("url parse: {0}")]
1596 Url(#[from] url::ParseError),
1597 #[error("utf8: {0}")]
1598 Utf8(#[from] FromUtf8Error),
1599 #[error("{0}")]
1600 Std(#[source] StdError),
1601 #[error("{0}")]
1602 Aes(#[from] aes::cipher::InvalidLength),
1603
1604 #[error("Other RTCP Err: {0}")]
1606 OtherRtcpErr(String),
1607 #[error("Other RTP Err: {0}")]
1608 OtherRtpErr(String),
1609 #[error("Other SRTP Err: {0}")]
1610 OtherSrtpErr(String),
1611 #[error("Other STUN Err: {0}")]
1612 OtherStunErr(String),
1613 #[error("Other TURN Err: {0}")]
1614 OtherTurnErr(String),
1615 #[error("Other ICE Err: {0}")]
1616 OtherIceErr(String),
1617 #[error("Other DTLS Err: {0}")]
1618 OtherDtlsErr(String),
1619 #[error("Other SCTP Err: {0}")]
1620 OtherSctpErr(String),
1621 #[error("Other DataChannel Err: {0}")]
1622 OtherDataChannelErr(String),
1623 #[error("Other Interceptor Err: {0}")]
1624 OtherInterceptorErr(String),
1625 #[error("Other Media Err: {0}")]
1626 OtherMediaErr(String),
1627 #[error("Other mDNS Err: {0}")]
1628 OtherMdnsErr(String),
1629 #[error("Other SDP Err: {0}")]
1630 OtherSdpErr(String),
1631 #[error("Other PeerConnection Err: {0}")]
1632 OtherPeerConnectionErr(String),
1633 #[error("{0}")]
1634 Other(String),
1635}
1636
1637impl Error {
1638 pub fn from_std<T>(error: T) -> Self
1639 where
1640 T: std::error::Error + Send + Sync + 'static,
1641 {
1642 Error::Std(StdError(Box::new(error)))
1643 }
1644
1645 pub fn downcast_ref<T: std::error::Error + 'static>(&self) -> Option<&T> {
1646 if let Error::Std(s) = self {
1647 return s.0.downcast_ref();
1648 }
1649
1650 None
1651 }
1652}
1653
1654#[derive(Debug, Error)]
1655#[error("io error: {0}")]
1656pub struct IoError(#[from] pub io::Error);
1657
1658impl PartialEq for IoError {
1660 fn eq(&self, other: &Self) -> bool {
1661 self.0.kind() == other.0.kind()
1662 }
1663}
1664
1665impl From<io::Error> for Error {
1666 fn from(e: io::Error) -> Self {
1667 Error::Io(IoError(e))
1668 }
1669}
1670
1671#[derive(Debug, Error)]
1680#[error("{0}")]
1681pub struct StdError(pub Box<dyn std::error::Error + Send + Sync>);
1682
1683impl PartialEq for StdError {
1684 fn eq(&self, _: &Self) -> bool {
1685 false
1686 }
1687}
1688
1689impl<T> From<std::sync::PoisonError<T>> for Error {
1690 fn from(e: std::sync::PoisonError<T>) -> Self {
1691 Error::PoisonError(e.to_string())
1692 }
1693}
1694
1695impl From<sec1::Error> for Error {
1696 fn from(e: sec1::Error) -> Self {
1697 Error::Sec1(e)
1698 }
1699}
1700
1701#[derive(Debug, Error)]
1702#[error("{0}")]
1703pub struct P256Error(#[source] p256::elliptic_curve::Error);
1704
1705impl PartialEq for P256Error {
1706 fn eq(&self, _: &Self) -> bool {
1707 false
1708 }
1709}
1710
1711impl From<p256::elliptic_curve::Error> for Error {
1712 fn from(e: p256::elliptic_curve::Error) -> Self {
1713 Error::P256(P256Error(e))
1714 }
1715}
1716
1717impl From<SystemTimeError> for Error {
1718 fn from(e: SystemTimeError) -> Self {
1719 Error::Other(e.to_string())
1720 }
1721}
1722
1723pub fn flatten_errs(errs: Vec<impl Into<Error>>) -> Result<()> {
1725 if errs.is_empty() {
1726 Ok(())
1727 } else {
1728 let errs_strs: Vec<String> = errs.into_iter().map(|e| e.into().to_string()).collect();
1729 Err(Error::Other(errs_strs.join("\n")))
1730 }
1731}