mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
Let Sample::new(), TagList::add(), Structure::set() and others take more values by reference instead of by value
This commit is contained in:
parent
b6d13272df
commit
b198ee21da
6 changed files with 24 additions and 24 deletions
|
@ -133,7 +133,7 @@ fn example_main() -> Result<(), Error> {
|
|||
("Failed to insert sink"),
|
||||
details: gst::Structure::builder("error-details")
|
||||
.field("error",
|
||||
glib::AnySendValue::new(Arc::new(Mutex::new(Some(err)))))
|
||||
&glib::AnySendValue::new(Arc::new(Mutex::new(Some(err)))))
|
||||
.build()
|
||||
);
|
||||
|
||||
|
|
|
@ -382,7 +382,7 @@ impl Builder {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn field<V: ToSendValue>(mut self, name: &str, value: V) -> Self {
|
||||
pub fn field<V: ToSendValue>(mut self, name: &str, value: &V) -> Self {
|
||||
self.s.set(name, value);
|
||||
self
|
||||
}
|
||||
|
@ -440,11 +440,11 @@ mod tests {
|
|||
::init().unwrap();
|
||||
|
||||
let caps = Caps::builder("foo/bar")
|
||||
.field("int", 12)
|
||||
.field("bool", true)
|
||||
.field("string", "bla")
|
||||
.field("fraction", Fraction::new(1, 2))
|
||||
.field("array", Array::new(&[&1, &2]))
|
||||
.field("int", &12)
|
||||
.field("bool", &true)
|
||||
.field("string", &"bla")
|
||||
.field("fraction", &Fraction::new(1, 2))
|
||||
.field("array", &Array::new(&[&1, &2]))
|
||||
.build();
|
||||
assert_eq!(
|
||||
caps.to_string(),
|
||||
|
|
|
@ -30,8 +30,8 @@ unsafe impl MiniObject for SampleRef {
|
|||
|
||||
impl GstRc<SampleRef> {
|
||||
pub fn new(
|
||||
buffer: Option<Buffer>,
|
||||
caps: Option<Caps>,
|
||||
buffer: Option<&Buffer>,
|
||||
caps: Option<&Caps>,
|
||||
segment: Option<&Segment>,
|
||||
info: Option<&StructureRef>,
|
||||
) -> Self {
|
||||
|
|
|
@ -305,7 +305,7 @@ impl StructureRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set<T: ToSendValue>(&mut self, name: &str, value: T) {
|
||||
pub fn set<T: ToSendValue>(&mut self, name: &str, value: &T) {
|
||||
let value = value.to_send_value();
|
||||
self.set_value(name, value);
|
||||
}
|
||||
|
@ -608,7 +608,7 @@ impl Builder {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn field<V: ToSendValue>(mut self, name: &str, value: V) -> Self {
|
||||
pub fn field<V: ToSendValue>(mut self, name: &str, value: &V) -> Self {
|
||||
self.s.set(name, value);
|
||||
self
|
||||
}
|
||||
|
@ -629,9 +629,9 @@ mod tests {
|
|||
let mut s = Structure::new_empty("test");
|
||||
assert_eq!(s.get_name(), "test");
|
||||
|
||||
s.set("f1", "abc");
|
||||
s.set("f2", String::from("bcd"));
|
||||
s.set("f3", 123i32);
|
||||
s.set("f1", &"abc");
|
||||
s.set("f2", &String::from("bcd"));
|
||||
s.set("f3", &123i32);
|
||||
|
||||
assert_eq!(s.get::<&str>("f1").unwrap(), "abc");
|
||||
assert_eq!(s.get::<&str>("f2").unwrap(), "bcd");
|
||||
|
@ -657,9 +657,9 @@ mod tests {
|
|||
::init().unwrap();
|
||||
|
||||
let s = Structure::builder("test")
|
||||
.field("f1", "abc")
|
||||
.field("f2", String::from("bcd"))
|
||||
.field("f3", 123i32)
|
||||
.field("f1", &"abc")
|
||||
.field("f2", &String::from("bcd"))
|
||||
.field("f3", &123i32)
|
||||
.build();
|
||||
|
||||
assert_eq!(s.get_name(), "test");
|
||||
|
|
|
@ -255,7 +255,7 @@ impl Default for GstRc<TagListRef> {
|
|||
}
|
||||
|
||||
impl TagListRef {
|
||||
pub fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode)
|
||||
pub fn add<'a, T: Tag<'a>>(&mut self, value: &T::TagType, mode: TagMergeMode)
|
||||
where
|
||||
T::TagType: ToSendValue,
|
||||
{
|
||||
|
@ -442,8 +442,8 @@ mod tests {
|
|||
assert_eq!(tags.to_string(), "taglist;");
|
||||
{
|
||||
let tags = tags.get_mut().unwrap();
|
||||
tags.add::<Title>("some title".into(), TagMergeMode::Append);
|
||||
tags.add::<Duration>((1000u64 * 1000 * 1000 * 120).into(), TagMergeMode::Append);
|
||||
tags.add::<Title>(&"some title", TagMergeMode::Append);
|
||||
tags.add::<Duration>(&(1000u64 * 1000 * 1000 * 120).into(), TagMergeMode::Append);
|
||||
}
|
||||
assert_eq!(
|
||||
tags.to_string(),
|
||||
|
@ -459,8 +459,8 @@ mod tests {
|
|||
assert_eq!(tags.to_string(), "taglist;");
|
||||
{
|
||||
let tags = tags.get_mut().unwrap();
|
||||
tags.add::<Title>("some title".into(), TagMergeMode::Append);
|
||||
tags.add::<Duration>((1000u64 * 1000 * 1000 * 120).into(), TagMergeMode::Append);
|
||||
tags.add::<Title>(&"some title", TagMergeMode::Append);
|
||||
tags.add::<Duration>(&(1000u64 * 1000 * 1000 * 120).into(), TagMergeMode::Append);
|
||||
}
|
||||
|
||||
assert_eq!(tags.get::<Title>().unwrap().get(), Some("some title"));
|
||||
|
|
|
@ -80,7 +80,7 @@ impl TocRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn merge_tags(&mut self, tag_list: TagList, mode: TagMergeMode) {
|
||||
pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) {
|
||||
unsafe {
|
||||
ffi::gst_toc_merge_tags(self.as_mut_ptr(), tag_list.as_mut_ptr(), mode.to_glib());
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ impl TocEntryRef {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn merge_tags(&mut self, tag_list: TagList, mode: TagMergeMode) {
|
||||
pub fn merge_tags(&mut self, tag_list: &TagList, mode: TagMergeMode) {
|
||||
unsafe {
|
||||
ffi::gst_toc_entry_merge_tags(self.as_mut_ptr(), tag_list.as_mut_ptr(), mode.to_glib());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue