clients.livekit #
livekit
To get started
import freeflowuniverse.crystallib.clients.livekit
mut client:= livekit.get()!
client...
example heroscript
!!livekit.configure
livekit_url:''
livekit_api_key:''
livekit_api_secret:''
fn new #
fn new(client Client) Client
type TTLValue #
type TTLValue = int | string
TTLValue represents either seconds as int or duration as string
struct AccessToken #
struct AccessToken {
pub mut:
api_key string // LiveKit API Key
api_secret string // LiveKit API Secret
identity string // User identity
ttl int // Time to live in seconds
grants ClaimGrants // JWT claims
}
AccessToken represents a LiveKit access token
fn (AccessToken) add_video_grant #
fn (mut token AccessToken) add_video_grant(grant VideoGrant)
Method to add a video grant to the token
fn (AccessToken) to_jwt #
fn (token AccessToken) to_jwt() !string
Method to generate a JWT token
struct AccessTokenOptions #
struct AccessTokenOptions {
pub mut:
ttl TTLValue // TTL in seconds or a time span (e.g., '2d', '5h')
name string // Display name for the participant
identity string // Identity of the user
metadata string // Custom metadata to be passed to participants
}
AccessTokenOptions defines parameters for token generation
struct ClaimGrants #
struct ClaimGrants {
pub mut:
exp i64 // Expiration time
iss string // Issuer (API Key)
sub string // Subject (user ID)
name string // User's display name
}
ClaimGrants represents the JWT claims for LiveKit
struct Client #
struct Client {
pub:
url string @[required]
api_key string @[required]
api_secret string @[required]
}
App struct with livekit.Client
, API keys, and other shared data
fn (Client) list_rooms #
fn (c Client) list_rooms(params ListRoomsParams) !ListRoomsResponse
fn (Client) new_access_token #
fn (client Client) new_access_token(options AccessTokenOptions) !AccessToken
new_access_token creates a new access token with the given options
struct Codec #
struct Codec {
pub:
fmtp_line string
mime string
}
struct ListRoomsParams #
@[params]
struct ListRoomsParams {
names []string
}
struct ListRoomsResponse #
struct ListRoomsResponse {
pub:
rooms []Room
}
struct Room #
struct Room {
pub:
active_recording bool
creation_time string
departure_timeout int
empty_timeout int
enabled_codecs []Codec
max_participants int
metadata string
name string
num_participants int
num_publishers int
sid string
turn_password string
version Version
}
struct Version #
struct Version {
pub:
ticks u64
unix_micro string
}
struct VideoGrant #
struct VideoGrant {
pub mut:
room string
room_join bool @[json: 'roomJoin']
room_list bool @[json: 'roomList']
can_publish bool @[json: 'canPublish']
can_publish_data bool @[json: 'canPublishData']
can_subscribe bool @[json: 'canSubscribe']
}
VideoGrant struct placeholder