Skip to content

Commit 1f01fe6

Browse files
committed
fix(rust): Resolve critical build and API issues
- Fix CMakeLists.txt circular dependency (remove ccap <- ccap-rust dep) - Add Windows Media Foundation libraries for video playback support - Fix error type in set_new_frame_callback (use InvalidParameter) - Document global error callback memory management behavior Fixes: - Windows build failures in CI - Circular dependency preventing CMake configuration - Incorrect error type returned from callback registration
1 parent b7b2140 commit 1f01fe6

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,8 @@ if (CCAP_BUILD_RUST)
400400
COMMENT "Testing Rust bindings"
401401
DEPENDS ccap-rust
402402
)
403-
# Add to main build if requested
404-
if (CCAP_IS_ROOT_PROJECT)
405-
add_dependencies(ccap ccap-rust)
406-
endif ()
403+
# Rust bindings are optional, do not add to main build automatically
404+
# Users can explicitly build with: cmake --build . --target ccap-rust
407405
message(STATUS "ccap: Rust bindings targets added:")
408406
message(STATUS " ccap-rust: Build Rust bindings")
409407
message(STATUS " ccap-rust-test: Test Rust bindings")

bindings/rust/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ fn main() {
165165
println!("cargo:rustc-link-lib=strmiids");
166166
println!("cargo:rustc-link-lib=ole32");
167167
println!("cargo:rustc-link-lib=oleaut32");
168+
// Media Foundation libraries for video file playback
169+
println!("cargo:rustc-link-lib=mfplat");
170+
println!("cargo:rustc-link-lib=mfreadwrite");
171+
println!("cargo:rustc-link-lib=mfuuid");
168172
}
169173

170174
// Tell cargo to invalidate the built crate whenever the wrapper changes

bindings/rust/src/provider.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ impl Provider {
328328
}
329329

330330
/// Set error callback for camera errors
331+
///
332+
/// # Memory Safety
333+
///
334+
/// This is a **global** callback that persists for the lifetime of the program.
335+
/// The callback memory is intentionally leaked as it's meant to be set once
336+
/// and used throughout the application lifetime.
337+
///
338+
/// If you need to change or remove the callback, consider using instance-level
339+
/// callbacks via `set_new_frame_callback` instead.
331340
pub fn set_error_callback<F>(callback: F)
332341
where
333342
F: Fn(i32, &str) + Send + Sync + 'static,
@@ -444,7 +453,7 @@ impl Provider {
444453
unsafe {
445454
let _ = Box::from_raw(callback_ptr);
446455
}
447-
Err(CcapError::CaptureStartFailed)
456+
Err(CcapError::InvalidParameter("Failed to set frame callback".to_string()))
448457
}
449458
}
450459

0 commit comments

Comments
 (0)