Skip to content

Commit fc5798e

Browse files
Copilotvsem-azamat
andcommitted
Address code review feedback for vdo crate
Co-authored-by: vsem-azamat <[email protected]>
1 parent 78b975a commit fc5798e

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ Each crate has a corresponding `*-sys`, which is omitted for brevity.
156156
- Status: ⚠️ Alpha
157157
- Documentation: [Source code](crates/mdb/src/lib.rs)
158158
- `vdo`: Bindings for the Video Capture API.
159-
- Status: 💡 Started
160-
- Documentation: [Pull request](https://github.com/AxisCommunications/acap-rs/pull/153)
159+
- Status: ⚠️ Alpha
160+
- Documentation: [Source code](crates/vdo/src/lib.rs)
161161

162162
### VAPIX API bindings
163163

crates/vdo/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ description = "Safe Rust bindings for the Axis VDO (Video Capture) API"
77

88
[dependencies]
99
log = { workspace = true }
10-
thiserror = { workspace = true }
1110
vdo-sys = { workspace = true }
1211
glib-sys = { workspace = true }
1312
gobject-sys = { workspace = true }

crates/vdo/src/format.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ impl Format {
4848
}
4949
}
5050

51+
/// Returns the format as a 32-bit integer value.
52+
pub(crate) fn as_i32(self) -> i32 {
53+
self.to_raw().0
54+
}
55+
5156
/// Converts from the raw VDO format type.
5257
#[allow(dead_code)]
5358
pub(crate) fn from_raw(raw: RawVdoFormat) -> Option<Self> {

crates/vdo/src/stream.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use std::ptr;
66

77
use glib_sys::GError;
8+
use log::warn;
89
use vdo_sys::VdoStream as RawVdoStream;
910

1011
use crate::buffer::{Buffer, StandaloneBuffer};
@@ -228,43 +229,57 @@ impl StreamSettings {
228229

229230
/// Sets the video format.
230231
pub fn format(mut self, format: Format) -> Self {
231-
let _ = self.map.set_uint32("format", format.to_raw().0 as u32);
232+
if let Err(e) = self.map.set_int32("format", format.as_i32()) {
233+
warn!("Failed to set format: {}", e);
234+
}
232235
self
233236
}
234237

235238
/// Sets the video width in pixels.
236239
pub fn width(mut self, width: u32) -> Self {
237-
let _ = self.map.set_uint32("width", width);
240+
if let Err(e) = self.map.set_uint32("width", width) {
241+
warn!("Failed to set width: {}", e);
242+
}
238243
self
239244
}
240245

241246
/// Sets the video height in pixels.
242247
pub fn height(mut self, height: u32) -> Self {
243-
let _ = self.map.set_uint32("height", height);
248+
if let Err(e) = self.map.set_uint32("height", height) {
249+
warn!("Failed to set height: {}", e);
250+
}
244251
self
245252
}
246253

247254
/// Sets the framerate in frames per second.
248255
pub fn framerate(mut self, fps: f64) -> Self {
249-
let _ = self.map.set_double("framerate", fps);
256+
if let Err(e) = self.map.set_double("framerate", fps) {
257+
warn!("Failed to set framerate: {}", e);
258+
}
250259
self
251260
}
252261

253262
/// Sets the buffer count for the stream.
254263
pub fn buffer_count(mut self, count: u32) -> Self {
255-
let _ = self.map.set_uint32("buffer.count", count);
264+
if let Err(e) = self.map.set_uint32("buffer.count", count) {
265+
warn!("Failed to set buffer count: {}", e);
266+
}
256267
self
257268
}
258269

259270
/// Sets a custom setting.
260271
pub fn set(mut self, key: &str, value: u32) -> Self {
261-
let _ = self.map.set_uint32(key, value);
272+
if let Err(e) = self.map.set_uint32(key, value) {
273+
warn!("Failed to set {}: {}", key, e);
274+
}
262275
self
263276
}
264277

265278
/// Sets a custom string setting.
266279
pub fn set_string(mut self, key: &str, value: &str) -> Self {
267-
let _ = self.map.set_string(key, value);
280+
if let Err(e) = self.map.set_string(key, value) {
281+
warn!("Failed to set {}: {}", key, e);
282+
}
268283
self
269284
}
270285

0 commit comments

Comments
 (0)