net10.0
Media contracts for Koan: models, transforms, tasks, and events.
Published
May 16, 2026
5mo ago
Total Downloads
3.8K
3,833
Install
dotnet add package Sylin.Koan.Media.Abstractions --version 0.8.0
| Product | Versions |
|---|---|
| .NET |
README
Koan.Media.Abstractions
Contract
- Purpose: Define media contracts, transforms, and task models shared across Koan media pipelines.
- Primary inputs:
MediaAsset,MediaVariant, and pipeline task definitions consumed by storage and web modules. - Outputs: Serializable DTOs for persistence, events emitted through messaging adapters, and helper extensions for variant resolution.
- Failure modes: Unregistered media tasks, missing variant identifiers, or incompatible serialization when persisting custom metadata.
- Success criteria: Media modules share a consistent shape, variant naming stays predictable, and downstream services can compose media tasks without duplication.
Quick start
using Koan.Media.Abstractions;
public static class MediaVariants
{
public static MediaVariant HdMp4(string assetId) => new()
{
VariantId = "video:hd",
SourceAssetId = assetId,
ContentType = "video/mp4",
Transforms = { MediaTransform.For("encode", new { profile = "h264_hd" }) }
};
}
public async Task<MediaAsset> CreateMediaAsync(string title)
{
var asset = new MediaAsset
{
Title = title,
Variants = { MediaVariants.HdMp4(Guid.NewGuid().ToString()) }
};
return await MediaAssetExtensions.ValidateAsync(asset);
}
- Use the core models to describe variants and transforms; downstream modules (storage, web) will respect the shared schema.
- Leverage helper extensions for validation and canonical naming.
Configuration
- Pair with
Koan.Storageproviders to persist media assets. - Register default variants in your module’s auto-registrar to keep variant IDs consistent across environments.
- Use
MediaTaskdescriptors to configure pipeline workers (encoding, thumbnailing, etc.).
Edge cases
- Unsupported content types: provide fallback transforms or mark variants as optional to avoid failing the entire asset.
- Large metadata payloads: ensure custom metadata remains serializable through Koan storage adapters.
- Concurrent updates: apply optimistic concurrency using the asset’s version fields.
- Cross-service access: share variant IDs as constants to avoid drift between producers and consumers.
Related packages
Koan.Media.Core– runtime orchestration consuming these abstractions.Koan.Media.Web– HTTP APIs that rely on the contracts defined here.Koan.Storage– storage routing used for persisting assets.
Reference
MediaAsset– root entity describing media items.MediaVariant– variant metadata structure.MediaTask– pipeline work item descriptor.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Compatibility metadata lists 1 target framework; confirm the exact target used by your application.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.