Skip to content

Commit 15a5a7f

Browse files
authored
Fix carah error of get session stats request (#490)
1 parent fe8037a commit 15a5a7f

File tree

3 files changed

+45
-1
lines changed

3 files changed

+45
-1
lines changed

libwebrtc/src/stats.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub enum RtcStats {
2828
LocalCandidate(LocalCandidateStats),
2929
RemoteCandidate(RemoteCandidateStats),
3030
Certificate(CertificateStats),
31+
Stream(StreamStats),
3132
Track, // Deprecated
3233
}
3334

@@ -272,6 +273,15 @@ pub struct CertificateStats {
272273
pub certificate: dictionaries::CertificateStats,
273274
}
274275

276+
#[derive(Debug, Default, Clone, Deserialize)]
277+
pub struct StreamStats {
278+
#[serde(flatten)]
279+
pub rtc: dictionaries::RtcStats,
280+
281+
#[serde(flatten)]
282+
pub stream: dictionaries::StreamStats,
283+
}
284+
275285
#[derive(Debug, Default, Clone, Deserialize)]
276286
pub struct TrackStats {}
277287

@@ -588,4 +598,13 @@ pub mod dictionaries {
588598
pub base64_certificate: String,
589599
pub issuer_certificate_id: String,
590600
}
601+
602+
#[derive(Debug, Default, Clone, Deserialize)]
603+
#[serde(rename_all = "camelCase")]
604+
#[serde(default)]
605+
pub struct StreamStats {
606+
pub id: String,
607+
pub stream_identifier: String,
608+
// pub timestamp: i64,
609+
}
591610
}

livekit-ffi/protocol/stats.proto

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ message RtcStats {
170170
required CertificateStats certificate = 2;
171171
}
172172

173+
message Stream {
174+
required RtcStatsData rtc = 1;
175+
required StreamStats stream = 2;
176+
}
177+
173178
message Track {
174179
// Deprecated
175180
}
@@ -189,7 +194,8 @@ message RtcStats {
189194
LocalCandidate local_candidate = 14;
190195
RemoteCandidate remote_candidate = 15;
191196
Certificate certificate = 16;
192-
Track track = 17;
197+
Stream stream = 17;
198+
Track track = 18;
193199
}
194200
}
195201

@@ -447,3 +453,9 @@ message CertificateStats {
447453
required string issuer_certificate_id = 4;
448454
}
449455

456+
message StreamStats {
457+
required string id = 1;
458+
required string stream_identifier = 2;
459+
// required int64 timestamp = 3;
460+
}
461+

livekit-ffi/src/conversion/stats.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ impl From<rtc::RtcStats> for proto::RtcStats {
164164
rtc::RtcStats::Certificate(certificate) => {
165165
proto::rtc_stats::Stats::Certificate(certificate.into())
166166
}
167+
rtc::RtcStats::Stream(stream) => proto::rtc_stats::Stats::Stream(stream.into()),
167168
rtc::RtcStats::Track {} => {
168169
proto::rtc_stats::Stats::Track(proto::rtc_stats::Track {})
169170
}
@@ -281,6 +282,12 @@ impl From<rtc::CertificateStats> for proto::rtc_stats::Certificate {
281282
}
282283
}
283284

285+
impl From<rtc::StreamStats> for proto::rtc_stats::Stream {
286+
fn from(value: rtc::StreamStats) -> Self {
287+
Self { rtc: value.rtc.into(), stream: value.stream.into() }
288+
}
289+
}
290+
284291
// Dictionaries
285292

286293
impl From<rtc::dictionaries::RtcStats> for proto::RtcStatsData {
@@ -289,6 +296,12 @@ impl From<rtc::dictionaries::RtcStats> for proto::RtcStatsData {
289296
}
290297
}
291298

299+
impl From<rtc::dictionaries::StreamStats> for proto::StreamStats {
300+
fn from(value: rtc::dictionaries::StreamStats) -> Self {
301+
Self { id: value.id, stream_identifier: value.stream_identifier }
302+
}
303+
}
304+
292305
impl From<rtc::dictionaries::CodecStats> for proto::CodecStats {
293306
fn from(value: rtc::dictionaries::CodecStats) -> Self {
294307
Self {

0 commit comments

Comments
 (0)