Skip to content

Commit a00c070

Browse files
Documentation cleanup: initial pass (#135)
* Doxygen consistency, agents.md, fix old connect() methods
1 parent 7e476e5 commit a00c070

35 files changed

Lines changed: 1366 additions & 1746 deletions

AGENTS.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,71 @@ with the same library loaded elsewhere in the host process.
235235
- Use `LK_LOG_WARN` for non-fatal unexpected conditions.
236236
- Use `Result<T, E>` for operations that can fail with typed errors (e.g., data track publish/subscribe).
237237

238+
### Public API Documentation (Doxygen)
239+
240+
The public API (`include/livekit/*.h`) is what consumers read first and is also
241+
published as a Doxygen site (`docs/Doxyfile`, `.github/workflows/publish-docs.yml`).
242+
Every doc comment in `include/livekit/` must use the rules below, and PRs that
243+
add or modify public symbols are gated on these rules during review.
244+
245+
#### Comment style
246+
247+
- Use triple-slash `///` Doxygen comments. Do **not** use `/** ... */` Javadoc
248+
blocks or `/* ... */` block comments for documentation.
249+
- Apache license headers stay as `/* ... */` block comments — they are not
250+
documentation.
251+
- Section organization comments (e.g. `// ---- Accessors ----`,
252+
`// Read-only properties`) may stay as `//` since they do not document a
253+
specific symbol.
254+
- Implementation comments inside `.cpp` files (non-Doxygen) may use `//`
255+
freely.
256+
- Use Doxygen `@`-prefixed commands (`@param`, `@return`, `@throws`, `@note`,
257+
`@brief`, `@deprecated`, `@ref`, `@p`, `@c`). Do not use the equivalent
258+
`\`-prefixed forms in new code.
259+
260+
#### Required tags
261+
262+
- Document parameters using `@param name Description.`
263+
- Document non-void return values using `@return Description.`
264+
- Document thrown exceptions using `@throws ExceptionType When/why it's
265+
thrown.` Operations that can fail without throwing should return
266+
`Result<T, E>` (see Error Handling above) and the variants should be
267+
documented in the doc block.
268+
- Free-text "Parameters:", "Returns:", "Throws:" sections in legacy comments
269+
must be converted to the corresponding `@param` / `@return` / `@throws`
270+
tags when the comment is touched.
271+
272+
#### Example
273+
274+
```cpp
275+
/// Publish a local track to the room.
276+
///
277+
/// Blocks until the FFI publish response arrives.
278+
///
279+
/// @param track Track to publish. Must be non-null.
280+
/// @param options Publish options (codec, simulcast, etc.).
281+
/// @throws std::runtime_error if the FFI reports an error.
282+
void publishTrack(const std::shared_ptr<Track>& track, const TrackPublishOptions& options);
283+
```
284+
285+
#### Deprecation comments
286+
287+
When superseding a public API, every retained back-compat shim must carry a
288+
Doxygen `/// @deprecated Use <newName>() instead.` line so the generated docs
289+
render a deprecation callout (see "Deprecating a public API" above).
290+
291+
#### Verifying locally
292+
293+
Run Doxygen from the repository root to regenerate the HTML docs:
294+
295+
```bash
296+
doxygen docs/Doxyfile
297+
```
298+
299+
The output lands in `docs/html/`. Doxygen warnings about "is not documented"
300+
indicate undocumented public symbols — adding documentation to them is
301+
encouraged but not strictly required by these rules.
302+
238303
### Integer Types
239304

240305
- Prefer fixed-width integer types from `<cstdint>` (`std::int32_t`, `std::uint64_t`, etc.) over raw primitive integer types when size or signedness matters.

include/livekit/audio_frame.h

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,30 @@ class AudioFrameBufferInfo;
2929
class OwnedAudioFrameBuffer;
3030
} // namespace proto
3131

