LiveKit ESP32 SDK v0.3.7
Loading...
Searching...
No Matches
livekit_data_stream.h
1/*
2 * Copyright 2025 LiveKit, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <stdbool.h>
20#include <stddef.h>
21#include <stdint.h>
22
24#define LIVEKIT_DATA_STREAM_CHUNK_SIZE 15000
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
33
36typedef struct {
37 const char* stream_id;
38 const char* topic;
39 const char* sender_identity;
40 int64_t timestamp;
41 uint64_t total_length;
44 bool is_text;
46
49typedef struct {
50 const char* stream_id;
51 uint64_t chunk_index;
52 const uint8_t* content;
55
58typedef struct {
59 const char* stream_id;
61 const char* reason;
63
67 const livekit_data_stream_header_t* header, void* ctx);
68
72 const livekit_data_stream_chunk_t* chunk, void* ctx);
73
77 const livekit_data_stream_trailer_t* trailer, void* ctx);
78
81typedef struct {
83 const char *topic;
85 bool is_text;
87 uint64_t total_length;
91
107
108#ifdef __cplusplus
109}
110#endif
const char * topic
Definition livekit_data_stream.h:38
livekit_data_stream_close_cb_t on_close
Callback invoked when a stream is closed. Optional, can be NULL.
Definition livekit_data_stream.h:102
uint64_t chunk_index
Definition livekit_data_stream.h:51
bool is_text
True if this is a text stream (UTF-8 chunks), false if byte stream (raw binary).
Definition livekit_data_stream.h:44
const char * stream_id
Definition livekit_data_stream.h:37
uint64_t total_length
Definition livekit_data_stream.h:41
const char * sender_identity
Definition livekit_data_stream.h:39
const uint8_t * content
Definition livekit_data_stream.h:52
int64_t timestamp
Definition livekit_data_stream.h:40
bool has_total_length
Definition livekit_data_stream.h:42
bool has_total_length
Whether total_length is set.
Definition livekit_data_stream.h:89
size_t content_size
Definition livekit_data_stream.h:53
const char * stream_id
Definition livekit_data_stream.h:59
const char * reason
Empty string for normal closure, non-empty for abnormal end.
Definition livekit_data_stream.h:61
bool is_text
True for a text stream (UTF-8 chunks), false for a byte stream (raw binary).
Definition livekit_data_stream.h:85
uint64_t total_length
Total size of the stream in bytes, if known upfront.
Definition livekit_data_stream.h:87
const char * topic
Topic to publish the stream under. Required.
Definition livekit_data_stream.h:83
const char * stream_id
Definition livekit_data_stream.h:50
livekit_data_stream_open_cb_t on_open
Callback invoked when a new stream is opened. Optional, can be NULL.
Definition livekit_data_stream.h:99
void * ctx
User context passed to all callbacks.
Definition livekit_data_stream.h:105
livekit_data_stream_recv_cb_t on_recv
Callback invoked for each received chunk. Required.
Definition livekit_data_stream.h:96
void(* livekit_data_stream_recv_cb_t)(const livekit_data_stream_chunk_t *chunk, void *ctx)
Called for each received chunk of a data stream.
Definition livekit_data_stream.h:71
void(* livekit_data_stream_open_cb_t)(const livekit_data_stream_header_t *header, void *ctx)
Called when a new data stream is opened.
Definition livekit_data_stream.h:66
void(* livekit_data_stream_close_cb_t)(const livekit_data_stream_trailer_t *trailer, void *ctx)
Called when a data stream is closed.
Definition livekit_data_stream.h:76
void * livekit_data_stream_handle_t
Opaque handle to an open outgoing data stream.
Definition livekit_data_stream.h:32
A received chunk of data stream content.
Definition livekit_data_stream.h:49
Handler for incoming data streams on a topic.
Definition livekit_data_stream.h:94
Header information about a data stream.
Definition livekit_data_stream.h:36
Options for opening an outgoing data stream.
Definition livekit_data_stream.h:81
Trailer information when a data stream closes.
Definition livekit_data_stream.h:58