mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
gstreamer: Manually implement StateChange::get_name on < v1_14
By setting the version to 1.8 and using `manual = true` an unconditional trait implementation calling get_name is generated, while the autogenerated version is omitted.
This commit is contained in:
parent
1b1a99b320
commit
01ae47c90c
2 changed files with 42 additions and 1 deletions
|
@ -43,7 +43,6 @@ generate = [
|
||||||
"Gst.SchedulingFlags",
|
"Gst.SchedulingFlags",
|
||||||
"Gst.SeekType",
|
"Gst.SeekType",
|
||||||
"Gst.State",
|
"Gst.State",
|
||||||
"Gst.StateChange",
|
|
||||||
"Gst.StreamError",
|
"Gst.StreamError",
|
||||||
"Gst.StreamStatusType",
|
"Gst.StreamStatusType",
|
||||||
"Gst.StreamType",
|
"Gst.StreamType",
|
||||||
|
@ -1631,6 +1630,16 @@ status = "generate"
|
||||||
# confusing return type
|
# confusing return type
|
||||||
ignore = true
|
ignore = true
|
||||||
|
|
||||||
|
[[object]]
|
||||||
|
name = "Gst.StateChange"
|
||||||
|
status = "generate"
|
||||||
|
[[object.function]]
|
||||||
|
name = "get_name"
|
||||||
|
# Manual function for < v1_14:
|
||||||
|
manual = true
|
||||||
|
# Always generate the trait, without version constraint:
|
||||||
|
version = "1.8"
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.StateChangeReturn"
|
name = "Gst.StateChangeReturn"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
|
|
|
@ -684,4 +684,36 @@ impl StateChange {
|
||||||
StateChange::__Unknown(value) => State::__Unknown(value & 0x7),
|
StateChange::__Unknown(value) => State::__Unknown(value & 0x7),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_name<'a>(self) -> &'a str {
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(feature = "v1_14")] {
|
||||||
|
// This implementation is autogenerated on 1.14 and up
|
||||||
|
use std::ffi::CStr;
|
||||||
|
unsafe {
|
||||||
|
CStr::from_ptr(
|
||||||
|
ffi::gst_state_change_get_name(self.to_glib())
|
||||||
|
.as_ref()
|
||||||
|
.expect("gst_state_change_get_name returned NULL"),
|
||||||
|
)
|
||||||
|
.to_str()
|
||||||
|
.expect("gst_state_change_get_name returned an invalid string")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match self {
|
||||||
|
Self::NullToReady => "NULL->READY",
|
||||||
|
Self::ReadyToPaused => "READY->PAUSED",
|
||||||
|
Self::PausedToPlaying => "PAUSED->PLAYING",
|
||||||
|
Self::PlayingToPaused => "PLAYING->PAUSED",
|
||||||
|
Self::PausedToReady => "PAUSED->READY",
|
||||||
|
Self::ReadyToNull => "READY->NULL",
|
||||||
|
Self::NullToNull => "NULL->NULL",
|
||||||
|
Self::ReadyToReady => "READY->READY",
|
||||||
|
Self::PausedToPaused => "PAUSED->PAUSED",
|
||||||
|
Self::PlayingToPlaying => "PLAYING->PLAYING",
|
||||||
|
_ => "Unknown state return",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue