Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Format, OrbbecError> {
self.inner.get_format().map_err(OrbbecError::from)
}
}

impl AsRef<OBStreamProfile> for VideoStreamProfile {
Expand Down
47 changes: 47 additions & 0 deletions src/sys/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,53 @@ impl OBStreamProfile {

Ok(OBCameraIntrinsic::from(intrinsics))
}

/// Get stream profile format
pub fn get_format(&self) -> Result<OBFormat, OBError> {
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<u32, OBError> {
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<u32, OBError> {
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<u32, OBError> {
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
Expand Down