Skip to content

Commit 8f570b7

Browse files
Unified method style (#127)
* All methods now use camelBack() style * Enforced in CI via clang-tidy * Violating methods deprecated but not removed
1 parent 9c7cc2e commit 8f570b7

55 files changed

Lines changed: 475 additions & 224 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.clang-tidy‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Checks: >
66
modernize-*,
77
readability-misleading-indentation,
88
readability-redundant-smartptr-get,
9+
readability-identifier-naming,
910
-bugprone-easily-swappable-parameters,
1011
-modernize-use-trailing-return-type,
1112
-modernize-avoid-c-arrays,
@@ -38,3 +39,7 @@ FormatStyle: file
3839
CheckOptions:
3940
- key: modernize-use-nullptr.NullMacros
4041
value: 'NULL'
42+
- key: readability-identifier-naming.ClassCase
43+
value: CamelCase
44+
- key: readability-identifier-naming.MethodCase
45+
value: camelBack

‎AGENTS.md‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ When making larger scale changes, check with the developer before committing to
4040

4141
The SDK has three categories of threads:
4242

43-
**FFI callback thread** — The Rust FFI layer calls `LivekitFfiCallback` from a Rust-managed thread (typically a Tokio runtime thread). This single entry point deserializes the `FfiEvent` and calls `FfiClient::PushEvent`, which:
43+
**FFI callback thread** — The Rust FFI layer calls `LivekitFfiCallback` from a Rust-managed thread (typically a Tokio runtime thread). This single entry point deserializes the `FfiEvent` and calls `FfiClient::pushEvent`, which:
4444
1. Completes any pending async `std::promise` matched by `async_id`.
45-
2. Invokes all registered `FfiClient` listeners (including `Room::OnEvent`).
45+
2. Invokes all registered `FfiClient` listeners (including `Room::onEvent`).
4646

4747
All `RoomDelegate` callbacks and stream handler callbacks (e.g., `registerTextStreamHandler`) are invoked on this FFI callback thread. **Handlers must not block**; spawn a background thread if synchronous work is needed.
4848

4949
**Per-subscription reader threads** — `SubscriptionThreadDispatcher` creates a dedicated `std::thread` for each active audio, video, or data track subscription. These threads block on `AudioStream::read()`, `VideoStream::read()`, or `DataTrackStream::read()` and invoke the registered `AudioFrameCallback`, `VideoFrameCallback`, or `DataFrameCallback` on that reader thread — not on the FFI callback thread. A hard limit of 20 concurrent reader threads is enforced.
5050

51-
**Application threads** — The calling thread for public API methods such as `Room::Connect`, `LocalParticipant::publishTrack`, `AudioSource::captureFrame`, etc. These may block while waiting for FFI responses or future completion.
51+
**Application threads** — The calling thread for public API methods such as `Room::connect`, `LocalParticipant::publishTrack`, `AudioSource::captureFrame`, etc. These may block while waiting for FFI responses or future completion.
5252

5353
#### Thread-safety guarantees
5454

@@ -146,6 +146,32 @@ All source files must have the LiveKit Apache 2.0 copyright header. Use the curr
146146
- `lk_log.h` lives under `src/` (internal). The public-facing logging API is `include/livekit/logging.h`.
147147
- spdlog must not appear in any public header or installed header.
148148

149+
#### Deprecating a public API
150+
151+
When superseding a public API (renaming, replacing, or removing in a future major
152+
version), every retained back-compat shim must carry **both** annotations:
153+
154+
1. The C++11 `[[deprecated("...")]]` attribute so the compiler warns at every
155+
call site. The message should name the replacement (e.g.
156+
`"AudioFrame::sample_rate is deprecated; use AudioFrame::sampleRate instead"`).
157+
2. A Doxygen `/// @deprecated Use <newName>() instead.` line immediately above
158+
the attribute so the generated docs render a deprecation callout and add the
159+
symbol to Doxygen's auto-generated *Deprecated List* page. Doxygen does not
160+
read the C++ attribute, so this line is required even though it duplicates
161+
information.
162+
163+
Example:
164+
165+
```cpp
166+
/// @deprecated Use sampleRate() instead.
167+
[[deprecated("AudioFrame::sample_rate is deprecated; use AudioFrame::sampleRate instead")]]
168+
int sample_rate() const noexcept { return sampleRate(); }
169+
```
170+
171+
Keep the prose consistent: `Use <newName>() instead.` Per-symbol deprecations
172+
must use `///` (not `//`); only section-level asides (e.g. "Deprecated public
173+
mutators" group headers) may stay as plain `//` comments.
174+
149175
### Include Conventions
150176
151177
- **Public headers (`include/livekit/*.h`) must include other public headers

‎benchmarks/data_track_throughput/consumer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ int main(int argc, char* argv[]) {
477477
room_options.dynacast = false;
478478

479479
std::cout << "Connecting to " << options.url << std::endl;
480-
if (!room.Connect(options.url, options.token, room_options)) {
480+
if (!room.connect(options.url, options.token, room_options)) {
481481
throw std::runtime_error("Failed to connect to LiveKit room");
482482
}
483483

‎benchmarks/data_track_throughput/producer.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ int main(int argc, char* argv[]) {
312312
room_options.dynacast = false;
313313

314314
std::cout << "Connecting to " << options.url << std::endl;
315-
if (!room.Connect(options.url, options.token, room_options)) {
315+
if (!room.connect(options.url, options.token, room_options)) {
316316
throw std::runtime_error("Failed to connect to LiveKit room");
317317
}
318318

‎docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bool initializeLivekit(const std::string& url, const std::string& token) {
1717
livekit::RoomOptions options;
1818
options.auto_subscribe = true;
1919
options.dynacast = false;
20-
if (!room_->Connect(url, token, options)) {
20+
if (!room_->connect(url, token, options)) {
2121
std::cerr << "Failed to connect\n";
2222
livekit::shutdown();
2323
return false;

‎include/livekit/audio_frame.h‎

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,50 @@ class LIVEKIT_API AudioFrame {
6969
std::vector<std::int16_t>& data() noexcept { return data_; }
7070

7171
/// Number of samples in the buffer (per all channels).
72-
std::size_t total_samples() const noexcept { return data_.size(); }
72+
std::size_t totalSamples() const noexcept { return data_.size(); }
7373

7474
/// Sample rate in Hz.
75-
int sample_rate() const noexcept { return sample_rate_; }
75+
int sampleRate() const noexcept { return sample_rate_; }
7676

7777
/// Number of channels.
78-
int num_channels() const noexcept { return num_channels_; }
78+
int numChannels() const noexcept { return num_channels_; }
7979

8080
/// Samples per channel.
81-
int samples_per_channel() const noexcept { return samples_per_channel_; }
81+
int samplesPerChannel() const noexcept { return samples_per_channel_; }
8282

83-
/// Duration in seconds (samples_per_channel / sample_rate).
83+
/// Duration in seconds (samplesPerChannel / sampleRate).
8484
double duration() const noexcept;
8585

8686
/// A human-readable description.
87-
std::string to_string() const;
87+
std::string toString() const;
88+
89+
/// @deprecated Use totalSamples() instead.
90+
[[deprecated("AudioFrame::total_samples is deprecated; use AudioFrame::totalSamples instead")]]
91+
std::size_t total_samples() const noexcept { // NOLINT(readability-identifier-naming)
92+
return totalSamples();
93+
}
94+
95+
/// @deprecated Use sampleRate() instead.
96+
[[deprecated("AudioFrame::sample_rate is deprecated; use AudioFrame::sampleRate instead")]]
97+
int sample_rate() const noexcept { // NOLINT(readability-identifier-naming)
98+
return sampleRate();
99+
}
100+
101+
/// @deprecated Use numChannels() instead.
102+
[[deprecated("AudioFrame::num_channels is deprecated; use AudioFrame::numChannels instead")]]
103+
int num_channels() const noexcept { // NOLINT(readability-identifier-naming)
104+
return numChannels();
105+
}
106+
107+
/// @deprecated Use samplesPerChannel() instead.
108+
[[deprecated("AudioFrame::samples_per_channel is deprecated; use AudioFrame::samplesPerChannel instead")]]
109+
int samples_per_channel() const noexcept { // NOLINT(readability-identifier-naming)
110+
return samplesPerChannel();
111+
}
112+
113+
/// @deprecated Use toString() instead.
114+
[[deprecated("AudioFrame::to_string is deprecated; use AudioFrame::toString instead")]]
115+
std::string to_string() const; // NOLINT(readability-identifier-naming)
88116

89117
protected:
90118
// Build a proto AudioFrameBufferInfo pointing at this frame’s data.

‎include/livekit/audio_processing_module.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class LIVEKIT_API AudioProcessingModule {
160160
bool valid() const noexcept { return handle_.valid(); }
161161

162162
/// Get the underlying FFI handle ID (used internally).
163-
std::uint64_t ffi_handle_id() const noexcept { return static_cast<std::uint64_t>(handle_.get()); }
163+
std::uint64_t ffiHandleId() const noexcept { return static_cast<std::uint64_t>(handle_.get()); }
164164

165165
FfiHandle handle_;
166166
};

‎include/livekit/audio_source.h‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,31 @@ class LIVEKIT_API AudioSource {
7878
AudioSource& operator=(AudioSource&&) noexcept = default;
7979

8080
/// The sample rate of the audio source in Hz.
81-
int sample_rate() const noexcept { return sample_rate_; }
81+
int sampleRate() const noexcept { return sample_rate_; }
8282

8383
/// The number of audio channels.
84-
int num_channels() const noexcept { return num_channels_; }
84+
int numChannels() const noexcept { return num_channels_; }
8585

8686
/// Underlying FFI handle ID used in FFI requests.
87-
std::uint64_t ffi_handle_id() const noexcept { return static_cast<std::uint64_t>(handle_.get()); }
87+
std::uint64_t ffiHandleId() const noexcept { return static_cast<std::uint64_t>(handle_.get()); }
88+
89+
/// @deprecated Use sampleRate() instead.
90+
[[deprecated("AudioSource::sample_rate is deprecated; use AudioSource::sampleRate instead")]]
91+
int sample_rate() const noexcept { // NOLINT(readability-identifier-naming)
92+
return sampleRate();
93+
}
94+
95+
/// @deprecated Use numChannels() instead.
96+
[[deprecated("AudioSource::num_channels is deprecated; use AudioSource::numChannels instead")]]
97+
int num_channels() const noexcept { // NOLINT(readability-identifier-naming)
98+
return numChannels();
99+
}
100+
101+
/// @deprecated Use ffiHandleId() instead.
102+
[[deprecated("AudioSource::ffi_handle_id is deprecated; use AudioSource::ffiHandleId instead")]]
103+
std::uint64_t ffi_handle_id() const noexcept { // NOLINT(readability-identifier-naming)
104+
return ffiHandleId();
105+
}
88106

89107
/// Current duration of queued audio (in seconds).
90108
double queuedDuration() const noexcept;

‎include/livekit/local_audio_track.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ class LIVEKIT_API LocalAudioTrack : public Track {
7777

7878
/// Returns a human-readable string representation of the track,
7979
/// including its SID and name. Useful for debugging and logging.
80+
std::string toString() const;
81+
82+
/// @deprecated Use toString() instead.
83+
// NOLINTBEGIN(readability-identifier-naming)
84+
[[deprecated("LocalAudioTrack::to_string is deprecated; use LocalAudioTrack::toString instead")]]
8085
std::string to_string() const;
86+
// NOLINTEND(readability-identifier-naming)
8187

8288
/// Returns the publication that owns this track, or nullptr if the track is
8389
/// not published.

‎include/livekit/local_data_track.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class LIVEKIT_API LocalDataTrack {
9898

9999
explicit LocalDataTrack(const proto::OwnedLocalDataTrack& owned);
100100

101-
uintptr_t ffi_handle_id() const noexcept { return handle_.get(); }
101+
uintptr_t ffiHandleId() const noexcept { return handle_.get(); }
102102

103103
/** RAII wrapper for the Rust-owned FFI resource. */
104104
FfiHandle handle_;

0 commit comments

Comments
 (0)