88 * http://www.apache.org/licenses/LICENSE-2.0
99 *
1010 * Unless required by applicable law or agreed to in writing, software
11- * distributed under the License is distributed on an “ AS IS” BASIS,
11+ * distributed under the License is distributed on an " AS IS" BASIS,
1212 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313 * See the License for the specific language governing permissions and
1414 * limitations under the License.
@@ -29,65 +29,81 @@ class AudioFrameBufferInfo;
2929class 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+ // / A raw PCM audio frame with interleaved `int16` samples.
33+ // /
34+ // / `AudioFrame` holds decoded audio data along with metadata such as
35+ // / sample rate, number of channels, and samples per channel. It is used
36+ // / for capturing and processing audio in the LiveKit SDK.
37+ // /
38+ // / @note Thread-safety: Not thread-safe. A single `AudioFrame` instance
39+ // / must not be mutated concurrently from multiple threads; concurrent
40+ // / const-access is safe.
3941class LIVEKIT_API AudioFrame {
4042public:
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- */
43+ // / Construct an `AudioFrame` from raw PCM samples.
44+ // /
45+ // / @param data Interleaved PCM samples (`int16`).
46+ // / @param sample_rate Sample rate (Hz).
47+ // / @param num_channels Number of channels.
48+ // / @param samples_per_channel Number of samples per channel.
49+ // /
50+ // / @throws std::invalid_argument if `data.size()` is inconsistent with
51+ // / `num_channels * samples_per_channel`.
5252 AudioFrame (std::vector<std::int16_t > data, int sample_rate, int num_channels, int samples_per_channel);
53- AudioFrame (); // Default constructor
53+
54+ // / Construct an empty `AudioFrame` (all fields zero-initialized).
55+ AudioFrame ();
56+
5457 virtual ~AudioFrame () = default ;
5558
56- /* *
57- * Create a new zero-initialized AudioFrame instance.
58- */
59+ // / Create a new zero-initialized `AudioFrame` instance.
60+ // /
61+ // / @param sample_rate Sample rate (Hz).
62+ // / @param num_channels Number of channels.
63+ // / @param samples_per_channel Number of samples per channel.
64+ // / @return A frame whose buffer is sized to
65+ // / `num_channels * samples_per_channel`
66+ // / and zero-filled.
67+ // /
68+ // / @note Thread-safety: Thread-safe. Pure factory function.
5969 static AudioFrame create (int sample_rate, int num_channels, int samples_per_channel);
6070
61- /* *
62- * Construct an AudioFrame by copying data out of an OwnedAudioFrameBuffer.
63- */
71+ // / Construct an `AudioFrame` by copying data out of an FFI-owned
72+ // / audio buffer.
73+ // /
74+ // / @param owned Buffer received from the FFI (data is copied).
75+ // / @return A new `AudioFrame` owning a copy of the samples.
76+ // /
77+ // / @note Thread-safety: Thread-safe. Pure transformation; no global
78+ // / state.
6479 static AudioFrame fromOwnedInfo (const proto::OwnedAudioFrameBuffer& owned);
6580
66- // ---- Accessors ----
67-
81+ // / @return Mutable reference to the underlying sample buffer.
6882 const std::vector<std::int16_t >& data () const noexcept { return data_; }
83+
84+ // / @return Mutable reference to the underlying sample buffer.
6985 std::vector<std::int16_t >& data () noexcept { return data_; }
7086
71- // / Number of samples in the buffer (per all channels) .
87+ // / @return Total number of samples in the buffer across all channels.
7288 std::size_t total_samples () const noexcept { return data_.size (); }
7389
74- // / Sample rate in Hz.
90+ // / @return Sample rate in Hz.
7591 int sample_rate () const noexcept { return sample_rate_; }
7692
77- // / Number of channels.
93+ // / @return Number of channels.
7894 int num_channels () const noexcept { return num_channels_; }
7995
80- // / Samples per channel.
96+ // / @return Samples per channel.
8197 int samples_per_channel () const noexcept { return samples_per_channel_; }
8298
83- // / Duration in seconds (samples_per_channel / sample_rate).
99+ // / @return Duration in seconds (` samples_per_channel / sample_rate` ).
84100 double duration () const noexcept ;
85101
86- // / A human -readable description.
102+ // / @return Human -readable description (sample rate, channels, size) .
87103 std::string to_string () const ;
88104
89105protected:
90- // Build a proto AudioFrameBufferInfo pointing at this frame’ s data.
106+ // Build a proto AudioFrameBufferInfo pointing at this frame' s data.
91107 // Used internally by AudioSource.
92108 proto::AudioFrameBufferInfo toProto () const ;
93109 friend class AudioSource ;
@@ -99,4 +115,4 @@ class LIVEKIT_API AudioFrame {
99115 int samples_per_channel_;
100116};
101117
102- } // namespace livekit
118+ } // namespace livekit
0 commit comments