-
-
Notifications
You must be signed in to change notification settings - Fork 229
Use config struct to pass hls params #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
89b9fb0
266421f
5842528
e4a5fc8
f441670
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||
| use { | ||||||
| super::{errors::MediaError, ts::Ts}, | ||||||
| config::HlsConfig, | ||||||
| bytes::BytesMut, | ||||||
| std::{collections::VecDeque, fs, fs::File, io::Write}, | ||||||
| streamhub::define::Segment, | ||||||
|
|
@@ -32,16 +33,30 @@ pub struct M3u8 { | |||||
| impl M3u8 { | ||||||
| pub fn new( | ||||||
| duration: i64, | ||||||
| live_ts_count: usize, | ||||||
| app_name: String, | ||||||
| stream_name: String, | ||||||
| need_record: bool, | ||||||
| path: String, | ||||||
| hls_config: Option<HlsConfig>, | ||||||
| ) -> Self { | ||||||
|
|
||||||
| let path = hls_config | ||||||
| .as_ref() | ||||||
| .and_then(|config| config.path.clone()) | ||||||
| .unwrap_or("./".to_string()); | ||||||
|
|
||||||
| let m3u8_folder = format!("{path}{app_name}/{stream_name}"); | ||||||
| fs::create_dir_all(m3u8_folder.clone()).unwrap(); | ||||||
|
|
||||||
| let live_m3u8_name = format!("{stream_name}.m3u8"); | ||||||
|
|
||||||
| let need_record = hls_config | ||||||
| .as_ref() | ||||||
| .and_then(|config| Some(config.need_record)) | ||||||
|
||||||
| .and_then(|config| Some(config.need_record)) | |
| .map(|config| config.need_record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The imports are formatted on a single line making them hard to read. Consider breaking this into multiple lines for better readability.