mirror of
				https://github.com/pion/webrtc.git
				synced 2025-10-31 10:46:39 +08:00 
			
		
		
		
	Expose NewSDPType
Allows a user to easily marshal a string to SDPType
This commit is contained in:
		| @@ -258,6 +258,7 @@ Check out the **[contributing wiki](https://github.com/pion/webrtc/wiki/Contribu | ||||
| * [baiyufei](https://github.com/baiyufei) | ||||
| * [pascal-ace](https://github.com/pascal-ace) | ||||
| * [Threadnaught](https://github.com/Threadnaught) | ||||
| * [Dean Eigenmann](https://github.com/decanus) | ||||
|  | ||||
| ### License | ||||
| MIT License - see [LICENSE](LICENSE) for full text | ||||
|   | ||||
| @@ -809,7 +809,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()) == SDPType(Unknown): | ||||
| 		return &rtcerr.TypeError{Err: fmt.Errorf("%w: '%d' is not a valid enum value of type SDPType", errPeerConnSDPTypeInvalidValue, sd.Type)} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -623,7 +623,7 @@ func valueToSessionDescription(descValue js.Value) *SessionDescription { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return &SessionDescription{ | ||||
| 		Type: newSDPType(descValue.Get("type").String()), | ||||
| 		Type: NewSDPType(descValue.Get("type").String()), | ||||
| 		SDP:  descValue.Get("sdp").String(), | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -41,7 +41,8 @@ const ( | ||||
| 	sdpTypeRollbackStr = "rollback" | ||||
| ) | ||||
|  | ||||
| func newSDPType(raw string) SDPType { | ||||
| // NewSDPType creates an SDPType from a string | ||||
| func NewSDPType(raw string) SDPType { | ||||
| 	switch raw { | ||||
| 	case sdpTypeOfferStr: | ||||
| 		return SDPTypeOffer | ||||
|   | ||||
| @@ -21,7 +21,7 @@ func TestNewSDPType(t *testing.T) { | ||||
| 	for i, testCase := range testCases { | ||||
| 		assert.Equal(t, | ||||
| 			testCase.expectedSDPType, | ||||
| 			newSDPType(testCase.sdpTypeString), | ||||
| 			NewSDPType(testCase.sdpTypeString), | ||||
| 			"testCase: %d %v", i, testCase, | ||||
| 		) | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 decanus
					decanus