mirror of
https://github.com/pion/webrtc.git
synced 2025-09-26 11:11:26 +08:00
Remove the "Unknown" constant
This commit replaces the Unknown constant with separate constants for each enumeration that uses it. Fixes #1293
This commit is contained in:

committed by
Sean DuBois

parent
7e598b5a63
commit
13450332a4
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
}
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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},
|
||||
|
@@ -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
|
||||
|
@@ -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())
|
||||
}
|
||||
}
|
||||
|
@@ -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},
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
4
sdp.go
4
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) {
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ func TestSDPSemantics_String(t *testing.T) {
|
||||
}
|
||||
|
||||
assert.Equal(t,
|
||||
unknownStr,
|
||||
ErrUnknownType.Error(),
|
||||
SDPSemantics(42).String(),
|
||||
)
|
||||
|
||||
|
10
sdptype.go
10
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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
Reference in New Issue
Block a user