Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
livekit-ffi: minor
---

# Sending device model over ffi for client telemetry

#966 by @MaxHeimbrock

Send device_model in client telemetry if set from ffi. This adds a parameter `livekit_ffi_initialize`, all ffi clients must provide the device_model or null.
8 changes: 8 additions & 0 deletions livekit-api/src/signal_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub struct SignalOptions {
pub single_peer_connection: bool,
/// Timeout for each individual signal connection attempt
pub connect_timeout: Duration,
/// Device model string for ClientInfo (e.g. "MacBookPro18,3")
pub device_model: Option<String>,
}

impl Default for SignalOptions {
Expand All @@ -111,6 +113,7 @@ impl Default for SignalOptions {
sdk_options: SignalSdkOptions::default(),
single_peer_connection: false,
connect_timeout: SIGNAL_CONNECT_TIMEOUT,
device_model: None,
}
}
}
Expand Down Expand Up @@ -569,6 +572,7 @@ fn create_join_request_param(
protocol: PROTOCOL_VERSION as i32,
os,
os_version,
device_model: options.device_model.clone().unwrap_or_default(),
..Default::default()
};

Expand Down Expand Up @@ -668,6 +672,10 @@ fn get_livekit_url(
lk_url.query_pairs_mut().append_pair("version", sdk_version.as_str());
}

if let Some(device_model) = &options.device_model {
lk_url.query_pairs_mut().append_pair("device_model", device_model.as_str());
}

// For reconnects in v0 path, add reconnect and sid as separate query parameters
if reconnect {
lk_url
Expand Down
1 change: 1 addition & 0 deletions livekit-ffi-node-bindings/src/nodejs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn livekit_initialize(cb: Function<Uint8Array, ()>, capture_logs: bool, sdk_vers
capture_logs,
sdk: "node".to_string(),
sdk_version,
device_model: None,
});
}

Expand Down
13 changes: 13 additions & 0 deletions livekit-ffi/src/cabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub unsafe extern "C" fn livekit_ffi_initialize(
capture_logs: bool,
sdk: *const c_char,
sdk_version: *const c_char,
device_model: *const c_char,
Comment thread
MaxHeimbrock marked this conversation as resolved.
) {
FFI_SERVER.setup(FfiConfig {
callback_fn: Arc::new(move |event| {
Expand All @@ -45,6 +46,18 @@ pub unsafe extern "C" fn livekit_ffi_initialize(
capture_logs,
sdk: CStr::from_ptr(sdk).to_string_lossy().into_owned(),
sdk_version: CStr::from_ptr(sdk_version).to_string_lossy().into_owned(),
device_model: {
if device_model.is_null() {
None
} else {
let s = CStr::from_ptr(device_model).to_string_lossy().into_owned();
if s.is_empty() {
None
} else {
Some(s)
}
}
},
});

log::info!("initializing ffi server v{}", env!("CARGO_PKG_VERSION"));
Expand Down
1 change: 1 addition & 0 deletions livekit-ffi/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct FfiConfig {
pub capture_logs: bool,
pub sdk: String,
pub sdk_version: String,
pub device_model: Option<String>,
}

/// To make sure we use the right types, only types that implement this trait
Expand Down
1 change: 1 addition & 0 deletions livekit-ffi/src/server/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl FfiRoom {
if let Some(c) = config.as_ref() {
options.sdk_options.sdk = c.sdk.clone();
options.sdk_options.sdk_version = c.sdk_version.clone();
options.device_model = c.device_model.clone();
}
}

Expand Down
4 changes: 4 additions & 0 deletions livekit/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ pub struct RoomOptions {
pub single_peer_connection: bool,
/// Timeout for each individual signal connection attempt
pub connect_timeout: Duration,
/// Device model string for ClientInfo (e.g. "MacBookPro18,3")
pub device_model: Option<String>,
}

impl Default for RoomOptions {
Expand All @@ -396,6 +398,7 @@ impl Default for RoomOptions {
sdk_options: RoomSdkOptions::default(),
single_peer_connection: false,
connect_timeout: SIGNAL_CONNECT_TIMEOUT,
device_model: None,
}
}
}
Expand Down Expand Up @@ -491,6 +494,7 @@ impl Room {
signal_options.adaptive_stream = options.adaptive_stream;
signal_options.single_peer_connection = options.single_peer_connection;
signal_options.connect_timeout = options.connect_timeout;
signal_options.device_model = options.device_model.clone();
let (rtc_engine, join_response, engine_events) = RtcEngine::connect(
url,
token,
Expand Down
Loading