Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/opentake-agent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ opentake-domain = { workspace = true }
opentake-ops = { workspace = true }
opentake-core = { workspace = true }
opentake-gen = { workspace = true }
opentake-media = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_path_to_error = "0.1"
Expand Down
26 changes: 25 additions & 1 deletion crates/opentake-agent/src/mcp/core_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
use std::path::PathBuf;

use opentake_core::AppCore;
use opentake_domain::{MediaManifest, Timeline};
use opentake_domain::{MediaManifest, MediaResolver, Timeline};
use opentake_media::{extract_pcm, PcmBuffer, PcmSpec};
use opentake_ops::command::{EditCommand, EditResult};

/// The narrow document surface the dispatch shell needs. `Send + Sync` so a
Expand All @@ -32,6 +33,29 @@ pub trait CoreHandle: Send + Sync {

/// The open project's bundle directory, or `None` for an unsaved project.
fn project_dir(&self) -> Option<PathBuf>;

/// Resolve an asset id to the local file path that media analysis can read.
/// The default implementation mirrors `MediaResolver.expected_path`.
fn media_path(&self, media_ref: &str) -> Option<PathBuf> {
let manifest = self.media();
let project_dir = self.project_dir();
MediaResolver::new(&manifest, project_dir.as_deref()).expected_path(media_ref)
}

/// Decode a media asset's first audio track into the PCM format requested by
/// an analysis tool. Test handles can override this to inject synthetic PCM
/// without invoking ffmpeg.
fn extract_analysis_pcm(
&self,
media_ref: &str,
spec: PcmSpec,
range: Option<(f64, f64)>,
) -> anyhow::Result<PcmBuffer> {
let path = self
.media_path(media_ref)
.ok_or_else(|| anyhow::anyhow!("media path not found for mediaRef: {media_ref}"))?;
extract_pcm(&path, &spec, range).map_err(|e| anyhow::anyhow!("{e}"))
}
}

/// Production [`CoreHandle`] over the authoritative [`AppCore`]. A clone of the
Expand Down
Loading
Loading