]> git.nihav.org Git - nihav-encoder.git/commitdiff
parse requested formaton and soniton
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 11 Jul 2020 13:34:09 +0000 (15:34 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 11 Jul 2020 13:34:09 +0000 (15:34 +0200)
src/main.rs

index b06f7b635c7489a6b779fe06d8142d5c02b3b7b6..8d5efd377fd67aa680101adeacd4e6ea267caafe 100644 (file)
@@ -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::<NAPixelFormaton>();
+                            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::<NASoniton>();
+                            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::<NAChannelMap>();
+                            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::<u32>();
                         if let Ok(val) = ret {