32-
/**
33-
* @brief Represents a raw PCM audio frame with interleaved int16 samples.
34-
*
35-
* AudioFrame holds decoded audio data along with metadata such as sample rate,
36-
* number of channels, and samples per channel. It is used for capturing and
37-
* processing audio in the LiveKit SDK.
38-
*/
32+
/// @brief Represents a raw PCM audio frame with interleaved int16 samples.
33+
///
34+
/// AudioFrame holds decoded audio data along with metadata such as sample rate,
35+
/// number of channels, and samples per channel. It is used for capturing and
36+
/// processing audio in the LiveKit SDK.
3937
class LIVEKIT_API AudioFrame {
4038
public:
41-
/**
42-
* Construct an AudioFrame from raw PCM samples.
43-
*
44-
* @param data Interleaved PCM samples (int16).
45-
* @param sample_rate Sample rate (Hz).
46-
* @param num_channels Number of channels.
47-
* @param samples_per_channel Number of samples per channel.
48-
*
49-
* Throws std::invalid_argument if the data size is inconsistent with
50-
* num_channels * samples_per_channel.
51-
*/
39+
/// Construct an AudioFrame from raw PCM samples.
40+
///
41+
/// @param data Interleaved PCM samples (int16).
42+
/// @param sample_rate Sample rate (Hz).
43+
/// @param num_channels Number of channels.
44+
/// @param samples_per_channel Number of samples per channel.
45+
///
46+
/// @throws std::invalid_argument if the data size is inconsistent with
47+
/// num_channels * samples_per_channel.
5248
AudioFrame(std::vector<std::int16_t> data, int sample_rate, int num_channels, int samples_per_channel);
5349
AudioFrame(); // Default constructor
5450
virtual ~AudioFrame() = default;
5551

56-
/**
57-
* Create a new zero-initialized AudioFrame instance.
58-
*/
52+
/// Create a new zero-initialized AudioFrame instance.
5953
static AudioFrame create(int sample_rate, int num_channels, int samples_per_channel);
6054

61-
/**
62-
* Construct an AudioFrame by copying data out of an OwnedAudioFrameBuffer.
63-
*/
55+
/// Construct an AudioFrame by copying data out of an OwnedAudioFrameBuffer.
6456
static AudioFrame fromOwnedInfo(const proto::OwnedAudioFrameBuffer& owned);
6557

6658
// ---- Accessors ----

include/livekit/audio_processing_module.h

Lines changed: 74 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,25 @@
2424

2525
namespace livekit {
2626

27-
/**
28-
* @brief WebRTC Audio Processing Module (APM) for real-time audio enhancement.
29-
*
30-
* AudioProcessingModule exposes WebRTC's built-in audio processing capabilities
31-
* including echo cancellation, noise suppression, automatic gain control, and
32-
* high-pass filtering.
33-
*
34-
* This class is designed for scenarios where you need explicit control over
35-
* audio processing, separate from the built-in processing in AudioSource.
36-
*
37-
* Typical usage pattern for echo cancellation:
38-
* 1. Create an APM with desired features enabled
39-
* 2. Call processReverseStream() with speaker/playback audio (reference signal)
40-
* 3. Call processStream() with microphone audio (near-end signal)
41-
* 4. The processed microphone audio will have echo removed
42-
*
43-
* Note: Audio frames must be exactly 10ms in duration.
44-
*/
27+
/// @brief WebRTC Audio Processing Module (APM) for real-time audio enhancement.
28+
///
29+
/// AudioProcessingModule exposes WebRTC's built-in audio processing capabilities
30+
/// including echo cancellation, noise suppression, automatic gain control, and
31+
/// high-pass filtering.
32+
///
33+
/// This class is designed for scenarios where you need explicit control over
34+
/// audio processing, separate from the built-in processing in AudioSource.
35+
///
36+
/// Typical usage pattern for echo cancellation:
37+
/// 1. Create an APM with desired features enabled
38+
/// 2. Call processReverseStream() with speaker/playback audio (reference signal)
39+
/// 3. Call processStream() with microphone audio (near-end signal)
40+
/// 4. The processed microphone audio will have echo removed
41+
///
42+
/// @note Audio frames must be exactly 10ms in duration.
4543
class LIVEKIT_API AudioProcessingModule {
4644
public:
47-
/**
48-
* @brief Configuration options for the Audio Processing Module.
49-
*/
45+
/// @brief Configuration options for the Audio Processing Module.
5046
struct Options {
5147
/// Enable acoustic echo cancellation (AEC3).
5248
/// Removes acoustic echo in two-way communication scenarios.
@@ -68,20 +64,16 @@ class LIVEKIT_API AudioProcessingModule {
6864
Options() = default;
6965
};
7066

71-
/**
72-
* @brief Create a new Audio Processing Module with default options (all
73-
* disabled).
74-
*
75-
* @throws std::runtime_error if the APM could not be created.
76-
*/
67+
/// @brief Create a new Audio Processing Module with default options (all
68+
/// disabled).
69+
///
70+
/// @throws std::runtime_error if the APM could not be created.
7771
AudioProcessingModule();
7872

79-
/**
80-
* @brief Create a new Audio Processing Module with the specified options.
81-
*
82-
* @param options Configuration for which processing features to enable.
83-
* @throws std::runtime_error if the APM could not be created.
84-
*/
73+
/// @brief Create a new Audio Processing Module with the specified options.
74+
///
75+
/// @param options Configuration for which processing features to enable.
76+
/// @throws std::runtime_error if the APM could not be created.
8577
explicit AudioProcessingModule(const Options& options);
8678

8779
virtual ~AudioProcessingModule() = default;
@@ -94,65 +86,59 @@ class LIVEKIT_API AudioProcessingModule {
9486
AudioProcessingModule(AudioProcessingModule&&) noexcept = default;
9587
AudioProcessingModule& operator=(AudioProcessingModule&&) noexcept = default;
9688

97-
/**
98-
* @brief Process the forward (near-end/microphone) audio stream.
99-
*
100-
* This method processes audio captured from the local microphone. It applies
101-
* the enabled processing features (noise suppression, gain control, etc.)
102-
* and removes echo based on the reference signal provided via
103-
* processReverseStream().
104-
*
105-
* The audio data is modified in-place.
106-
*
107-
* @param frame The audio frame to process (modified in-place).
108-
*
109-
* @throws std::runtime_error if processing fails.
110-
*
111-
* @note The frame must contain exactly 10ms of audio.
112-
*/
89+
/// @brief Process the forward (near-end/microphone) audio stream.
90+
///
91+
/// This method processes audio captured from the local microphone. It applies
92+
/// the enabled processing features (noise suppression, gain control, etc.)
93+
/// and removes echo based on the reference signal provided via
94+
/// processReverseStream().
95+
///
96+
/// The audio data is modified in-place.
97+
///
98+
/// @param frame The audio frame to process (modified in-place).
99+
///
100+
/// @throws std::runtime_error if processing fails.
101+
///
102+
/// @note The frame must contain exactly 10ms of audio.
113103
void processStream(AudioFrame& frame);
114104

115-
/**
116-
* @brief Process the reverse (far-end/speaker) audio stream.
117-
*
118-
* This method provides the reference signal for echo cancellation. Call this
119-
* with the audio that is being played through the speakers, so the APM can
120-
* learn the acoustic characteristics and remove the echo from the microphone
121-
* signal.
122-
*
123-
* The audio data is modified in-place.
124-
*
125-
* @param frame The audio frame to process (modified in-place).
126-
*
127-
* @throws std::runtime_error if processing fails.
128-
*
129-
* @note The frame must contain exactly 10ms of audio.
130-
*/
105+
/// @brief Process the reverse (far-end/speaker) audio stream.
106+
///
107+
/// This method provides the reference signal for echo cancellation. Call this
108+
/// with the audio that is being played through the speakers, so the APM can
109+
/// learn the acoustic characteristics and remove the echo from the microphone
110+
/// signal.
111+
///
112+
/// The audio data is modified in-place.
113+
///
114+
/// @param frame The audio frame to process (modified in-place).
115+
///
116+
/// @throws std::runtime_error if processing fails.
117+
///
118+
/// @note The frame must contain exactly 10ms of audio.
131119
void processReverseStream(AudioFrame& frame);
132120

133-
/**
134-
* @brief Set the estimated delay between the reverse and forward streams.
135-
*
136-
* This must be called if and only if echo processing is enabled.
137-
*
138-
* Sets the delay in ms between processReverseStream() receiving a far-end
139-
* frame and processStream() receiving a near-end frame containing the
140-
* corresponding echo. On the client-side this can be expressed as:
141-
*
142-
* delay = (t_render - t_analyze) + (t_process - t_capture)
143-
*
144-
* where:
145-
* - t_analyze is the time a frame is passed to processReverseStream() and
146-
* t_render is the time the first sample of the same frame is rendered by
147-
* the audio hardware.
148-
* - t_capture is the time the first sample of a frame is captured by the
149-
* audio hardware and t_process is the time the same frame is passed to
150-
* processStream().
151-
*
152-
* @param delay_ms Delay in milliseconds.
153-
*
154-
* @throws std::runtime_error if setting the delay fails.
155-
*/
121+
/// @brief Set the estimated delay between the reverse and forward streams.
122+
///
123+
/// This must be called if and only if echo processing is enabled.
124+
///
125+
/// Sets the delay in ms between processReverseStream() receiving a far-end
126+
/// frame and processStream() receiving a near-end frame containing the
127+
/// corresponding echo. On the client-side this can be expressed as:
128+
///
129+
/// delay = (t_render - t_analyze) + (t_process - t_capture)
130+
///
131+
/// where:
132+
/// - t_analyze is the time a frame is passed to processReverseStream() and
133+
/// t_render is the time the first sample of the same frame is rendered by
134+
/// the audio hardware.
135+
/// - t_capture is the time the first sample of a frame is captured by the
136+
/// audio hardware and t_process is the time the same frame is passed to
137+
/// processStream().
138+
///
139+
/// @param delay_ms Delay in milliseconds.
140+
///
141+
/// @throws std::runtime_error if setting the delay fails.
156142
void setStreamDelayMs(int delay_ms);
157143

158144
private:

0 commit comments

Comments
 (0)