mirror of
https://github.com/v0l/zap-stream-core.git
synced 2025-06-21 06:00:45 +00:00
refactor: cleanup directory handling
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@ -149,7 +149,7 @@ fn main() -> Result<()> {
|
||||
|
||||
println!("Analyzing HLS stream: {}", hls_dir.display());
|
||||
println!("Playlist: {}", playlist_path.display());
|
||||
|
||||
|
||||
// Check for initialization segment
|
||||
let init_path = hls_dir.join("init.mp4");
|
||||
if init_path.exists() {
|
||||
@ -612,7 +612,7 @@ fn analyze_init_segment(path: &Path) -> Result<InitSegmentInfo> {
|
||||
|
||||
let file = fs::File::open(path)
|
||||
.with_context(|| format!("Failed to open init segment: {}", path.display()))?;
|
||||
|
||||
|
||||
let mut demuxer = Demuxer::new_custom_io(Box::new(file), None)?;
|
||||
|
||||
// Probe the input to get stream information
|
||||
@ -622,7 +622,7 @@ fn analyze_init_segment(path: &Path) -> Result<InitSegmentInfo> {
|
||||
|
||||
let mut streams = Vec::new();
|
||||
let mut pixel_format_set = false;
|
||||
|
||||
|
||||
// Try to get streams - we'll iterate until we hit an error
|
||||
let mut i = 0;
|
||||
loop {
|
||||
@ -631,7 +631,7 @@ fn analyze_init_segment(path: &Path) -> Result<InitSegmentInfo> {
|
||||
Ok(stream) => unsafe {
|
||||
let codecpar = (*stream).codecpar;
|
||||
let codec_type = (*codecpar).codec_type;
|
||||
|
||||
|
||||
let codec_name = {
|
||||
let name_ptr = avcodec_get_name((*codecpar).codec_id);
|
||||
if name_ptr.is_null() {
|
||||
@ -643,9 +643,17 @@ fn analyze_init_segment(path: &Path) -> Result<InitSegmentInfo> {
|
||||
|
||||
let (codec_type_str, width, height, pixel_format) = match codec_type {
|
||||
AVMEDIA_TYPE_VIDEO => {
|
||||
let w = if (*codecpar).width > 0 { Some((*codecpar).width) } else { None };
|
||||
let h = if (*codecpar).height > 0 { Some((*codecpar).height) } else { None };
|
||||
|
||||
let w = if (*codecpar).width > 0 {
|
||||
Some((*codecpar).width)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let h = if (*codecpar).height > 0 {
|
||||
Some((*codecpar).height)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let pix_fmt = if (*codecpar).format != AV_PIX_FMT_NONE as i32 {
|
||||
pixel_format_set = true;
|
||||
// Skip pixel format name resolution for now due to type mismatch
|
||||
@ -653,15 +661,11 @@ fn analyze_init_segment(path: &Path) -> Result<InitSegmentInfo> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
|
||||
("video".to_string(), w, h, pix_fmt)
|
||||
}
|
||||
AVMEDIA_TYPE_AUDIO => {
|
||||
("audio".to_string(), None, None, None)
|
||||
}
|
||||
_ => {
|
||||
("other".to_string(), None, None, None)
|
||||
}
|
||||
AVMEDIA_TYPE_AUDIO => ("audio".to_string(), None, None, None),
|
||||
_ => ("other".to_string(), None, None, None),
|
||||
};
|
||||
|
||||
streams.push(StreamInfo {
|
||||
@ -671,7 +675,7 @@ fn analyze_init_segment(path: &Path) -> Result<InitSegmentInfo> {
|
||||
height,
|
||||
pixel_format,
|
||||
});
|
||||
|
||||
|
||||
i += 1;
|
||||
},
|
||||
Err(_) => break, // No more streams
|
||||
|
@ -152,7 +152,7 @@ impl HttpServer {
|
||||
.title
|
||||
.unwrap_or_else(|| format!("Stream {}", &stream.id[..8])),
|
||||
summary: stream.summary,
|
||||
live_url: format!("/{}/{}/live.m3u8", HlsEgress::PATH, stream.id),
|
||||
live_url: format!("/{}/{}/live.m3u8", stream.id, HlsEgress::PATH),
|
||||
viewer_count: if viewer_count > 0 {
|
||||
Some(viewer_count as _)
|
||||
} else {
|
||||
|
@ -229,13 +229,14 @@ impl ZapStreamOverseer {
|
||||
pubkey: &Vec<u8>,
|
||||
) -> Result<Event> {
|
||||
// TODO: remove assumption that HLS is enabled
|
||||
let pipeline_dir = PathBuf::from(stream.id.to_string());
|
||||
let extra_tags = vec![
|
||||
Tag::parse(["p", hex::encode(pubkey).as_str(), "", "host"])?,
|
||||
Tag::parse([
|
||||
"streaming",
|
||||
self.map_to_public_url(
|
||||
PathBuf::from(HlsEgress::PATH)
|
||||
.join(stream.id.to_string())
|
||||
pipeline_dir
|
||||
.join(HlsEgress::PATH)
|
||||
.join("live.m3u8")
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
@ -244,13 +245,8 @@ impl ZapStreamOverseer {
|
||||
])?,
|
||||
Tag::parse([
|
||||
"image",
|
||||
self.map_to_public_url(
|
||||
PathBuf::from(stream.id.to_string())
|
||||
.join("thumb.webp")
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
)?
|
||||
.as_str(),
|
||||
self.map_to_public_url(pipeline_dir.join("thumb.webp").to_str().unwrap())?
|
||||
.as_str(),
|
||||
])?,
|
||||
Tag::parse(["service", self.map_to_public_url("api/v1")?.as_str()])?,
|
||||
];
|
||||
@ -642,7 +638,7 @@ fn get_variants_from_endpoint<'a>(
|
||||
bitrate: bitrate as u64,
|
||||
codec: "libx264".to_string(),
|
||||
profile: 77, // AV_PROFILE_H264_MAIN
|
||||
level: 51, // High 5.1 (4K)
|
||||
level: 51, // High 5.1 (4K)
|
||||
keyframe_interval: video_src.fps as u16,
|
||||
pixel_format: AV_PIX_FMT_YUV420P as u32,
|
||||
}));
|
||||
|
Reference in New Issue
Block a user