diff --git a/src/stream.rs b/src/stream.rs index 9ca185c..f67a0b1 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -59,6 +59,35 @@ impl VideoStreamProfile { .map(|intrinsic| intrinsic.into()) .map_err(OrbbecError::from) } + + /// Get the width of this video stream profile in pixels + pub fn width(&self) -> u32 { + self.inner + .get_video_width() + .map_err(OrbbecError::from) + .unwrap() + } + + /// Get the height of this video stream profile in pixels + pub fn height(&self) -> u32 { + self.inner + .get_video_height() + .map_err(OrbbecError::from) + .unwrap() + } + + /// Get the frame rate of this video stream profile + pub fn fps(&self) -> u32 { + self.inner + .get_video_fps() + .map_err(OrbbecError::from) + .unwrap() + } + + /// Get the pixel format of this stream profile + pub fn format(&self) -> Result { + self.inner.get_format().map_err(OrbbecError::from) + } } impl AsRef for VideoStreamProfile { diff --git a/src/sys/stream.rs b/src/sys/stream.rs index 69651c3..8dcd0e1 100644 --- a/src/sys/stream.rs +++ b/src/sys/stream.rs @@ -72,6 +72,53 @@ impl OBStreamProfile { Ok(OBCameraIntrinsic::from(intrinsics)) } + + /// Get stream profile format + pub fn get_format(&self) -> Result { + let mut err_ptr = std::ptr::null_mut(); + + let format = unsafe { orb::ob_stream_profile_get_format(self.inner, &mut err_ptr) }; + + OBError::consume(err_ptr)?; + + Ok(format.into()) + } + + /// Get the frame rate of the video stream. + /// Returns error if the profile is not a video stream profile. + pub fn get_video_fps(&self) -> Result { + let mut err_ptr = std::ptr::null_mut(); + + let fps = unsafe { orb::ob_video_stream_profile_get_fps(self.inner, &mut err_ptr) }; + + OBError::consume(err_ptr)?; + + Ok(fps) + } + + /// Get the width of the video stream. + /// Returns error if the profile is not a video stream profile. + pub fn get_video_width(&self) -> Result { + let mut err_ptr = std::ptr::null_mut(); + + let width = unsafe { orb::ob_video_stream_profile_get_width(self.inner, &mut err_ptr) }; + + OBError::consume(err_ptr)?; + + Ok(width) + } + + /// Get the height of the video stream. + /// Returns error if the profile is not a video stream profile. + pub fn get_video_height(&self) -> Result { + let mut err_ptr = std::ptr::null_mut(); + + let height = unsafe { orb::ob_video_stream_profile_get_height(self.inner, &mut err_ptr) }; + + OBError::consume(err_ptr)?; + + Ok(height) + } } /// List of video stream profiles