LiveKit ESP32 SDK
Loading...
Searching...
No Matches
livekit.h
1
2#pragma once
3
4#include "media_lib_os.h"
5#include "esp_capture.h"
6#include "av_render.h"
7
8#include "livekit_rpc.h"
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
15typedef enum {
16 LIVEKIT_ERR_NONE = 0,
17 LIVEKIT_ERR_INVALID_ARG = -1,
18 LIVEKIT_ERR_NO_MEM = -2,
19 LIVEKIT_ERR_ENGINE = -3,
20 LIVEKIT_ERR_OTHER = -4,
21 LIVEKIT_ERR_INVALID_STATE = -5,
22 LIVEKIT_ERR_SYSTEM_INIT = -6
23} livekit_err_t;
24
34
36typedef enum {
37 LIVEKIT_VIDEO_CODEC_NONE = 0,
38 LIVEKIT_VIDEO_CODEC_H264 = 1
39} livekit_video_codec_t;
40
42typedef enum {
43 LIVEKIT_AUDIO_CODEC_NONE = 0,
44 LIVEKIT_AUDIO_CODEC_G711A = 1,
45 LIVEKIT_AUDIO_CODEC_G711U = 2,
46 LIVEKIT_AUDIO_CODEC_OPUS = 3
47} livekit_audio_codec_t;
48
50typedef enum {
51 LIVEKIT_MEDIA_TYPE_NONE = 0,
52 LIVEKIT_MEDIA_TYPE_AUDIO = (1 << 0),
53 LIVEKIT_MEDIA_TYPE_VIDEO = (1 << 1),
54 LIVEKIT_MEDIA_TYPE_BOTH = LIVEKIT_MEDIA_TYPE_AUDIO | LIVEKIT_MEDIA_TYPE_VIDEO,
55} livekit_media_kind_t;
56
58typedef struct {
59 livekit_video_codec_t codec;
60 int width;
61 int height;
62 int fps;
64
66typedef struct {
67 livekit_audio_codec_t codec;
68 uint32_t sample_rate;
69 uint8_t channel_count;
71
89
91typedef struct {
93 livekit_media_kind_t kind;
94
97 av_render_handle_t renderer;
99
102typedef struct {
103 uint8_t *bytes;
104 size_t size;
106
120
123typedef struct {
125 char* sid;
127 char* name;
129 char* metadata;
135
152
165
182
190typedef struct {
194
198
202
205 void (*on_rpc_result)(const livekit_rpc_result_t* result, void* ctx);
206
209 void (*on_data_received)(const livekit_data_received_t* data, void* ctx);
210
213 void (*on_room_info)(const livekit_room_info_t* info, void* ctx);
214
218
220 void* ctx;
222
226
234livekit_err_t livekit_system_init(void);
235
237
241
244
250
257
259
267
275livekit_err_t livekit_room_connect(livekit_room_handle_t handle, const char *server_url, const char *token);
276
283
290
297
299
331
343
362
388
390
399
410livekit_err_t livekit_room_rpc_register(livekit_room_handle_t handle, const char* method, livekit_rpc_handler_t handler);
411
418livekit_err_t livekit_room_rpc_unregister(livekit_room_handle_t handle, const char* method);
419
421
422#ifdef __cplusplus
423}
424#endif
livekit_err_t livekit_room_close(livekit_room_handle_t handle)
Disconnects from a room asynchronously.
livekit_connection_state_t
Connection state of a room.
Definition livekit.h:27
livekit_connection_state_t livekit_room_get_state(livekit_room_handle_t handle)
Gets the current connection state of a room.
const char * livekit_connection_state_str(livekit_connection_state_t state)
Gets a string representation of a connection state.
livekit_err_t livekit_room_connect(livekit_room_handle_t handle, const char *server_url, const char *token)
Connects to a room asynchronously.
@ LIVEKIT_CONNECTION_STATE_RECONNECTING
Connection was previously established, but was lost.
Definition livekit.h:31
@ LIVEKIT_CONNECTION_STATE_CONNECTED
Connected.
Definition livekit.h:30
@ LIVEKIT_CONNECTION_STATE_CONNECTING
Establishing connection.
Definition livekit.h:29
@ LIVEKIT_CONNECTION_STATE_FAILED
Connection failed.
Definition livekit.h:32
@ LIVEKIT_CONNECTION_STATE_DISCONNECTED
Disconnected.
Definition livekit.h:28
livekit_data_payload_t * payload
Data to publish and its size.
Definition livekit.h:347
livekit_data_payload_t payload
Received data.
Definition livekit.h:112
size_t size
Size of the data.
Definition livekit.h:104
char * topic
Topic the data was sent under if specified by the sender.
Definition livekit.h:115
uint8_t * bytes
Pointer to data.
Definition livekit.h:103
char ** destination_identities
Identifies of participants to send the data packet to.
Definition livekit.h:357
int destination_identities_count
Number of destination identities.
Definition livekit.h:360
char * topic
Topic to send the data packet under.
Definition livekit.h:350
bool lossy
Whether the data packet is sent using the lossy channel.
Definition livekit.h:353
char * sender_identity
Identity of the participant who sent the data.
Definition livekit.h:118
livekit_err_t livekit_room_publish_data(livekit_room_handle_t handle, livekit_data_publish_options_t *options)
Publishes a data packet to participants in a room asynchronously.
Payload containing a pointer to data and its size.
Definition livekit.h:102
Options passed to livekit_room_publish_data.
Definition livekit.h:345
Information about a data packet received from a remote participant passed to livekit_room_options_t::...
Definition livekit.h:110
char * sid
Unique identifier generated by LiveKit server.
Definition livekit.h:170
char * metadata
Optional arbitrary metadata in string format.
Definition livekit.h:129
char * name
Optional display name.
Definition livekit.h:174
uint32_t participant_count
Number of participants in the room, including the local participant.
Definition livekit.h:131
char * identity
Unique identity of the participant, as specified when connecting.
Definition livekit.h:172
livekit_participant_kind_t kind
The participant's kind (e.g. standard, agent, etc.).
Definition livekit.h:178
livekit_participant_state_t state
The current state of the participant.
Definition livekit.h:180
char * sid
Unique identifier generated by LiveKit server.
Definition livekit.h:125
bool active_recording
Whether the room is actively being recorded.
Definition livekit.h:133
char * name
Optional display name.
Definition livekit.h:127
char * metadata
Optional arbitrary metadata in string format.
Definition livekit.h:176
livekit_participant_kind_t
Participant kind.
Definition livekit.h:138
livekit_participant_state_t
Participant state.
Definition livekit.h:155
@ LIVEKIT_PARTICIPANT_KIND_SIP
A telephony user connected via SIP.
Definition livekit.h:148
@ LIVEKIT_PARTICIPANT_KIND_AGENT
An agent spawned with the Agents Framework.
Definition livekit.h:150
@ LIVEKIT_PARTICIPANT_KIND_INGRESS
A server-side process that is ingesting media into the session using LiveKit Ingress.
Definition livekit.h:143
@ LIVEKIT_PARTICIPANT_KIND_EGRESS
A server-side process that is recording the session using LiveKit Egress.
Definition livekit.h:146
@ LIVEKIT_PARTICIPANT_KIND_STANDARD
A regular participant, typically an end-user in your application.
Definition livekit.h:140
@ LIVEKIT_PARTICIPANT_STATE_ACTIVE
The participant is connected to the room and can publish or subscribe to media.
Definition livekit.h:161
@ LIVEKIT_PARTICIPANT_STATE_JOINING
The participant is in the process of joining the room.
Definition livekit.h:157
@ LIVEKIT_PARTICIPANT_STATE_DISCONNECTED
The participant has disconnected from the room.
Definition livekit.h:163
@ LIVEKIT_PARTICIPANT_STATE_JOINED
The participant has joined the room but is not able to publish or subscribe to media yet.
Definition livekit.h:159
Information about a participant in a room.
Definition livekit.h:168
Information about a room.
Definition livekit.h:123
void * ctx
User context passed to all handlers.
Definition livekit.h:220
livekit_pub_options_t publish
Options for publishing media.
Definition livekit.h:193
void(* on_state_changed)(livekit_connection_state_t state, void *ctx)
Handler for when the room's connection state changes.
Definition livekit.h:201
void(* on_data_received)(const livekit_data_received_t *data, void *ctx)
Handler for data packets received from remote participants.
Definition livekit.h:209
void(* on_rpc_result)(const livekit_rpc_result_t *result, void *ctx)
Handler for when an RPC method invoked with livekit_room_rpc_invoke returns a result.
Definition livekit.h:205
void(* on_participant_info)(const livekit_participant_info_t *info, void *ctx)
Handler for when participant information is received.
Definition livekit.h:217
livekit_sub_options_t subscribe
Options for subscribing to media.
Definition livekit.h:197
void(* on_room_info)(const livekit_room_info_t *info, void *ctx)
Handler for when room information is received.
Definition livekit.h:213
livekit_err_t livekit_room_create(livekit_room_handle_t *handle, const livekit_room_options_t *options)
Creates a room.
void * livekit_room_handle_t
Handle to a room object.
Definition livekit.h:243
livekit_err_t livekit_room_destroy(livekit_room_handle_t handle)
Destroys a room.
Options for creating a room.
Definition livekit.h:190
void(* livekit_rpc_handler_t)(const livekit_rpc_invocation_t *invocation, void *ctx)
Handler for an RPC invocation.
Definition livekit_rpc.h:96
livekit_err_t livekit_room_rpc_register(livekit_room_handle_t handle, const char *method, livekit_rpc_handler_t handler)
Registers a handler for an RPC method.
livekit_err_t livekit_room_rpc_unregister(livekit_room_handle_t handle, const char *method)
Unregisters a handler for an RPC method.
livekit_err_t livekit_system_init(void)
Performs one-time system initialization.
livekit_video_encode_options_t video_encode
Video encoder options.
Definition livekit.h:79
esp_capture_handle_t capturer
Capturer to use for obtaining media to publish.
Definition livekit.h:87
livekit_video_codec_t codec
Codec to use for encoding.
Definition livekit.h:59
livekit_media_kind_t kind
Kind of media that can be published.
Definition livekit.h:75
livekit_audio_codec_t codec
Codec to use for encoding.
Definition livekit.h:67
int fps
Output frame per second.
Definition livekit.h:62
livekit_audio_encode_options_t audio_encode
Audio encoder options.
Definition livekit.h:83
uint32_t sample_rate
Output sample rate in Hz.
Definition livekit.h:68
int height
Output frame height in pixels.
Definition livekit.h:61
int width
Output frame width in pixels.
Definition livekit.h:60
uint8_t channel_count
Output number of channels.
Definition livekit.h:69
livekit_media_kind_t kind
Kind of media that can be subscribed to.
Definition livekit.h:93
av_render_handle_t renderer
Renderer to use for subscribed media tracks.
Definition livekit.h:97
Options for the audio encoder.
Definition livekit.h:66
Options for publishing media.
Definition livekit.h:73
The result of an RPC method invocation.
Definition livekit_rpc.h:54
Options for subscribing to media.
Definition livekit.h:91
Options for the video encoder.
Definition livekit.h:58