github.com/livekit/protocol@v1.39.3/utils/id.go (about) 1 // Copyright 2023 LiveKit, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package utils 16 17 import ( 18 "github.com/livekit/protocol/livekit" 19 "github.com/livekit/protocol/utils/guid" 20 ) 21 22 const ( 23 GuidSize = guid.Size 24 ) 25 26 const ( 27 RoomPrefix = guid.RoomPrefix 28 NodePrefix = guid.NodePrefix 29 ParticipantPrefix = guid.ParticipantPrefix 30 TrackPrefix = guid.TrackPrefix 31 APIKeyPrefix = guid.APIKeyPrefix 32 EgressPrefix = guid.EgressPrefix 33 IngressPrefix = guid.IngressPrefix 34 SIPTrunkPrefix = guid.SIPTrunkPrefix 35 SIPDispatchRulePrefix = guid.SIPDispatchRulePrefix 36 SIPCallPrefix = guid.SIPCallPrefix 37 SIPTransferPrefix = guid.SIPTransferPrefix 38 RPCPrefix = guid.RPCPrefix 39 WHIPResourcePrefix = guid.WHIPResourcePrefix 40 RTMPResourcePrefix = guid.RTMPResourcePrefix 41 URLResourcePrefix = guid.URLResourcePrefix 42 AgentWorkerPrefix = guid.AgentWorkerPrefix 43 AgentJobPrefix = guid.AgentJobPrefix 44 AgentDispatchPrefix = guid.AgentDispatchPrefix 45 CloudAgentPrefix = guid.CloudAgentPrefix 46 CloudAgentRegionPrefix = guid.CloudAgentRegionPrefix 47 CloudAgentVersionPrefix = guid.CloudAgentVersionPrefix 48 CloudAgentSecretPrefix = guid.CloudAgentSecretPrefix 49 CloudAgentWorkerPrefix = guid.CloudAgentWorkerPrefix 50 ) 51 52 func NewGuid(prefix string) string { 53 return guid.New(prefix) 54 } 55 56 // HashedID creates a hashed ID from a unique string 57 func HashedID(id string) string { 58 return guid.HashedID(id) 59 } 60 61 func LocalNodeID() (string, error) { 62 return guid.LocalNodeID() 63 } 64 65 func MarshalGuid[T livekit.Guid](id T) livekit.GuidBlock { 66 return guid.Marshal(id) 67 } 68 69 func UnmarshalGuid[T livekit.Guid](b livekit.GuidBlock) T { 70 return guid.Unmarshal[T](b) 71 }