Various fixes for from_string() -> from_str(), to_string() vs. to_str()

The latter also does not allocate.
This commit is contained in:
Sebastian Dröge 2019-10-04 11:47:50 +03:00
parent 9897336896
commit 074a82d8ad
10 changed files with 31 additions and 30 deletions

View file

@ -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::<i32>::new(0, i32::MAX)),

View file

@ -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)),

View file

@ -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<ValidVideoTimeCode> = 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

View file

@ -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::<i32>::new(1, std::i32::MAX)),
("channels", &gst::IntRange::<i32>::new(1, 255)),
("layout", &"interleaved"),

View file

@ -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")

View file

@ -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::<i32>::new(1, std::i32::MAX)),

View file

@ -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::<i32>::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::<i32>::new(0, i32::MAX)),
("height", &gst::IntRange::<i32>::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());

View file

@ -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"),

View file

@ -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::<i32>::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::<i32>::new(0, i32::MAX)),
("height", &gst::IntRange::<i32>::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());

View file

@ -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"),