Skip to content

Commit 31b64ea

Browse files
some more cleanup
1 parent af4412b commit 31b64ea

File tree

13 files changed

+13
-53
lines changed

13 files changed

+13
-53
lines changed

examples/simple_data_stream/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void handleWelcomeImage(std::shared_ptr<livekit::ByteStreamReader> reader,
187187
} // namespace
188188

189189
int main(int argc, char *argv[]) {
190-
// Get URL and token from env, like the Python example
190+
// Get URL and token from env.
191191
std::string url = getenvOrEmpty("LIVEKIT_URL");
192192
std::string token = getenvOrEmpty("LIVEKIT_TOKEN");
193193

include/livekit/audio_frame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class AudioFrame {
8585
/// Duration in seconds (samples_per_channel / sample_rate).
8686
double duration() const noexcept;
8787

88-
/// A human-readable description (like Python __repr__).
88+
/// A human-readable description.
8989
std::string to_string() const;
9090

9191
private:

include/livekit/audio_source.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,6 @@ class AudioSource {
102102
*/
103103
void captureFrame(const AudioFrame &frame, int timeout_ms = 20);
104104

105-
/**
106-
* Block until the currently queued audio has (roughly) played out.
107-
*/
108-
void waitForPlayout() const;
109-
110105
private:
111106
// Internal helper to reset the local queue tracking (like _release_waiter).
112107
void resetQueueTracking() noexcept;

include/livekit/data_stream.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ namespace livekit {
3131

3232
class LocalParticipant;
3333

34-
// Same size as Python STREAM_CHUNK_SIZE
35-
constexpr std::size_t kStreamChunkSize = 15'000;
34+
// Chunk size for data streams (matches Python STREAM_CHUNK_SIZE).
35+
// Chosen to balance throughput and latency, and to work well with WebRTC data
36+
// channels.
37+
constexpr std::size_t kStreamChunkSize = 15'000; // 15 KB
3638

3739
/// Base metadata for any stream (text or bytes).
3840
struct BaseStreamInfo {
@@ -67,11 +69,9 @@ struct ByteStreamInfo : BaseStreamInfo {
6769
std::string name;
6870
};
6971

70-
// ---------------------------------------------------------------------
7172
// Readers
7273
// - TextStreamReader: yields UTF-8 text chunks (std::string)
7374
// - ByteStreamReader: yields raw bytes (std::vector<uint8_t>)
74-
// ---------------------------------------------------------------------
7575

7676
/// Reader for incoming text streams.
7777
/// Created internally by the SDK when a text stream header is received.
@@ -149,10 +149,6 @@ class ByteStreamReader {
149149
std::condition_variable cv_;
150150
};
151151

152-
// ---------------------------------------------------------------------
153-
// Writers (sync API mirroring Python BaseStreamWriter/TextStreamWriter)
154-
// ---------------------------------------------------------------------
155-
156152
/// Base class for sending data streams.
157153
/// Concrete subclasses are TextStreamWriter and ByteStreamWriter.
158154
class BaseStreamWriter {

include/livekit/remote_participant.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ class RemoteParticipant : public Participant {
4646
return track_publications_;
4747
}
4848

49-
// C++ equivalent of Python's __repr__
5049
std::string to_string() const;
5150

5251
protected:

include/livekit/room.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class LocalParticipant;
3636
class RemoteParticipant;
3737

3838
/// Represents end-to-end encryption (E2EE) settings.
39-
/// Mirrors python sdk: `E2EEOptions`
4039
struct E2EEOptions {
4140
// Encryption algorithm type.
4241
int encryption_type = 0;
@@ -55,7 +54,6 @@ struct E2EEOptions {
5554
};
5655

5756
// Represents a single ICE server configuration.
58-
// Mirrors python: RtcConfiguration.ice_servers[*]
5957
struct IceServer {
6058
// TURN/STUN server URL (e.g. "stun:stun.l.google.com:19302").
6159
std::string url;
@@ -68,7 +66,6 @@ struct IceServer {
6866
};
6967

7068
// WebRTC configuration (ICE, transport, etc.).
71-
// Mirrors python: `RtcConfiguration`
7269
struct RtcConfig {
7370
// ICE transport type (e.g., ALL, RELAY). Maps to proto::IceTransportType.
7471
int ice_transport_type = 0;
@@ -82,7 +79,6 @@ struct RtcConfig {
8279
};
8380

8481
// Top-level room connection options.
85-
// Mirrors python: `RoomOptions`
8682
struct RoomOptions {
8783
// If true (default), automatically subscribe to all remote tracks.
8884
// This is CRITICAL. Without auto_subscribe, you will never receive:
@@ -195,7 +191,7 @@ class Room {
195191
* Notes:
196192
* - Only one handler may be registered per topic.
197193
* - If no handler is registered for a topic, incoming streams with that
198-
* topic are ignored (mirrors Python SDK behavior).
194+
* topic are ignored.
199195
* - The handler is invoked on the Room event thread. The handler must
200196
* not block; spawn a background thread if synchronous reading is
201197
* required.

include/livekit/rpc_error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class RpcError;
4040
class RpcError : public std::runtime_error {
4141
public:
4242
/**
43-
* Built-in error codes, mirroring the Python RpcError.ErrorCode enum.
43+
* Built-in error codes
4444
*/
4545
enum class ErrorCode : std::uint32_t {
4646
APPLICATION_ERROR = 1500,
@@ -97,7 +97,7 @@ class RpcError : public std::runtime_error {
9797

9898
/**
9999
* Create a built-in RpcError using a predefined ErrorCode and default
100-
* message text that matches the Python RpcError.ErrorMessage table.
100+
* message text.
101101
*
102102
* @param code Built-in error code.
103103
* @param data Optional extra data payload (JSON recommended).

src/audio_source.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,4 @@ void AudioSource::captureFrame(const AudioFrame &frame, int timeout_ms) {
128128
}
129129
}
130130

131-
void AudioSource::waitForPlayout() const {
132-
// Python uses a future + event loop timer that fires after q_size.
133-
// Here we approximate that by simply sleeping for the current queued
134-
// duration.
135-
double dur = queuedDuration();
136-
if (dur <= 0.0) {
137-
return;
138-
}
139-
140-
std::this_thread::sleep_for(std::chrono::duration<double>(dur));
141-
}
142-
143131
} // namespace livekit

src/audio_stream.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,6 @@ void AudioStream::onFfiEvent(const FfiEvent &event) {
212212
}
213213
if (ase.has_frame_received()) {
214214
const auto &fr = ase.frame_received();
215-
216-
// Convert owned buffer -> AudioFrame via helper.
217-
// Implement AudioFrame::fromOwnedInfo(...) to mirror Python's
218-
// AudioFrame._from_owned_info.
219215
AudioFrame frame = AudioFrame::fromOwnedInfo(fr.frame());
220216
AudioFrameEvent ev{std::move(frame)};
221217
pushFrame(std::move(ev));

src/data_stream.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ std::string generateRandomId(std::size_t bytes = 16) {
2929
}
3030

3131
// Split UTF-8 string into chunks of at most max_bytes, not breaking codepoints.
32-
// Mimics Python split_utf8 helper.
3332
std::vector<std::string> splitUtf8(const std::string &s,
3433
std::size_t max_bytes) {
3534
std::vector<std::string> result;
@@ -69,14 +68,6 @@ std::vector<std::string> splitUtf8(const std::string &s,
6968
return result;
7069
}
7170

72-
std::map<std::string, std::string>
73-
toMap(const google::protobuf::Map<std::string, std::string> &m) {
74-
std::map<std::string, std::string> out;
75-
for (const auto &kv : m)
76-
out.emplace(kv.first, kv.second);
77-
return out;
78-
}
79-
8071
void fillBaseInfo(BaseStreamInfo &dst, const std::string &stream_id,
8172
const std::string &mime_type, const std::string &topic,
8273
std::int64_t timestamp_ms,

0 commit comments

Comments
 (0)