diff --git a/bundlepolicy.go b/bundlepolicy.go index ea6dad5aeb0..7e3d6c506fa 100644 --- a/bundlepolicy.go +++ b/bundlepolicy.go @@ -14,11 +14,14 @@ import ( type BundlePolicy int const ( + // BundlePolicyUnknown is the enum's zero-value + BundlePolicyUnknown BundlePolicy = iota + // BundlePolicyBalanced indicates to gather ICE candidates for each // media type in use (audio, video, and data). If the remote endpoint is // not bundle-aware, negotiate only one audio and video track on separate // transports. - BundlePolicyBalanced BundlePolicy = iota + 1 + BundlePolicyBalanced // BundlePolicyMaxCompat indicates to gather ICE candidates for each // track. If the remote endpoint is not bundle-aware, negotiate all media @@ -47,7 +50,7 @@ func newBundlePolicy(raw string) BundlePolicy { case bundlePolicyMaxBundleStr: return BundlePolicyMaxBundle default: - return BundlePolicy(Unknown) + return BundlePolicyUnknown } } diff --git a/bundlepolicy_test.go b/bundlepolicy_test.go index 747fb901d71..2fc3c2e6bdc 100644 --- a/bundlepolicy_test.go +++ b/bundlepolicy_test.go @@ -14,7 +14,7 @@ func TestNewBundlePolicy(t *testing.T) { policyString string expectedPolicy BundlePolicy }{ - {unknownStr, BundlePolicy(Unknown)}, + {ErrUnknownType.Error(), BundlePolicyUnknown}, {"balanced", BundlePolicyBalanced}, {"max-compat", BundlePolicyMaxCompat}, {"max-bundle", BundlePolicyMaxBundle}, @@ -34,7 +34,7 @@ func TestBundlePolicy_String(t *testing.T) { policy BundlePolicy expectedString string }{ - {BundlePolicy(Unknown), unknownStr}, + {BundlePolicyUnknown, ErrUnknownType.Error()}, {BundlePolicyBalanced, "balanced"}, {BundlePolicyMaxCompat, "max-compat"}, {BundlePolicyMaxBundle, "max-bundle"}, diff --git a/constants.go b/constants.go index 94ba78494a6..70778506b59 100644 --- a/constants.go +++ b/constants.go @@ -6,11 +6,6 @@ package webrtc import "github.com/pion/dtls/v2" const ( - // Unknown defines default public constant to use for "enum" like struct - // comparisons when no value was defined. - Unknown = iota - unknownStr = "unknown" - // Equal to UDP MTU receiveMTU = 1460 diff --git a/datachannelstate.go b/datachannelstate.go index 55dc916e972..848d94ca89d 100644 --- a/datachannelstate.go +++ b/datachannelstate.go @@ -7,10 +7,13 @@ package webrtc type DataChannelState int const ( + // DataChannelStateUnknown is the enum's zero-value + DataChannelStateUnknown DataChannelState = iota + // DataChannelStateConnecting indicates that the data channel is being // established. This is the initial state of DataChannel, whether created // with CreateDataChannel, or dispatched as a part of an DataChannelEvent. - DataChannelStateConnecting DataChannelState = iota + 1 + DataChannelStateConnecting // DataChannelStateOpen indicates that the underlying data transport is // established and communication is possible. @@ -44,7 +47,7 @@ func newDataChannelState(raw string) DataChannelState { case dataChannelStateClosedStr: return DataChannelStateClosed default: - return DataChannelState(Unknown) + return DataChannelStateUnknown } } diff --git a/datachannelstate_test.go b/datachannelstate_test.go index cb658a64e13..64426089523 100644 --- a/datachannelstate_test.go +++ b/datachannelstate_test.go @@ -14,7 +14,7 @@ func TestNewDataChannelState(t *testing.T) { stateString string expectedState DataChannelState }{ - {unknownStr, DataChannelState(Unknown)}, + {ErrUnknownType.Error(), DataChannelStateUnknown}, {"connecting", DataChannelStateConnecting}, {"open", DataChannelStateOpen}, {"closing", DataChannelStateClosing}, @@ -35,7 +35,7 @@ func TestDataChannelState_String(t *testing.T) { state DataChannelState expectedString string }{ - {DataChannelState(Unknown), unknownStr}, + {DataChannelStateUnknown, ErrUnknownType.Error()}, {DataChannelStateConnecting, "connecting"}, {DataChannelStateOpen, "open"}, {DataChannelStateClosing, "closing"}, diff --git a/dtlsrole.go b/dtlsrole.go index 9cee581d9ec..40a14e87214 100644 --- a/dtlsrole.go +++ b/dtlsrole.go @@ -11,10 +11,13 @@ import ( type DTLSRole byte const ( + // DTLSRoleUnknown is the enum's zero-value + DTLSRoleUnknown DTLSRole = iota + // DTLSRoleAuto defines the DTLS role is determined based on // the resolved ICE role: the ICE controlled role acts as the DTLS // client and the ICE controlling role acts as the DTLS server. - DTLSRoleAuto DTLSRole = iota + 1 + DTLSRoleAuto // DTLSRoleClient defines the DTLS client role. DTLSRoleClient @@ -51,7 +54,7 @@ func (r DTLSRole) String() string { case DTLSRoleServer: return "server" default: - return unknownStr + return ErrUnknownType.Error() } } diff --git a/dtlsrole_test.go b/dtlsrole_test.go index 0c9a5692627..c709f31dfeb 100644 --- a/dtlsrole_test.go +++ b/dtlsrole_test.go @@ -16,7 +16,7 @@ func TestDTLSRole_String(t *testing.T) { role DTLSRole expectedString string }{ - {DTLSRole(Unknown), unknownStr}, + {DTLSRoleUnknown, ErrUnknownType.Error()}, {DTLSRoleAuto, "auto"}, {DTLSRoleClient, "client"}, {DTLSRoleServer, "server"}, diff --git a/dtlstransportstate.go b/dtlstransportstate.go index 573dd4bf038..c938ae2c0f5 100644 --- a/dtlstransportstate.go +++ b/dtlstransportstate.go @@ -7,9 +7,12 @@ package webrtc type DTLSTransportState int const ( + // DTLSTransportStateUnknown is the enum's zero-value + DTLSTransportStateUnknown DTLSTransportState = iota + // DTLSTransportStateNew indicates that DTLS has not started negotiating // yet. - DTLSTransportStateNew DTLSTransportState = iota + 1 + DTLSTransportStateNew // DTLSTransportStateConnecting indicates that DTLS is in the process of // negotiating a secure connection and verifying the remote fingerprint. @@ -52,7 +55,7 @@ func newDTLSTransportState(raw string) DTLSTransportState { case dtlsTransportStateFailedStr: return DTLSTransportStateFailed default: - return DTLSTransportState(Unknown) + return DTLSTransportStateUnknown } } diff --git a/dtlstransportstate_test.go b/dtlstransportstate_test.go index f5e61a410a5..06ec0dfa3bd 100644 --- a/dtlstransportstate_test.go +++ b/dtlstransportstate_test.go @@ -14,7 +14,7 @@ func TestNewDTLSTransportState(t *testing.T) { stateString string expectedState DTLSTransportState }{ - {unknownStr, DTLSTransportState(Unknown)}, + {ErrUnknownType.Error(), DTLSTransportStateUnknown}, {"new", DTLSTransportStateNew}, {"connecting", DTLSTransportStateConnecting}, {"connected", DTLSTransportStateConnected}, @@ -36,7 +36,7 @@ func TestDTLSTransportState_String(t *testing.T) { state DTLSTransportState expectedString string }{ - {DTLSTransportState(Unknown), unknownStr}, + {DTLSTransportStateUnknown, ErrUnknownType.Error()}, {DTLSTransportStateNew, "new"}, {DTLSTransportStateConnecting, "connecting"}, {DTLSTransportStateConnected, "connected"}, diff --git a/icecandidatetype.go b/icecandidatetype.go index 01f35119600..e77098d581a 100644 --- a/icecandidatetype.go +++ b/icecandidatetype.go @@ -13,12 +13,15 @@ import ( type ICECandidateType int const ( + // ICECandidateTypeUnknown is the enum's zero-value + ICECandidateTypeUnknown ICECandidateType = iota + // ICECandidateTypeHost indicates that the candidate is of Host type as // described in https://tools.ietf.org/html/rfc8445#section-5.1.1.1. A // candidate obtained by binding to a specific port from an IP address on // the host. This includes IP addresses on physical interfaces and logical // ones, such as ones obtained through VPNs. - ICECandidateTypeHost ICECandidateType = iota + 1 + ICECandidateTypeHost // ICECandidateTypeSrflx indicates the the candidate is of Server // Reflexive type as described @@ -60,7 +63,7 @@ func NewICECandidateType(raw string) (ICECandidateType, error) { case iceCandidateTypeRelayStr: return ICECandidateTypeRelay, nil default: - return ICECandidateType(Unknown), fmt.Errorf("%w: %s", errICECandidateTypeUnknown, raw) + return ICECandidateTypeUnknown, fmt.Errorf("%w: %s", errICECandidateTypeUnknown, raw) } } @@ -92,7 +95,7 @@ func getCandidateType(candidateType ice.CandidateType) (ICECandidateType, error) default: // NOTE: this should never happen[tm] err := fmt.Errorf("%w: %s", errICEInvalidConvertCandidateType, candidateType.String()) - return ICECandidateType(Unknown), err + return ICECandidateTypeUnknown, err } } diff --git a/icecandidatetype_test.go b/icecandidatetype_test.go index 993a0be9edd..10969b12fde 100644 --- a/icecandidatetype_test.go +++ b/icecandidatetype_test.go @@ -15,7 +15,7 @@ func TestICECandidateType(t *testing.T) { shouldFail bool expectedType ICECandidateType }{ - {unknownStr, true, ICECandidateType(Unknown)}, + {ErrUnknownType.Error(), true, ICECandidateTypeUnknown}, {"host", false, ICECandidateTypeHost}, {"srflx", false, ICECandidateTypeSrflx}, {"prflx", false, ICECandidateTypePrflx}, @@ -40,7 +40,7 @@ func TestICECandidateType_String(t *testing.T) { cType ICECandidateType expectedString string }{ - {ICECandidateType(Unknown), unknownStr}, + {ICECandidateTypeUnknown, ErrUnknownType.Error()}, {ICECandidateTypeHost, "host"}, {ICECandidateTypeSrflx, "srflx"}, {ICECandidateTypePrflx, "prflx"}, diff --git a/icecomponent.go b/icecomponent.go index c65a893dcd8..ae8f230fbf5 100644 --- a/icecomponent.go +++ b/icecomponent.go @@ -8,12 +8,15 @@ package webrtc type ICEComponent int const ( + // ICEComponentUnknown is the enum's zero-value + ICEComponentUnknown ICEComponent = iota + // ICEComponentRTP indicates that the ICE Transport is used for RTP (or // RTCP multiplexing), as defined in // https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols // multiplexed with RTP (e.g. data channel) share its component ID. This // represents the component-id value 1 when encoded in candidate-attribute. - ICEComponentRTP ICEComponent = iota + 1 + ICEComponentRTP // ICEComponentRTCP indicates that the ICE Transport is used for RTCP as // defined by https://tools.ietf.org/html/rfc5245#section-4.1.1.1. This @@ -34,7 +37,7 @@ func newICEComponent(raw string) ICEComponent { case iceComponentRTCPStr: return ICEComponentRTCP default: - return ICEComponent(Unknown) + return ICEComponentUnknown } } diff --git a/icecomponent_test.go b/icecomponent_test.go index 6d71f0a4ced..9d2bb3635b1 100644 --- a/icecomponent_test.go +++ b/icecomponent_test.go @@ -14,7 +14,7 @@ func TestICEComponent(t *testing.T) { componentString string expectedComponent ICEComponent }{ - {unknownStr, ICEComponent(Unknown)}, + {ErrUnknownType.Error(), ICEComponentUnknown}, {"rtp", ICEComponentRTP}, {"rtcp", ICEComponentRTCP}, } @@ -33,7 +33,7 @@ func TestICEComponent_String(t *testing.T) { state ICEComponent expectedString string }{ - {ICEComponent(Unknown), unknownStr}, + {ICEComponentUnknown, ErrUnknownType.Error()}, {ICEComponentRTP, "rtp"}, {ICEComponentRTCP, "rtcp"}, } diff --git a/iceconnectionstate.go b/iceconnectionstate.go index e52e1328aed..4b7deb802fe 100644 --- a/iceconnectionstate.go +++ b/iceconnectionstate.go @@ -7,11 +7,14 @@ package webrtc type ICEConnectionState int const ( + // ICEConnectionStateUnknown is the enum's zero-value + ICEConnectionStateUnknown ICEConnectionState = iota + // ICEConnectionStateNew indicates that any of the ICETransports are // in the "new" state and none of them are in the "checking", "disconnected" // or "failed" state, or all ICETransports are in the "closed" state, or // there are no transports. - ICEConnectionStateNew ICEConnectionState = iota + 1 + ICEConnectionStateNew // ICEConnectionStateChecking indicates that any of the ICETransports // are in the "checking" state and none of them are in the "disconnected" @@ -71,7 +74,7 @@ func NewICEConnectionState(raw string) ICEConnectionState { case iceConnectionStateClosedStr: return ICEConnectionStateClosed default: - return ICEConnectionState(Unknown) + return ICEConnectionStateUnknown } } diff --git a/iceconnectionstate_test.go b/iceconnectionstate_test.go index 595e66abd7a..5f4259bd295 100644 --- a/iceconnectionstate_test.go +++ b/iceconnectionstate_test.go @@ -14,7 +14,7 @@ func TestNewICEConnectionState(t *testing.T) { stateString string expectedState ICEConnectionState }{ - {unknownStr, ICEConnectionState(Unknown)}, + {ErrUnknownType.Error(), ICEConnectionStateUnknown}, {"new", ICEConnectionStateNew}, {"checking", ICEConnectionStateChecking}, {"connected", ICEConnectionStateConnected}, @@ -38,7 +38,7 @@ func TestICEConnectionState_String(t *testing.T) { state ICEConnectionState expectedString string }{ - {ICEConnectionState(Unknown), unknownStr}, + {ICEConnectionStateUnknown, ErrUnknownType.Error()}, {ICEConnectionStateNew, "new"}, {ICEConnectionStateChecking, "checking"}, {ICEConnectionStateConnected, "connected"}, diff --git a/icegathererstate.go b/icegathererstate.go index b90acd33eed..b78df5fc5f6 100644 --- a/icegathererstate.go +++ b/icegathererstate.go @@ -11,9 +11,12 @@ import ( type ICEGathererState uint32 const ( + // ICEGathererStateUnknown is the enum's zero-value + ICEGathererStateUnknown ICEGathererState = iota + // ICEGathererStateNew indicates object has been created but // gather() has not been called. - ICEGathererStateNew ICEGathererState = iota + 1 + ICEGathererStateNew // ICEGathererStateGathering indicates gather() has been called, // and the ICEGatherer is in the process of gathering candidates. @@ -38,7 +41,7 @@ func (s ICEGathererState) String() string { case ICEGathererStateClosed: return "closed" default: - return unknownStr + return ErrUnknownType.Error() } } diff --git a/icegathererstate_test.go b/icegathererstate_test.go index 71c4fe35aeb..a618cc816c5 100644 --- a/icegathererstate_test.go +++ b/icegathererstate_test.go @@ -14,7 +14,7 @@ func TestICEGathererState_String(t *testing.T) { state ICEGathererState expectedString string }{ - {ICEGathererState(Unknown), unknownStr}, + {ICEGathererStateUnknown, ErrUnknownType.Error()}, {ICEGathererStateNew, "new"}, {ICEGathererStateGathering, "gathering"}, {ICEGathererStateComplete, "complete"}, diff --git a/icegatheringstate.go b/icegatheringstate.go index 1925dddbfe0..13ea2f73d4e 100644 --- a/icegatheringstate.go +++ b/icegatheringstate.go @@ -7,10 +7,13 @@ package webrtc type ICEGatheringState int const ( + // ICEGatheringStateUnknown is the enum's zero-value + ICEGatheringStateUnknown ICEGatheringState = iota + // ICEGatheringStateNew indicates that any of the ICETransports are // in the "new" gathering state and none of the transports are in the // "gathering" state, or there are no transports. - ICEGatheringStateNew ICEGatheringState = iota + 1 + ICEGatheringStateNew // ICEGatheringStateGathering indicates that any of the ICETransports // are in the "gathering" state. @@ -38,7 +41,7 @@ func NewICEGatheringState(raw string) ICEGatheringState { case iceGatheringStateCompleteStr: return ICEGatheringStateComplete default: - return ICEGatheringState(Unknown) + return ICEGatheringStateUnknown } } diff --git a/icegatheringstate_test.go b/icegatheringstate_test.go index 018688cc35e..6220a54385c 100644 --- a/icegatheringstate_test.go +++ b/icegatheringstate_test.go @@ -14,7 +14,7 @@ func TestNewICEGatheringState(t *testing.T) { stateString string expectedState ICEGatheringState }{ - {unknownStr, ICEGatheringState(Unknown)}, + {ErrUnknownType.Error(), ICEGatheringStateUnknown}, {"new", ICEGatheringStateNew}, {"gathering", ICEGatheringStateGathering}, {"complete", ICEGatheringStateComplete}, @@ -34,7 +34,7 @@ func TestICEGatheringState_String(t *testing.T) { state ICEGatheringState expectedString string }{ - {ICEGatheringState(Unknown), unknownStr}, + {ICEGatheringStateUnknown, ErrUnknownType.Error()}, {ICEGatheringStateNew, "new"}, {ICEGatheringStateGathering, "gathering"}, {ICEGatheringStateComplete, "complete"}, diff --git a/iceprotocol.go b/iceprotocol.go index 3582b683011..67254f7d2f5 100644 --- a/iceprotocol.go +++ b/iceprotocol.go @@ -13,8 +13,11 @@ import ( type ICEProtocol int const ( + // ICEProtocolUnknown is the enum's zero-value + ICEProtocolUnknown ICEProtocol = iota + // ICEProtocolUDP indicates the URL uses a UDP transport. - ICEProtocolUDP ICEProtocol = iota + 1 + ICEProtocolUDP // ICEProtocolTCP indicates the URL uses a TCP transport. ICEProtocolTCP @@ -34,7 +37,7 @@ func NewICEProtocol(raw string) (ICEProtocol, error) { case strings.EqualFold(iceProtocolTCPStr, raw): return ICEProtocolTCP, nil default: - return ICEProtocol(Unknown), fmt.Errorf("%w: %s", errICEProtocolUnknown, raw) + return ICEProtocolUnknown, fmt.Errorf("%w: %s", errICEProtocolUnknown, raw) } } diff --git a/iceprotocol_test.go b/iceprotocol_test.go index 428d00067d5..d2c305f8544 100644 --- a/iceprotocol_test.go +++ b/iceprotocol_test.go @@ -15,7 +15,7 @@ func TestNewICEProtocol(t *testing.T) { shouldFail bool expectedProto ICEProtocol }{ - {unknownStr, true, ICEProtocol(Unknown)}, + {ErrUnknownType.Error(), true, ICEProtocolUnknown}, {"udp", false, ICEProtocolUDP}, {"tcp", false, ICEProtocolTCP}, {"UDP", false, ICEProtocolUDP}, @@ -40,7 +40,7 @@ func TestICEProtocol_String(t *testing.T) { proto ICEProtocol expectedString string }{ - {ICEProtocol(Unknown), unknownStr}, + {ICEProtocolUnknown, ErrUnknownType.Error()}, {ICEProtocolUDP, "udp"}, {ICEProtocolTCP, "tcp"}, } diff --git a/icerole.go b/icerole.go index a46b45590f6..dce6336e9fe 100644 --- a/icerole.go +++ b/icerole.go @@ -8,11 +8,14 @@ package webrtc type ICERole int const ( + // ICERoleUnknown is the enum's zero-value + ICERoleUnknown ICERole = iota + // ICERoleControlling indicates that the ICE agent that is responsible // for selecting the final choice of candidate pairs and signaling them // through STUN and an updated offer, if needed. In any session, one agent // is always controlling. The other is the controlled agent. - ICERoleControlling ICERole = iota + 1 + ICERoleControlling // ICERoleControlled indicates that an ICE agent that waits for the // controlling agent to select the final choice of candidate pairs. @@ -32,7 +35,7 @@ func newICERole(raw string) ICERole { case iceRoleControlledStr: return ICERoleControlled default: - return ICERole(Unknown) + return ICERoleUnknown } } diff --git a/icerole_test.go b/icerole_test.go index fce0edd8de7..d1a2655bff7 100644 --- a/icerole_test.go +++ b/icerole_test.go @@ -14,7 +14,7 @@ func TestNewICERole(t *testing.T) { roleString string expectedRole ICERole }{ - {unknownStr, ICERole(Unknown)}, + {ErrUnknownType.Error(), ICERoleUnknown}, {"controlling", ICERoleControlling}, {"controlled", ICERoleControlled}, } @@ -33,7 +33,7 @@ func TestICERole_String(t *testing.T) { proto ICERole expectedString string }{ - {ICERole(Unknown), unknownStr}, + {ICERoleUnknown, ErrUnknownType.Error()}, {ICERoleControlling, "controlling"}, {ICERoleControlled, "controlled"}, } diff --git a/iceserver_test.go b/iceserver_test.go index 60a27ea4329..02921f06a66 100644 --- a/iceserver_test.go +++ b/iceserver_test.go @@ -79,7 +79,7 @@ func TestICEServer_validate(t *testing.T) { URLs: []string{"turn:192.158.29.39?transport=udp"}, Username: "unittest", Credential: false, - CredentialType: Unknown, + CredentialType: ICECredentialTypePassword, }, &rtcerr.InvalidAccessError{Err: ErrTurnCredentials}}, {ICEServer{ URLs: []string{"stun:google.de?transport=udp"}, diff --git a/icetransportpolicy.go b/icetransportpolicy.go index a2629fdab4e..d9a41637a05 100644 --- a/icetransportpolicy.go +++ b/icetransportpolicy.go @@ -34,10 +34,8 @@ func NewICETransportPolicy(raw string) ICETransportPolicy { switch raw { case iceTransportPolicyRelayStr: return ICETransportPolicyRelay - case iceTransportPolicyAllStr: - return ICETransportPolicyAll default: - return ICETransportPolicy(Unknown) + return ICETransportPolicyAll } } diff --git a/icetransportstate.go b/icetransportstate.go index fc2b62401fc..159083bb3c8 100644 --- a/icetransportstate.go +++ b/icetransportstate.go @@ -9,9 +9,12 @@ import "github.com/pion/ice/v3" type ICETransportState int const ( + // ICETransportStateUnknown is the enum's zero-value + ICETransportStateUnknown ICETransportState = iota + // ICETransportStateNew indicates the ICETransport is waiting // for remote candidates to be supplied. - ICETransportStateNew = iota + 1 + ICETransportStateNew // ICETransportStateChecking indicates the ICETransport has // received at least one remote candidate, and a local and remote @@ -63,7 +66,7 @@ func (c ICETransportState) String() string { case ICETransportStateClosed: return "closed" default: - return unknownStr + return ErrUnknownType.Error() } } @@ -84,7 +87,7 @@ func newICETransportStateFromICE(i ice.ConnectionState) ICETransportState { case ice.ConnectionStateClosed: return ICETransportStateClosed default: - return ICETransportState(Unknown) + return ICETransportStateUnknown } } @@ -105,6 +108,6 @@ func (c ICETransportState) toICE() ice.ConnectionState { case ICETransportStateClosed: return ice.ConnectionStateClosed default: - return ice.ConnectionState(Unknown) + return ice.ConnectionStateUnknown } } diff --git a/icetransportstate_test.go b/icetransportstate_test.go index a1ee930e089..324c0e40f18 100644 --- a/icetransportstate_test.go +++ b/icetransportstate_test.go @@ -15,7 +15,7 @@ func TestICETransportState_String(t *testing.T) { state ICETransportState expectedString string }{ - {ICETransportState(Unknown), unknownStr}, + {ICETransportStateUnknown, ErrUnknownType.Error()}, {ICETransportStateNew, "new"}, {ICETransportStateChecking, "checking"}, {ICETransportStateConnected, "connected"}, @@ -39,7 +39,7 @@ func TestICETransportState_Convert(t *testing.T) { native ICETransportState ice ice.ConnectionState }{ - {ICETransportState(Unknown), ice.ConnectionState(Unknown)}, + {ICETransportStateUnknown, ice.ConnectionStateUnknown}, {ICETransportStateNew, ice.ConnectionStateNew}, {ICETransportStateChecking, ice.ConnectionStateChecking}, {ICETransportStateConnected, ice.ConnectionStateConnected}, diff --git a/mediaengine.go b/mediaengine.go index 2d63ab567cf..5e5a2bfdfb7 100644 --- a/mediaengine.go +++ b/mediaengine.go @@ -286,13 +286,12 @@ func (m *MediaEngine) RegisterFeedback(feedback RTCPFeedback, typ RTPCodecType) m.mu.Lock() defer m.mu.Unlock() - switch typ { - case RTPCodecTypeVideo: + if typ == RTPCodecTypeVideo { for i, v := range m.videoCodecs { v.RTCPFeedback = append(v.RTCPFeedback, feedback) m.videoCodecs[i] = v } - case RTPCodecTypeAudio: + } else if typ == RTPCodecTypeAudio { for i, v := range m.audioCodecs { v.RTCPFeedback = append(v.RTCPFeedback, feedback) m.audioCodecs[i] = v diff --git a/networktype.go b/networktype.go index 76b42465969..7169fa2efe4 100644 --- a/networktype.go +++ b/networktype.go @@ -22,8 +22,11 @@ func supportedNetworkTypes() []NetworkType { type NetworkType int const ( + // NetworkTypeUnknown is the enum's zero-value + NetworkTypeUnknown NetworkType = iota + // NetworkTypeUDP4 indicates UDP over IPv4. - NetworkTypeUDP4 NetworkType = iota + 1 + NetworkTypeUDP4 // NetworkTypeUDP6 indicates UDP over IPv6. NetworkTypeUDP6 @@ -87,7 +90,7 @@ func NewNetworkType(raw string) (NetworkType, error) { case networkTypeTCP6Str: return NetworkTypeTCP6, nil default: - return NetworkType(Unknown), fmt.Errorf("%w: %s", errNetworkTypeUnknown, raw) + return NetworkTypeUnknown, fmt.Errorf("%w: %s", errNetworkTypeUnknown, raw) } } @@ -102,6 +105,6 @@ func getNetworkType(iceNetworkType ice.NetworkType) (NetworkType, error) { case ice.NetworkTypeTCP6: return NetworkTypeTCP6, nil default: - return NetworkType(Unknown), fmt.Errorf("%w: %s", errNetworkTypeUnknown, iceNetworkType.String()) + return NetworkTypeUnknown, fmt.Errorf("%w: %s", errNetworkTypeUnknown, iceNetworkType.String()) } } diff --git a/networktype_test.go b/networktype_test.go index 213b55a9d3c..6fec764b7e9 100644 --- a/networktype_test.go +++ b/networktype_test.go @@ -14,7 +14,7 @@ func TestNetworkType_String(t *testing.T) { cType NetworkType expectedString string }{ - {NetworkType(Unknown), unknownStr}, + {NetworkTypeUnknown, ErrUnknownType.Error()}, {NetworkTypeUDP4, "udp4"}, {NetworkTypeUDP6, "udp6"}, {NetworkTypeTCP4, "tcp4"}, @@ -36,7 +36,7 @@ func TestNetworkType(t *testing.T) { shouldFail bool expectedType NetworkType }{ - {unknownStr, true, NetworkType(Unknown)}, + {ErrUnknownType.Error(), true, NetworkTypeUnknown}, {"udp4", false, NetworkTypeUDP4}, {"udp6", false, NetworkTypeUDP6}, {"tcp4", false, NetworkTypeTCP4}, diff --git a/peerconnection.go b/peerconnection.go index ec2425fba6c..7b5dec14333 100644 --- a/peerconnection.go +++ b/peerconnection.go @@ -225,11 +225,11 @@ func (pc *PeerConnection) initConfiguration(configuration Configuration) error { pc.configuration.Certificates = []Certificate{*certificate} } - if configuration.BundlePolicy != BundlePolicy(Unknown) { + if configuration.BundlePolicy != BundlePolicyUnknown { pc.configuration.BundlePolicy = configuration.BundlePolicy } - if configuration.RTCPMuxPolicy != RTCPMuxPolicy(Unknown) { + if configuration.RTCPMuxPolicy != RTCPMuxPolicyUnknown { pc.configuration.RTCPMuxPolicy = configuration.RTCPMuxPolicy } @@ -237,13 +237,8 @@ func (pc *PeerConnection) initConfiguration(configuration Configuration) error { pc.configuration.ICECandidatePoolSize = configuration.ICECandidatePoolSize } - if configuration.ICETransportPolicy != ICETransportPolicy(Unknown) { - pc.configuration.ICETransportPolicy = configuration.ICETransportPolicy - } - - if configuration.SDPSemantics != SDPSemantics(Unknown) { - pc.configuration.SDPSemantics = configuration.SDPSemantics - } + pc.configuration.ICETransportPolicy = configuration.ICETransportPolicy + pc.configuration.SDPSemantics = configuration.SDPSemantics sanitizedICEServers := configuration.getICEServers() if len(sanitizedICEServers) > 0 { @@ -549,7 +544,7 @@ func (pc *PeerConnection) SetConfiguration(configuration Configuration) error { } // https://www.w3.org/TR/webrtc/#set-the-configuration (step #5) - if configuration.BundlePolicy != BundlePolicy(Unknown) { + if configuration.BundlePolicy != BundlePolicyUnknown { if configuration.BundlePolicy != pc.configuration.BundlePolicy { return &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy} } @@ -557,7 +552,7 @@ func (pc *PeerConnection) SetConfiguration(configuration Configuration) error { } // https://www.w3.org/TR/webrtc/#set-the-configuration (step #6) - if configuration.RTCPMuxPolicy != RTCPMuxPolicy(Unknown) { + if configuration.RTCPMuxPolicy != RTCPMuxPolicyUnknown { if configuration.RTCPMuxPolicy != pc.configuration.RTCPMuxPolicy { return &rtcerr.InvalidModificationError{Err: ErrModifyingRTCPMuxPolicy} } @@ -574,9 +569,7 @@ func (pc *PeerConnection) SetConfiguration(configuration Configuration) error { } // https://www.w3.org/TR/webrtc/#set-the-configuration (step #8) - if configuration.ICETransportPolicy != ICETransportPolicy(Unknown) { - pc.configuration.ICETransportPolicy = configuration.ICETransportPolicy - } + pc.configuration.ICETransportPolicy = configuration.ICETransportPolicy // https://www.w3.org/TR/webrtc/#set-the-configuration (step #11) if len(configuration.ICEServers) > 0 { @@ -879,7 +872,7 @@ func (pc *PeerConnection) setDescription(sd *SessionDescription, op stateChangeO switch { case pc.isClosed.get(): return &rtcerr.InvalidStateError{Err: ErrConnectionClosed} - case NewSDPType(sd.Type.String()) == SDPType(Unknown): + case NewSDPType(sd.Type.String()) == SDPTypeUnknown: return &rtcerr.TypeError{Err: fmt.Errorf("%w: '%d' is not a valid enum value of type SDPType", errPeerConnSDPTypeInvalidValue, sd.Type)} } @@ -1092,7 +1085,7 @@ func (pc *PeerConnection) SetRemoteDescription(desc SessionDescription) error { kind := NewRTPCodecType(media.MediaName.Media) direction := getPeerDirection(media) - if kind == 0 || direction == RTPTransceiverDirection(Unknown) { + if kind == 0 || direction == RTPTransceiverDirectionUnknown { continue } @@ -1292,7 +1285,7 @@ func setRTPTransceiverCurrentDirection(answer *SessionDescription, currentTransc } direction := getPeerDirection(media) - if direction == RTPTransceiverDirection(Unknown) { + if direction == RTPTransceiverDirectionUnknown { continue } @@ -2432,7 +2425,7 @@ func (pc *PeerConnection) generateMatchedSDP(transceivers []*RTPTransceiver, use kind := NewRTPCodecType(media.MediaName.Media) direction := getPeerDirection(media) - if kind == 0 || direction == RTPTransceiverDirection(Unknown) { + if kind == 0 || direction == RTPTransceiverDirectionUnknown { continue } diff --git a/peerconnection_js.go b/peerconnection_js.go index 7fd1b1ca9f6..f97b2b493a3 100644 --- a/peerconnection_js.go +++ b/peerconnection_js.go @@ -182,14 +182,14 @@ func (pc *PeerConnection) checkConfiguration(configuration Configuration) error // } // https://www.w3.org/TR/webrtc/#set-the-configuration (step #5) - if configuration.BundlePolicy != BundlePolicy(Unknown) { + if configuration.BundlePolicy != BundlePolicyUnknown { if configuration.BundlePolicy != existingConfig.BundlePolicy { return &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy} } } // https://www.w3.org/TR/webrtc/#set-the-configuration (step #6) - if configuration.RTCPMuxPolicy != RTCPMuxPolicy(Unknown) { + if configuration.RTCPMuxPolicy != RTCPMuxPolicyUnknown { if configuration.RTCPMuxPolicy != existingConfig.RTCPMuxPolicy { return &rtcerr.InvalidModificationError{Err: ErrModifyingRTCPMuxPolicy} } diff --git a/peerconnectionstate.go b/peerconnectionstate.go index 1f1456882d8..9ff712112a7 100644 --- a/peerconnectionstate.go +++ b/peerconnectionstate.go @@ -7,11 +7,14 @@ package webrtc type PeerConnectionState int const ( + // PeerConnectionStateUnknown is the enum's zero-value + PeerConnectionStateUnknown PeerConnectionState = iota + // PeerConnectionStateNew indicates that any of the ICETransports or // DTLSTransports are in the "new" state and none of the transports are // in the "connecting", "checking", "failed" or "disconnected" state, or // all transports are in the "closed" state, or there are no transports. - PeerConnectionStateNew PeerConnectionState = iota + 1 + PeerConnectionStateNew // PeerConnectionStateConnecting indicates that any of the // ICETransports or DTLSTransports are in the "connecting" or @@ -62,7 +65,7 @@ func newPeerConnectionState(raw string) PeerConnectionState { case peerConnectionStateClosedStr: return PeerConnectionStateClosed default: - return PeerConnectionState(Unknown) + return PeerConnectionStateUnknown } } diff --git a/peerconnectionstate_test.go b/peerconnectionstate_test.go index f57ff8e0f61..27260cd9d43 100644 --- a/peerconnectionstate_test.go +++ b/peerconnectionstate_test.go @@ -14,7 +14,7 @@ func TestNewPeerConnectionState(t *testing.T) { stateString string expectedState PeerConnectionState }{ - {unknownStr, PeerConnectionState(Unknown)}, + {ErrUnknownType.Error(), PeerConnectionStateUnknown}, {"new", PeerConnectionStateNew}, {"connecting", PeerConnectionStateConnecting}, {"connected", PeerConnectionStateConnected}, @@ -37,7 +37,7 @@ func TestPeerConnectionState_String(t *testing.T) { state PeerConnectionState expectedString string }{ - {PeerConnectionState(Unknown), unknownStr}, + {PeerConnectionStateUnknown, ErrUnknownType.Error()}, {PeerConnectionStateNew, "new"}, {PeerConnectionStateConnecting, "connecting"}, {PeerConnectionStateConnected, "connected"}, diff --git a/rtcpmuxpolicy.go b/rtcpmuxpolicy.go index bd68ab562ca..ec84ea91327 100644 --- a/rtcpmuxpolicy.go +++ b/rtcpmuxpolicy.go @@ -12,11 +12,14 @@ import ( type RTCPMuxPolicy int const ( + // RTCPMuxPolicyUnknown is the enum's zero-value + RTCPMuxPolicyUnknown RTCPMuxPolicy = iota + // RTCPMuxPolicyNegotiate indicates to gather ICE candidates for both // RTP and RTCP candidates. If the remote-endpoint is capable of // multiplexing RTCP, multiplex RTCP on the RTP candidates. If it is not, // use both the RTP and RTCP candidates separately. - RTCPMuxPolicyNegotiate RTCPMuxPolicy = iota + 1 + RTCPMuxPolicyNegotiate // RTCPMuxPolicyRequire indicates to gather ICE candidates only for // RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is @@ -37,7 +40,7 @@ func newRTCPMuxPolicy(raw string) RTCPMuxPolicy { case rtcpMuxPolicyRequireStr: return RTCPMuxPolicyRequire default: - return RTCPMuxPolicy(Unknown) + return RTCPMuxPolicyUnknown } } diff --git a/rtcpmuxpolicy_test.go b/rtcpmuxpolicy_test.go index 817ea82c519..66ffefae7de 100644 --- a/rtcpmuxpolicy_test.go +++ b/rtcpmuxpolicy_test.go @@ -14,7 +14,7 @@ func TestNewRTCPMuxPolicy(t *testing.T) { policyString string expectedPolicy RTCPMuxPolicy }{ - {unknownStr, RTCPMuxPolicy(Unknown)}, + {ErrUnknownType.Error(), RTCPMuxPolicyUnknown}, {"negotiate", RTCPMuxPolicyNegotiate}, {"require", RTCPMuxPolicyRequire}, } @@ -33,7 +33,7 @@ func TestRTCPMuxPolicy_String(t *testing.T) { policy RTCPMuxPolicy expectedString string }{ - {RTCPMuxPolicy(Unknown), unknownStr}, + {RTCPMuxPolicyUnknown, ErrUnknownType.Error()}, {RTCPMuxPolicyNegotiate, "negotiate"}, {RTCPMuxPolicyRequire, "require"}, } diff --git a/rtpcodec.go b/rtpcodec.go index 69e7e07daa6..40463dcb0ce 100644 --- a/rtpcodec.go +++ b/rtpcodec.go @@ -13,9 +13,11 @@ import ( type RTPCodecType int const ( + // RTPCodecTypeUnknown is the enum's zero-value + RTPCodecTypeUnknown RTPCodecType = iota // RTPCodecTypeAudio indicates this is an audio codec - RTPCodecTypeAudio RTPCodecType = iota + 1 + RTPCodecTypeAudio // RTPCodecTypeVideo indicates this is a video codec RTPCodecTypeVideo diff --git a/rtptransceiver.go b/rtptransceiver.go index 02ddf79243b..15d28f720d1 100644 --- a/rtptransceiver.go +++ b/rtptransceiver.go @@ -42,7 +42,7 @@ func newRTPTransceiver( t.setReceiver(receiver) t.setSender(sender) t.setDirection(direction) - t.setCurrentDirection(RTPTransceiverDirection(Unknown)) + t.setCurrentDirection(RTPTransceiverDirectionUnknown) return t } @@ -193,7 +193,7 @@ func (t *RTPTransceiver) getCurrentDirection() RTPTransceiverDirection { if v, ok := t.currentDirection.Load().(RTPTransceiverDirection); ok { return v } - return RTPTransceiverDirection(Unknown) + return RTPTransceiverDirectionUnknown } func (t *RTPTransceiver) setSendingTrack(track TrackLocal) error { diff --git a/rtptransceiverdirection.go b/rtptransceiverdirection.go index 752cd5b9c6c..5e1a5be1bc7 100644 --- a/rtptransceiverdirection.go +++ b/rtptransceiverdirection.go @@ -7,9 +7,12 @@ package webrtc type RTPTransceiverDirection int const ( + // RTPTransceiverDirectionUnknown is the enum's zero-value + RTPTransceiverDirectionUnknown RTPTransceiverDirection = iota + // RTPTransceiverDirectionSendrecv indicates the RTPSender will offer // to send RTP and the RTPReceiver will offer to receive RTP. - RTPTransceiverDirectionSendrecv RTPTransceiverDirection = iota + 1 + RTPTransceiverDirectionSendrecv // RTPTransceiverDirectionSendonly indicates the RTPSender will offer // to send RTP. @@ -45,7 +48,7 @@ func NewRTPTransceiverDirection(raw string) RTPTransceiverDirection { case rtpTransceiverDirectionInactiveStr: return RTPTransceiverDirectionInactive default: - return RTPTransceiverDirection(Unknown) + return RTPTransceiverDirectionUnknown } } diff --git a/rtptransceiverdirection_test.go b/rtptransceiverdirection_test.go index c8a8da0ec45..78c6899532c 100644 --- a/rtptransceiverdirection_test.go +++ b/rtptransceiverdirection_test.go @@ -14,7 +14,7 @@ func TestNewRTPTransceiverDirection(t *testing.T) { directionString string expectedDirection RTPTransceiverDirection }{ - {unknownStr, RTPTransceiverDirection(Unknown)}, + {ErrUnknownType.Error(), RTPTransceiverDirectionUnknown}, {"sendrecv", RTPTransceiverDirectionSendrecv}, {"sendonly", RTPTransceiverDirectionSendonly}, {"recvonly", RTPTransceiverDirectionRecvonly}, @@ -35,7 +35,7 @@ func TestRTPTransceiverDirection_String(t *testing.T) { direction RTPTransceiverDirection expectedString string }{ - {RTPTransceiverDirection(Unknown), unknownStr}, + {RTPTransceiverDirectionUnknown, ErrUnknownType.Error()}, {RTPTransceiverDirectionSendrecv, "sendrecv"}, {RTPTransceiverDirectionSendonly, "sendonly"}, {RTPTransceiverDirectionRecvonly, "recvonly"}, diff --git a/sctptransportstate.go b/sctptransportstate.go index 5dd51d6f5d6..9deb73813ed 100644 --- a/sctptransportstate.go +++ b/sctptransportstate.go @@ -7,10 +7,13 @@ package webrtc type SCTPTransportState int const ( + // SCTPTransportStateUnknown is the enum's zero-value + SCTPTransportStateUnknown SCTPTransportState = iota + // SCTPTransportStateConnecting indicates the SCTPTransport is in the // process of negotiating an association. This is the initial state of the // SCTPTransportState when an SCTPTransport is created. - SCTPTransportStateConnecting SCTPTransportState = iota + 1 + SCTPTransportStateConnecting // SCTPTransportStateConnected indicates the negotiation of an // association is completed. @@ -39,7 +42,7 @@ func newSCTPTransportState(raw string) SCTPTransportState { case sctpTransportStateClosedStr: return SCTPTransportStateClosed default: - return SCTPTransportState(Unknown) + return SCTPTransportStateUnknown } } diff --git a/sctptransportstate_test.go b/sctptransportstate_test.go index c97f277c7a9..59b6d52b1ee 100644 --- a/sctptransportstate_test.go +++ b/sctptransportstate_test.go @@ -14,7 +14,7 @@ func TestNewSCTPTransportState(t *testing.T) { transportStateString string expectedTransportState SCTPTransportState }{ - {unknownStr, SCTPTransportState(Unknown)}, + {ErrUnknownType.Error(), SCTPTransportStateUnknown}, {"connecting", SCTPTransportStateConnecting}, {"connected", SCTPTransportStateConnected}, {"closed", SCTPTransportStateClosed}, @@ -34,7 +34,7 @@ func TestSCTPTransportState_String(t *testing.T) { transportState SCTPTransportState expectedString string }{ - {SCTPTransportState(Unknown), unknownStr}, + {SCTPTransportStateUnknown, ErrUnknownType.Error()}, {SCTPTransportStateConnecting, "connecting"}, {SCTPTransportStateConnected, "connected"}, {SCTPTransportStateClosed, "closed"}, diff --git a/sdp.go b/sdp.go index 0622c759011..0cd61873d3f 100644 --- a/sdp.go +++ b/sdp.go @@ -653,11 +653,11 @@ func descriptionPossiblyPlanB(desc *SessionDescription) bool { func getPeerDirection(media *sdp.MediaDescription) RTPTransceiverDirection { for _, a := range media.Attributes { - if direction := NewRTPTransceiverDirection(a.Key); direction != RTPTransceiverDirection(Unknown) { + if direction := NewRTPTransceiverDirection(a.Key); direction != RTPTransceiverDirectionUnknown { return direction } } - return RTPTransceiverDirection(Unknown) + return RTPTransceiverDirectionUnknown } func extractFingerprint(desc *sdp.SessionDescription) (string, string, error) { diff --git a/sdpsemantics.go b/sdpsemantics.go index 6d63350477a..689b4e95bf5 100644 --- a/sdpsemantics.go +++ b/sdpsemantics.go @@ -36,14 +36,12 @@ const ( func newSDPSemantics(raw string) SDPSemantics { switch raw { - case sdpSemanticsUnifiedPlan: - return SDPSemanticsUnifiedPlan case sdpSemanticsPlanB: return SDPSemanticsPlanB case sdpSemanticsUnifiedPlanWithFallback: return SDPSemanticsUnifiedPlanWithFallback default: - return SDPSemantics(Unknown) + return SDPSemanticsUnifiedPlan } } diff --git a/sdpsemantics_test.go b/sdpsemantics_test.go index d513c3b994c..eff518f7321 100644 --- a/sdpsemantics_test.go +++ b/sdpsemantics_test.go @@ -29,7 +29,7 @@ func TestSDPSemantics_String(t *testing.T) { } assert.Equal(t, - unknownStr, + ErrUnknownType.Error(), SDPSemantics(42).String(), ) diff --git a/sdptype.go b/sdptype.go index 0c6d1d4649c..5aa3b986116 100644 --- a/sdptype.go +++ b/sdptype.go @@ -12,9 +12,11 @@ import ( type SDPType int const ( - // SDPTypeOffer indicates that a description MUST be treated as an SDP - // offer. - SDPTypeOffer SDPType = iota + 1 + // SDPTypeUnknown is the enum's zero-value + SDPTypeUnknown SDPType = iota + + // SDPTypeOffer indicates that a description MUST be treated as an SDP offer. + SDPTypeOffer // SDPTypePranswer indicates that a description MUST be treated as an // SDP answer, but not a final answer. A description used as an SDP @@ -56,7 +58,7 @@ func NewSDPType(raw string) SDPType { case sdpTypeRollbackStr: return SDPTypeRollback default: - return SDPType(Unknown) + return SDPTypeUnknown } } diff --git a/sdptype_test.go b/sdptype_test.go index 40daedf127e..9f045d18608 100644 --- a/sdptype_test.go +++ b/sdptype_test.go @@ -14,7 +14,7 @@ func TestNewSDPType(t *testing.T) { sdpTypeString string expectedSDPType SDPType }{ - {unknownStr, SDPType(Unknown)}, + {ErrUnknownType.Error(), SDPTypeUnknown}, {"offer", SDPTypeOffer}, {"pranswer", SDPTypePranswer}, {"answer", SDPTypeAnswer}, @@ -35,7 +35,7 @@ func TestSDPType_String(t *testing.T) { sdpType SDPType expectedString string }{ - {SDPType(Unknown), unknownStr}, + {SDPTypeUnknown, ErrUnknownType.Error()}, {SDPTypeOffer, "offer"}, {SDPTypePranswer, "pranswer"}, {SDPTypeAnswer, "answer"}, diff --git a/sessiondescription_test.go b/sessiondescription_test.go index d9eb2580153..c167d0d10f0 100644 --- a/sessiondescription_test.go +++ b/sessiondescription_test.go @@ -21,7 +21,7 @@ func TestSessionDescription_JSON(t *testing.T) { {SessionDescription{Type: SDPTypePranswer, SDP: "sdp"}, `{"type":"pranswer","sdp":"sdp"}`, nil}, {SessionDescription{Type: SDPTypeAnswer, SDP: "sdp"}, `{"type":"answer","sdp":"sdp"}`, nil}, {SessionDescription{Type: SDPTypeRollback, SDP: "sdp"}, `{"type":"rollback","sdp":"sdp"}`, nil}, - {SessionDescription{Type: SDPType(Unknown), SDP: "sdp"}, `{"type":"unknown","sdp":"sdp"}`, ErrUnknownType}, + {SessionDescription{Type: SDPTypeUnknown, SDP: "sdp"}, `{"type":"unknown","sdp":"sdp"}`, ErrUnknownType}, } for i, testCase := range testCases { diff --git a/signalingstate.go b/signalingstate.go index ebbf7542cbd..9d60afd2601 100644 --- a/signalingstate.go +++ b/signalingstate.go @@ -32,10 +32,13 @@ func (op stateChangeOp) String() string { type SignalingState int32 const ( + // SignalingStateUnknown is the enum's zero-value + SignalingStateUnknown SignalingState = iota + // SignalingStateStable indicates there is no offer/answer exchange in // progress. This is also the initial state, in which case the local and // remote descriptions are nil. - SignalingStateStable SignalingState = iota + 1 + SignalingStateStable // SignalingStateHaveLocalOffer indicates that a local description, of // type "offer", has been successfully applied. @@ -84,7 +87,7 @@ func newSignalingState(raw string) SignalingState { case signalingStateClosedStr: return SignalingStateClosed default: - return SignalingState(Unknown) + return SignalingStateUnknown } } diff --git a/signalingstate_test.go b/signalingstate_test.go index 140e20f7a36..1708d316a24 100644 --- a/signalingstate_test.go +++ b/signalingstate_test.go @@ -15,7 +15,7 @@ func TestNewSignalingState(t *testing.T) { stateString string expectedState SignalingState }{ - {unknownStr, SignalingState(Unknown)}, + {ErrUnknownType.Error(), SignalingStateUnknown}, {"stable", SignalingStateStable}, {"have-local-offer", SignalingStateHaveLocalOffer}, {"have-remote-offer", SignalingStateHaveRemoteOffer}, @@ -38,7 +38,7 @@ func TestSignalingState_String(t *testing.T) { state SignalingState expectedString string }{ - {SignalingState(Unknown), unknownStr}, + {SignalingStateUnknown, ErrUnknownType.Error()}, {SignalingStateStable, "stable"}, {SignalingStateHaveLocalOffer, "have-local-offer"}, {SignalingStateHaveRemoteOffer, "have-remote-offer"},