diff options
Diffstat (limited to 'stream/src/stream_info.rs')
| -rw-r--r-- | stream/src/stream_info.rs | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/stream/src/stream_info.rs b/stream/src/stream_info.rs index 16b77c2..1cc1663 100644 --- a/stream/src/stream_info.rs +++ b/stream/src/stream_info.rs @@ -6,13 +6,15 @@ use crate::{Config, SMediaInfo, cues::generate_cues, metadata::read_metadata}; use anyhow::Result; use jellycache::Cache; -use jellyremuxer::matroska::{self, Segment, TrackEntry, TrackType}; +use jellyremuxer::{ + codec_param, + matroska::{self, Segment, TrackEntry, TrackType}, +}; use jellystream_types::{ StreamContainer, StreamFormatInfo, StreamInfo, StreamTrackInfo, TrackKind, }; use jellytranscoder::fragment::transcode_init; use std::{ - fmt::Write, io::{Cursor, Read}, path::PathBuf, sync::Arc, @@ -196,50 +198,3 @@ pub(crate) fn write_stream_info(info: &SMediaInfo) -> Result<Box<dyn Read + Send fn media_duration(info: &matroska::Info) -> f64 { (info.duration.unwrap_or_default() * info.timestamp_scale as f64) / 1_000_000_000. } - -fn codec_param(te: &TrackEntry) -> String { - let cp = te.codec_private.as_ref().unwrap(); - match te.codec_id.as_str() { - "A_OPUS" => "opus".to_string(), - "A_VORBIS" => "vorbis".to_string(), - "V_MPEG4/ISO/AVC" => format!("avc1.{:02x}{:02x}{:02x}", cp[1], cp[2], cp[3]), - "V_MPEGH/ISO/HEVC" => { - let general_profile_space = cp[1] >> 6; - let general_tier_flag = (cp[1] >> 5) & 0b1; - let general_profile_idc = cp[1] & 0b11111; - let general_level_idc = cp[12]; - let general_profile_compatibility_flag = - u32::from_be_bytes([cp[2], cp[3], cp[4], cp[5]]); - let mut d = String::new(); - for &flag in &cp[6..12] { - write!(d, ".{flag:02x}").unwrap(); - } - format!( - "hvc1.{}{}.{:x}.{}{}{d}", - match general_profile_space { - 0 => "", - 1 => "A", - 2 => "B", - 3 => "C", - _ => unreachable!(), - }, - general_profile_idc, - general_profile_compatibility_flag, - match general_tier_flag { - 0 => 'L', - 1 => 'H', - _ => unreachable!(), - }, - general_level_idc, - ) - } - "V_AV1" => { - let seq_profile = (cp[1] >> 5) & 0b111; - format!("av01") - } - "A_AAC" => { - format!("aac1") - } - x => todo!("{x:?}"), - } -} |