mirror of
https://github.com/pion/webrtc.git
synced 2025-09-26 19:21:12 +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
|
type BundlePolicy int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// BundlePolicyUnknown is the enum's zero-value
|
||||||
|
BundlePolicyUnknown BundlePolicy = iota
|
||||||
|
|
||||||
// BundlePolicyBalanced indicates to gather ICE candidates for each
|
// BundlePolicyBalanced indicates to gather ICE candidates for each
|
||||||
// media type in use (audio, video, and data). If the remote endpoint is
|
// 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
|
// not bundle-aware, negotiate only one audio and video track on separate
|
||||||
// transports.
|
// transports.
|
||||||
BundlePolicyBalanced BundlePolicy = iota + 1
|
BundlePolicyBalanced
|
||||||
|
|
||||||
// BundlePolicyMaxCompat indicates to gather ICE candidates for each
|
// BundlePolicyMaxCompat indicates to gather ICE candidates for each
|
||||||
// track. If the remote endpoint is not bundle-aware, negotiate all media
|
// track. If the remote endpoint is not bundle-aware, negotiate all media
|
||||||
@@ -47,7 +50,7 @@ func newBundlePolicy(raw string) BundlePolicy {
|
|||||||
case bundlePolicyMaxBundleStr:
|
case bundlePolicyMaxBundleStr:
|
||||||
return BundlePolicyMaxBundle
|
return BundlePolicyMaxBundle
|
||||||
default:
|
default:
|
||||||
return BundlePolicy(Unknown)
|
return BundlePolicyUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewBundlePolicy(t *testing.T) {
|
|||||||
policyString string
|
policyString string
|
||||||
expectedPolicy BundlePolicy
|
expectedPolicy BundlePolicy
|
||||||
}{
|
}{
|
||||||
{unknownStr, BundlePolicy(Unknown)},
|
{ErrUnknownType.Error(), BundlePolicyUnknown},
|
||||||
{"balanced", BundlePolicyBalanced},
|
{"balanced", BundlePolicyBalanced},
|
||||||
{"max-compat", BundlePolicyMaxCompat},
|
{"max-compat", BundlePolicyMaxCompat},
|
||||||
{"max-bundle", BundlePolicyMaxBundle},
|
{"max-bundle", BundlePolicyMaxBundle},
|
||||||
@@ -34,7 +34,7 @@ func TestBundlePolicy_String(t *testing.T) {
|
|||||||
policy BundlePolicy
|
policy BundlePolicy
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{BundlePolicy(Unknown), unknownStr},
|
{BundlePolicyUnknown, ErrUnknownType.Error()},
|
||||||
{BundlePolicyBalanced, "balanced"},
|
{BundlePolicyBalanced, "balanced"},
|
||||||
{BundlePolicyMaxCompat, "max-compat"},
|
{BundlePolicyMaxCompat, "max-compat"},
|
||||||
{BundlePolicyMaxBundle, "max-bundle"},
|
{BundlePolicyMaxBundle, "max-bundle"},
|
||||||
|
@@ -6,11 +6,6 @@ package webrtc
|
|||||||
import "github.com/pion/dtls/v2"
|
import "github.com/pion/dtls/v2"
|
||||||
|
|
||||||
const (
|
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
|
// Equal to UDP MTU
|
||||||
receiveMTU = 1460
|
receiveMTU = 1460
|
||||||
|
|
||||||
|
@@ -7,10 +7,13 @@ package webrtc
|
|||||||
type DataChannelState int
|
type DataChannelState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// DataChannelStateUnknown is the enum's zero-value
|
||||||
|
DataChannelStateUnknown DataChannelState = iota
|
||||||
|
|
||||||
// DataChannelStateConnecting indicates that the data channel is being
|
// DataChannelStateConnecting indicates that the data channel is being
|
||||||
// established. This is the initial state of DataChannel, whether created
|
// established. This is the initial state of DataChannel, whether created
|
||||||
// with CreateDataChannel, or dispatched as a part of an DataChannelEvent.
|
// with CreateDataChannel, or dispatched as a part of an DataChannelEvent.
|
||||||
DataChannelStateConnecting DataChannelState = iota + 1
|
DataChannelStateConnecting
|
||||||
|
|
||||||
// DataChannelStateOpen indicates that the underlying data transport is
|
// DataChannelStateOpen indicates that the underlying data transport is
|
||||||
// established and communication is possible.
|
// established and communication is possible.
|
||||||
@@ -44,7 +47,7 @@ func newDataChannelState(raw string) DataChannelState {
|
|||||||
case dataChannelStateClosedStr:
|
case dataChannelStateClosedStr:
|
||||||
return DataChannelStateClosed
|
return DataChannelStateClosed
|
||||||
default:
|
default:
|
||||||
return DataChannelState(Unknown)
|
return DataChannelStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewDataChannelState(t *testing.T) {
|
|||||||
stateString string
|
stateString string
|
||||||
expectedState DataChannelState
|
expectedState DataChannelState
|
||||||
}{
|
}{
|
||||||
{unknownStr, DataChannelState(Unknown)},
|
{ErrUnknownType.Error(), DataChannelStateUnknown},
|
||||||
{"connecting", DataChannelStateConnecting},
|
{"connecting", DataChannelStateConnecting},
|
||||||
{"open", DataChannelStateOpen},
|
{"open", DataChannelStateOpen},
|
||||||
{"closing", DataChannelStateClosing},
|
{"closing", DataChannelStateClosing},
|
||||||
@@ -35,7 +35,7 @@ func TestDataChannelState_String(t *testing.T) {
|
|||||||
state DataChannelState
|
state DataChannelState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{DataChannelState(Unknown), unknownStr},
|
{DataChannelStateUnknown, ErrUnknownType.Error()},
|
||||||
{DataChannelStateConnecting, "connecting"},
|
{DataChannelStateConnecting, "connecting"},
|
||||||
{DataChannelStateOpen, "open"},
|
{DataChannelStateOpen, "open"},
|
||||||
{DataChannelStateClosing, "closing"},
|
{DataChannelStateClosing, "closing"},
|
||||||
|
@@ -11,10 +11,13 @@ import (
|
|||||||
type DTLSRole byte
|
type DTLSRole byte
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// DTLSRoleUnknown is the enum's zero-value
|
||||||
|
DTLSRoleUnknown DTLSRole = iota
|
||||||
|
|
||||||
// DTLSRoleAuto defines the DTLS role is determined based on
|
// DTLSRoleAuto defines the DTLS role is determined based on
|
||||||
// the resolved ICE role: the ICE controlled role acts as the DTLS
|
// the resolved ICE role: the ICE controlled role acts as the DTLS
|
||||||
// client and the ICE controlling role acts as the DTLS server.
|
// client and the ICE controlling role acts as the DTLS server.
|
||||||
DTLSRoleAuto DTLSRole = iota + 1
|
DTLSRoleAuto
|
||||||
|
|
||||||
// DTLSRoleClient defines the DTLS client role.
|
// DTLSRoleClient defines the DTLS client role.
|
||||||
DTLSRoleClient
|
DTLSRoleClient
|
||||||
@@ -51,7 +54,7 @@ func (r DTLSRole) String() string {
|
|||||||
case DTLSRoleServer:
|
case DTLSRoleServer:
|
||||||
return "server"
|
return "server"
|
||||||
default:
|
default:
|
||||||
return unknownStr
|
return ErrUnknownType.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ func TestDTLSRole_String(t *testing.T) {
|
|||||||
role DTLSRole
|
role DTLSRole
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{DTLSRole(Unknown), unknownStr},
|
{DTLSRoleUnknown, ErrUnknownType.Error()},
|
||||||
{DTLSRoleAuto, "auto"},
|
{DTLSRoleAuto, "auto"},
|
||||||
{DTLSRoleClient, "client"},
|
{DTLSRoleClient, "client"},
|
||||||
{DTLSRoleServer, "server"},
|
{DTLSRoleServer, "server"},
|
||||||
|
@@ -7,9 +7,12 @@ package webrtc
|
|||||||
type DTLSTransportState int
|
type DTLSTransportState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// DTLSTransportStateUnknown is the enum's zero-value
|
||||||
|
DTLSTransportStateUnknown DTLSTransportState = iota
|
||||||
|
|
||||||
// DTLSTransportStateNew indicates that DTLS has not started negotiating
|
// DTLSTransportStateNew indicates that DTLS has not started negotiating
|
||||||
// yet.
|
// yet.
|
||||||
DTLSTransportStateNew DTLSTransportState = iota + 1
|
DTLSTransportStateNew
|
||||||
|
|
||||||
// DTLSTransportStateConnecting indicates that DTLS is in the process of
|
// DTLSTransportStateConnecting indicates that DTLS is in the process of
|
||||||
// negotiating a secure connection and verifying the remote fingerprint.
|
// negotiating a secure connection and verifying the remote fingerprint.
|
||||||
@@ -52,7 +55,7 @@ func newDTLSTransportState(raw string) DTLSTransportState {
|
|||||||
case dtlsTransportStateFailedStr:
|
case dtlsTransportStateFailedStr:
|
||||||
return DTLSTransportStateFailed
|
return DTLSTransportStateFailed
|
||||||
default:
|
default:
|
||||||
return DTLSTransportState(Unknown)
|
return DTLSTransportStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewDTLSTransportState(t *testing.T) {
|
|||||||
stateString string
|
stateString string
|
||||||
expectedState DTLSTransportState
|
expectedState DTLSTransportState
|
||||||
}{
|
}{
|
||||||
{unknownStr, DTLSTransportState(Unknown)},
|
{ErrUnknownType.Error(), DTLSTransportStateUnknown},
|
||||||
{"new", DTLSTransportStateNew},
|
{"new", DTLSTransportStateNew},
|
||||||
{"connecting", DTLSTransportStateConnecting},
|
{"connecting", DTLSTransportStateConnecting},
|
||||||
{"connected", DTLSTransportStateConnected},
|
{"connected", DTLSTransportStateConnected},
|
||||||
@@ -36,7 +36,7 @@ func TestDTLSTransportState_String(t *testing.T) {
|
|||||||
state DTLSTransportState
|
state DTLSTransportState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{DTLSTransportState(Unknown), unknownStr},
|
{DTLSTransportStateUnknown, ErrUnknownType.Error()},
|
||||||
{DTLSTransportStateNew, "new"},
|
{DTLSTransportStateNew, "new"},
|
||||||
{DTLSTransportStateConnecting, "connecting"},
|
{DTLSTransportStateConnecting, "connecting"},
|
||||||
{DTLSTransportStateConnected, "connected"},
|
{DTLSTransportStateConnected, "connected"},
|
||||||
|
@@ -13,12 +13,15 @@ import (
|
|||||||
type ICECandidateType int
|
type ICECandidateType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICECandidateTypeUnknown is the enum's zero-value
|
||||||
|
ICECandidateTypeUnknown ICECandidateType = iota
|
||||||
|
|
||||||
// ICECandidateTypeHost indicates that the candidate is of Host type as
|
// ICECandidateTypeHost indicates that the candidate is of Host type as
|
||||||
// described in https://tools.ietf.org/html/rfc8445#section-5.1.1.1. A
|
// 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
|
// candidate obtained by binding to a specific port from an IP address on
|
||||||
// the host. This includes IP addresses on physical interfaces and logical
|
// the host. This includes IP addresses on physical interfaces and logical
|
||||||
// ones, such as ones obtained through VPNs.
|
// ones, such as ones obtained through VPNs.
|
||||||
ICECandidateTypeHost ICECandidateType = iota + 1
|
ICECandidateTypeHost
|
||||||
|
|
||||||
// ICECandidateTypeSrflx indicates the the candidate is of Server
|
// ICECandidateTypeSrflx indicates the the candidate is of Server
|
||||||
// Reflexive type as described
|
// Reflexive type as described
|
||||||
@@ -60,7 +63,7 @@ func NewICECandidateType(raw string) (ICECandidateType, error) {
|
|||||||
case iceCandidateTypeRelayStr:
|
case iceCandidateTypeRelayStr:
|
||||||
return ICECandidateTypeRelay, nil
|
return ICECandidateTypeRelay, nil
|
||||||
default:
|
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:
|
default:
|
||||||
// NOTE: this should never happen[tm]
|
// NOTE: this should never happen[tm]
|
||||||
err := fmt.Errorf("%w: %s", errICEInvalidConvertCandidateType, candidateType.String())
|
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
|
shouldFail bool
|
||||||
expectedType ICECandidateType
|
expectedType ICECandidateType
|
||||||
}{
|
}{
|
||||||
{unknownStr, true, ICECandidateType(Unknown)},
|
{ErrUnknownType.Error(), true, ICECandidateTypeUnknown},
|
||||||
{"host", false, ICECandidateTypeHost},
|
{"host", false, ICECandidateTypeHost},
|
||||||
{"srflx", false, ICECandidateTypeSrflx},
|
{"srflx", false, ICECandidateTypeSrflx},
|
||||||
{"prflx", false, ICECandidateTypePrflx},
|
{"prflx", false, ICECandidateTypePrflx},
|
||||||
@@ -40,7 +40,7 @@ func TestICECandidateType_String(t *testing.T) {
|
|||||||
cType ICECandidateType
|
cType ICECandidateType
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICECandidateType(Unknown), unknownStr},
|
{ICECandidateTypeUnknown, ErrUnknownType.Error()},
|
||||||
{ICECandidateTypeHost, "host"},
|
{ICECandidateTypeHost, "host"},
|
||||||
{ICECandidateTypeSrflx, "srflx"},
|
{ICECandidateTypeSrflx, "srflx"},
|
||||||
{ICECandidateTypePrflx, "prflx"},
|
{ICECandidateTypePrflx, "prflx"},
|
||||||
|
@@ -8,12 +8,15 @@ package webrtc
|
|||||||
type ICEComponent int
|
type ICEComponent int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICEComponentUnknown is the enum's zero-value
|
||||||
|
ICEComponentUnknown ICEComponent = iota
|
||||||
|
|
||||||
// ICEComponentRTP indicates that the ICE Transport is used for RTP (or
|
// ICEComponentRTP indicates that the ICE Transport is used for RTP (or
|
||||||
// RTCP multiplexing), as defined in
|
// RTCP multiplexing), as defined in
|
||||||
// https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols
|
// https://tools.ietf.org/html/rfc5245#section-4.1.1.1. Protocols
|
||||||
// multiplexed with RTP (e.g. data channel) share its component ID. This
|
// multiplexed with RTP (e.g. data channel) share its component ID. This
|
||||||
// represents the component-id value 1 when encoded in candidate-attribute.
|
// 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
|
// 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
|
// 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:
|
case iceComponentRTCPStr:
|
||||||
return ICEComponentRTCP
|
return ICEComponentRTCP
|
||||||
default:
|
default:
|
||||||
return ICEComponent(Unknown)
|
return ICEComponentUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestICEComponent(t *testing.T) {
|
|||||||
componentString string
|
componentString string
|
||||||
expectedComponent ICEComponent
|
expectedComponent ICEComponent
|
||||||
}{
|
}{
|
||||||
{unknownStr, ICEComponent(Unknown)},
|
{ErrUnknownType.Error(), ICEComponentUnknown},
|
||||||
{"rtp", ICEComponentRTP},
|
{"rtp", ICEComponentRTP},
|
||||||
{"rtcp", ICEComponentRTCP},
|
{"rtcp", ICEComponentRTCP},
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ func TestICEComponent_String(t *testing.T) {
|
|||||||
state ICEComponent
|
state ICEComponent
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICEComponent(Unknown), unknownStr},
|
{ICEComponentUnknown, ErrUnknownType.Error()},
|
||||||
{ICEComponentRTP, "rtp"},
|
{ICEComponentRTP, "rtp"},
|
||||||
{ICEComponentRTCP, "rtcp"},
|
{ICEComponentRTCP, "rtcp"},
|
||||||
}
|
}
|
||||||
|
@@ -7,11 +7,14 @@ package webrtc
|
|||||||
type ICEConnectionState int
|
type ICEConnectionState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICEConnectionStateUnknown is the enum's zero-value
|
||||||
|
ICEConnectionStateUnknown ICEConnectionState = iota
|
||||||
|
|
||||||
// ICEConnectionStateNew indicates that any of the ICETransports are
|
// ICEConnectionStateNew indicates that any of the ICETransports are
|
||||||
// in the "new" state and none of them are in the "checking", "disconnected"
|
// 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
|
// or "failed" state, or all ICETransports are in the "closed" state, or
|
||||||
// there are no transports.
|
// there are no transports.
|
||||||
ICEConnectionStateNew ICEConnectionState = iota + 1
|
ICEConnectionStateNew
|
||||||
|
|
||||||
// ICEConnectionStateChecking indicates that any of the ICETransports
|
// ICEConnectionStateChecking indicates that any of the ICETransports
|
||||||
// are in the "checking" state and none of them are in the "disconnected"
|
// are in the "checking" state and none of them are in the "disconnected"
|
||||||
@@ -71,7 +74,7 @@ func NewICEConnectionState(raw string) ICEConnectionState {
|
|||||||
case iceConnectionStateClosedStr:
|
case iceConnectionStateClosedStr:
|
||||||
return ICEConnectionStateClosed
|
return ICEConnectionStateClosed
|
||||||
default:
|
default:
|
||||||
return ICEConnectionState(Unknown)
|
return ICEConnectionStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewICEConnectionState(t *testing.T) {
|
|||||||
stateString string
|
stateString string
|
||||||
expectedState ICEConnectionState
|
expectedState ICEConnectionState
|
||||||
}{
|
}{
|
||||||
{unknownStr, ICEConnectionState(Unknown)},
|
{ErrUnknownType.Error(), ICEConnectionStateUnknown},
|
||||||
{"new", ICEConnectionStateNew},
|
{"new", ICEConnectionStateNew},
|
||||||
{"checking", ICEConnectionStateChecking},
|
{"checking", ICEConnectionStateChecking},
|
||||||
{"connected", ICEConnectionStateConnected},
|
{"connected", ICEConnectionStateConnected},
|
||||||
@@ -38,7 +38,7 @@ func TestICEConnectionState_String(t *testing.T) {
|
|||||||
state ICEConnectionState
|
state ICEConnectionState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICEConnectionState(Unknown), unknownStr},
|
{ICEConnectionStateUnknown, ErrUnknownType.Error()},
|
||||||
{ICEConnectionStateNew, "new"},
|
{ICEConnectionStateNew, "new"},
|
||||||
{ICEConnectionStateChecking, "checking"},
|
{ICEConnectionStateChecking, "checking"},
|
||||||
{ICEConnectionStateConnected, "connected"},
|
{ICEConnectionStateConnected, "connected"},
|
||||||
|
@@ -11,9 +11,12 @@ import (
|
|||||||
type ICEGathererState uint32
|
type ICEGathererState uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICEGathererStateUnknown is the enum's zero-value
|
||||||
|
ICEGathererStateUnknown ICEGathererState = iota
|
||||||
|
|
||||||
// ICEGathererStateNew indicates object has been created but
|
// ICEGathererStateNew indicates object has been created but
|
||||||
// gather() has not been called.
|
// gather() has not been called.
|
||||||
ICEGathererStateNew ICEGathererState = iota + 1
|
ICEGathererStateNew
|
||||||
|
|
||||||
// ICEGathererStateGathering indicates gather() has been called,
|
// ICEGathererStateGathering indicates gather() has been called,
|
||||||
// and the ICEGatherer is in the process of gathering candidates.
|
// and the ICEGatherer is in the process of gathering candidates.
|
||||||
@@ -38,7 +41,7 @@ func (s ICEGathererState) String() string {
|
|||||||
case ICEGathererStateClosed:
|
case ICEGathererStateClosed:
|
||||||
return "closed"
|
return "closed"
|
||||||
default:
|
default:
|
||||||
return unknownStr
|
return ErrUnknownType.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestICEGathererState_String(t *testing.T) {
|
|||||||
state ICEGathererState
|
state ICEGathererState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICEGathererState(Unknown), unknownStr},
|
{ICEGathererStateUnknown, ErrUnknownType.Error()},
|
||||||
{ICEGathererStateNew, "new"},
|
{ICEGathererStateNew, "new"},
|
||||||
{ICEGathererStateGathering, "gathering"},
|
{ICEGathererStateGathering, "gathering"},
|
||||||
{ICEGathererStateComplete, "complete"},
|
{ICEGathererStateComplete, "complete"},
|
||||||
|
@@ -7,10 +7,13 @@ package webrtc
|
|||||||
type ICEGatheringState int
|
type ICEGatheringState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICEGatheringStateUnknown is the enum's zero-value
|
||||||
|
ICEGatheringStateUnknown ICEGatheringState = iota
|
||||||
|
|
||||||
// ICEGatheringStateNew indicates that any of the ICETransports are
|
// ICEGatheringStateNew indicates that any of the ICETransports are
|
||||||
// in the "new" gathering state and none of the transports are in the
|
// in the "new" gathering state and none of the transports are in the
|
||||||
// "gathering" state, or there are no transports.
|
// "gathering" state, or there are no transports.
|
||||||
ICEGatheringStateNew ICEGatheringState = iota + 1
|
ICEGatheringStateNew
|
||||||
|
|
||||||
// ICEGatheringStateGathering indicates that any of the ICETransports
|
// ICEGatheringStateGathering indicates that any of the ICETransports
|
||||||
// are in the "gathering" state.
|
// are in the "gathering" state.
|
||||||
@@ -38,7 +41,7 @@ func NewICEGatheringState(raw string) ICEGatheringState {
|
|||||||
case iceGatheringStateCompleteStr:
|
case iceGatheringStateCompleteStr:
|
||||||
return ICEGatheringStateComplete
|
return ICEGatheringStateComplete
|
||||||
default:
|
default:
|
||||||
return ICEGatheringState(Unknown)
|
return ICEGatheringStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewICEGatheringState(t *testing.T) {
|
|||||||
stateString string
|
stateString string
|
||||||
expectedState ICEGatheringState
|
expectedState ICEGatheringState
|
||||||
}{
|
}{
|
||||||
{unknownStr, ICEGatheringState(Unknown)},
|
{ErrUnknownType.Error(), ICEGatheringStateUnknown},
|
||||||
{"new", ICEGatheringStateNew},
|
{"new", ICEGatheringStateNew},
|
||||||
{"gathering", ICEGatheringStateGathering},
|
{"gathering", ICEGatheringStateGathering},
|
||||||
{"complete", ICEGatheringStateComplete},
|
{"complete", ICEGatheringStateComplete},
|
||||||
@@ -34,7 +34,7 @@ func TestICEGatheringState_String(t *testing.T) {
|
|||||||
state ICEGatheringState
|
state ICEGatheringState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICEGatheringState(Unknown), unknownStr},
|
{ICEGatheringStateUnknown, ErrUnknownType.Error()},
|
||||||
{ICEGatheringStateNew, "new"},
|
{ICEGatheringStateNew, "new"},
|
||||||
{ICEGatheringStateGathering, "gathering"},
|
{ICEGatheringStateGathering, "gathering"},
|
||||||
{ICEGatheringStateComplete, "complete"},
|
{ICEGatheringStateComplete, "complete"},
|
||||||
|
@@ -13,8 +13,11 @@ import (
|
|||||||
type ICEProtocol int
|
type ICEProtocol int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICEProtocolUnknown is the enum's zero-value
|
||||||
|
ICEProtocolUnknown ICEProtocol = iota
|
||||||
|
|
||||||
// ICEProtocolUDP indicates the URL uses a UDP transport.
|
// ICEProtocolUDP indicates the URL uses a UDP transport.
|
||||||
ICEProtocolUDP ICEProtocol = iota + 1
|
ICEProtocolUDP
|
||||||
|
|
||||||
// ICEProtocolTCP indicates the URL uses a TCP transport.
|
// ICEProtocolTCP indicates the URL uses a TCP transport.
|
||||||
ICEProtocolTCP
|
ICEProtocolTCP
|
||||||
@@ -34,7 +37,7 @@ func NewICEProtocol(raw string) (ICEProtocol, error) {
|
|||||||
case strings.EqualFold(iceProtocolTCPStr, raw):
|
case strings.EqualFold(iceProtocolTCPStr, raw):
|
||||||
return ICEProtocolTCP, nil
|
return ICEProtocolTCP, nil
|
||||||
default:
|
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
|
shouldFail bool
|
||||||
expectedProto ICEProtocol
|
expectedProto ICEProtocol
|
||||||
}{
|
}{
|
||||||
{unknownStr, true, ICEProtocol(Unknown)},
|
{ErrUnknownType.Error(), true, ICEProtocolUnknown},
|
||||||
{"udp", false, ICEProtocolUDP},
|
{"udp", false, ICEProtocolUDP},
|
||||||
{"tcp", false, ICEProtocolTCP},
|
{"tcp", false, ICEProtocolTCP},
|
||||||
{"UDP", false, ICEProtocolUDP},
|
{"UDP", false, ICEProtocolUDP},
|
||||||
@@ -40,7 +40,7 @@ func TestICEProtocol_String(t *testing.T) {
|
|||||||
proto ICEProtocol
|
proto ICEProtocol
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICEProtocol(Unknown), unknownStr},
|
{ICEProtocolUnknown, ErrUnknownType.Error()},
|
||||||
{ICEProtocolUDP, "udp"},
|
{ICEProtocolUDP, "udp"},
|
||||||
{ICEProtocolTCP, "tcp"},
|
{ICEProtocolTCP, "tcp"},
|
||||||
}
|
}
|
||||||
|
@@ -8,11 +8,14 @@ package webrtc
|
|||||||
type ICERole int
|
type ICERole int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICERoleUnknown is the enum's zero-value
|
||||||
|
ICERoleUnknown ICERole = iota
|
||||||
|
|
||||||
// ICERoleControlling indicates that the ICE agent that is responsible
|
// ICERoleControlling indicates that the ICE agent that is responsible
|
||||||
// for selecting the final choice of candidate pairs and signaling them
|
// for selecting the final choice of candidate pairs and signaling them
|
||||||
// through STUN and an updated offer, if needed. In any session, one agent
|
// through STUN and an updated offer, if needed. In any session, one agent
|
||||||
// is always controlling. The other is the controlled 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
|
// ICERoleControlled indicates that an ICE agent that waits for the
|
||||||
// controlling agent to select the final choice of candidate pairs.
|
// controlling agent to select the final choice of candidate pairs.
|
||||||
@@ -32,7 +35,7 @@ func newICERole(raw string) ICERole {
|
|||||||
case iceRoleControlledStr:
|
case iceRoleControlledStr:
|
||||||
return ICERoleControlled
|
return ICERoleControlled
|
||||||
default:
|
default:
|
||||||
return ICERole(Unknown)
|
return ICERoleUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewICERole(t *testing.T) {
|
|||||||
roleString string
|
roleString string
|
||||||
expectedRole ICERole
|
expectedRole ICERole
|
||||||
}{
|
}{
|
||||||
{unknownStr, ICERole(Unknown)},
|
{ErrUnknownType.Error(), ICERoleUnknown},
|
||||||
{"controlling", ICERoleControlling},
|
{"controlling", ICERoleControlling},
|
||||||
{"controlled", ICERoleControlled},
|
{"controlled", ICERoleControlled},
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ func TestICERole_String(t *testing.T) {
|
|||||||
proto ICERole
|
proto ICERole
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICERole(Unknown), unknownStr},
|
{ICERoleUnknown, ErrUnknownType.Error()},
|
||||||
{ICERoleControlling, "controlling"},
|
{ICERoleControlling, "controlling"},
|
||||||
{ICERoleControlled, "controlled"},
|
{ICERoleControlled, "controlled"},
|
||||||
}
|
}
|
||||||
|
@@ -79,7 +79,7 @@ func TestICEServer_validate(t *testing.T) {
|
|||||||
URLs: []string{"turn:192.158.29.39?transport=udp"},
|
URLs: []string{"turn:192.158.29.39?transport=udp"},
|
||||||
Username: "unittest",
|
Username: "unittest",
|
||||||
Credential: false,
|
Credential: false,
|
||||||
CredentialType: Unknown,
|
CredentialType: ICECredentialTypePassword,
|
||||||
}, &rtcerr.InvalidAccessError{Err: ErrTurnCredentials}},
|
}, &rtcerr.InvalidAccessError{Err: ErrTurnCredentials}},
|
||||||
{ICEServer{
|
{ICEServer{
|
||||||
URLs: []string{"stun:google.de?transport=udp"},
|
URLs: []string{"stun:google.de?transport=udp"},
|
||||||
|
@@ -34,10 +34,8 @@ func NewICETransportPolicy(raw string) ICETransportPolicy {
|
|||||||
switch raw {
|
switch raw {
|
||||||
case iceTransportPolicyRelayStr:
|
case iceTransportPolicyRelayStr:
|
||||||
return ICETransportPolicyRelay
|
return ICETransportPolicyRelay
|
||||||
case iceTransportPolicyAllStr:
|
|
||||||
return ICETransportPolicyAll
|
|
||||||
default:
|
default:
|
||||||
return ICETransportPolicy(Unknown)
|
return ICETransportPolicyAll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,9 +9,12 @@ import "github.com/pion/ice/v3"
|
|||||||
type ICETransportState int
|
type ICETransportState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ICETransportStateUnknown is the enum's zero-value
|
||||||
|
ICETransportStateUnknown ICETransportState = iota
|
||||||
|
|
||||||
// ICETransportStateNew indicates the ICETransport is waiting
|
// ICETransportStateNew indicates the ICETransport is waiting
|
||||||
// for remote candidates to be supplied.
|
// for remote candidates to be supplied.
|
||||||
ICETransportStateNew = iota + 1
|
ICETransportStateNew
|
||||||
|
|
||||||
// ICETransportStateChecking indicates the ICETransport has
|
// ICETransportStateChecking indicates the ICETransport has
|
||||||
// received at least one remote candidate, and a local and remote
|
// received at least one remote candidate, and a local and remote
|
||||||
@@ -63,7 +66,7 @@ func (c ICETransportState) String() string {
|
|||||||
case ICETransportStateClosed:
|
case ICETransportStateClosed:
|
||||||
return "closed"
|
return "closed"
|
||||||
default:
|
default:
|
||||||
return unknownStr
|
return ErrUnknownType.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +87,7 @@ func newICETransportStateFromICE(i ice.ConnectionState) ICETransportState {
|
|||||||
case ice.ConnectionStateClosed:
|
case ice.ConnectionStateClosed:
|
||||||
return ICETransportStateClosed
|
return ICETransportStateClosed
|
||||||
default:
|
default:
|
||||||
return ICETransportState(Unknown)
|
return ICETransportStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +108,6 @@ func (c ICETransportState) toICE() ice.ConnectionState {
|
|||||||
case ICETransportStateClosed:
|
case ICETransportStateClosed:
|
||||||
return ice.ConnectionStateClosed
|
return ice.ConnectionStateClosed
|
||||||
default:
|
default:
|
||||||
return ice.ConnectionState(Unknown)
|
return ice.ConnectionStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ func TestICETransportState_String(t *testing.T) {
|
|||||||
state ICETransportState
|
state ICETransportState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{ICETransportState(Unknown), unknownStr},
|
{ICETransportStateUnknown, ErrUnknownType.Error()},
|
||||||
{ICETransportStateNew, "new"},
|
{ICETransportStateNew, "new"},
|
||||||
{ICETransportStateChecking, "checking"},
|
{ICETransportStateChecking, "checking"},
|
||||||
{ICETransportStateConnected, "connected"},
|
{ICETransportStateConnected, "connected"},
|
||||||
@@ -39,7 +39,7 @@ func TestICETransportState_Convert(t *testing.T) {
|
|||||||
native ICETransportState
|
native ICETransportState
|
||||||
ice ice.ConnectionState
|
ice ice.ConnectionState
|
||||||
}{
|
}{
|
||||||
{ICETransportState(Unknown), ice.ConnectionState(Unknown)},
|
{ICETransportStateUnknown, ice.ConnectionStateUnknown},
|
||||||
{ICETransportStateNew, ice.ConnectionStateNew},
|
{ICETransportStateNew, ice.ConnectionStateNew},
|
||||||
{ICETransportStateChecking, ice.ConnectionStateChecking},
|
{ICETransportStateChecking, ice.ConnectionStateChecking},
|
||||||
{ICETransportStateConnected, ice.ConnectionStateConnected},
|
{ICETransportStateConnected, ice.ConnectionStateConnected},
|
||||||
|
@@ -286,13 +286,12 @@ func (m *MediaEngine) RegisterFeedback(feedback RTCPFeedback, typ RTPCodecType)
|
|||||||
m.mu.Lock()
|
m.mu.Lock()
|
||||||
defer m.mu.Unlock()
|
defer m.mu.Unlock()
|
||||||
|
|
||||||
switch typ {
|
if typ == RTPCodecTypeVideo {
|
||||||
case RTPCodecTypeVideo:
|
|
||||||
for i, v := range m.videoCodecs {
|
for i, v := range m.videoCodecs {
|
||||||
v.RTCPFeedback = append(v.RTCPFeedback, feedback)
|
v.RTCPFeedback = append(v.RTCPFeedback, feedback)
|
||||||
m.videoCodecs[i] = v
|
m.videoCodecs[i] = v
|
||||||
}
|
}
|
||||||
case RTPCodecTypeAudio:
|
} else if typ == RTPCodecTypeAudio {
|
||||||
for i, v := range m.audioCodecs {
|
for i, v := range m.audioCodecs {
|
||||||
v.RTCPFeedback = append(v.RTCPFeedback, feedback)
|
v.RTCPFeedback = append(v.RTCPFeedback, feedback)
|
||||||
m.audioCodecs[i] = v
|
m.audioCodecs[i] = v
|
||||||
|
@@ -22,8 +22,11 @@ func supportedNetworkTypes() []NetworkType {
|
|||||||
type NetworkType int
|
type NetworkType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// NetworkTypeUnknown is the enum's zero-value
|
||||||
|
NetworkTypeUnknown NetworkType = iota
|
||||||
|
|
||||||
// NetworkTypeUDP4 indicates UDP over IPv4.
|
// NetworkTypeUDP4 indicates UDP over IPv4.
|
||||||
NetworkTypeUDP4 NetworkType = iota + 1
|
NetworkTypeUDP4
|
||||||
|
|
||||||
// NetworkTypeUDP6 indicates UDP over IPv6.
|
// NetworkTypeUDP6 indicates UDP over IPv6.
|
||||||
NetworkTypeUDP6
|
NetworkTypeUDP6
|
||||||
@@ -87,7 +90,7 @@ func NewNetworkType(raw string) (NetworkType, error) {
|
|||||||
case networkTypeTCP6Str:
|
case networkTypeTCP6Str:
|
||||||
return NetworkTypeTCP6, nil
|
return NetworkTypeTCP6, nil
|
||||||
default:
|
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:
|
case ice.NetworkTypeTCP6:
|
||||||
return NetworkTypeTCP6, nil
|
return NetworkTypeTCP6, nil
|
||||||
default:
|
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
|
cType NetworkType
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{NetworkType(Unknown), unknownStr},
|
{NetworkTypeUnknown, ErrUnknownType.Error()},
|
||||||
{NetworkTypeUDP4, "udp4"},
|
{NetworkTypeUDP4, "udp4"},
|
||||||
{NetworkTypeUDP6, "udp6"},
|
{NetworkTypeUDP6, "udp6"},
|
||||||
{NetworkTypeTCP4, "tcp4"},
|
{NetworkTypeTCP4, "tcp4"},
|
||||||
@@ -36,7 +36,7 @@ func TestNetworkType(t *testing.T) {
|
|||||||
shouldFail bool
|
shouldFail bool
|
||||||
expectedType NetworkType
|
expectedType NetworkType
|
||||||
}{
|
}{
|
||||||
{unknownStr, true, NetworkType(Unknown)},
|
{ErrUnknownType.Error(), true, NetworkTypeUnknown},
|
||||||
{"udp4", false, NetworkTypeUDP4},
|
{"udp4", false, NetworkTypeUDP4},
|
||||||
{"udp6", false, NetworkTypeUDP6},
|
{"udp6", false, NetworkTypeUDP6},
|
||||||
{"tcp4", false, NetworkTypeTCP4},
|
{"tcp4", false, NetworkTypeTCP4},
|
||||||
|
@@ -225,11 +225,11 @@ func (pc *PeerConnection) initConfiguration(configuration Configuration) error {
|
|||||||
pc.configuration.Certificates = []Certificate{*certificate}
|
pc.configuration.Certificates = []Certificate{*certificate}
|
||||||
}
|
}
|
||||||
|
|
||||||
if configuration.BundlePolicy != BundlePolicy(Unknown) {
|
if configuration.BundlePolicy != BundlePolicyUnknown {
|
||||||
pc.configuration.BundlePolicy = configuration.BundlePolicy
|
pc.configuration.BundlePolicy = configuration.BundlePolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
if configuration.RTCPMuxPolicy != RTCPMuxPolicy(Unknown) {
|
if configuration.RTCPMuxPolicy != RTCPMuxPolicyUnknown {
|
||||||
pc.configuration.RTCPMuxPolicy = configuration.RTCPMuxPolicy
|
pc.configuration.RTCPMuxPolicy = configuration.RTCPMuxPolicy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,13 +237,8 @@ func (pc *PeerConnection) initConfiguration(configuration Configuration) error {
|
|||||||
pc.configuration.ICECandidatePoolSize = configuration.ICECandidatePoolSize
|
pc.configuration.ICECandidatePoolSize = configuration.ICECandidatePoolSize
|
||||||
}
|
}
|
||||||
|
|
||||||
if configuration.ICETransportPolicy != ICETransportPolicy(Unknown) {
|
|
||||||
pc.configuration.ICETransportPolicy = configuration.ICETransportPolicy
|
pc.configuration.ICETransportPolicy = configuration.ICETransportPolicy
|
||||||
}
|
|
||||||
|
|
||||||
if configuration.SDPSemantics != SDPSemantics(Unknown) {
|
|
||||||
pc.configuration.SDPSemantics = configuration.SDPSemantics
|
pc.configuration.SDPSemantics = configuration.SDPSemantics
|
||||||
}
|
|
||||||
|
|
||||||
sanitizedICEServers := configuration.getICEServers()
|
sanitizedICEServers := configuration.getICEServers()
|
||||||
if len(sanitizedICEServers) > 0 {
|
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)
|
// 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 {
|
if configuration.BundlePolicy != pc.configuration.BundlePolicy {
|
||||||
return &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy}
|
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)
|
// 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 {
|
if configuration.RTCPMuxPolicy != pc.configuration.RTCPMuxPolicy {
|
||||||
return &rtcerr.InvalidModificationError{Err: ErrModifyingRTCPMuxPolicy}
|
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)
|
// 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)
|
// https://www.w3.org/TR/webrtc/#set-the-configuration (step #11)
|
||||||
if len(configuration.ICEServers) > 0 {
|
if len(configuration.ICEServers) > 0 {
|
||||||
@@ -879,7 +872,7 @@ func (pc *PeerConnection) setDescription(sd *SessionDescription, op stateChangeO
|
|||||||
switch {
|
switch {
|
||||||
case pc.isClosed.get():
|
case pc.isClosed.get():
|
||||||
return &rtcerr.InvalidStateError{Err: ErrConnectionClosed}
|
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)}
|
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)
|
kind := NewRTPCodecType(media.MediaName.Media)
|
||||||
direction := getPeerDirection(media)
|
direction := getPeerDirection(media)
|
||||||
if kind == 0 || direction == RTPTransceiverDirection(Unknown) {
|
if kind == 0 || direction == RTPTransceiverDirectionUnknown {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1292,7 +1285,7 @@ func setRTPTransceiverCurrentDirection(answer *SessionDescription, currentTransc
|
|||||||
}
|
}
|
||||||
|
|
||||||
direction := getPeerDirection(media)
|
direction := getPeerDirection(media)
|
||||||
if direction == RTPTransceiverDirection(Unknown) {
|
if direction == RTPTransceiverDirectionUnknown {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2432,7 +2425,7 @@ func (pc *PeerConnection) generateMatchedSDP(transceivers []*RTPTransceiver, use
|
|||||||
|
|
||||||
kind := NewRTPCodecType(media.MediaName.Media)
|
kind := NewRTPCodecType(media.MediaName.Media)
|
||||||
direction := getPeerDirection(media)
|
direction := getPeerDirection(media)
|
||||||
if kind == 0 || direction == RTPTransceiverDirection(Unknown) {
|
if kind == 0 || direction == RTPTransceiverDirectionUnknown {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -182,14 +182,14 @@ func (pc *PeerConnection) checkConfiguration(configuration Configuration) error
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// https://www.w3.org/TR/webrtc/#set-the-configuration (step #5)
|
// 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 {
|
if configuration.BundlePolicy != existingConfig.BundlePolicy {
|
||||||
return &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy}
|
return &rtcerr.InvalidModificationError{Err: ErrModifyingBundlePolicy}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/webrtc/#set-the-configuration (step #6)
|
// 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 {
|
if configuration.RTCPMuxPolicy != existingConfig.RTCPMuxPolicy {
|
||||||
return &rtcerr.InvalidModificationError{Err: ErrModifyingRTCPMuxPolicy}
|
return &rtcerr.InvalidModificationError{Err: ErrModifyingRTCPMuxPolicy}
|
||||||
}
|
}
|
||||||
|
@@ -7,11 +7,14 @@ package webrtc
|
|||||||
type PeerConnectionState int
|
type PeerConnectionState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// PeerConnectionStateUnknown is the enum's zero-value
|
||||||
|
PeerConnectionStateUnknown PeerConnectionState = iota
|
||||||
|
|
||||||
// PeerConnectionStateNew indicates that any of the ICETransports or
|
// PeerConnectionStateNew indicates that any of the ICETransports or
|
||||||
// DTLSTransports are in the "new" state and none of the transports are
|
// DTLSTransports are in the "new" state and none of the transports are
|
||||||
// in the "connecting", "checking", "failed" or "disconnected" state, or
|
// in the "connecting", "checking", "failed" or "disconnected" state, or
|
||||||
// all transports are in the "closed" state, or there are no transports.
|
// all transports are in the "closed" state, or there are no transports.
|
||||||
PeerConnectionStateNew PeerConnectionState = iota + 1
|
PeerConnectionStateNew
|
||||||
|
|
||||||
// PeerConnectionStateConnecting indicates that any of the
|
// PeerConnectionStateConnecting indicates that any of the
|
||||||
// ICETransports or DTLSTransports are in the "connecting" or
|
// ICETransports or DTLSTransports are in the "connecting" or
|
||||||
@@ -62,7 +65,7 @@ func newPeerConnectionState(raw string) PeerConnectionState {
|
|||||||
case peerConnectionStateClosedStr:
|
case peerConnectionStateClosedStr:
|
||||||
return PeerConnectionStateClosed
|
return PeerConnectionStateClosed
|
||||||
default:
|
default:
|
||||||
return PeerConnectionState(Unknown)
|
return PeerConnectionStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewPeerConnectionState(t *testing.T) {
|
|||||||
stateString string
|
stateString string
|
||||||
expectedState PeerConnectionState
|
expectedState PeerConnectionState
|
||||||
}{
|
}{
|
||||||
{unknownStr, PeerConnectionState(Unknown)},
|
{ErrUnknownType.Error(), PeerConnectionStateUnknown},
|
||||||
{"new", PeerConnectionStateNew},
|
{"new", PeerConnectionStateNew},
|
||||||
{"connecting", PeerConnectionStateConnecting},
|
{"connecting", PeerConnectionStateConnecting},
|
||||||
{"connected", PeerConnectionStateConnected},
|
{"connected", PeerConnectionStateConnected},
|
||||||
@@ -37,7 +37,7 @@ func TestPeerConnectionState_String(t *testing.T) {
|
|||||||
state PeerConnectionState
|
state PeerConnectionState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{PeerConnectionState(Unknown), unknownStr},
|
{PeerConnectionStateUnknown, ErrUnknownType.Error()},
|
||||||
{PeerConnectionStateNew, "new"},
|
{PeerConnectionStateNew, "new"},
|
||||||
{PeerConnectionStateConnecting, "connecting"},
|
{PeerConnectionStateConnecting, "connecting"},
|
||||||
{PeerConnectionStateConnected, "connected"},
|
{PeerConnectionStateConnected, "connected"},
|
||||||
|
@@ -12,11 +12,14 @@ import (
|
|||||||
type RTCPMuxPolicy int
|
type RTCPMuxPolicy int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// RTCPMuxPolicyUnknown is the enum's zero-value
|
||||||
|
RTCPMuxPolicyUnknown RTCPMuxPolicy = iota
|
||||||
|
|
||||||
// RTCPMuxPolicyNegotiate indicates to gather ICE candidates for both
|
// RTCPMuxPolicyNegotiate indicates to gather ICE candidates for both
|
||||||
// RTP and RTCP candidates. If the remote-endpoint is capable of
|
// RTP and RTCP candidates. If the remote-endpoint is capable of
|
||||||
// multiplexing RTCP, multiplex RTCP on the RTP candidates. If it is not,
|
// multiplexing RTCP, multiplex RTCP on the RTP candidates. If it is not,
|
||||||
// use both the RTP and RTCP candidates separately.
|
// use both the RTP and RTCP candidates separately.
|
||||||
RTCPMuxPolicyNegotiate RTCPMuxPolicy = iota + 1
|
RTCPMuxPolicyNegotiate
|
||||||
|
|
||||||
// RTCPMuxPolicyRequire indicates to gather ICE candidates only for
|
// RTCPMuxPolicyRequire indicates to gather ICE candidates only for
|
||||||
// RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is
|
// RTP and multiplex RTCP on the RTP candidates. If the remote endpoint is
|
||||||
@@ -37,7 +40,7 @@ func newRTCPMuxPolicy(raw string) RTCPMuxPolicy {
|
|||||||
case rtcpMuxPolicyRequireStr:
|
case rtcpMuxPolicyRequireStr:
|
||||||
return RTCPMuxPolicyRequire
|
return RTCPMuxPolicyRequire
|
||||||
default:
|
default:
|
||||||
return RTCPMuxPolicy(Unknown)
|
return RTCPMuxPolicyUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewRTCPMuxPolicy(t *testing.T) {
|
|||||||
policyString string
|
policyString string
|
||||||
expectedPolicy RTCPMuxPolicy
|
expectedPolicy RTCPMuxPolicy
|
||||||
}{
|
}{
|
||||||
{unknownStr, RTCPMuxPolicy(Unknown)},
|
{ErrUnknownType.Error(), RTCPMuxPolicyUnknown},
|
||||||
{"negotiate", RTCPMuxPolicyNegotiate},
|
{"negotiate", RTCPMuxPolicyNegotiate},
|
||||||
{"require", RTCPMuxPolicyRequire},
|
{"require", RTCPMuxPolicyRequire},
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ func TestRTCPMuxPolicy_String(t *testing.T) {
|
|||||||
policy RTCPMuxPolicy
|
policy RTCPMuxPolicy
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{RTCPMuxPolicy(Unknown), unknownStr},
|
{RTCPMuxPolicyUnknown, ErrUnknownType.Error()},
|
||||||
{RTCPMuxPolicyNegotiate, "negotiate"},
|
{RTCPMuxPolicyNegotiate, "negotiate"},
|
||||||
{RTCPMuxPolicyRequire, "require"},
|
{RTCPMuxPolicyRequire, "require"},
|
||||||
}
|
}
|
||||||
|
@@ -13,9 +13,11 @@ import (
|
|||||||
type RTPCodecType int
|
type RTPCodecType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// RTPCodecTypeUnknown is the enum's zero-value
|
||||||
|
RTPCodecTypeUnknown RTPCodecType = iota
|
||||||
|
|
||||||
// RTPCodecTypeAudio indicates this is an audio codec
|
// RTPCodecTypeAudio indicates this is an audio codec
|
||||||
RTPCodecTypeAudio RTPCodecType = iota + 1
|
RTPCodecTypeAudio
|
||||||
|
|
||||||
// RTPCodecTypeVideo indicates this is a video codec
|
// RTPCodecTypeVideo indicates this is a video codec
|
||||||
RTPCodecTypeVideo
|
RTPCodecTypeVideo
|
||||||
|
@@ -42,7 +42,7 @@ func newRTPTransceiver(
|
|||||||
t.setReceiver(receiver)
|
t.setReceiver(receiver)
|
||||||
t.setSender(sender)
|
t.setSender(sender)
|
||||||
t.setDirection(direction)
|
t.setDirection(direction)
|
||||||
t.setCurrentDirection(RTPTransceiverDirection(Unknown))
|
t.setCurrentDirection(RTPTransceiverDirectionUnknown)
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ func (t *RTPTransceiver) getCurrentDirection() RTPTransceiverDirection {
|
|||||||
if v, ok := t.currentDirection.Load().(RTPTransceiverDirection); ok {
|
if v, ok := t.currentDirection.Load().(RTPTransceiverDirection); ok {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
return RTPTransceiverDirection(Unknown)
|
return RTPTransceiverDirectionUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *RTPTransceiver) setSendingTrack(track TrackLocal) error {
|
func (t *RTPTransceiver) setSendingTrack(track TrackLocal) error {
|
||||||
|
@@ -7,9 +7,12 @@ package webrtc
|
|||||||
type RTPTransceiverDirection int
|
type RTPTransceiverDirection int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// RTPTransceiverDirectionUnknown is the enum's zero-value
|
||||||
|
RTPTransceiverDirectionUnknown RTPTransceiverDirection = iota
|
||||||
|
|
||||||
// RTPTransceiverDirectionSendrecv indicates the RTPSender will offer
|
// RTPTransceiverDirectionSendrecv indicates the RTPSender will offer
|
||||||
// to send RTP and the RTPReceiver will offer to receive RTP.
|
// to send RTP and the RTPReceiver will offer to receive RTP.
|
||||||
RTPTransceiverDirectionSendrecv RTPTransceiverDirection = iota + 1
|
RTPTransceiverDirectionSendrecv
|
||||||
|
|
||||||
// RTPTransceiverDirectionSendonly indicates the RTPSender will offer
|
// RTPTransceiverDirectionSendonly indicates the RTPSender will offer
|
||||||
// to send RTP.
|
// to send RTP.
|
||||||
@@ -45,7 +48,7 @@ func NewRTPTransceiverDirection(raw string) RTPTransceiverDirection {
|
|||||||
case rtpTransceiverDirectionInactiveStr:
|
case rtpTransceiverDirectionInactiveStr:
|
||||||
return RTPTransceiverDirectionInactive
|
return RTPTransceiverDirectionInactive
|
||||||
default:
|
default:
|
||||||
return RTPTransceiverDirection(Unknown)
|
return RTPTransceiverDirectionUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewRTPTransceiverDirection(t *testing.T) {
|
|||||||
directionString string
|
directionString string
|
||||||
expectedDirection RTPTransceiverDirection
|
expectedDirection RTPTransceiverDirection
|
||||||
}{
|
}{
|
||||||
{unknownStr, RTPTransceiverDirection(Unknown)},
|
{ErrUnknownType.Error(), RTPTransceiverDirectionUnknown},
|
||||||
{"sendrecv", RTPTransceiverDirectionSendrecv},
|
{"sendrecv", RTPTransceiverDirectionSendrecv},
|
||||||
{"sendonly", RTPTransceiverDirectionSendonly},
|
{"sendonly", RTPTransceiverDirectionSendonly},
|
||||||
{"recvonly", RTPTransceiverDirectionRecvonly},
|
{"recvonly", RTPTransceiverDirectionRecvonly},
|
||||||
@@ -35,7 +35,7 @@ func TestRTPTransceiverDirection_String(t *testing.T) {
|
|||||||
direction RTPTransceiverDirection
|
direction RTPTransceiverDirection
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{RTPTransceiverDirection(Unknown), unknownStr},
|
{RTPTransceiverDirectionUnknown, ErrUnknownType.Error()},
|
||||||
{RTPTransceiverDirectionSendrecv, "sendrecv"},
|
{RTPTransceiverDirectionSendrecv, "sendrecv"},
|
||||||
{RTPTransceiverDirectionSendonly, "sendonly"},
|
{RTPTransceiverDirectionSendonly, "sendonly"},
|
||||||
{RTPTransceiverDirectionRecvonly, "recvonly"},
|
{RTPTransceiverDirectionRecvonly, "recvonly"},
|
||||||
|
@@ -7,10 +7,13 @@ package webrtc
|
|||||||
type SCTPTransportState int
|
type SCTPTransportState int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// SCTPTransportStateUnknown is the enum's zero-value
|
||||||
|
SCTPTransportStateUnknown SCTPTransportState = iota
|
||||||
|
|
||||||
// SCTPTransportStateConnecting indicates the SCTPTransport is in the
|
// SCTPTransportStateConnecting indicates the SCTPTransport is in the
|
||||||
// process of negotiating an association. This is the initial state of the
|
// process of negotiating an association. This is the initial state of the
|
||||||
// SCTPTransportState when an SCTPTransport is created.
|
// SCTPTransportState when an SCTPTransport is created.
|
||||||
SCTPTransportStateConnecting SCTPTransportState = iota + 1
|
SCTPTransportStateConnecting
|
||||||
|
|
||||||
// SCTPTransportStateConnected indicates the negotiation of an
|
// SCTPTransportStateConnected indicates the negotiation of an
|
||||||
// association is completed.
|
// association is completed.
|
||||||
@@ -39,7 +42,7 @@ func newSCTPTransportState(raw string) SCTPTransportState {
|
|||||||
case sctpTransportStateClosedStr:
|
case sctpTransportStateClosedStr:
|
||||||
return SCTPTransportStateClosed
|
return SCTPTransportStateClosed
|
||||||
default:
|
default:
|
||||||
return SCTPTransportState(Unknown)
|
return SCTPTransportStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewSCTPTransportState(t *testing.T) {
|
|||||||
transportStateString string
|
transportStateString string
|
||||||
expectedTransportState SCTPTransportState
|
expectedTransportState SCTPTransportState
|
||||||
}{
|
}{
|
||||||
{unknownStr, SCTPTransportState(Unknown)},
|
{ErrUnknownType.Error(), SCTPTransportStateUnknown},
|
||||||
{"connecting", SCTPTransportStateConnecting},
|
{"connecting", SCTPTransportStateConnecting},
|
||||||
{"connected", SCTPTransportStateConnected},
|
{"connected", SCTPTransportStateConnected},
|
||||||
{"closed", SCTPTransportStateClosed},
|
{"closed", SCTPTransportStateClosed},
|
||||||
@@ -34,7 +34,7 @@ func TestSCTPTransportState_String(t *testing.T) {
|
|||||||
transportState SCTPTransportState
|
transportState SCTPTransportState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{SCTPTransportState(Unknown), unknownStr},
|
{SCTPTransportStateUnknown, ErrUnknownType.Error()},
|
||||||
{SCTPTransportStateConnecting, "connecting"},
|
{SCTPTransportStateConnecting, "connecting"},
|
||||||
{SCTPTransportStateConnected, "connected"},
|
{SCTPTransportStateConnected, "connected"},
|
||||||
{SCTPTransportStateClosed, "closed"},
|
{SCTPTransportStateClosed, "closed"},
|
||||||
|
4
sdp.go
4
sdp.go
@@ -653,11 +653,11 @@ func descriptionPossiblyPlanB(desc *SessionDescription) bool {
|
|||||||
|
|
||||||
func getPeerDirection(media *sdp.MediaDescription) RTPTransceiverDirection {
|
func getPeerDirection(media *sdp.MediaDescription) RTPTransceiverDirection {
|
||||||
for _, a := range media.Attributes {
|
for _, a := range media.Attributes {
|
||||||
if direction := NewRTPTransceiverDirection(a.Key); direction != RTPTransceiverDirection(Unknown) {
|
if direction := NewRTPTransceiverDirection(a.Key); direction != RTPTransceiverDirectionUnknown {
|
||||||
return direction
|
return direction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RTPTransceiverDirection(Unknown)
|
return RTPTransceiverDirectionUnknown
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractFingerprint(desc *sdp.SessionDescription) (string, string, error) {
|
func extractFingerprint(desc *sdp.SessionDescription) (string, string, error) {
|
||||||
|
@@ -36,14 +36,12 @@ const (
|
|||||||
|
|
||||||
func newSDPSemantics(raw string) SDPSemantics {
|
func newSDPSemantics(raw string) SDPSemantics {
|
||||||
switch raw {
|
switch raw {
|
||||||
case sdpSemanticsUnifiedPlan:
|
|
||||||
return SDPSemanticsUnifiedPlan
|
|
||||||
case sdpSemanticsPlanB:
|
case sdpSemanticsPlanB:
|
||||||
return SDPSemanticsPlanB
|
return SDPSemanticsPlanB
|
||||||
case sdpSemanticsUnifiedPlanWithFallback:
|
case sdpSemanticsUnifiedPlanWithFallback:
|
||||||
return SDPSemanticsUnifiedPlanWithFallback
|
return SDPSemanticsUnifiedPlanWithFallback
|
||||||
default:
|
default:
|
||||||
return SDPSemantics(Unknown)
|
return SDPSemanticsUnifiedPlan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ func TestSDPSemantics_String(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t,
|
assert.Equal(t,
|
||||||
unknownStr,
|
ErrUnknownType.Error(),
|
||||||
SDPSemantics(42).String(),
|
SDPSemantics(42).String(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
10
sdptype.go
10
sdptype.go
@@ -12,9 +12,11 @@ import (
|
|||||||
type SDPType int
|
type SDPType int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// SDPTypeOffer indicates that a description MUST be treated as an SDP
|
// SDPTypeUnknown is the enum's zero-value
|
||||||
// offer.
|
SDPTypeUnknown SDPType = iota
|
||||||
SDPTypeOffer SDPType = iota + 1
|
|
||||||
|
// SDPTypeOffer indicates that a description MUST be treated as an SDP offer.
|
||||||
|
SDPTypeOffer
|
||||||
|
|
||||||
// SDPTypePranswer indicates that a description MUST be treated as an
|
// SDPTypePranswer indicates that a description MUST be treated as an
|
||||||
// SDP answer, but not a final answer. A description used as an SDP
|
// SDP answer, but not a final answer. A description used as an SDP
|
||||||
@@ -56,7 +58,7 @@ func NewSDPType(raw string) SDPType {
|
|||||||
case sdpTypeRollbackStr:
|
case sdpTypeRollbackStr:
|
||||||
return SDPTypeRollback
|
return SDPTypeRollback
|
||||||
default:
|
default:
|
||||||
return SDPType(Unknown)
|
return SDPTypeUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ func TestNewSDPType(t *testing.T) {
|
|||||||
sdpTypeString string
|
sdpTypeString string
|
||||||
expectedSDPType SDPType
|
expectedSDPType SDPType
|
||||||
}{
|
}{
|
||||||
{unknownStr, SDPType(Unknown)},
|
{ErrUnknownType.Error(), SDPTypeUnknown},
|
||||||
{"offer", SDPTypeOffer},
|
{"offer", SDPTypeOffer},
|
||||||
{"pranswer", SDPTypePranswer},
|
{"pranswer", SDPTypePranswer},
|
||||||
{"answer", SDPTypeAnswer},
|
{"answer", SDPTypeAnswer},
|
||||||
@@ -35,7 +35,7 @@ func TestSDPType_String(t *testing.T) {
|
|||||||
sdpType SDPType
|
sdpType SDPType
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{SDPType(Unknown), unknownStr},
|
{SDPTypeUnknown, ErrUnknownType.Error()},
|
||||||
{SDPTypeOffer, "offer"},
|
{SDPTypeOffer, "offer"},
|
||||||
{SDPTypePranswer, "pranswer"},
|
{SDPTypePranswer, "pranswer"},
|
||||||
{SDPTypeAnswer, "answer"},
|
{SDPTypeAnswer, "answer"},
|
||||||
|
@@ -21,7 +21,7 @@ func TestSessionDescription_JSON(t *testing.T) {
|
|||||||
{SessionDescription{Type: SDPTypePranswer, SDP: "sdp"}, `{"type":"pranswer","sdp":"sdp"}`, nil},
|
{SessionDescription{Type: SDPTypePranswer, SDP: "sdp"}, `{"type":"pranswer","sdp":"sdp"}`, nil},
|
||||||
{SessionDescription{Type: SDPTypeAnswer, SDP: "sdp"}, `{"type":"answer","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: 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 {
|
for i, testCase := range testCases {
|
||||||
|
@@ -32,10 +32,13 @@ func (op stateChangeOp) String() string {
|
|||||||
type SignalingState int32
|
type SignalingState int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// SignalingStateUnknown is the enum's zero-value
|
||||||
|
SignalingStateUnknown SignalingState = iota
|
||||||
|
|
||||||
// SignalingStateStable indicates there is no offer/answer exchange in
|
// SignalingStateStable indicates there is no offer/answer exchange in
|
||||||
// progress. This is also the initial state, in which case the local and
|
// progress. This is also the initial state, in which case the local and
|
||||||
// remote descriptions are nil.
|
// remote descriptions are nil.
|
||||||
SignalingStateStable SignalingState = iota + 1
|
SignalingStateStable
|
||||||
|
|
||||||
// SignalingStateHaveLocalOffer indicates that a local description, of
|
// SignalingStateHaveLocalOffer indicates that a local description, of
|
||||||
// type "offer", has been successfully applied.
|
// type "offer", has been successfully applied.
|
||||||
@@ -84,7 +87,7 @@ func newSignalingState(raw string) SignalingState {
|
|||||||
case signalingStateClosedStr:
|
case signalingStateClosedStr:
|
||||||
return SignalingStateClosed
|
return SignalingStateClosed
|
||||||
default:
|
default:
|
||||||
return SignalingState(Unknown)
|
return SignalingStateUnknown
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ func TestNewSignalingState(t *testing.T) {
|
|||||||
stateString string
|
stateString string
|
||||||
expectedState SignalingState
|
expectedState SignalingState
|
||||||
}{
|
}{
|
||||||
{unknownStr, SignalingState(Unknown)},
|
{ErrUnknownType.Error(), SignalingStateUnknown},
|
||||||
{"stable", SignalingStateStable},
|
{"stable", SignalingStateStable},
|
||||||
{"have-local-offer", SignalingStateHaveLocalOffer},
|
{"have-local-offer", SignalingStateHaveLocalOffer},
|
||||||
{"have-remote-offer", SignalingStateHaveRemoteOffer},
|
{"have-remote-offer", SignalingStateHaveRemoteOffer},
|
||||||
@@ -38,7 +38,7 @@ func TestSignalingState_String(t *testing.T) {
|
|||||||
state SignalingState
|
state SignalingState
|
||||||
expectedString string
|
expectedString string
|
||||||
}{
|
}{
|
||||||
{SignalingState(Unknown), unknownStr},
|
{SignalingStateUnknown, ErrUnknownType.Error()},
|
||||||
{SignalingStateStable, "stable"},
|
{SignalingStateStable, "stable"},
|
||||||
{SignalingStateHaveLocalOffer, "have-local-offer"},
|
{SignalingStateHaveLocalOffer, "have-local-offer"},
|
||||||
{SignalingStateHaveRemoteOffer, "have-remote-offer"},
|
{SignalingStateHaveRemoteOffer, "have-remote-offer"},
|
||||||
|
Reference in New Issue
Block a user