1 use { 2 super::define::epsi_stream_type, 3 bytesio::{bytes_errors::BytesWriteError, bytes_writer::BytesWriter}, 4 }; 5 pcr_write(pcr_result: &mut BytesWriter, pcr: i64) -> Result<(), BytesWriteError>6pub fn pcr_write(pcr_result: &mut BytesWriter, pcr: i64) -> Result<(), BytesWriteError> { 7 let pcr_base: i64 = pcr / 300; 8 let pcr_ext: i64 = pcr % 300; 9 10 pcr_result.write_u8((pcr_base >> 25) as u8)?; 11 pcr_result.write_u8((pcr_base >> 17) as u8)?; 12 pcr_result.write_u8((pcr_base >> 9) as u8)?; 13 pcr_result.write_u8((pcr_base >> 1) as u8)?; 14 pcr_result.write_u8(((pcr_base & 0x01) << 7) as u8 | 0x7E | ((pcr_ext >> 8) & 0x01) as u8)?; 15 pcr_result.write_u8((pcr_ext & 0xFF) as u8)?; 16 17 Ok(()) 18 } 19 is_steam_type_video(stream_type: u8) -> bool20pub fn is_steam_type_video(stream_type: u8) -> bool { 21 matches!(stream_type, epsi_stream_type::PSI_STREAM_H264) 22 } 23 is_steam_type_audio(stream_type: u8) -> bool24pub fn is_steam_type_audio(stream_type: u8) -> bool { 25 matches!( 26 stream_type, 27 epsi_stream_type::PSI_STREAM_AUDIO_OPUS 28 | epsi_stream_type::PSI_STREAM_AAC 29 | epsi_stream_type::PSI_STREAM_MP3 30 | epsi_stream_type::PSI_STREAM_MPEG4_AAC 31 ) 32 } 33