Skip to main content

Crate ustreamer_app

Crate ustreamer_app 

Source
Expand description

App-facing integration traits and helpers for ultra-streamer-rs.

This crate defines the public contract that an adopting wgpu application can implement without depending on the demo binary’s internal glue. The intent is to keep integration explicit but small:

A minimal integration typically looks like this:

use std::time::Duration;
use ustreamer_app::{AppActionSink, MappedInputApp, StreamFrameProvider, StreamFrameSource};
use ustreamer_input::{AppAction, InputMapper};
use ustreamer_proto::input::InputEvent;

struct MyRenderer {
    instance: wgpu::Instance,
    device: wgpu::Device,
    queue: wgpu::Queue,
    texture: wgpu::Texture,
}

impl StreamFrameProvider for MyRenderer {
    fn stream_frame_source(&self) -> StreamFrameSource<'_> {
        StreamFrameSource {
            instance: &self.instance,
            device: &self.device,
            queue: &self.queue,
            texture: &self.texture,
        }
    }
}

struct MyScene {
    mapper: InputMapper,
}

impl AppActionSink for MyScene {
    fn apply_app_action(&mut self, action: AppAction) -> Option<String> {
        match action {
            AppAction::PointerUpdate { .. } => None,
            _ => Some(format!("handled {action:?}")),
        }
    }
}

impl MappedInputApp for MyScene {
    fn input_mapper(&mut self) -> &mut InputMapper {
        &mut self.mapper
    }

    fn handle_input_event(&mut self, event: &InputEvent) -> Option<String> {
        let _ = event;
        None
    }
}

Structs§

LocalStreamEndpoints
Loopback endpoints for the built-in demo/browser bootstrap flow.
StreamFrameSource
Borrowed wgpu objects required by capture backends.

Constants§

DEFAULT_HTTP_PORT
Default local HTTP bootstrap port used by the bundled browser client.
DEFAULT_STREAM_PORT
Default local WebSocket streaming port used by the bundled browser client.

Traits§

AppActionSink
Sink for default ustreamer-input AppAction values.
MappedInputApp
App that wants raw input pre-processing plus the default mapped action bridge.
RawInputApp
App that wants to consume raw browser input directly.
SessionLifecycle
Optional lifecycle hooks for integrations that want explicit connection events.
StreamFrameProvider
Trait for apps/renderers that can expose their current wgpu render target.

Functions§

drain_mapped_input_events
Drain raw browser input, feed the adaptive quality controller, and apply the default InputMapper translation for an app that uses MappedInputApp.
drain_raw_input_events
Drain raw browser input for an app that wants to handle InputEvents directly.