Skip to content

Commit b754b69

Browse files
committed
[feat] support HLS record
1 parent 4f118a9 commit b754b69

25 files changed

Lines changed: 201 additions & 90 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Xiu is a simple,high performance and secure live media server written in pure Ru
4444
- [x] Support querying stream information.
4545
- [x] Support notification of stream status.
4646
- [x] Support token authentications.
47+
- [x] Support recording live streams into HLS files(m3u8+ts).
4748

4849

4950
## Preparation
@@ -163,6 +164,8 @@ You can use command line to configure the xiu server easily. You can specify to
163164
enabled = true
164165
# listening port
165166
port = 8080
167+
# need record the live stream or not
168+
need_record = true
166169

167170
##### Log
168171

README_CN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ XIU是用纯Rust开发的一款简单和安全的流媒体服务器,目前支
4242
- [x] 支持查询流信息
4343
- [x] 支持流事件通知
4444
- [x] 支持token鉴权
45+
- [x] 支持把直播流录制成HLS协议(m3u8+ts)文件.
4546

4647
## 准备工作
4748
#### 安装 Rust and Cargo
@@ -163,6 +164,8 @@ XIU是用纯Rust开发的一款简单和安全的流媒体服务器,目前支
163164
enabled = true
164165
# listening port
165166
port = 8080
167+
# need record the live stream or not
168+
need_record = true
166169

167170
##### Log
168171

application/http-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ serde_json = { version = "1", default-features = false, features = [
1515
] }
1616
axum = "0.6.10"
1717
log = "0.4.0"
18-
env_logger = "0.9.3"
18+
env_logger = "0.10.0"
1919

2020
[dependencies.tokio]
2121
version = "1.4.0"

application/pprtmp/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ edition = "2021"
88
[dependencies]
99
anyhow = "^1.0"
1010
log = "0.4.0"
11-
env_logger = "0.9.3"
11+
env_logger = "0.10.0"
1212
clap = "4.1.4"
1313

1414
rtmp = "0.4.0"

application/xiu/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "xiu"
33
description = "A powerful live server by Rust ."
4-
version = "0.7.0"
4+
version = "0.8.0"
55
authors = ["HarlanC <wawacry@qq.com"]
66
repository = "https://github.com/harlanc/xiu"
77
license = "MIT"
@@ -31,7 +31,7 @@ streamhub = "0.1.0"
3131
rtmp = "0.4.0"
3232
xrtsp = "0.1.0"
3333
httpflv = "0.3.0"
34-
hls = "0.3.0"
34+
hls = "0.4.0"
3535

3636
[features]
3737
default = ["std"]

application/xiu/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,5 +322,7 @@ Open issues if you have any problems. Star and pull requests are welcomed. Your
322322
- Fix RTMP examples in README.
323323
## v0.7.0
324324
- Support RTSP.
325+
## v0.8.0
326+
- Support HLS record.
325327

326328

application/xiu/src/api.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ impl ApiService {
3636
async fn get_stream_status(&self) -> Result<String> {
3737
let (data_sender, mut data_receiver) = mpsc::unbounded_channel();
3838
let (size_sender, size_receiver) = oneshot::channel();
39-
let channel_event = define::StreamHubEvent::ApiStatistic {
39+
let hub_event = define::StreamHubEvent::ApiStatistic {
4040
data_sender,
4141
size_sender,
4242
};
43-
if let Err(err) = self.channel_event_producer.send(channel_event) {
43+
if let Err(err) = self.channel_event_producer.send(hub_event) {
4444
log::error!("send api event error: {}", err);
4545
}
4646
let mut data = Vec::new();
@@ -74,9 +74,9 @@ impl ApiService {
7474
let id_result = Uuid::from_str2(&id.id);
7575

7676
if let Some(id) = id_result {
77-
let channel_event = define::StreamHubEvent::ApiKickClient { id };
77+
let hub_event = define::StreamHubEvent::ApiKickClient { id };
7878

79-
if let Err(err) = self.channel_event_producer.send(channel_event) {
79+
if let Err(err) = self.channel_event_producer.send(hub_event) {
8080
log::error!("send api kick_off_client event error: {}", err);
8181
}
8282
}

application/xiu/src/config/config_rtmp_hls.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ port = 1935
1212
[hls]
1313
enabled = true
1414
port = 8080
15+
#defalut false
16+
need_record = true
1517

1618
#######################################
1719
# LOG configurations #
1820
#######################################
1921
[log]
20-
level = "info"
22+
level = "info"

application/xiu/src/config/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ impl Config {
5656
hls_config = Some(HlsConfig {
5757
enabled: true,
5858
port: hls_port,
59+
need_record: false,
5960
});
6061
}
6162

@@ -113,6 +114,8 @@ pub struct HttpFlvConfig {
113114
pub struct HlsConfig {
114115
pub enabled: bool,
115116
pub port: usize,
117+
//record or not
118+
pub need_record: bool,
116119
}
117120

118121
pub enum LogLevel {
@@ -164,7 +167,9 @@ fn test_toml_parse() {
164167
// Err(err) => print!("{}\n", err),
165168
// }
166169

167-
let str = fs::read_to_string("/Users/zexu/github/xiu_live_rust/application/xiu/src/config/config.toml");
170+
let str = fs::read_to_string(
171+
"/Users/zexu/github/xiu_live_rust/application/xiu/src/config/config.toml",
172+
);
168173

169174
match str {
170175
Ok(val) => {

application/xiu/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async fn main() -> Result<()> {
1414

1515
let mut cmd = Command::new("XIU")
1616
.bin_name("xiu")
17-
.version("0.7.0")
17+
.version("0.8.0")
1818
.author("HarlanC <harlanc@foxmail.com>")
1919
.about("A secure and easy to use live media server, hope you love it!!!")
2020
.arg(

0 commit comments

Comments
 (0)