From 074a82d8ad44d7c7988c5e79296b03349b416797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 4 Oct 2019 11:47:50 +0300 Subject: [PATCH] Various fixes for from_string() -> from_str(), to_string() vs. to_str() The latter also does not allocate. --- gst-plugin-audiofx/src/audioecho.rs | 4 ++-- gst-plugin-cdg/src/cdgdec.rs | 2 +- gst-plugin-closedcaption/tests/scc_parse.rs | 3 ++- gst-plugin-lewton/src/lewtondec.rs | 2 +- gst-plugin-lewton/tests/lewtondec.rs | 2 +- gst-plugin-rav1e/src/rav1enc.rs | 20 ++++++++++---------- gst-plugin-tutorial/src/rgb2gray.rs | 10 +++++----- gst-plugin-tutorial/src/sinesrc.rs | 4 ++-- gst-plugin-tutorial/tutorial-1.md | 10 +++++----- gst-plugin-tutorial/tutorial-2.md | 4 ++-- 10 files changed, 31 insertions(+), 30 deletions(-) diff --git a/gst-plugin-audiofx/src/audioecho.rs b/gst-plugin-audiofx/src/audioecho.rs index a3187fe0..516e3813 100644 --- a/gst-plugin-audiofx/src/audioecho.rs +++ b/gst-plugin-audiofx/src/audioecho.rs @@ -159,8 +159,8 @@ impl ObjectSubclass for AudioEcho { ( "format", &gst::List::new(&[ - &gst_audio::AUDIO_FORMAT_F32.to_string(), - &gst_audio::AUDIO_FORMAT_F64.to_string(), + &gst_audio::AUDIO_FORMAT_F32.to_str(), + &gst_audio::AUDIO_FORMAT_F64.to_str(), ]), ), ("rate", &gst::IntRange::::new(0, i32::MAX)), diff --git a/gst-plugin-cdg/src/cdgdec.rs b/gst-plugin-cdg/src/cdgdec.rs index 5cc496dd..94ee0e50 100644 --- a/gst-plugin-cdg/src/cdgdec.rs +++ b/gst-plugin-cdg/src/cdgdec.rs @@ -69,7 +69,7 @@ impl ObjectSubclass for CdgDec { let src_caps = gst::Caps::new_simple( "video/x-raw", &[ - ("format", &gst_video::VideoFormat::Rgba.to_string()), + ("format", &gst_video::VideoFormat::Rgba.to_str()), ("width", &(CDG_WIDTH as i32)), ("height", &(CDG_HEIGHT as i32)), ("framerate", &gst::Fraction::new(0, 1)), diff --git a/gst-plugin-closedcaption/tests/scc_parse.rs b/gst-plugin-closedcaption/tests/scc_parse.rs index 4c2e0d6f..15a20250 100644 --- a/gst-plugin-closedcaption/tests/scc_parse.rs +++ b/gst-plugin-closedcaption/tests/scc_parse.rs @@ -112,6 +112,7 @@ fn test_parse() { #[test] fn test_timecodes() { use std::convert::TryInto; + use std::str::FromStr; init(); let data = include_bytes!("timecodes-cut-down-sample.scc").as_ref(); @@ -144,7 +145,7 @@ fn test_timecodes() { let mut valid_timecodes: VecDeque = timecodes .iter() .map(|s| { - let mut t = VideoTimeCode::from_string(s).unwrap(); + let mut t = VideoTimeCode::from_str(s).unwrap(); t.set_fps(gst::Fraction::new(30000, 1001)); t.set_flags(gst_video::VideoTimeCodeFlags::DROP_FRAME); t diff --git a/gst-plugin-lewton/src/lewtondec.rs b/gst-plugin-lewton/src/lewtondec.rs index 6c345e28..f3e3654c 100644 --- a/gst-plugin-lewton/src/lewtondec.rs +++ b/gst-plugin-lewton/src/lewtondec.rs @@ -76,7 +76,7 @@ impl ObjectSubclass for LewtonDec { let src_caps = gst::Caps::new_simple( "audio/x-raw", &[ - ("format", &gst_audio::AUDIO_FORMAT_F32.to_string()), + ("format", &gst_audio::AUDIO_FORMAT_F32.to_str()), ("rate", &gst::IntRange::::new(1, std::i32::MAX)), ("channels", &gst::IntRange::::new(1, 255)), ("layout", &"interleaved"), diff --git a/gst-plugin-lewton/tests/lewtondec.rs b/gst-plugin-lewton/tests/lewtondec.rs index 567f1907..177415ee 100644 --- a/gst-plugin-lewton/tests/lewtondec.rs +++ b/gst-plugin-lewton/tests/lewtondec.rs @@ -98,7 +98,7 @@ fn run_test(inline_headers: bool) { assert_eq!( caps, gst::Caps::builder("audio/x-raw") - .field("format", &gst_audio::AUDIO_FORMAT_F32.to_string()) + .field("format", &gst_audio::AUDIO_FORMAT_F32.to_str()) .field("rate", &44_100i32) .field("channels", &1i32) .field("layout", &"interleaved") diff --git a/gst-plugin-rav1e/src/rav1enc.rs b/gst-plugin-rav1e/src/rav1enc.rs index a5f09ae3..14ecf5b6 100644 --- a/gst-plugin-rav1e/src/rav1enc.rs +++ b/gst-plugin-rav1e/src/rav1enc.rs @@ -324,16 +324,16 @@ impl ObjectSubclass for Rav1Enc { ( "format", &gst::List::new(&[ - &gst_video::VideoFormat::I420.to_string(), - &gst_video::VideoFormat::Y42b.to_string(), - &gst_video::VideoFormat::Y444.to_string(), - &gst_video::VideoFormat::I42010le.to_string(), - &gst_video::VideoFormat::I42210le.to_string(), - &gst_video::VideoFormat::Y44410le.to_string(), - &gst_video::VideoFormat::I42012le.to_string(), - &gst_video::VideoFormat::I42212le.to_string(), - &gst_video::VideoFormat::Y44412le.to_string(), - // &gst_video::VideoFormat::Gray8.to_string(), + &gst_video::VideoFormat::I420.to_str(), + &gst_video::VideoFormat::Y42b.to_str(), + &gst_video::VideoFormat::Y444.to_str(), + &gst_video::VideoFormat::I42010le.to_str(), + &gst_video::VideoFormat::I42210le.to_str(), + &gst_video::VideoFormat::Y44410le.to_str(), + &gst_video::VideoFormat::I42012le.to_str(), + &gst_video::VideoFormat::I42212le.to_str(), + &gst_video::VideoFormat::Y44412le.to_str(), + // &gst_video::VideoFormat::Gray8.to_str(), ]), ), ("width", &gst::IntRange::::new(1, std::i32::MAX)), diff --git a/gst-plugin-tutorial/src/rgb2gray.rs b/gst-plugin-tutorial/src/rgb2gray.rs index 83182260..44e2dcf6 100644 --- a/gst-plugin-tutorial/src/rgb2gray.rs +++ b/gst-plugin-tutorial/src/rgb2gray.rs @@ -164,8 +164,8 @@ impl ObjectSubclass for Rgb2Gray { ( "format", &gst::List::new(&[ - &gst_video::VideoFormat::Bgrx.to_string(), - &gst_video::VideoFormat::Gray8.to_string(), + &gst_video::VideoFormat::Bgrx.to_str(), + &gst_video::VideoFormat::Gray8.to_str(), ]), ), ("width", &gst::IntRange::::new(0, i32::MAX)), @@ -195,7 +195,7 @@ impl ObjectSubclass for Rgb2Gray { let caps = gst::Caps::new_simple( "video/x-raw", &[ - ("format", &gst_video::VideoFormat::Bgrx.to_string()), + ("format", &gst_video::VideoFormat::Bgrx.to_str()), ("width", &gst::IntRange::::new(0, i32::MAX)), ("height", &gst::IntRange::::new(0, i32::MAX)), ( @@ -317,7 +317,7 @@ impl BaseTransformImpl for Rgb2Gray { let mut caps = caps.clone(); for s in caps.make_mut().iter_mut() { - s.set("format", &gst_video::VideoFormat::Bgrx.to_string()); + s.set("format", &gst_video::VideoFormat::Bgrx.to_str()); } caps @@ -333,7 +333,7 @@ impl BaseTransformImpl for Rgb2Gray { for s in caps.iter() { let mut s_gray = s.to_owned(); - s_gray.set("format", &gst_video::VideoFormat::Gray8.to_string()); + s_gray.set("format", &gst_video::VideoFormat::Gray8.to_str()); gray_caps.append_structure(s_gray); } gray_caps.append(caps.clone()); diff --git a/gst-plugin-tutorial/src/sinesrc.rs b/gst-plugin-tutorial/src/sinesrc.rs index 589bac96..9a3f4577 100644 --- a/gst-plugin-tutorial/src/sinesrc.rs +++ b/gst-plugin-tutorial/src/sinesrc.rs @@ -253,8 +253,8 @@ impl ObjectSubclass for SineSrc { ( "format", &gst::List::new(&[ - &gst_audio::AUDIO_FORMAT_F32.to_string(), - &gst_audio::AUDIO_FORMAT_F64.to_string(), + &gst_audio::AUDIO_FORMAT_F32.to_str(), + &gst_audio::AUDIO_FORMAT_F64.to_str(), ]), ), ("layout", &"interleaved"), diff --git a/gst-plugin-tutorial/tutorial-1.md b/gst-plugin-tutorial/tutorial-1.md index f84cbf32..69eb3211 100644 --- a/gst-plugin-tutorial/tutorial-1.md +++ b/gst-plugin-tutorial/tutorial-1.md @@ -321,8 +321,8 @@ In our case we only have always pads, one sink pad called “sink”, on which w ( "format", &gst::List::new(&[ - &gst_video::VideoFormat::Bgrx.to_string(), - &gst_video::VideoFormat::Gray8.to_string(), + &gst_video::VideoFormat::Bgrx.to_str(), + &gst_video::VideoFormat::Gray8.to_str(), ]), ), ("width", &gst::IntRange::::new(0, i32::MAX)), @@ -349,7 +349,7 @@ In our case we only have always pads, one sink pad called “sink”, on which w let caps = gst::Caps::new_simple( "video/x-raw", &[ - ("format", &gst_video::VideoFormat::Bgrx.to_string()), + ("format", &gst_video::VideoFormat::Bgrx.to_str()), ("width", &gst::IntRange::::new(0, i32::MAX)), ("height", &gst::IntRange::::new(0, i32::MAX)), ( @@ -488,7 +488,7 @@ impl BaseTransformImpl for Rgb2Gray { let mut caps = caps.clone(); for s in caps.make_mut().iter_mut() { - s.set("format", &gst_video::VideoFormat::Bgrx.to_string()); + s.set("format", &gst_video::VideoFormat::Bgrx.to_str()); } caps @@ -500,7 +500,7 @@ impl BaseTransformImpl for Rgb2Gray { for s in caps.iter() { let mut s_gray = s.to_owned(); - s_gray.set("format", &gst_video::VideoFormat::Gray8.to_string()); + s_gray.set("format", &gst_video::VideoFormat::Gray8.to_str()); gray_caps.append_structure(s_gray); } gray_caps.append(caps.clone()); diff --git a/gst-plugin-tutorial/tutorial-2.md b/gst-plugin-tutorial/tutorial-2.md index 05c95ffe..81447767 100644 --- a/gst-plugin-tutorial/tutorial-2.md +++ b/gst-plugin-tutorial/tutorial-2.md @@ -184,8 +184,8 @@ impl SineSrc { ( "format", &gst::List::new(&[ - &gst_audio::AUDIO_FORMAT_F32.to_string(), - &gst_audio::AUDIO_FORMAT_F64.to_string(), + &gst_audio::AUDIO_FORMAT_F32.to_str(), + &gst_audio::AUDIO_FORMAT_F64.to_str(), ]), ), ("layout", &"interleaved"),