Single-lib cleanup: the per-crate src/bridge/ and src/ffi.rs layers are gone (oakundo/oakcommon/oaknode/oaktimeline/oakcodec/oakaudio/ oakrender/oaktask/oakplugin/oakstorage); cross-crate calls are plain Rust, CHandle marshalling shrinks to the oakengine boundary, and tests call the Rust APIs directly (pure C-ABI wrapper tests removed where the domain layer already covers the behavior). exporter.h family implemented: oakengine_export_render (CLI contract), oakengine_export_render_with_params (was a stub), last_error and progress callback; synchronous path reuses task_create_export + start_sync. Fixes on the way: oaktask video ticket self-deadlock, audio params dropped on the export path, codec encoder AAC slicing and H.264 time base. Real-mp4 tests cover both entry points, progress and the illegal-argument matrix. Also: oakstorage session maps null project handles to None (version- info path), configstore test double literal 3.14 -> 3.15 (clippy PI lint), oakaudio output callback scratch buffer + env-aware P1 test, cli media round-trip test uses a generated 16-frame clip (no more minute-long debug runs).
88 lines
3.2 KiB
Rust
88 lines
3.2 KiB
Rust
// Oak Video Editor - Non-Linear Video Editor
|
|
// Copyright (C) 2026 Oak Team
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! oakcommon helpers (config, file functions) — direct Rust calls into
|
|
//! the oakcommon crate (single-lib unification; the former
|
|
//! `bridge/common.rs`). The configuration-location and disk-cache
|
|
//! helpers delegate to oakcommon's own implementation.
|
|
|
|
use std::sync::Mutex;
|
|
|
|
/// Read a config string via the domain store
|
|
/// (`ConfigStore::get(group, key)`); `None` when missing or empty.
|
|
pub fn config_get_string(group: Option<&str>, key: &str) -> Option<String> {
|
|
oakcommon::configstore::ConfigStore::instance()
|
|
.get(group, key)
|
|
.ok()
|
|
.filter(|s| !s.is_empty())
|
|
}
|
|
|
|
/// `oakcommon_config_get_int(group, key, default)`.
|
|
pub fn config_get_int(group: Option<&str>, key: &str, default: i32) -> i32 {
|
|
oakcommon::configstore::ConfigStore::instance().get_int(group, key, default)
|
|
}
|
|
|
|
/// The configuration directory — oakcommon's implementation
|
|
/// (`FileFunctions::get_configuration_location`, honoring `OAK_CONFIG_DIR`
|
|
/// and the platform fallbacks).
|
|
pub fn configuration_location() -> String {
|
|
oakcommon::filefunctions::FileFunctions::new()
|
|
.get_configuration_location()
|
|
.unwrap_or_default()
|
|
}
|
|
|
|
/// Serializes tests that mutate `OAK_CONFIG_DIR` / `OAK_RENDER_BACKEND`
|
|
/// (env is process-global; the manager tests share this lock too).
|
|
pub static ENV_TEST_LOCK: Mutex<()> = Mutex::new(());
|
|
|
|
/// The default disk cache directory (C++ `DiskManager::
|
|
/// get_default_disk_cache_path`): `<configuration_location>/mediacache`.
|
|
pub fn default_disk_cache_path() -> String {
|
|
oakcommon::filefunctions::default_disk_cache_path()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn config_missing_key_falls_back() {
|
|
// The real config store is empty under cargo test: defaults apply.
|
|
assert_eq!(config_get_int(None, "GraphicsBackend", 7), 7);
|
|
assert_eq!(config_get_string(None, "missing"), None);
|
|
}
|
|
|
|
#[test]
|
|
fn configuration_location_uses_env_override() {
|
|
let _guard = ENV_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
|
|
let dir = std::env::temp_dir().join("oakrender-config-test");
|
|
std::env::set_var("OAK_CONFIG_DIR", &dir);
|
|
let loc = configuration_location();
|
|
assert_eq!(loc, dir.to_string_lossy());
|
|
std::env::remove_var("OAK_CONFIG_DIR");
|
|
}
|
|
|
|
#[test]
|
|
fn default_disk_cache_path_is_under_config() {
|
|
let _guard = ENV_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
|
|
let dir = std::env::temp_dir().join("oakrender-cache-test");
|
|
std::env::set_var("OAK_CONFIG_DIR", &dir);
|
|
let p = default_disk_cache_path();
|
|
assert!(p.ends_with("/mediacache") || p.ends_with("\\mediacache"));
|
|
std::env::remove_var("OAK_CONFIG_DIR");
|
|
}
|
|
}
|