Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
livekit-ffi: minor
---

# Expose error message on EOS for data track subscriptions
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions livekit-ffi-node-bindings/proto/data_track_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,12 @@ export declare class DataTrackStreamFrameReceived extends Message<DataTrackStrea
*/
export declare class DataTrackStreamEOS extends Message<DataTrackStreamEOS> {
/**
* If the track could not be subscribed to, a message describing the error.
* Absent if the stream ended normally.
* Present if stream ended before any frames were emitted due to subscription establishment failing.
* Absent if the stream ended normally (i.e., due to the track being unpublished).
*
* @generated from field: optional string error = 1;
* @generated from field: optional livekit.proto.SubscribeDataTrackError error = 1;
*/
error?: string;
error?: SubscribeDataTrackError;

constructor(data?: PartialMessage<DataTrackStreamEOS>);

Expand Down
2 changes: 1 addition & 1 deletion livekit-ffi-node-bindings/proto/data_track_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ const DataTrackStreamFrameReceived = /*@__PURE__*/ proto2.makeMessageType(
const DataTrackStreamEOS = /*@__PURE__*/ proto2.makeMessageType(
"livekit.proto.DataTrackStreamEOS",
() => [
{ no: 1, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 1, name: "error", kind: "message", T: SubscribeDataTrackError, opt: true },
],
);

Expand Down
6 changes: 3 additions & 3 deletions livekit-ffi/protocol/data_track.proto
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ message DataTrackStreamFrameReceived {

// Stream has ended.
message DataTrackStreamEOS {
// If the track could not be subscribed to, a message describing the error.
// Absent if the stream ended normally.
optional string error = 1;
// Present if stream ended before any frames were emitted due to subscription establishment failing.
// Absent if the stream ended normally (i.e., due to the track being unpublished).
optional SubscribeDataTrackError error = 1;
}
8 changes: 5 additions & 3 deletions livekit-ffi/src/server/data_track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use super::{FfiHandle, FfiServer};
use crate::{proto, FfiHandleId, FfiResult};
use futures_util::StreamExt;
use livekit::data_track::{
DataTrackFrame, DataTrackStream, DataTrackSubscribeOptions, LocalDataTrack, RemoteDataTrack,
DataTrackFrame, DataTrackStream, DataTrackSubscribeError, DataTrackSubscribeOptions,
LocalDataTrack, RemoteDataTrack,
};
use std::sync::Arc;
use tokio::sync::{oneshot, Notify};
Expand Down Expand Up @@ -176,7 +177,7 @@ impl SubscriptionTask {
result = track.subscribe_with_options(options) => match result {
Ok(stream) => Some(stream),
Err(err) => {
self.send_eos(Some(err.to_string()));
self.send_eos(Some(err));
None
}
},
Expand All @@ -198,7 +199,8 @@ impl SubscriptionTask {
let _ = self.server.send_event(event.into());
}

fn send_eos(&self, error: Option<String>) {
fn send_eos(&self, error: Option<DataTrackSubscribeError>) {
let error: Option<proto::SubscribeDataTrackError> = error.map(|err| err.into());
let event = proto::DataTrackStreamEvent {
stream_handle: self.handle_id,
detail: Some(proto::DataTrackStreamEos { error }.into()),
Expand Down
Loading