github.com/whoyao/protocol@v0.0.0-20230519045905-2d8ace718ca5/livekit/types.go (about)

     1  package livekit
     2  
     3  // ----------------------------------------------------------------
     4  
     5  type TrackID string
     6  
     7  func StringsAsTrackIDs(trackIDs []string) []TrackID {
     8  	asTrackID := make([]TrackID, 0, len(trackIDs))
     9  	for _, trackID := range trackIDs {
    10  		asTrackID = append(asTrackID, TrackID(trackID))
    11  	}
    12  
    13  	return asTrackID
    14  }
    15  
    16  // ----------------------------------------------------------------
    17  
    18  type ParticipantID string
    19  
    20  func ParticipantIDsAsStrings(ids []ParticipantID) []string {
    21  	strs := make([]string, 0, len(ids))
    22  	for _, id := range ids {
    23  		strs = append(strs, string(id))
    24  	}
    25  	return strs
    26  }
    27  
    28  // ----------------------------------------------------------------
    29  
    30  type ParticipantIdentity string
    31  type ParticipantName string
    32  
    33  type RoomID string
    34  
    35  // ----------------------------------------------------------------
    36  
    37  type RoomName string
    38  
    39  func RoomNamesAsStrings(roomNames []RoomName) []string {
    40  	asString := make([]string, 0, len(roomNames))
    41  	for _, roomName := range roomNames {
    42  		asString = append(asString, string(roomName))
    43  	}
    44  
    45  	return asString
    46  }
    47  
    48  func StringsAsRoomNames(roomNames []string) []RoomName {
    49  	asRoomName := make([]RoomName, 0, len(roomNames))
    50  	for _, roomName := range roomNames {
    51  		asRoomName = append(asRoomName, RoomName(roomName))
    52  	}
    53  
    54  	return asRoomName
    55  }
    56  
    57  // ----------------------------------------------------------------
    58  
    59  type ConnectionID string
    60  
    61  // ----------------------------------------------------------------
    62  
    63  type NodeID string
    64  
    65  func NodeIDsAsStrings(ids []NodeID) []string {
    66  	strs := make([]string, 0, len(ids))
    67  	for _, id := range ids {
    68  		strs = append(strs, string(id))
    69  	}
    70  	return strs
    71  }
    72  
    73  // ----------------------------------------------------------------
    74  type ParticipantKey string
    75  
    76  // ----------------------------------------------------------------
    77  
    78  type Guid interface {
    79  	TrackID | ParticipantID | RoomID
    80  }
    81  
    82  type GuidBlock [9]byte