hls_audio_server/lib.rs
1//! A hassle free way to serve audio over HLS.
2//!
3//! Example:
4//! ```
5//! use hls_audio_server::m3u8::{HLSConfig, Playlist};
6//! use hls_audio_server::server::HLSServer;
7//! use std::net::SocketAddr;
8//!
9//! #[tokio::main]
10//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
11//! let hls_config = HLSConfig {
12//! segments_to_keep: 10,
13//! segment_duration: 8.0,
14//! uri: "http://localhost:3000/".into(),
15//! file_extension: ".aac".into(),
16//! };
17//!
18//! let hls_playback = Playlist::new(hls_config);
19//!
20//! let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
21//! let hls_server = HLSServer::new(addr, hls_playback).await?;
22//!
23//! hls_server
24//! .serve_data(move || {
25//! // Serve your encoded audio here
26//! Vec::new()
27//! })
28//! .await?;
29//! Ok(())
30//! }
31//! ```
32//!
33//! The playlist will be available at `http://localhost:3000/stream.m3u8` in this case.
34//!
35//! It is the user's responsibility to encode audio in the format compatible with RFC: 8216 section
36//! 3.4. The appropriate ID3 tag is automatically added, so the encoded audio must have no ID3 tags.
37//!
38//! But do not worry! You can find a complete example that uses AAC LC coding to serve a .wav file
39//! in the project repository in case you do not want to mess with different codecs.
40
41pub mod m3u8;
42pub mod playback;
43pub mod server;