From d83faa044efccc141007194796c7bc6abce54645 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 5 May 2022 14:36:43 +0200 Subject: [PATCH] rtp_buffer: buffer() does not need to return an Option When a RTP buffer is mapped, its buffer field always holds a non-null pointer. --- gstreamer-rtp/src/rtp_buffer.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gstreamer-rtp/src/rtp_buffer.rs b/gstreamer-rtp/src/rtp_buffer.rs index b67759ac8..982bde40b 100644 --- a/gstreamer-rtp/src/rtp_buffer.rs +++ b/gstreamer-rtp/src/rtp_buffer.rs @@ -315,15 +315,13 @@ impl<'a, T> RTPBuffer<'a, T> { } } - pub fn buffer(&self) -> Option<&gst::BufferRef> { + pub fn buffer(&self) -> &gst::BufferRef { unsafe { let ptr = self.rtp_buffer.buffer; - if ptr.is_null() { - None - } else { - Some(gst::BufferRef::from_ptr(ptr)) - } + assert!(!ptr.is_null()); + + gst::BufferRef::from_ptr(ptr) } }