Skip to content

Commit

Permalink
feat: rtsp grid view
Browse files Browse the repository at this point in the history
  • Loading branch information
mosure committed Mar 8, 2024
1 parent 438260f commit 26112bb
Show file tree
Hide file tree
Showing 6 changed files with 521 additions and 344 deletions.
10 changes: 0 additions & 10 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
# alternatively, `export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-server-runner`

[target.wasm32-unknown-unknown]
runner = "wasm-server-runner"
rustflags = [
"--cfg=web_sys_unstable_apis",
# "-C",
# "target-feature=+atomics,+bulk-memory,+mutable-globals", # for wasm-bindgen-rayon
]


# fix spurious network error on windows
# [source.crates-io]
Expand Down
40 changes: 9 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,28 @@ default-run = "viewer"


[dependencies]
anyhow = "1.0.80"
async-compat = "0.2.3"
futures = "0.3.30"
openh264 = "0.5.0"
retina = "0.4.7"
tokio = "1.36.0"
url = "2.5.0"
anyhow = "1.0"
async-compat = "0.2"
futures = "0.3"
openh264 = "0.5"
retina = "0.4"
tokio = { version = "1.36", features = ["full"] }
url = "2.5"


[dependencies.bevy]
version = "0.13"
default-features = false
features = [
"bevy_asset",
"bevy_core_pipeline",
"bevy_render",
"bevy_ui",
"bevy_winit",
"multi-threaded",
]


[target.'cfg(target_arch = "wasm32")'.dependencies]
console_error_panic_hook = "0.1"
wasm-bindgen = "0.2"


[dependencies.web-sys]
version = "=0.3.67"
features = [
'Document',
'Element',
'HtmlElement',
'Location',
'Node',
'Window',
]


[profile.dev.package."*"]
opt-level = 3

Expand All @@ -75,13 +60,6 @@ lto = "thin"
codegen-units = 1
opt-level = 3

[profile.wasm-release]
inherits = "release"
opt-level = "z"
lto = "fat"
codegen-units = 1



[lib]
path = "src/lib.rs"
Expand Down
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,107 @@
rust bevy light field camera array tooling


## example

```rust
use bevy::{
prelude::*,
render::render_resource::{
Extent3d,
TextureDescriptor,
TextureDimension,
TextureFormat,
TextureUsages,
},
};

use bevy_light_field::stream::{
RtspStreamDescriptor,
RtspStreamPlugin,
StreamId,
};


const RTSP_URIS: [&str; 1] = [
"rtsp://localhost:554/lizard",
];


fn main() {
App::new()
.add_plugins((
DefaultPlugins,
RtspStreamPlugin,
))
.add_systems(Startup, create_streams)
.add_systems(Startup, setup_camera)
.run();
}


fn create_streams(
mut commands: Commands,
mut images: ResMut<Assets<Image>>,
) {
RTSP_URIS.iter()
.enumerate()
.for_each(|(index, &url)| {
let entity = commands.spawn_empty().id();

let size = Extent3d {
width: 640,
height: 360,
..default()
};

let mut image = Image {
texture_descriptor: TextureDescriptor {
label: Some(url),
size,
dimension: TextureDimension::D2,
format: TextureFormat::Rgba8UnormSrgb,
mip_level_count: 1,
sample_count: 1,
usage: TextureUsages::COPY_DST
| TextureUsages::TEXTURE_BINDING
| TextureUsages::RENDER_ATTACHMENT,
view_formats: &[TextureFormat::Rgba8UnormSrgb],
},
..default()
};
image.resize(size);

let image = images.add(image);
commands.spawn(SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::new(640.0, 360.0)),
..default()
},
texture: image.clone(),
..default()
});

let rtsp_stream = RtspStreamDescriptor::new(
url.to_string(),
StreamId(index),
image,
);

commands.entity(entity).insert(rtsp_stream);
});
}

fn setup_camera(
mut commands: Commands,
) {
commands.spawn((
Camera2dBundle {
..default()
},
));
}
```


## run the viewer

Expand Down Expand Up @@ -52,3 +153,7 @@ it is useful to test the light field viewer with emulated camera streams
| `bevy_light_field` | `bevy` |
| :-- | :-- |
| `0.1.0` | `0.13` |


## credits
- [bevy_video](https://github.com/PortalCloudInc/bevy_video)
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// pub mod stream;
pub mod stream;
Loading

0 comments on commit 26112bb

Please sign in to comment.