Skip to content

Commit aac4687

Browse files
committed
fix: ffi build
1 parent 2d21bfe commit aac4687

File tree

7 files changed

+70
-12
lines changed

7 files changed

+70
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

livekit-ffi/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ futures-util = { version = "0.3", default-features = false, features = ["sink"]
2727
parking_lot = { version = "0.12", features = ["deadlock_detection"] }
2828
prost = "0.12"
2929
prost-types = "0.12"
30+
pbjson = "0.6"
31+
pbjson-types = "0.6"
3032
lazy_static = "1.4"
3133
thiserror = "1.0"
3234
log = "0.4"

livekit-ffi/generate_proto.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ OUT_RUST=src
2020
protoc \
2121
-I=$PROTOCOL \
2222
--prost_out=$OUT_RUST \
23+
--prost_opt=compile_well_known_types \
24+
--prost_opt=extern_path=.google.protobuf=::pbjson_types \
2325
$PROTOCOL/ffi.proto \
2426
$PROTOCOL/handle.proto \
2527
$PROTOCOL/room.proto \

livekit-ffi/generate_proto_win.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ set OUT_RUST=src
2020
protoc.exe ^
2121
-I=%PROTOCOL% ^
2222
--prost_out=%OUT_RUST% ^
23+
--prost_opt=compile_well_known_types ^
24+
--prost_opt=extern_path=.google.protobuf=::pbjson_types ^
2325
%PROTOCOL%/ffi.proto ^
2426
%PROTOCOL%/handle.proto ^
2527
%PROTOCOL%/room.proto ^

livekit-ffi/src/conversion/metrics.rs

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl From<protocol::MetricLabel> for proto::MetricLabel {
3838
protocol::MetricLabel::PublisherRtt => Self::PublisherRtt,
3939
protocol::MetricLabel::ServerMeshRtt => Self::ServerMeshRtt,
4040
protocol::MetricLabel::SubscriberRtt => Self::SubscriberRtt,
41-
protocol::MetricLabel::PredefinedMaxValue => Self::MetricLabelPredefinedMaxValue,
41+
protocol::MetricLabel::PredefinedMaxValue => Self::PredefinedMaxValue,
4242
}
4343
}
4444
}
@@ -47,7 +47,7 @@ impl From<protocol::MetricSample> for proto::MetricSample {
4747
fn from(value: protocol::MetricSample) -> Self {
4848
Self {
4949
timestamp_ms: value.timestamp_ms,
50-
normalized_timestamp: value.normalized_timestamp.map(Into::into),
50+
normalized_timestamp: value.normalized_timestamp,
5151
value: value.value,
5252
}
5353
}
@@ -73,8 +73,8 @@ impl From<protocol::EventMetric> for proto::EventMetric {
7373
track_sid: value.track_sid,
7474
start_timestamp_ms: value.start_timestamp_ms,
7575
end_timestamp_ms: value.end_timestamp_ms,
76-
normalized_start_timestamp: value.normalized_start_timestamp.map(Into::into),
77-
normalized_end_timestamp: value.normalized_end_timestamp.map(Into::into),
76+
normalized_start_timestamp: value.normalized_start_timestamp,
77+
normalized_end_timestamp: value.normalized_end_timestamp,
7878
metadata: value.metadata,
7979
rid: value.rid,
8080
}
@@ -85,7 +85,57 @@ impl From<protocol::MetricsBatch> for proto::MetricsBatch {
8585
fn from(value: protocol::MetricsBatch) -> Self {
8686
Self {
8787
timestamp_ms: value.timestamp_ms,
88-
normalized_timestamp: value.normalized_timestamp.map(Into::into),
88+
normalized_timestamp: value.normalized_timestamp,
89+
str_data: value.str_data,
90+
time_series: value.time_series.into_iter().map(Into::into).collect(),
91+
events: value.events.into_iter().map(Into::into).collect(),
92+
}
93+
}
94+
}
95+
96+
impl From<proto::TimeSeriesMetric> for protocol::TimeSeriesMetric {
97+
fn from(value: proto::TimeSeriesMetric) -> Self {
98+
Self {
99+
label: value.label,
100+
participant_identity: value.participant_identity,
101+
track_sid: value.track_sid,
102+
samples: value.samples.into_iter().map(Into::into).collect(),
103+
rid: value.rid,
104+
}
105+
}
106+
}
107+
108+
impl From<proto::MetricSample> for protocol::MetricSample {
109+
fn from(value: proto::MetricSample) -> Self {
110+
Self {
111+
timestamp_ms: value.timestamp_ms,
112+
normalized_timestamp: value.normalized_timestamp,
113+
value: value.value,
114+
}
115+
}
116+
}
117+
118+
impl From<proto::EventMetric> for protocol::EventMetric {
119+
fn from(value: proto::EventMetric) -> Self {
120+
Self {
121+
label: value.label,
122+
participant_identity: value.participant_identity,
123+
track_sid: value.track_sid,
124+
start_timestamp_ms: value.start_timestamp_ms,
125+
end_timestamp_ms: value.end_timestamp_ms,
126+
normalized_start_timestamp: value.normalized_start_timestamp,
127+
normalized_end_timestamp: value.normalized_end_timestamp,
128+
metadata: value.metadata,
129+
rid: value.rid,
130+
}
131+
}
132+
}
133+
134+
impl From<proto::MetricsBatch> for protocol::MetricsBatch {
135+
fn from(value: proto::MetricsBatch) -> Self {
136+
Self {
137+
timestamp_ms: value.timestamp_ms,
138+
normalized_timestamp: value.normalized_timestamp,
89139
str_data: value.str_data,
90140
time_series: value.time_series.into_iter().map(Into::into).collect(),
91141
events: value.events.into_iter().map(Into::into).collect(),

livekit-ffi/src/livekit.proto.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4780,7 +4780,7 @@ pub struct MetricsBatch {
47804780
#[prost(int64, tag="1")]
47814781
pub timestamp_ms: i64,
47824782
#[prost(message, optional, tag="2")]
4783-
pub normalized_timestamp: ::core::option::Option<::prost_types::Timestamp>,
4783+
pub normalized_timestamp: ::core::option::Option<::pbjson_types::Timestamp>,
47844784
/// To avoid repeating string values, we store them in a separate list and reference them by index
47854785
/// This is useful for storing participant identities, track names, etc.
47864786
/// There is also a predefined list of labels that can be used to reference common metrics.
@@ -4820,7 +4820,7 @@ pub struct MetricSample {
48204820
#[prost(int64, tag="1")]
48214821
pub timestamp_ms: i64,
48224822
#[prost(message, optional, tag="2")]
4823-
pub normalized_timestamp: ::core::option::Option<::prost_types::Timestamp>,
4823+
pub normalized_timestamp: ::core::option::Option<::pbjson_types::Timestamp>,
48244824
#[prost(float, tag="3")]
48254825
pub value: f32,
48264826
}
@@ -4842,9 +4842,9 @@ pub struct EventMetric {
48424842
#[prost(int64, optional, tag="5")]
48434843
pub end_timestamp_ms: ::core::option::Option<i64>,
48444844
#[prost(message, optional, tag="6")]
4845-
pub normalized_start_timestamp: ::core::option::Option<::prost_types::Timestamp>,
4845+
pub normalized_start_timestamp: ::core::option::Option<::pbjson_types::Timestamp>,
48464846
#[prost(message, optional, tag="7")]
4847-
pub normalized_end_timestamp: ::core::option::Option<::prost_types::Timestamp>,
4847+
pub normalized_end_timestamp: ::core::option::Option<::pbjson_types::Timestamp>,
48484848
#[prost(string, tag="8")]
48494849
pub metadata: ::prost::alloc::string::String,
48504850
/// index into 'str_data'

livekit-ffi/src/server/requests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,9 +1425,9 @@ pub fn handle_request(
14251425
)
14261426
}
14271427
proto::ffi_request::Message::PublishMetrics(publish_metrics) => {
1428-
on_publish_metrics(server, publish_metrics).map(|res| {
1429-
proto::ffi_response::Message::PublishMetrics(res)
1430-
})
1428+
proto::ffi_response::Message::PublishMetrics(
1429+
on_publish_metrics(server, publish_metrics)?
1430+
)
14311431
},
14321432
});
14331433

0 commit comments

Comments
 (0)