Skip to content

Commit 8bcea38

Browse files
Additional clang-tidy changes
1 parent ccc021f commit 8bcea38

4 files changed

Lines changed: 28 additions & 28 deletions

File tree

include/livekit/data_stream.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct ByteStreamInfo : BaseStreamInfo {
7878
class TextStreamReader {
7979
public:
8080
/// Construct a reader from initial stream metadata.
81-
explicit TextStreamReader(const TextStreamInfo &info);
81+
explicit TextStreamReader(TextStreamInfo info);
8282

8383
TextStreamReader(const TextStreamReader &) = delete;
8484
TextStreamReader &operator=(const TextStreamReader &) = delete;
@@ -118,7 +118,7 @@ class TextStreamReader {
118118
class ByteStreamReader {
119119
public:
120120
/// Construct a reader from initial stream metadata.
121-
explicit ByteStreamReader(const ByteStreamInfo &info);
121+
explicit ByteStreamReader(ByteStreamInfo info);
122122

123123
ByteStreamReader(const ByteStreamReader &) = delete;
124124
ByteStreamReader &operator=(const ByteStreamReader &) = delete;
@@ -177,13 +177,13 @@ class BaseStreamWriter {
177177

178178
protected:
179179
BaseStreamWriter(LocalParticipant &local_participant,
180-
const std::string &topic = "",
181-
const std::map<std::string, std::string> &attributes = {},
182-
const std::string &stream_id = "",
180+
std::string topic = "",
181+
std::map<std::string, std::string> attributes = {},
182+
std::string stream_id = "",
183183
std::optional<std::size_t> total_size = std::nullopt,
184-
const std::string &mime_type = "",
185-
const std::vector<std::string> &destination_identities = {},
186-
const std::string &sender_identity = "");
184+
std::string mime_type = "",
185+
std::vector<std::string> destination_identities = {},
186+
std::string sender_identity = "");
187187

188188
enum class StreamKind { kUnknown, kText, kByte };
189189

src/audio_frame.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ AudioFrame AudioFrame::create(int sample_rate, int num_channels,
5454
const std::size_t count = static_cast<std::size_t>(num_channels) *
5555
static_cast<std::size_t>(samples_per_channel);
5656
std::vector<std::int16_t> data(count, 0);
57-
return AudioFrame(std::move(data), sample_rate, num_channels,
58-
samples_per_channel);
57+
return {std::move(data), sample_rate, num_channels, samples_per_channel};
5958
}
6059

6160
AudioFrame
@@ -69,8 +68,8 @@ AudioFrame::fromOwnedInfo(const proto::OwnedAudioFrameBuffer &owned) {
6968
const std::size_t count = static_cast<std::size_t>(num_channels) *
7069
static_cast<std::size_t>(samples_per_channel);
7170

72-
const std::int16_t *ptr =
73-
reinterpret_cast<const std::int16_t *>(info.data_ptr());
71+
const auto *ptr =
72+
reinterpret_cast<const std::int16_t *>(info.data_ptr()); // NOLINT(performance-no-int-to-ptr)
7473

7574
if (ptr == nullptr && count > 0) {
7675
throw std::runtime_error(
@@ -88,8 +87,7 @@ AudioFrame::fromOwnedInfo(const proto::OwnedAudioFrameBuffer &owned) {
8887
// drop the OwnedAudioFrameBuffer.
8988
}
9089

91-
return AudioFrame(std::move(data), sample_rate, num_channels,
92-
samples_per_channel);
90+
return {std::move(data), sample_rate, num_channels, samples_per_channel};
9391
}
9492

9593
proto::AudioFrameBufferInfo AudioFrame::toProto() const {

src/data_stream.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ void fillBaseInfo(BaseStreamInfo &dst, const std::string &stream_id,
104104
// Reader implementation
105105
// =====================================================================
106106

107-
TextStreamReader::TextStreamReader(const TextStreamInfo &info) : info_(info) {}
107+
TextStreamReader::TextStreamReader(TextStreamInfo info)
108+
: info_(std::move(info)) {}
108109

109110
void TextStreamReader::onChunkUpdate(const std::string &text) {
110111
{
@@ -148,7 +149,8 @@ std::string TextStreamReader::readAll() {
148149
return result;
149150
}
150151

151-
ByteStreamReader::ByteStreamReader(const ByteStreamInfo &info) : info_(info) {}
152+
ByteStreamReader::ByteStreamReader(ByteStreamInfo info)
153+
: info_(std::move(info)) {}
152154

153155
void ByteStreamReader::onChunkUpdate(const std::vector<std::uint8_t> &bytes) {
154156
{
@@ -189,21 +191,22 @@ bool ByteStreamReader::readNext(std::vector<std::uint8_t> &out) {
189191
// =====================================================================
190192

191193
BaseStreamWriter::BaseStreamWriter(
192-
LocalParticipant &local_participant, const std::string &topic,
193-
const std::map<std::string, std::string> &attributes,
194-
const std::string &stream_id, std::optional<std::size_t> total_size,
195-
const std::string &mime_type,
196-
const std::vector<std::string> &destination_identities,
197-
const std::string &sender_identity)
194+
LocalParticipant &local_participant, std::string topic,
195+
std::map<std::string, std::string> attributes,
196+
std::string stream_id, std::optional<std::size_t> total_size,
197+
std::string mime_type,
198+
std::vector<std::string> destination_identities,
199+
std::string sender_identity)
198200
: local_participant_(local_participant),
199-
stream_id_(stream_id.empty() ? generateRandomId() : stream_id),
200-
mime_type_(mime_type), topic_(topic),
201+
stream_id_(stream_id.empty() ? generateRandomId()
202+
: std::move(stream_id)),
203+
mime_type_(std::move(mime_type)), topic_(std::move(topic)),
201204
timestamp_ms_(std::chrono::duration_cast<std::chrono::milliseconds>(
202205
std::chrono::system_clock::now().time_since_epoch())
203206
.count()),
204-
total_size_(total_size), attributes_(attributes),
205-
destination_identities_(destination_identities),
206-
sender_identity_(sender_identity) {
207+
total_size_(total_size), attributes_(std::move(attributes)),
208+
destination_identities_(std::move(destination_identities)),
209+
sender_identity_(std::move(sender_identity)) {
207210
if (sender_identity_.empty()) {
208211
sender_identity_ = local_participant_.identity();
209212
}

src/stats.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ QualityLimitationReason fromProto(livekit::proto::QualityLimitationReason r) {
5050
case P::LIMITATION_BANDWIDTH:
5151
return QualityLimitationReason::Bandwidth;
5252
case P::LIMITATION_OTHER:
53-
return QualityLimitationReason::Other;
5453
default:
5554
return QualityLimitationReason::Other;
5655
}

0 commit comments

Comments
 (0)