### Build the Audio Example Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Compile the local audio example project in release mode. ```bash cd examples/local_audio cargo build --release ``` -------------------------------- ### Run with Default Settings Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Execute the audio capture example using environment variables for configuration. ```bash cargo run ``` -------------------------------- ### Run Basic E2E Tests Source: https://github.com/livekit/rust-sdks/blob/main/livekit/tests/README.md Start a local LiveKit server in development mode and run basic E2E tests. Requires the '__lk-e2e-test' feature. ```sh livekit-server --dev cargo test --features default,__lk-e2e-test -- --nocapture ``` -------------------------------- ### Generate Swift Package Bindings Source: https://github.com/livekit/rust-sdks/blob/main/livekit-uniffi/README.md Use this command to generate Swift bindings and build a multi-platform XCFramework. Ensure cargo-make is installed. ```bash cargo make swift-package ``` -------------------------------- ### SSL Get Functions Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt A collection of functions to retrieve various SSL/TLS related information from an SSL connection. ```APIDOC ## SSL Get Functions ### Description These functions are used to retrieve specific details about an SSL/TLS connection, such as certificates, ciphers, session information, and protocol versions. ### Methods and Endpoints This section lists various `SSL_get` functions. Since these are likely internal SDK functions and not REST endpoints, they are presented as a list of available operations. ### Available Functions - **SSL_get0_signed_cert_timestamp_list**: Retrieves the signed certificate timestamp list. - **SSL_get1_session**: Retrieves the SSL session. - **SSL_get_SSL_CTX**: Retrieves the SSL context. - **SSL_get_certificate**: Retrieves the SSL certificate. - **SSL_get_cipher_by_value**: Retrieves cipher information by its value. - **SSL_get_cipher_list**: Retrieves the list of available ciphers. - **SSL_get_ciphers**: Retrieves the current ciphers in use. - **SSL_get_client_CA_list**: Retrieves the list of client Certificate Authorities. - **SSL_get_client_random**: Retrieves the client's random value. - **SSL_get_current_cipher**: Retrieves the currently used cipher. - **SSL_get_current_compression**: Retrieves the current compression method. - **SSL_get_current_expansion**: Retrieves the current expansion. - **SSL_get_curve_id**: Retrieves the curve ID. - **SSL_get_curve_name**: Retrieves the curve name. - **SSL_get_default_timeout**: Retrieves the default timeout value. - **SSL_get_early_data_reason**: Retrieves the reason for early data rejection. - **SSL_get_error**: Retrieves the SSL error code. - **SSL_get_ex_data**: Retrieves application-specific data. - **SSL_get_ex_data_X509_STORE_CTX_idx**: Retrieves application-specific data from X509_STORE_CTX. - **SSL_get_ex_new_index**: Gets a new index for application-specific data. - **SSL_get_extms_support**: Checks for extension master secret support. - **SSL_get_fd**: Retrieves the file descriptor associated with the SSL object. - **SSL_get_finished**: Retrieves the finished message. - **SSL_get_ivs**: Retrieves initialization vectors. - **SSL_get_key_block_len**: Retrieves the key block length. - **SSL_get_max_cert_list**: Retrieves the maximum certificate list size. - **SSL_get_max_proto_version**: Retrieves the maximum supported protocol version. - **SSL_get_min_proto_version**: Retrieves the minimum supported protocol version. - **SSL_get_mode**: Retrieves the SSL mode. - **SSL_get_options**: Retrieves the SSL options. - **SSL_get_peer_cert_chain**: Retrieves the peer's certificate chain. - **SSL_get_peer_certificate**: Retrieves the peer's certificate. - **SSL_get_peer_finished**: Retrieves the peer's finished message. - **SSL_get_peer_full_cert_chain**: Retrieves the peer's full certificate chain. - **SSL_get_peer_quic_transport_params**: Retrieves the peer's QUIC transport parameters. - **SSL_get_peer_signature_algorithm**: Retrieves the peer's signature algorithm. - **SSL_get_pending_cipher**: Retrieves the pending cipher. - **SSL_get_privatekey**: Retrieves the private key. - **SSL_get_psk_identity**: Retrieves the PSK identity. - **SSL_get_psk_identity_hint**: Retrieves the PSK identity hint. - **SSL_get_quiet_shutdown**: Retrieves the quiet shutdown status. - **SSL_get_rbio**: Retrieves the read BIO. - **SSL_get_read_ahead**: Retrieves the read-ahead status. - **SSL_get_read_sequence**: Retrieves the read sequence number. - **SSL_get_rfd**: Retrieves the read file descriptor. - **SSL_get_secure_renegotiation_support**: Checks for secure renegotiation support. - **SSL_get_selected_srtp_profile**: Retrieves the selected SRTP profile. - **SSL_get_server_random**: Retrieves the server's random value. - **SSL_get_server_tmp_key**: Retrieves the server's temporary key. - **SSL_get_servername**: Retrieves the server name. - **SSL_get_servername_type**: Retrieves the server name type. - **SSL_get_session**: Retrieves the SSL session. - **SSL_get_shared_ciphers**: Retrieves the shared ciphers. - **SSL_get_shared_sigalgs**: Retrieves the shared signature algorithms. - **SSL_get_shutdown**: Retrieves the shutdown status. - **SSL_get_signature_algorithm_digest**: Retrieves the signature algorithm digest. - **SSL_get_signature_algorithm_key_type**: Retrieves the signature algorithm key type. - **SSL_get_signature_algorithm_name**: Retrieves the signature algorithm name. - **SSL_get_srtp_profiles**: Retrieves the list of SRTP profiles. - **SSL_get_ticket_age_skew**: Retrieves the ticket age skew. - **SSL_get_tls_channel_id**: Retrieves the TLS channel ID. - **SSL_get_tls_unique**: Retrieves the TLS unique value. - **SSL_get_tlsext_status_ocsp_resp**: Retrieves the OCSP response for TLS extensions. - **SSL_get_tlsext_status_type**: Retrieves the status type for TLS extensions. - **SSL_get_traffic_secrets**: Retrieves the traffic secrets. - **SSL_get_verify_depth**: Retrieves the verification depth. - **SSL_get_verify_mode**: Retrieves the verification mode. - **SSL_get_verify_result**: Retrieves the verification result. - **SSL_get_version**: Retrieves the SSL/TLS protocol version. - **SSL_get_wbio**: Retrieves the write BIO. - **SSL_get_wfd**: Retrieves the write file descriptor. - **SSL_get_write_sequence**: Retrieves the write sequence number. ### Parameters N/A for this group of functions as they are typically called on an existing SSL object. ### Request Body N/A ### Request Example N/A ### Response N/A (return values depend on the specific function called and the state of the SSL object.) ``` -------------------------------- ### Run Publisher Source: https://github.com/livekit/rust-sdks/blob/main/examples/basic_data_track/README.md Set LIVEKIT_URL and LIVEKIT_TOKEN environment variables before running the publisher binary. ```sh export LIVEKIT_URL="..." export LIVEKIT_TOKEN="" cargo run --bin publisher ``` -------------------------------- ### Run with CLI Arguments Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Provide connection details directly via command-line flags. ```bash cargo run -- \ --url "wss://your-project.livekit.cloud" \ --api-key "your-api-key" \ --api-secret "your-api-secret" ``` -------------------------------- ### Run Publisher for Local Video Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_video/README.md Commands to list cameras or publish video tracks to a LiveKit room with optional encoding and connection flags. ```bash cargo run -p local_video -F desktop --bin publisher -- --list-cameras cargo run -p local_video -F desktop --bin publisher -- --camera-index 0 --room-name demo --identity cam-1 # with explicit LiveKit connection flags cargo run -p local_video -F desktop --bin publisher -- \ --camera-index 0 \ --room-name demo \ --identity cam-1 \ --simulcast \ --h265 \ --max-bitrate 1500000 \ --url https://your.livekit.server \ --api-key YOUR_KEY \ --api-secret YOUR_SECRET ``` -------------------------------- ### Update Participant Metadata and Attributes in Rust Source: https://context7.com/livekit/rust-sdks/llms.txt Update participant information including metadata, name, and custom attributes. Changes are propagated to all participants in the room. Includes examples for setting metadata, display name, attributes, and reading participant details. ```rust use livekit::prelude::*; use std::collections::HashMap; async fn update_participant_info(room: &Room) -> RoomResult<()> { let local = room.local_participant(); // Update metadata (JSON string) local.set_metadata(r#"{"status": "presenting", "hand_raised": true}"#.to_string()).await?; // Update display name local.set_name("John (Presenter)".to_string()).await?; // Update custom attributes local.set_attributes(HashMap::from([ ("role".to_string(), "moderator".to_string()), ("department".to_string(), "engineering".to_string()), ])).await?; // Read participant info println!("Identity: {}", local.identity()); println!("Name: {}", local.name()); println!("Metadata: {}", local.metadata()); println!("Attributes: {:?}", local.attributes()); println!("Connection quality: {:?}", local.connection_quality()); println!("Is speaking: {}", local.is_speaking()); println!("Audio level: {}", local.audio_level()); // Access remote participants for (identity, participant) in room.remote_participants() { println!("Remote participant: {} - {}", identity, participant.name()); // Get their published tracks for (sid, publication) in participant.track_publications() { println!(" Track: {} ({:?})", sid, publication.kind()); } } Ok(()) } ``` -------------------------------- ### Run Subscriber Source: https://github.com/livekit/rust-sdks/blob/main/examples/basic_data_track/README.md Set LIVEKIT_URL and LIVEKIT_TOKEN environment variables before running the subscriber binary. ```sh export LIVEKIT_URL="..." export LIVEKIT_TOKEN="" cargo run --bin subscriber ``` -------------------------------- ### Stream Text and Bytes Incrementally in Rust Source: https://context7.com/livekit/rust-sdks/llms.txt Send text or binary data incrementally to participants. Useful for AI-generated responses, file transfers, or any scenario requiring chunked data delivery. Includes examples for sending complete messages, streaming text, sending files, sending in-memory bytes, and streaming bytes. ```rust use livekit::prelude::*; use livekit::room::data_stream::{StreamTextOptions, StreamByteOptions}; use std::path::Path; async fn streaming_examples(room: &Room) -> Result<(), Box> { let local = room.local_participant(); // Send complete text at once let info = local.send_text( "Hello, this is a complete message!", StreamTextOptions { topic: "llm-response".to_string(), destination_identities: vec![], // All participants ..Default::default() } ).await?; println!("Sent text stream: {}", info.id); // Stream text incrementally (e.g., for AI responses) let mut writer = local.stream_text(StreamTextOptions { topic: "ai-response".to_string(), ..Default::default() }).await?; // Write chunks as they become available writer.write("Processing").await?; writer.write("...").await?; writer.write(" Done!").await?; writer.close().await?; // Send a file let file_info = local.send_file( Path::new("document.pdf"), StreamByteOptions { topic: "file-transfer".to_string(), ..Default::default() } ).await?; println!("Sent file: {}", file_info.id); // Send in-memory bytes let data = vec![0u8; 1024]; local.send_bytes( &data, StreamByteOptions { topic: "binary-data".to_string(), ..Default::default() } ).await?; // Stream bytes incrementally let mut byte_writer = local.stream_bytes(StreamByteOptions { topic: "large-transfer".to_string(), ..Default::default() }).await?; for chunk in data.chunks(256) { byte_writer.write(chunk).await?; } byte_writer.close().await?; Ok(()) } ``` ```rust use livekit::prelude::*; // Receiving streams async fn receive_streams(mut events: tokio::sync::mpsc::UnboundedReceiver) { use futures::StreamExt; while let Some(event) = events.recv().await { match event { RoomEvent::TextStreamOpened { reader, topic, participant_identity } => { let mut reader = reader.take().unwrap(); println!("Text stream from {} on topic {}", participant_identity, topic); tokio::spawn(async move { while let Some(chunk) = reader.next().await { print!("{}", chunk); } println!("\n[Stream complete]"); }); } RoomEvent::ByteStreamOpened { reader, topic, participant_identity } => { let mut reader = reader.take().unwrap(); println!("Byte stream from {} on topic {}", participant_identity, topic); tokio::spawn(async move { let mut total = 0; while let Some(chunk) = reader.next().await { total += chunk.len(); } println!("Received {} bytes", total); }); } _ => {} } } } ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/livekit/rust-sdks/blob/main/docker/README.md Required before building to ensure dependencies like libyuv and protocol are available. ```bash git submodule update --init ``` -------------------------------- ### Run Subscriber for Local Video Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_video/README.md Commands to connect to a room and subscribe to video tracks, using either environment variables or explicit flags. ```bash # relies on env vars LIVEKIT_URL, LIVEKIT_API_KEY, LIVEKIT_API_SECRET cargo run -p local_video -F desktop --bin subscriber -- --room-name demo --identity viewer-1 # or pass credentials via flags cargo run -p local_video -F desktop --bin subscriber -- \ --room-name demo \ --identity viewer-1 \ --url https://your.livekit.server \ --api-key YOUR_KEY \ --api-secret YOUR_SECRET # subscribe to a specific participant's video only cargo run -p local_video -F desktop --bin subscriber -- \ --room-name demo \ --identity viewer-1 \ --participant alice ``` -------------------------------- ### List Camera Devices Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_video/README.md Command to enumerate available cameras and their capabilities. ```bash cargo run -p local_video -F desktop --bin list_devices ``` -------------------------------- ### Makefile Build Targets Source: https://github.com/livekit/rust-sdks/blob/main/docker/README.md Commands to build environment images, the SDK, and the FFI library for specific architectures. ```makefile cd docker # Build environment images (done automatically by sdk/ffi targets) make env-x86_64 make env-aarch64 # Build the SDK (livekit crate) make sdk-x86_64 make sdk-aarch64 # Build the FFI library (livekit-ffi crate) make ffi-x86_64 make ffi-aarch64 # Remove environment images make clean ``` -------------------------------- ### Connect to a Room and Handle Events Source: https://context7.com/livekit/rust-sdks/llms.txt Establishes a connection to a LiveKit room using an access token and processes events such as participant joins, track subscriptions, and data reception. ```rust use livekit::prelude::*; use livekit_api::access_token::{AccessToken, VideoGrants}; use std::env; #[tokio::main] async fn main() -> Result<(), Box> { let url = env::var("LIVEKIT_URL")?; let api_key = env::var("LIVEKIT_API_KEY")?; let api_secret = env::var("LIVEKIT_API_SECRET")?; let token = AccessToken::with_api_key(&api_key, &api_secret) .with_identity("rust-bot") .with_name("Rust Bot") .with_grants(VideoGrants { room_join: true, room: "my-room".to_string(), ..Default::default() }) .to_jwt()?; // Connect with custom options let options = RoomOptions { auto_subscribe: true, adaptive_stream: false, dynacast: false, ..Default::default() }; let (room, mut events) = Room::connect(&url, &token, options).await?; println!("Connected to room: {} ({})", room.name(), room.sid().await); // Handle room events while let Some(event) = events.recv().await { match event { RoomEvent::ParticipantConnected(participant) => { println!("Participant joined: {}", participant.identity()); } RoomEvent::ParticipantDisconnected(participant) => { println!("Participant left: {}", participant.identity()); } RoomEvent::TrackSubscribed { track, publication, participant } => { println!("Subscribed to track {} from {}", publication.sid(), participant.identity()); match track { RemoteTrack::Audio(audio_track) => { println!("Audio track: {:?}", audio_track.sid()); } RemoteTrack::Video(video_track) => { println!("Video track: {:?}", video_track.sid()); } } } RoomEvent::DataReceived { payload, topic, participant, .. } => { let data = String::from_utf8_lossy(&payload); println!("Data from {:?}: {} (topic: {:?})", participant.map(|p| p.identity()), data, topic); } RoomEvent::Disconnected { reason } => { println!("Disconnected: {:?}", reason); break; } _ => {} } } room.close().await?; Ok(()) } ``` -------------------------------- ### Run LiveKit sender Source: https://github.com/livekit/rust-sdks/blob/main/examples/basic_text_stream/README.md Configures environment variables and executes the sender process. ```sh export LIVEKIT_URL="..." export LIVEKIT_TOKEN="" cargo run -- sender ``` -------------------------------- ### Create a Room using RoomService API Source: https://github.com/livekit/rust-sdks/blob/main/README.md Creates a new room on a LiveKit server using the RoomService API. Requires a running LiveKit server at http://localhost:7880. ```rust use livekit_api::services::room::{CreateRoomOptions, RoomClient}; #[tokio::main] async fn main() { let room_service = RoomClient::new("http://localhost:7880").unwrap(); let room = room_service .create_room("my_room", CreateRoomOptions::default()) .await .unwrap(); println!("Created room: {:?}", room); } ``` -------------------------------- ### Dispatch Agent via CLI Source: https://github.com/livekit/rust-sdks/blob/main/examples/agent_dispatch/README.md Execute the agent dispatch process by providing the necessary LiveKit connection credentials and room parameters. ```bash cargo run -- \ --url "wss://your-project.livekit.cloud" \ --api-key "your-api-key" \ --api-secret "your-api-secret" \ --room-name "my-room" \ --agent-name "my-agent" ``` -------------------------------- ### Publishing Audio Tracks in Rust Source: https://context7.com/livekit/rust-sdks/llms.txt Configures a native audio source and publishes it as a local track to a LiveKit room. Requires an active Room connection and appropriate track options. ```rust use livekit::{ prelude::*, options::TrackPublishOptions, track::{LocalAudioTrack, LocalTrack, TrackSource}, webrtc::{ audio_source::native::NativeAudioSource, prelude::{AudioFrame, AudioSourceOptions, RtcAudioSource}, }, }; use std::sync::Arc; async fn publish_audio(room: &Room) -> Result<(), Box> { let sample_rate = 48000; let num_channels = 2; // Create audio source let source = NativeAudioSource::new( AudioSourceOptions::default(), sample_rate, num_channels, 1000, // Queue size ); // Create local audio track let track = LocalAudioTrack::create_audio_track( "microphone", RtcAudioSource::Native(source.clone()), ); // Publish the track let publication = room.local_participant() .publish_track( LocalTrack::Audio(track), TrackPublishOptions { source: TrackSource::Microphone, dtx: true, // Discontinuous transmission red: true, // Redundant encoding for packet loss ..Default::default() }, ) .await?; println!("Published audio track: {}", publication.sid()); // Send audio frames tokio::spawn(async move { loop { let audio_frame = AudioFrame { data: vec![0i16; 960].into(), // 20ms at 48kHz num_channels, sample_rate, samples_per_channel: 480, }; source.capture_frame(&audio_frame).await.unwrap(); tokio::time::sleep(std::time::Duration::from_millis(20)).await; } }); Ok(()) } ``` -------------------------------- ### List Available Audio Devices Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Display all detected input and output audio devices. ```bash cargo run -- --list-devices ``` -------------------------------- ### Connect to LiveKit Room and Listen for Events Source: https://github.com/livekit/rust-sdks/blob/main/README.md Connects to a LiveKit room using the provided URL and token, and listens for room events. Handles subscribed tracks and other room events. ```rust use livekit::prelude::*; #[tokio::main] async fn main() -> Result<()> { let (room, mut room_events) = Room::connect(&url, &token).await?; while let Some(event) = room_events.recv().await { match event { RoomEvent::TrackSubscribed { track, publication, participant } => { // ... } _ => {} } } Ok(()) } ``` -------------------------------- ### Advanced Audio Configuration Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Specify input/output devices, sample rates, and volume levels. ```bash cargo run -- \ --url "wss://your-project.livekit.cloud" \ --api-key "your-api-key" \ --api-secret "your-api-secret" \ --input-device "USB Microphone" \ --output-device "USB Headphones" \ --sample-rate 44100 \ --channels 2 \ --volume 0.8 \ --room-name "conference-room" ``` -------------------------------- ### Run All Peer Connection Signaling Tests Locally Source: https://github.com/livekit/rust-sdks/blob/main/livekit/tests/README.md Execute all peer connection signaling tests on localhost. Note that V1 tests will fall back to V0 signaling. Running with '--test-threads=1' is recommended to avoid flakiness. Requires '__lk-e2e-test' and 'native-tls' features. ```sh # On localhost (V0 will work, V1 falls back to V0) # Note, suggest running with --test-threads=1 to avoid flakiness livekit-server --dev cargo test -p livekit --features "__lk-e2e-test,native-tls" --test peer_connection_signaling_test -- --nocapture --test-threads=1 ``` -------------------------------- ### Configure and Run V1 Peer Connection Signaling Tests Source: https://github.com/livekit/rust-sdks/blob/main/livekit/tests/README.md Set environment variables for LiveKit Cloud and run V1 (single peer connection) signaling tests. This ensures proper testing of the /rtc/v1 endpoint. Requires '__lk-e2e-test' and 'native-tls' features. ```sh export LIVEKIT_URL="wss://your-project.livekit.cloud" export LIVEKIT_API_KEY="your-api-key" export LIVEKIT_API_SECRET="your-api-secret" # Run V1 tests cargo test -p livekit --features "__lk-e2e-test,native-tls" --test peer_connection_signaling_test v1_ -- --nocapture ``` -------------------------------- ### Manage Rooms with Room Service API Source: https://context7.com/livekit/rust-sdks/llms.txt Demonstrates server-side room management including room creation, listing, participant updates, and sending data packets. Requires admin-level access tokens. ```rust use livekit_api::services::room::{ CreateRoomOptions, RoomClient, SendDataOptions, UpdateParticipantOptions, }; use livekit_protocol::data_packet::Kind; use std::collections::HashMap; #[tokio::main] async fn main() -> Result<(), Box> { let room_service = RoomClient::new("https://your-livekit-server.com")?; // Create a room let room = room_service.create_room("my-room", CreateRoomOptions { empty_timeout: 300, // Close after 5 minutes if empty max_participants: 100, metadata: r#"{"type": "meeting"}"# .to_string(), ..Default::default() }).await?; println!("Created room: {} ({})", room.name, room.sid); // List all rooms let rooms = room_service.list_rooms(vec![]).await?; for room in rooms { println!("Room: {} with {} participants", room.name, room.num_participants); } // List participants in a room let participants = room_service.list_participants("my-room").await?; for p in &participants { println!("Participant: {} ({})", p.identity, p.sid); } // Update participant metadata if !participants.is_empty() { room_service.update_participant("my-room", &participants[0].identity, UpdateParticipantOptions { metadata: r#"{"role": "moderator"}"# .to_string(), attributes: HashMap::from([ ("verified".to_string(), "true".to_string()), ]), ..Default::default() } ).await?; } // Send data to participants from server room_service.send_data( "my-room", b"Server announcement".to_vec(), SendDataOptions { kind: Kind::Reliable, topic: Some("announcements".to_string()), destination_identities: vec![], // Empty = all participants ..Default::default() } ).await?; // Remove a participant room_service.remove_participant("my-room", "user-123").await?; // Delete the room room_service.delete_room("my-room").await?; Ok(()) } ``` -------------------------------- ### Configure Connection via Environment Variables Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Set LiveKit connection details using shell environment variables. ```bash export LIVEKIT_URL="wss://your-livekit-server.com" export LIVEKIT_API_KEY="your-api-key" export LIVEKIT_API_SECRET="your-api-secret" ``` -------------------------------- ### Build WebRTC for Linux Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/README.md Executes a Linux debug build for the x64 architecture. ```sh $ ./build-linux.sh --arch x64 --profile release ``` -------------------------------- ### Run LiveKit receiver Source: https://github.com/livekit/rust-sdks/blob/main/examples/basic_text_stream/README.md Configures environment variables and executes the receiver process. ```sh export LIVEKIT_URL="..." export LIVEKIT_TOKEN="" cargo run ``` -------------------------------- ### Generate Node Bindings Source: https://github.com/livekit/rust-sdks/blob/main/livekit-uniffi/README.md Use this command to generate Node.js bindings. After generation, you can test them by navigating to the node_test directory and running the provided script. ```bash cargo make node-package ``` -------------------------------- ### Run V0 Peer Connection Signaling Tests Source: https://github.com/livekit/rust-sdks/blob/main/livekit/tests/README.md Execute V0 (dual peer connection) signaling tests locally. Ensure the LiveKit server is running in development mode. Requires '__lk-e2e-test' and 'native-tls' features. ```sh # Start local server livekit-server --dev # Run V0 tests cargo test -p livekit --features "__lk-e2e-test,native-tls" --test peer_connection_signaling_test v0_ -- --nocapture ``` -------------------------------- ### Configure Custom WebRTC Path Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/README.md Sets the LK_CUSTOM_WEBRTC environment variable in the configuration file to point to a custom build directory. ```toml [env] LK_CUSTOM_WEBRTC = { value = "webrtc-sys/libwebrtc/linux-x64-release", relative = true } ``` -------------------------------- ### Generate and Verify Access Tokens Source: https://context7.com/livekit/rust-sdks/llms.txt Use AccessToken to create JWTs for participant authentication and TokenVerifier to validate them. Requires LIVEKIT_API_KEY and LIVEKIT_API_SECRET environment variables. ```rust use livekit_api::access_token::{AccessToken, VideoGrants}; use std::env; use std::time::Duration; fn create_participant_token() -> Result> { let api_key = env::var("LIVEKIT_API_KEY")?; let api_secret = env::var("LIVEKIT_API_SECRET")?; let token = AccessToken::with_api_key(&api_key, &api_secret) .with_identity("user-123") .with_name("John Doe") .with_ttl(Duration::from_secs(3600 * 6)) // 6 hours .with_metadata(r#"{"role": "presenter"}"#) .with_grants(VideoGrants { room_join: true, room: "my-room".to_string(), can_publish: true, can_subscribe: true, can_publish_data: true, ..Default::default() }) .to_jwt()?; Ok(token) } // Token verification fn verify_token(token: &str) -> Result<(), Box> { use livekit_api::access_token::TokenVerifier; let api_key = env::var("LIVEKIT_API_KEY")?; let api_secret = env::var("LIVEKIT_API_SECRET")?; let verifier = TokenVerifier::with_api_key(&api_key, &api_secret); let claims = verifier.verify(token)?; println!("Identity: {}", claims.sub); println!("Room: {}", claims.video.room); Ok(()) } ``` -------------------------------- ### Receive Audio and Video Frames in Rust Source: https://github.com/livekit/rust-sdks/blob/main/README.md This snippet demonstrates how to subscribe to audio and video tracks from remote participants and process the incoming frames. It requires the `futures` and `livekit` crates. Each track is processed in a separate asynchronous task. ```rust use futures::StreamExt; use livekit::prelude::*; match event { RoomEvent::TrackSubscribed { track, publication, participant } => { match track { RemoteTrack::Audio(audio_track) => { let rtc_track = audio_track.rtc_track(); let mut audio_stream = NativeAudioStream::new(rtc_track); tokio::spawn(async move { // Receive the audio frames in a new task while let Some(audio_frame) = audio_stream.next().await { log::info!("received audio frame - {audio_frame:#?}"); } }); }, RemoteTrack::Video(video_track) => { let rtc_track = video_track.rtc_track(); let mut video_stream = NativeVideoStream::new(rtc_track); tokio::spawn(async move { // Receive the video frames in a new task while let Some(video_frame) = video_stream.next().await { log::info!("received video frame - {video_frame:#?}"); } }); }, } }, _ => {} } ``` -------------------------------- ### SSL Context Configuration API Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt This section lists the available functions for configuring SSL contexts in the LiveKit Rust SDK. These functions allow developers to set various security-related options, manage certificates and keys, and define callback functions for custom behavior. ```APIDOC ## SSL Context Configuration Functions ### Description This document outlines the various functions available for configuring `SSL_CTX` objects within the LiveKit Rust SDK. These functions provide granular control over SSL/TLS settings, including certificate management, cipher suites, protocol versions, and callback registrations. ### Methods and Endpoints While these are not traditional HTTP endpoints, they represent function calls within the SDK for configuring SSL contexts. ### Functions #### Certificate and Key Management - **`LK_SSL_CTX_use_certificate_file(ctx, file, type)`**: Load a certificate from a file. - **`LK_SSL_CTX_use_certificate_ASN1(ctx, asn1, len, type)`**: Load a certificate from ASN.1 data. - **`LK_SSL_CTX_use_certificate_chain_file(ctx, file)`**: Load a certificate chain from a file. - **`LK_SSL_CTX_use_PrivateKey_file(ctx, file, type)`**: Load a private key from a file. - **`LK_SSL_CTX_use_PrivateKey_ASN1(ctx, type, asn1, len)`**: Load a private key from ASN.1 data. - **`LK_SSL_CTX_use_RSAPrivateKey_file(ctx, file)`**: Load an RSA private key from a file. - **`LK_SSL_CTX_use_RSAPrivateKey_ASN1(ctx, asn1, len)`**: Load an RSA private key from ASN.1 data. - **`LK_SSL_CTX_use_PrivateKey(ctx, pkey)`**: Set a private key. - **`LK_SSL_CTX_set_chain_and_key(ctx, cert, pkey)`**: Set the certificate chain and private key. #### Security and Protocol Configuration - **`LK_SSL_CTX_set_alpn_select_cb(ctx, cb, arg)`**: Set the ALPN selection callback. - **`LK_SSL_CTX_set_cert_cb(ctx, cb, arg)`**: Set the certificate callback. - **`LK_SSL_CTX_set_cert_store(ctx, store)`**: Set the certificate store. - **`LK_SSL_CTX_set_cert_verify_callback(ctx, cb, arg)`**: Set the certificate verification callback. - **`LK_SSL_CTX_set_cipher_list(ctx, str)`**: Set the cipher list. - **`LK_SSL_CTX_set_client_CA_list(ctx, list)`**: Set the client CA list. - **`LK_SSL_CTX_set_client_cert_cb(ctx, cb, arg)`**: Set the client certificate callback. - **`LK_SSL_CTX_set_compliance_policy(ctx, policy)`**: Set the compliance policy. - **`LK_SSL_CTX_set_current_time_cb(ctx, cb, arg)`**: Set the current time callback. - **`LK_SSL_CTX_set_custom_verify(ctx, depth, cb)`**: Set the custom verification callback. - **`LK_SSL_CTX_set_default_passwd_cb(ctx, cb)`**: Set the default password callback. - **`LK_SSL_CTX_set_default_passwd_cb_userdata(ctx, userdata)`**: Set user data for the default password callback. - **`LK_SSL_CTX_set_default_verify_paths(ctx)`**: Set default verify paths. - **`LK_SSL_CTX_set_dos_protection_cb(ctx, cb, arg)`**: Set the DoS protection callback. - **`LK_SSL_CTX_set_early_data_enabled(ctx, enabled)`**: Enable or disable early data. - **`LK_SSL_CTX_set_ex_data(ctx, idx, data)`**: Set application-specific data. - **`LK_SSL_CTX_set_false_start_allowed_without_alpn(ctx, val)`**: Configure false start without ALPN. - **`LK_SSL_CTX_set_grease_enabled(ctx, enabled)`**: Enable or disable GREASE. - **`LK_SSL_CTX_set_handoff_mode(ctx, mode)`**: Set the handoff mode. - **`LK_SSL_CTX_set_info_callback(ctx, cb, arg)`**: Set the info callback. - **`LK_SSL_CTX_set_keylog_callback(ctx, cb, arg)`**: Set the key log callback. - **`LK_SSL_CTX_set_max_cert_list(ctx, max)`**: Set the maximum certificate list size. - **`LK_SSL_CTX_set_max_proto_version(ctx, version)`**: Set the maximum protocol version. - **`LK_SSL_CTX_set_max_send_fragment(ctx, frag)`**: Set the maximum send fragment size. - **`LK_SSL_CTX_set_min_proto_version(ctx, version)`**: Set the minimum protocol version. - **`LK_SSL_CTX_set_mode(ctx, mode)`**: Set the SSL mode. - **`LK_SSL_CTX_set_msg_callback(ctx, cb, arg)`**: Set the message callback. - **`LK_SSL_CTX_set_msg_callback_arg(ctx, arg)`**: Set the argument for the message callback. - **`LK_SSL_CTX_set_next_proto_select_cb(ctx, cb, arg)`**: Set the next protocol selection callback. - **`LK_SSL_CTX_set_next_protos_advertised_cb(ctx, cb, arg)`**: Set the callback for advertised next protocols. - **`LK_SSL_CTX_set_num_tickets(ctx, num)`**: Set the number of tickets. - **`LK_SSL_CTX_set_ocsp_response(ctx, resp)`**: Set the OCSP response. - **`LK_SSL_CTX_set_options(ctx, options)`**: Set SSL options. - **`LK_SSL_CTX_set_permute_extensions(ctx, permute)`**: Configure extension permutation. - **`LK_SSL_CTX_set_private_key_method(ctx, method)`**: Set the private key method. - **`LK_SSL_CTX_set_psk_client_callback(ctx, cb, arg)`**: Set the PSK client callback. - **`LK_SSL_CTX_set_psk_server_callback(ctx, cb, arg)`**: Set the PSK server callback. - **`LK_SSL_CTX_set_purpose(ctx, purpose)`**: Set the SSL purpose. - **`LK_SSL_CTX_set_quic_method(ctx, method)`**: Set the QUIC method. - **`LK_SSL_CTX_set_quiet_shutdown(ctx, mode)`**: Set quiet shutdown mode. - **`LK_SSL_CTX_set_read_ahead(ctx, ahead)`**: Enable read ahead. - **`LK_SSL_CTX_set_record_protocol_version(ctx, version)`**: Set the record protocol version. - **`LK_SSL_CTX_set_retain_only_sha256_of_client_certs(ctx, retain)`**: Configure retaining only SHA256 of client certs. - **`LK_SSL_CTX_set_reverify_on_resume(ctx, reverify)`**: Configure re-verification on resume. - **`LK_SSL_CTX_set_select_certificate_cb(ctx, cb, arg)`**: Set the certificate selection callback. - **`LK_SSL_CTX_set_session_cache_mode(ctx, mode)`**: Set the session cache mode. - **`LK_SSL_CTX_set_session_id_context(ctx, sid_ctx, len)`**: Set the session ID context. - **`LK_SSL_CTX_set_session_psk_dhe_timeout(ctx, timeout)`**: Set the session PSK DHE timeout. - **`LK_SSL_CTX_set_signed_cert_timestamp_list(ctx, list)`**: Set the signed certificate timestamp list. - **`LK_SSL_CTX_set_signing_algorithm_prefs(ctx, prefs)`**: Set signing algorithm preferences. - **`LK_SSL_CTX_set_srtp_profiles(ctx, profiles)`**: Set SRTP profiles. - **`LK_SSL_CTX_set_strict_cipher_list(ctx, str)`**: Set the strict cipher list. - **`LK_SSL_CTX_set_ticket_aead_method(ctx, method)`**: Set the ticket AEAD method. - **`LK_SSL_CTX_set_timeout(ctx, timeout)`**: Set the SSL timeout. - **`LK_SSL_CTX_set_tls_channel_id_enabled(ctx, enabled)`**: Enable or disable TLS channel ID. - **`LK_SSL_CTX_set_tlsext_servername_arg(ctx, arg)`**: Set the TLS extension server name argument. - **`LK_SSL_CTX_set_tlsext_servername_callback(ctx, cb)`**: Set the TLS extension server name callback. - **`LK_SSL_CTX_set_tlsext_status_arg(ctx, arg)`**: Set the TLS extension status argument. - **`LK_SSL_CTX_set_tlsext_status_cb(ctx, cb)`**: Set the TLS extension status callback. - **`LK_SSL_CTX_set_tlsext_ticket_key_cb(ctx, cb, arg)`**: Set the TLS extension ticket key callback. - **`LK_SSL_CTX_set_tlsext_ticket_keys(ctx, keys, len)`**: Set the TLS extension ticket keys. - **`LK_SSL_CTX_set_tlsext_use_srtp(ctx, profiles)`**: Configure SRTP usage for TLS extensions. - **`LK_SSL_CTX_set_tmp_dh(ctx, dh)`**: Set temporary DH parameters. - **`LK_SSL_CTX_set_tmp_dh_callback(ctx, cb)`**: Set the temporary DH callback. - **`LK_SSL_CTX_set_tmp_ecdh(ctx, ecdh)`**: Set temporary ECDH parameters. - **`LK_SSL_CTX_set_tmp_rsa(ctx, rsa)`**: Set temporary RSA key. - **`LK_SSL_CTX_set_tmp_rsa_callback(ctx, cb)`**: Set the temporary RSA callback. - **`LK_SSL_CTX_set_trust(ctx, trust)`**: Set the trust settings. - **`LK_SSL_CTX_set_verify(ctx, depth, cb)`**: Set the verification parameters. - **`LK_SSL_CTX_set_verify_algorithm_prefs(ctx, prefs)`**: Set verification algorithm preferences. - **`LK_SSL_CTX_set_verify_depth(ctx, depth)`**: Set the verification depth. #### Reference Counting - **`LK_SSL_CTX_up_ref(ctx)`**: Increment the reference count of the SSL context. ### Request Body N/A for these configuration functions. ### Response Typically returns a status code indicating success or failure (e.g., 0 for success, -1 for failure). ### Response Example ``` 0 // Success -1 // Failure ``` ``` -------------------------------- ### OpenSSL Bindings Overview Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt A collection of OpenSSL utility functions mapped to the LiveKit Rust SDK namespace. ```APIDOC ## OpenSSL Bindings ### Description The LiveKit Rust SDK provides a comprehensive set of bindings for OpenSSL functionality, prefixed with `LK_`. These include configuration management, object handling, memory allocation, and cryptographic utilities. ### Key Modules - **NCONF**: Configuration file handling (e.g., `LK_NCONF_new`, `LK_NCONF_load`) - **NETSCAPE_SPKI**: SPKI structure handling (e.g., `LK_NETSCAPE_SPKI_b64_encode`) - **OBJ**: Object identifier management (e.g., `LK_OBJ_nid2obj`, `LK_OBJ_txt2nid`) - **OPENSSL**: Core utilities, memory management, and string manipulation (e.g., `LK_OPENSSL_malloc`, `LK_OPENSSL_strdup`) - **PEM**: PEM file format operations (e.g., `LK_PEM_read_bio`, `LK_PEM_write_bio`) - **PKCS**: PKCS standards support (e.g., `LK_PKCS12_parse`, `LK_PKCS7_sign`) ``` -------------------------------- ### Join Room with Custom Identity Source: https://github.com/livekit/rust-sdks/blob/main/examples/local_audio/README.md Connect to a specific room using a custom participant identity. ```bash cargo run -- \ --url "wss://your-project.livekit.cloud" \ --api-key "your-api-key" \ --api-secret "your-api-secret" \ --room-name "my-meeting" \ --identity "john-doe" ``` -------------------------------- ### SSL Utility Functions Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt A collection of utility functions for initializing, loading, and managing SSL/TLS states and configurations. ```APIDOC ## SSL Utility Functions ### Description These functions provide essential utilities for initializing the OpenSSL library, loading error strings, configuring client Certificate Authorities, and managing various aspects of the SSL/TLS state. ### Methods and Endpoints This section lists various SSL utility functions. These are internal SDK functions and not REST endpoints. ### Available Functions - **SSL_has_application_settings**: Checks if application settings are available. - **SSL_has_pending**: Checks if there are pending data. - **SSL_in_early_data**: Checks if the connection is in early data state. - **SSL_in_false_start**: Checks if false start is enabled. - **SSL_in_init**: Checks if the SSL object is in initialization state. - **SSL_is_dtls**: Checks if the protocol is DTLS. - **SSL_is_init_finished**: Checks if initialization is finished. - **SSL_is_server**: Checks if the current role is a server. - **SSL_is_signature_algorithm_rsa_pss**: Checks if the signature algorithm is RSA-PSS. - **SSL_key_update**: Updates the session keys. - **SSL_library_init**: Initializes the OpenSSL library. - **SSL_load_client_CA_file**: Loads the client Certificate Authority file. - **SSL_load_error_strings**: Loads the OpenSSL error strings. - **SSL_magic_pending_session_ptr**: Internal function related to pending session pointers. - **SSL_marshal_ech_config**: Marshals the ECH (Encrypted Client Hello) configuration. - **SSL_max_seal_overhead**: Retrieves the maximum seal overhead. - **SSL_need_tmp_RSA**: Checks if a temporary RSA key is needed. - **SSL_new**: Creates a new SSL object. - **SSL_num_renegotiations**: Retrieves the number of renegotiations. - **SSL_peek**: Peeks at pending data without removing it. - **SSL_pending**: Returns the number of pending bytes. - **SSL_process_quic_post_handshake**: Processes QUIC post-handshake messages. - **SSL_process_tls13_new_session_ticket**: Processes a new TLS 1.3 session ticket. - **SSL_provide_quic_data**: Provides QUIC data to the SSL object. - **SSL_quic_max_handshake_flight_len**: Retrieves the maximum QUIC handshake flight length. - **SSL_quic_read_level**: Gets the QUIC read level. - **SSL_quic_write_level**: Gets the QUIC write level. - **SSL_read**: Reads data from the SSL connection. - **SSL_renegotiate**: Initiates a renegotiation. - **SSL_renegotiate_pending**: Checks if a renegotiation is pending. - **SSL_request_handshake_hints**: Requests handshake hints. - **SSL_reset_early_data_reject**: Resets early data rejection status. - **SSL_select_next_proto**: Selects the next protocol. - **SSL_send_fatal_alert**: Sends a fatal alert message. ### Parameters N/A for this group of functions as they are typically called directly or on an existing SSL object. ### Request Body N/A ### Request Example N/A ### Response N/A (return values depend on the specific function called and the state of the SSL object.) ``` -------------------------------- ### Run All Peer Connection Signaling Tests on LiveKit Cloud Source: https://github.com/livekit/rust-sdks/blob/main/livekit/tests/README.md Execute all peer connection signaling tests against LiveKit Cloud. This ensures both V0 and V1 signaling modes function correctly. Requires '__lk-e2e-test' and 'native-tls' features. ```sh # On LiveKit Cloud (both V0 and V1 work correctly) export LIVEKIT_URL="wss://your-project.livekit.cloud" export LIVEKIT_API_KEY="your-api-key" export LIVEKIT_API_SECRET="your-api-secret" cargo test -p livekit --features "__lk-e2e-test,native-tls" --test peer_connection_signaling_test -- --nocapture --test-threads=1 ``` -------------------------------- ### X509 Certificate Management Functions Source: https://github.com/livekit/rust-sdks/blob/main/webrtc-sys/libwebrtc/boringssl_prefix_symbols.txt A comprehensive list of X509 store, trust, and verification parameter functions available in the LiveKit Rust SDK. ```APIDOC ## X509 Certificate Management ### Description This module provides bindings for OpenSSL X509 certificate operations, including store management, trust settings, and verification parameters. ### Functions - **X509_STORE**: LK_X509_STORE_new, LK_X509_STORE_free, LK_X509_STORE_add_cert, LK_X509_STORE_add_crl, LK_X509_STORE_load_locations - **X509_TRUST**: LK_X509_TRUST_add, LK_X509_TRUST_get_by_id, LK_X509_TRUST_set - **X509_VERIFY_PARAM**: LK_X509_VERIFY_PARAM_new, LK_X509_VERIFY_PARAM_free, LK_X509_VERIFY_PARAM_set1_host, LK_X509_VERIFY_PARAM_set_depth - **X509_CHECK**: LK_X509_check_host, LK_X509_check_email, LK_X509_check_ca, LK_X509_check_private_key ```