mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 03:21:03 +00:00
Gracefully return None in Caps::get_structure() if the index is too high
This commit is contained in:
parent
332ab9690f
commit
3f8a087fd4
1 changed files with 8 additions and 0 deletions
|
@ -128,6 +128,10 @@ impl CapsRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_structure(&self, idx: u32) -> Option<&StructureRef> {
|
pub fn get_structure(&self, idx: u32) -> Option<&StructureRef> {
|
||||||
|
if idx >= self.get_size() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let structure = ffi::gst_caps_get_structure(self.as_ptr(), idx);
|
let structure = ffi::gst_caps_get_structure(self.as_ptr(), idx);
|
||||||
if structure.is_null() {
|
if structure.is_null() {
|
||||||
|
@ -141,6 +145,10 @@ impl CapsRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mut_structure(&mut self, idx: u32) -> Option<&mut StructureRef> {
|
pub fn get_mut_structure(&mut self, idx: u32) -> Option<&mut StructureRef> {
|
||||||
|
if idx >= self.get_size() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let structure = ffi::gst_caps_get_structure(self.as_ptr(), idx);
|
let structure = ffi::gst_caps_get_structure(self.as_ptr(), idx);
|
||||||
if structure.is_null() {
|
if structure.is_null() {
|
||||||
|
|
Loading…
Reference in a new issue