Skip to content

Commit

Permalink
add mp4 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
BenLocal committed Jan 3, 2025
1 parent 61c4bf4 commit dcb8b7a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/mp4/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "mp4"
version = "0.1.0"
edition = "2021"

[dependencies]
rszlm = { path = "../..", features = ["static"] }
tokio = { version = "1", features = ["full"] }
anyhow = "1"
35 changes: 35 additions & 0 deletions examples/mp4/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use rszlm::{
event::EVENTS,
init::EnvInitBuilder,
player::Mp4ProxyPlayer,
server::{rtsp_server_start, stop_all_server},
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
EnvInitBuilder::default()
.log_level(0)
.log_mask(0)
.thread_num(20)
.build();

rtsp_server_start(8554, false);

EVENTS.write().unwrap().on_media_play(move |msg| {
println!("media play: {}", msg.url_info.stream());
println!("start player");
Mp4ProxyPlayer::new(
&msg.url_info.vhost(),
&msg.url_info.app(),
&msg.url_info.stream(),
"/test1.mp4",
0,
None,
);
Ok(())
});

tokio::signal::ctrl_c().await?;
stop_all_server();
Ok(())
}

0 comments on commit dcb8b7a

Please sign in to comment.