How to do HLS streaming with javelin?

Hello.
I'm new to Rust.

I want to try using HLS server with rust.
I have chosen javelin for the tryout.

https://github.com/valeth/javelin

I checked the server worked as a RTMP server, and then, I tried to make sure the server works as a HLS server as well.

Although I have read the source code of javelin, I don't know how to check it out.

I think web/server.rs has a role of http server.

use {
    std::thread,
    warp::{Filter, Reply, Rejection, http::StatusCode},
    serde_json::json,
    super::api::{
        api,
        Error as ApiError,
    },
    crate::Shared,
};


macro_rules! json_error_response {
    ($code:expr, $message:expr) => {{
        let json = json!({ "error": $message });
        let reply = warp::reply::json(&json);
        Ok(warp::reply::with_status(reply, $code))
    }};
}


pub struct Server {
    shared: Shared,
}

impl Server {
    pub fn new(shared: Shared) -> Self {
        Self { shared }
    }

    pub fn start(&mut self) {
        let shared = self.shared.clone();
        thread::spawn(|| server(shared));
    }
}


fn server(shared: Shared) {
    let addr = {
        let config = shared.config.read();
        config.web.addr
    };

    let hls_root = {
        let config = shared.config.read();
        config.hls.root_dir.clone()
    };

    let hls_files = warp::path("hls")
        .and(warp::fs::dir(hls_root));

    let streams_api = warp::path("api")
        .and(api(shared.clone()));

    let routes = hls_files
        .or(streams_api)
        .recover(error_handler);

    warp::serve(routes).run(addr);
}

fn error_handler(err: Rejection) -> Result<impl Reply, Rejection> {
    match err.find_cause() {
        | Some(e @ ApiError::NoSuchResource)
        | Some(e @ ApiError::StreamNotFound) => {
            json_error_response!(StatusCode::NOT_FOUND, e.to_string())
        },
        None => Err(err)
    }
}

I didn't find a part of streaming hls data not only in this code, but any codes in the project.
So I think I have to add some codes to run HLS streaming with javelin.

Do you know how to run the javelin server?

Help!

If I've read it right, it looks like HLS streaming is an open issue in javelin: https://gitlab.com/valeth/javelin/-/issues/21, and the author is not currently implementing this.

If you want to implement this, maybe you could coordinate with the person who reported that, or show your support on that gitlab issue?

1 Like

I see,
I tried to implement the HLS streaming function on javelin.

It does not still work properly.
So I'll show it when I implement the hls streaming function.

Thanks!

1 Like

Hey, that is interesting.

I know nothing much about video or streaming it. Just now I need to push the output of a camera to a server so that it could then be viewed by connected clients somehow.

I hobbled something together with ffmpeg fetching the stream from the camera and pushing it to an nginx server as RTMP. From their I can view the stream in the browser using HLS or in something like VLC using RTMP.

A self contained Rust server to do just that job might me very nice.

1 Like

Thanks :heartbeat:
Someday I implement hls function on javelin!