From d54b49429206ccae317b92f3668af8b980731ad0 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Thu, 26 Sep 2019 01:07:42 -0700 Subject: [PATCH] Remove RTCDataChannel priority This has been removed from webrtc-pc[0] Relates to #748 [0] https://github.com/w3c/webrtc-pc/issues/2258 --- datachannel.go | 10 ----- datachannel_go_test.go | 2 - datachannel_js.go | 5 --- datachannelinit.go | 3 -- prioritytype.go | 71 --------------------------------- prioritytype_test.go | 61 ---------------------------- rtptransceiverdirection_test.go | 12 +++--- stats.go | 3 -- 8 files changed, 6 insertions(+), 161 deletions(-) delete mode 100644 prioritytype.go delete mode 100644 prioritytype_test.go diff --git a/datachannel.go b/datachannel.go index 3194fa26..4c52b68d 100644 --- a/datachannel.go +++ b/datachannel.go @@ -30,7 +30,6 @@ type DataChannel struct { protocol string negotiated bool id *uint16 - priority PriorityType readyState DataChannelState bufferedAmountLowThreshold uint64 @@ -453,15 +452,6 @@ func (d *DataChannel) ID() *uint16 { return d.id } -// Priority represents the priority for this DataChannel. The priority is -// assigned at channel creation time. -func (d *DataChannel) Priority() PriorityType { - d.mu.RLock() - defer d.mu.RUnlock() - - return d.priority -} - // ReadyState represents the state of the DataChannel object. func (d *DataChannel) ReadyState() DataChannelState { d.mu.RLock() diff --git a/datachannel_go_test.go b/datachannel_go_test.go index 082445b2..45b7395f 100644 --- a/datachannel_go_test.go +++ b/datachannel_go_test.go @@ -189,13 +189,11 @@ func TestDataChannelParamters_Go(t *testing.T) { dc.label = "mylabel" dc.protocol = "myprotocol" dc.negotiated = true - dc.priority = PriorityTypeMedium assert.Equal(t, dc.id, dc.ID(), "should match") assert.Equal(t, dc.label, dc.Label(), "should match") assert.Equal(t, dc.protocol, dc.Protocol(), "should match") assert.Equal(t, dc.negotiated, dc.Negotiated(), "should match") - assert.Equal(t, dc.priority, dc.Priority(), "should match") assert.Equal(t, dc.readyState, dc.ReadyState(), "should match") assert.Equal(t, uint64(0), dc.BufferedAmount(), "should match") dc.SetBufferedAmountLowThreshold(1500) diff --git a/datachannel_js.go b/datachannel_js.go index c82f9e7d..f90ba39d 100644 --- a/datachannel_js.go +++ b/datachannel_js.go @@ -207,11 +207,6 @@ func (d *DataChannel) ID() *uint16 { return valueToUint16Pointer(d.underlying.Get("id")) } -// NOTE(albrow): Apparently not part of the JavaScript WebRTC API -// // Priority represents the priority for this DataChannel. The priority is -// // assigned at channel creation time. -// Priority PriorityType - // ReadyState represents the state of the DataChannel object. func (d *DataChannel) ReadyState() DataChannelState { return newDataChannelState(d.underlying.Get("readyState").String()) diff --git a/datachannelinit.go b/datachannelinit.go index eeb49a22..a4320e46 100644 --- a/datachannelinit.go +++ b/datachannelinit.go @@ -30,7 +30,4 @@ type DataChannelInit struct { // ID overrides the default selection of ID for this channel. ID *uint16 - - // Priority describes the priority of this channel. - Priority *PriorityType } diff --git a/prioritytype.go b/prioritytype.go deleted file mode 100644 index df34fc7a..00000000 --- a/prioritytype.go +++ /dev/null @@ -1,71 +0,0 @@ -package webrtc - -// PriorityType determines the priority type of a data channel. -type PriorityType int - -const ( - // PriorityTypeVeryLow corresponds to "below normal". - PriorityTypeVeryLow PriorityType = iota + 1 - - // PriorityTypeLow corresponds to "normal". - PriorityTypeLow - - // PriorityTypeMedium corresponds to "high". - PriorityTypeMedium - - // PriorityTypeHigh corresponds to "extra high". - PriorityTypeHigh -) - -// This is done this way because of a linter. -const ( - priorityTypeVeryLowStr = "very-low" - priorityTypeLowStr = "low" - priorityTypeMediumStr = "medium" - priorityTypeHighStr = "high" -) - -func newPriorityTypeFromString(raw string) PriorityType { - switch raw { - case priorityTypeVeryLowStr: - return PriorityTypeVeryLow - case priorityTypeLowStr: - return PriorityTypeLow - case priorityTypeMediumStr: - return PriorityTypeMedium - case priorityTypeHighStr: - return PriorityTypeHigh - default: - return PriorityType(Unknown) - } -} - -func newPriorityTypeFromUint16(raw uint16) PriorityType { - switch { - case raw <= 128: - return PriorityTypeVeryLow - case 129 <= raw && raw <= 256: - return PriorityTypeLow - case 257 <= raw && raw <= 512: - return PriorityTypeMedium - case 513 <= raw: - return PriorityTypeHigh - default: - return PriorityType(Unknown) - } -} - -func (p PriorityType) String() string { - switch p { - case PriorityTypeVeryLow: - return priorityTypeVeryLowStr - case PriorityTypeLow: - return priorityTypeLowStr - case PriorityTypeMedium: - return priorityTypeMediumStr - case PriorityTypeHigh: - return priorityTypeHighStr - default: - return ErrUnknownType.Error() - } -} diff --git a/prioritytype_test.go b/prioritytype_test.go deleted file mode 100644 index a199cc50..00000000 --- a/prioritytype_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package webrtc - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestNewPriorityType(t *testing.T) { - testCases := []struct { - priorityString string - priorityUint16 uint16 - expectedPriority PriorityType - }{ - {unknownStr, 0, PriorityType(Unknown)}, - {"very-low", 100, PriorityTypeVeryLow}, - {"low", 200, PriorityTypeLow}, - {"medium", 300, PriorityTypeMedium}, - {"high", 1000, PriorityTypeHigh}, - } - - for i, testCase := range testCases { - assert.Equal(t, - testCase.expectedPriority, - newPriorityTypeFromString(testCase.priorityString), - "testCase: %d %v", i, testCase, - ) - - // There is no uint that produces generate PriorityType(Unknown). - if i == 0 { - continue - } - - assert.Equal(t, - testCase.expectedPriority, - newPriorityTypeFromUint16(testCase.priorityUint16), - "testCase: %d %v", i, testCase, - ) - } -} - -func TestPriorityType_String(t *testing.T) { - testCases := []struct { - priority PriorityType - expectedString string - }{ - {PriorityType(Unknown), unknownStr}, - {PriorityTypeVeryLow, "very-low"}, - {PriorityTypeLow, "low"}, - {PriorityTypeMedium, "medium"}, - {PriorityTypeHigh, "high"}, - } - - for i, testCase := range testCases { - assert.Equal(t, - testCase.expectedString, - testCase.priority.String(), - "testCase: %d %v", i, testCase, - ) - } -} diff --git a/rtptransceiverdirection_test.go b/rtptransceiverdirection_test.go index bffdef97..01dddb3d 100644 --- a/rtptransceiverdirection_test.go +++ b/rtptransceiverdirection_test.go @@ -8,8 +8,8 @@ import ( func TestNewRTPTransceiverDirection(t *testing.T) { testCases := []struct { - priorityString string - expectedPriority RTPTransceiverDirection + directionString string + expectedDirection RTPTransceiverDirection }{ {unknownStr, RTPTransceiverDirection(Unknown)}, {"sendrecv", RTPTransceiverDirectionSendrecv}, @@ -20,8 +20,8 @@ func TestNewRTPTransceiverDirection(t *testing.T) { for i, testCase := range testCases { assert.Equal(t, - NewRTPTransceiverDirection(testCase.priorityString), - testCase.expectedPriority, + NewRTPTransceiverDirection(testCase.directionString), + testCase.expectedDirection, "testCase: %d %v", i, testCase, ) } @@ -29,7 +29,7 @@ func TestNewRTPTransceiverDirection(t *testing.T) { func TestRTPTransceiverDirection_String(t *testing.T) { testCases := []struct { - priority RTPTransceiverDirection + direction RTPTransceiverDirection expectedString string }{ {RTPTransceiverDirection(Unknown), unknownStr}, @@ -41,7 +41,7 @@ func TestRTPTransceiverDirection_String(t *testing.T) { for i, testCase := range testCases { assert.Equal(t, - testCase.priority.String(), + testCase.direction.String(), testCase.expectedString, "testCase: %d %v", i, testCase, ) diff --git a/stats.go b/stats.go index aa55333e..7cf8508e 100644 --- a/stats.go +++ b/stats.go @@ -832,9 +832,6 @@ type AudioSenderStats struct { // Kind is either "audio" or "video". This reflects the "kind" attribute of the MediaStreamTrack. Kind string `json:"kind"` - // Priority indicates the priority set for the track. - Priority PriorityType `json:"priority"` - // AudioLevel represents the output audio level of the track. // // The value is a value between 0..1 (linear), where 1.0 represents 0 dBov,