From e7d72165b47b83d8042c939724fd5f35145d244b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Monnom?= Date: Mon, 2 Jan 2023 22:16:03 +0100 Subject: [PATCH] Update README.md (#15) * Update README.md * videoframes example * fix indents * fix indents x2 --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 62cab63..fae0eaf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # LiveKit: Native SDK - +![crates.io](https://img.shields.io/crates/v/livekit.svg) +[![Tests & Build](https://github.com/livekit/client-sdk-native/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/livekit/client-sdk-native/actions/workflows/rust.yml) > **Warning** > This SDK is a developer preview and is not ready for production use. There will be bugs and the APIs may change during this period. > All feedbacks/contributions are appreciated. You can create issues or discuss with us on the #rust-developer-preview channel in our [Slack](https://livekit.io/join-slack) @@ -64,6 +65,26 @@ async fn main() -> Result<()> { } ``` +### Receive video frames of a subscribed track + +```rust +match event { + RoomEvent::TrackSubscribed { track, publication, participant } => { + if let RemoteTrackHandle::Video(video_track) => { + let rtc_track = video_track.rtc_track(); + rtc_track.on_frame(Box::new(move |frame, buffer| { + // Just received a video frame! + // The buffer is YuvEncoded, you can decode it to ABGR by using our yuv_helper + // See the simple_room example for the conversion + }); + } else { + // Audio Track.. + } + } + _ => {} +} +``` + ## Examples We made [simple room](https://github.com/livekit/client-sdk-native/tree/main/examples/simple_room) demo using all features of the SDK. We render videos using wgpu and egui.