From e176bfee85e6cea16fccc182f56493174f3d0f8a Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sat, 11 Jul 2020 15:34:09 +0200 Subject: [PATCH] parse requested formaton and soniton --- src/main.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index b06f7b6..8d5efd3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -222,7 +222,21 @@ impl Transcoder { println!("video option for audio stream"); } }, -//todo formaton + "pixfmt" => { + if ostr.enc_params.format == NACodecTypeInfo::None { + ostr.enc_params.format = NACodecTypeInfo::Video(NAVideoInfo::new(0, 0, false, YUV420_FORMAT)); + } + if let NACodecTypeInfo::Video(ref mut vinfo) = ostr.enc_params.format { + let ret = oval[1].parse::(); + if let Ok(val) = ret { + vinfo.format = val; + } else { + println!("invalid pixel format"); + } + } else { + println!("video option for audio stream"); + } + }, "srate" => { if ostr.enc_params.format == NACodecTypeInfo::None { ostr.enc_params.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16_FORMAT, 0)); @@ -268,7 +282,37 @@ impl Transcoder { println!("audio option for video stream"); } }, -//todo soniton, channel map + "sfmt" => { + if ostr.enc_params.format == NACodecTypeInfo::None { + ostr.enc_params.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16_FORMAT, 0)); + } + if let NACodecTypeInfo::Audio(ref mut ainfo) = ostr.enc_params.format { + let ret = oval[1].parse::(); + if let Ok(val) = ret { + ainfo.format = val; + } else { + println!("invalid audio format"); + } + } else { + println!("audio option for video stream"); + } + }, +// todo channel map negotiation + /*"chmap" => { + if ostr.enc_params.format == NACodecTypeInfo::None { + ostr.enc_params.format = NACodecTypeInfo::Audio(NAAudioInfo::new(0, 0, SND_S16_FORMAT, 0)); + } + if let NACodecTypeInfo::Audio(ref mut ainfo) = ostr.enc_params.format { + let ret = oval[1].parse::(); + if let Ok(val) = ret { + ainfo.chmap = val; + } else { + println!("invalid channel map"); + } + } else { + println!("audio option for video stream"); + } + },*/ "bitrate" => { let ret = oval[1].parse::(); if let Ok(val) = ret { -- 2.39.5