// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package webrtc

import (
	
)

// ICETransportPolicy defines the ICE candidate policy surface the
// permitted candidates. Only these candidates are used for connectivity checks.
type ICETransportPolicy int

// ICEGatherPolicy is the ORTC equivalent of ICETransportPolicy.
type ICEGatherPolicy = ICETransportPolicy

const (
	// ICETransportPolicyAll indicates any type of candidate is used.
	ICETransportPolicyAll ICETransportPolicy = iota

	// ICETransportPolicyRelay indicates only media relay candidates such
	// as candidates passing through a TURN server are used.
	ICETransportPolicyRelay
)

// This is done this way because of a linter.
const (
	iceTransportPolicyRelayStr = "relay"
	iceTransportPolicyAllStr   = "all"
)

// NewICETransportPolicy takes a string and converts it to ICETransportPolicy.
func ( string) ICETransportPolicy {
	switch  {
	case iceTransportPolicyRelayStr:
		return ICETransportPolicyRelay
	default:
		return ICETransportPolicyAll
	}
}

func ( ICETransportPolicy) () string {
	switch  {
	case ICETransportPolicyRelay:
		return iceTransportPolicyRelayStr
	case ICETransportPolicyAll:
		return iceTransportPolicyAllStr
	default:
		return ErrUnknownType.Error()
	}
}

// UnmarshalJSON parses the JSON-encoded data and stores the result.
func ( *ICETransportPolicy) ( []byte) error {
	var  string
	if  := json.Unmarshal(, &);  != nil {
		return 
	}
	* = NewICETransportPolicy()

	return nil
}

// MarshalJSON returns the JSON encoding.
func ( ICETransportPolicy) () ([]byte, error) {
	return json.Marshal(.String())
}