Skip to content

Commit

Permalink
Unexport RTC State, Type and Policy structures
Browse files Browse the repository at this point in the history
Modify RTCSdpType to protect newRTCSdpType
Modify RTCPriorityType to protect methods
Modify RTCSctpTransportState to protect methods
Modify RTCRtcpMuxPolicy to protect methods
Modify RTCPeerConnectionState to protect methods
Modify RTCIceTransportPolicy to protect methods
Modify RTCIceGatheringState to protect methods
Modify RTCIceCredentialType to protect methods
Modify RTCIceConnectionState to protect methods
Modify RTCDtlsTransportState to protect methods
Modify RTCDataChannelState to protect methods
Modify RTCBundlePolicy to protect methods

Relates to #83
  • Loading branch information
trivigy committed Sep 14, 2018
1 parent 9a1a1f9 commit ffbf0aa
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 70 deletions.
4 changes: 1 addition & 3 deletions rtcbundlepolicy.go
Expand Up @@ -31,9 +31,7 @@ const (
rtcBundlePolicyMaxBundleStr = "max-bundle"
)

// NewRTCBundlePolicy defines a procedure for creating a new RTCBundlePolicy
// from a raw string naming the bundle policy.
func NewRTCBundlePolicy(raw string) RTCBundlePolicy {
func newRTCBundlePolicy(raw string) RTCBundlePolicy {
switch raw {
case rtcBundlePolicyBalancedStr:
return RTCBundlePolicyBalanced
Expand Down
4 changes: 2 additions & 2 deletions rtcbundlepolicy_test.go
Expand Up @@ -19,8 +19,8 @@ func TestNewRTCBundlePolicy(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCBundlePolicy(testCase.policyString),
testCase.expectedPolicy,
newRTCBundlePolicy(testCase.policyString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -39,8 +39,8 @@ func TestRTCBundlePolicy_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.policy.String(),
testCase.expectedString,
testCase.policy.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcdatachannelstate.go
Expand Up @@ -30,9 +30,7 @@ const (
rtcDataChannelStateClosedStr = "closed"
)

// NewRTCDataChannelState defines a procedure for creating a new
// RTCDataChannelState from a raw string naming the data chanenel state.
func NewRTCDataChannelState(raw string) RTCDataChannelState {
func newRTCDataChannelState(raw string) RTCDataChannelState {
switch raw {
case rtcDataChannelStateConnectingStr:
return RTCDataChannelStateConnecting
Expand Down
4 changes: 2 additions & 2 deletions rtcdatachannelstate_test.go
Expand Up @@ -20,8 +20,8 @@ func TestNewRTCDataChannelState(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCDataChannelState(testCase.stateString),
testCase.expectedState,
newRTCDataChannelState(testCase.stateString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -41,8 +41,8 @@ func TestRTCDataChannelState_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.state.String(),
testCase.expectedString,
testCase.state.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcdtlstransportstate.go
Expand Up @@ -36,9 +36,7 @@ const (
rtcDtlsTransportStateFailedStr = "failed"
)

// NewRTCDtlsTransportState defines a procedure for creating a new
// RTCDtlsTransportState from a raw string naming the transport state.
func NewRTCDtlsTransportState(raw string) RTCDtlsTransportState {
func newRTCDtlsTransportState(raw string) RTCDtlsTransportState {
switch raw {
case rtcDtlsTransportStateNewStr:
return RTCDtlsTransportStateNew
Expand Down
4 changes: 2 additions & 2 deletions rtcdtlstransportstate_test.go
Expand Up @@ -21,8 +21,8 @@ func TestNewRTCDtlsTransportState(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCDtlsTransportState(testCase.stateString),
testCase.expectedState,
newRTCDtlsTransportState(testCase.stateString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -43,8 +43,8 @@ func TestRTCDtlsTransportState_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.state.String(),
testCase.expectedString,
testCase.state.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtciceconnectionstate.go
Expand Up @@ -50,9 +50,7 @@ const (
rtcIceConnectionStateClosedStr = "closed"
)

// NewRTCIceConnectionState defines a procedure for creating a new
// RTCIceConnectionState from a raw string naming the signaling state.
func NewRTCIceConnectionState(raw string) RTCIceConnectionState {
func newRTCIceConnectionState(raw string) RTCIceConnectionState {
switch raw {
case rtcIceConnectionStateNewStr:
return RTCIceConnectionStateNew
Expand Down
4 changes: 2 additions & 2 deletions rtciceconnectionstate_test.go
Expand Up @@ -23,8 +23,8 @@ func TestNewRTCIceConnectionState(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCIceConnectionState(testCase.stateString),
testCase.expectedState,
newRTCIceConnectionState(testCase.stateString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -47,8 +47,8 @@ func TestRTCIceConnectionState_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.state.String(),
testCase.expectedString,
testCase.state.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcicecredentialtype.go
Expand Up @@ -20,9 +20,7 @@ const (
rtcIceCredentialTypeOauthStr = "oauth"
)

// NewRTCIceCredentialType defines a procedure for creating a new
// RTCIceCredentialType from a raw string naming the ice credential type.
func NewRTCIceCredentialType(raw string) RTCIceCredentialType {
func newRTCIceCredentialType(raw string) RTCIceCredentialType {
switch raw {
case rtcIceCredentialTypePasswordStr:
return RTCIceCredentialTypePassword
Expand Down
4 changes: 2 additions & 2 deletions rtcicecredentialtype_test.go
Expand Up @@ -18,8 +18,8 @@ func TestNewRTCIceCredentialType(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCIceCredentialType(testCase.credentialTypeString),
testCase.expectedCredentialType,
newRTCIceCredentialType(testCase.credentialTypeString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -37,8 +37,8 @@ func TestRTCIceCredentialType_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.credentialType.String(),
testCase.expectedString,
testCase.credentialType.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcicegatheringstate.go
Expand Up @@ -25,9 +25,7 @@ const (
rtcIceGatheringStateCompleteStr = "complete"
)

// NewRTCIceGatheringState defines a procedure for creating a new
// RTCIceGatheringState from a raw string naming the gathering state.
func NewRTCIceGatheringState(raw string) RTCIceGatheringState {
func newRTCIceGatheringState(raw string) RTCIceGatheringState {
switch raw {
case rtcIceGatheringStateNewStr:
return RTCIceGatheringStateNew
Expand Down
4 changes: 2 additions & 2 deletions rtcicegatheringstate_test.go
Expand Up @@ -19,8 +19,8 @@ func TestNewRTCIceGatheringState(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCIceGatheringState(testCase.stateString),
testCase.expectedState,
newRTCIceGatheringState(testCase.stateString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -39,8 +39,8 @@ func TestRTCIceGatheringState_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.state.String(),
testCase.expectedString,
testCase.state.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcicetransportpolicy.go
Expand Up @@ -19,9 +19,7 @@ const (
rtcIceTransportPolicyAllStr = "all"
)

// NewRTCIceTransportPolicy defines a procedure for creating a new
// RTCIceTransportPolicy from a raw string naming the ice transport policy.
func NewRTCIceTransportPolicy(raw string) RTCIceTransportPolicy {
func newRTCIceTransportPolicy(raw string) RTCIceTransportPolicy {
switch raw {
case rtcIceTransportPolicyRelayStr:
return RTCIceTransportPolicyRelay
Expand Down
4 changes: 2 additions & 2 deletions rtcicetransportpolicy_test.go
Expand Up @@ -18,8 +18,8 @@ func TestNewRTCIceTransportPolicy(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCIceTransportPolicy(testCase.policyString),
testCase.expectedPolicy,
newRTCIceTransportPolicy(testCase.policyString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -37,8 +37,8 @@ func TestRTCIceTransportPolicy_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.policy.String(),
testCase.expectedString,
testCase.policy.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcpeerconnectionstate.go
Expand Up @@ -44,9 +44,7 @@ const (
rtcPeerConnectionStateClosedStr = "closed"
)

// NewRTCPeerConnectionState defines a procedure for creating a new
// RTCPeerConnectionState from a raw string naming the peer connection state.
func NewRTCPeerConnectionState(raw string) RTCPeerConnectionState {
func newRTCPeerConnectionState(raw string) RTCPeerConnectionState {
switch raw {
case rtcPeerConnectionStateNewStr:
return RTCPeerConnectionStateNew
Expand Down
4 changes: 2 additions & 2 deletions rtcpeerconnectionstate_test.go
Expand Up @@ -22,8 +22,8 @@ func TestNewRTCPeerConnectionState(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCPeerConnectionState(testCase.stateString),
testCase.expectedState,
newRTCPeerConnectionState(testCase.stateString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -45,8 +45,8 @@ func TestRTCPeerConnectionState_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.state.String(),
testCase.expectedString,
testCase.state.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
19 changes: 16 additions & 3 deletions rtcprioritytype.go
Expand Up @@ -25,9 +25,7 @@ const (
rtcPriorityTypeHighStr = "high"
)

// NewRTCPriorityType defines a procedure for creating a new RTCPriorityType
// from a raw string naming the priority type.
func NewRTCPriorityType(raw string) RTCPriorityType {
func newRTCPriorityTypeFromString(raw string) RTCPriorityType {
switch raw {
case rtcPriorityTypeVeryLowStr:
return RTCPriorityTypeVeryLow
Expand All @@ -42,6 +40,21 @@ func NewRTCPriorityType(raw string) RTCPriorityType {
}
}

func newRTCPriorityTypeFromUint16(raw uint16) RTCPriorityType {
switch {
case raw <= 128:
return RTCPriorityTypeVeryLow
case 129 <= raw && raw <= 256:
return RTCPriorityTypeLow
case 257 <= raw && raw <= 512:
return RTCPriorityTypeMedium
case 513 <= raw:
return RTCPriorityTypeHigh
default:
return RTCPriorityType(Unknown)
}
}

func (p RTCPriorityType) String() string {
switch p {
case RTCPriorityTypeVeryLow:
Expand Down
26 changes: 19 additions & 7 deletions rtcprioritytype_test.go
Expand Up @@ -9,19 +9,31 @@ import (
func TestNewRTCPriorityType(t *testing.T) {
testCases := []struct {
priorityString string
priorityUint16 uint16
expectedPriority RTCPriorityType
}{
{"unknown", RTCPriorityType(Unknown)},
{"very-low", RTCPriorityTypeVeryLow},
{"low", RTCPriorityTypeLow},
{"medium", RTCPriorityTypeMedium},
{"high", RTCPriorityTypeHigh},
{"unknown", 0, RTCPriorityType(Unknown)},
{"very-low", 100, RTCPriorityTypeVeryLow},
{"low", 200, RTCPriorityTypeLow},
{"medium", 300, RTCPriorityTypeMedium},
{"high", 1000, RTCPriorityTypeHigh},
}

for i, testCase := range testCases {
assert.Equal(t,
NewRTCPriorityType(testCase.priorityString),
testCase.expectedPriority,
newRTCPriorityTypeFromString(testCase.priorityString),
"testCase: %d %v", i, testCase,
)

// There is no uint that produces generate RTCPriorityType(Unknown).
if i == 0 {
continue
}

assert.Equal(t,
testCase.expectedPriority,
newRTCPriorityTypeFromUint16(testCase.priorityUint16),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -41,8 +53,8 @@ func TestRTCPriorityType_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.priority.String(),
testCase.expectedString,
testCase.priority.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcrtcpmuxpolicy.go
Expand Up @@ -23,9 +23,7 @@ const (
rtcRtcpMuxPolicyRequireStr = "require"
)

// NewRTCRtcpMuxPolicy defines a procedure for creating a new RTCRtcpMuxPolicy
// from a raw string naming the rtcp multiplexing policy.
func NewRTCRtcpMuxPolicy(raw string) RTCRtcpMuxPolicy {
func newRTCRtcpMuxPolicy(raw string) RTCRtcpMuxPolicy {
switch raw {
case rtcRtcpMuxPolicyNegotiateStr:
return RTCRtcpMuxPolicyNegotiate
Expand Down
4 changes: 2 additions & 2 deletions rtcrtcpmuxpolicy_test.go
Expand Up @@ -18,8 +18,8 @@ func TestNewRTCRtcpMuxPolicy(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCRtcpMuxPolicy(testCase.policyString),
testCase.expectedPolicy,
newRTCRtcpMuxPolicy(testCase.policyString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -37,8 +37,8 @@ func TestRTCRtcpMuxPolicy_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.policy.String(),
testCase.expectedString,
testCase.policy.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down
4 changes: 1 addition & 3 deletions rtcsctptransportstate.go
Expand Up @@ -27,9 +27,7 @@ const (
rtcSctpTransportStateClosedStr = "closed"
)

// NewRTCSctpTransportState defines a procedure for creating a new
// RTCSctpTransportState from a raw string naming the transport state.
func NewRTCSctpTransportState(raw string) RTCSctpTransportState {
func newRTCSctpTransportState(raw string) RTCSctpTransportState {
switch raw {
case rtcSctpTransportStateConnectingStr:
return RTCSctpTransportStateConnecting
Expand Down
4 changes: 2 additions & 2 deletions rtcsctptransportstate_test.go
Expand Up @@ -19,8 +19,8 @@ func TestNewRTCSctpTransportState(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
NewRTCSctpTransportState(testCase.transportStateString),
testCase.expectedTransportState,
newRTCSctpTransportState(testCase.transportStateString),
"testCase: %d %v", i, testCase,
)
}
Expand All @@ -39,8 +39,8 @@ func TestRTCSctpTransportState_String(t *testing.T) {

for i, testCase := range testCases {
assert.Equal(t,
testCase.transportState.String(),
testCase.expectedString,
testCase.transportState.String(),
"testCase: %d %v", i, testCase,
)
}
Expand Down

0 comments on commit ffbf0aa

Please sign in to comment.