How visioforge/mediafoundationnet works
Project type and purpose
• This is a .NET class-library project (MediaFoundationNet) whose sole purpose is to expose the Windows Media Foundation COM APIs to managed (.NET) clients. It consists of two Visual Studio projects:
• MediaFoundation-2010 (the core wrapper)
• MediaFoundation.Extension-2010 (extension methods and helper classes)
• The library sits between a .NET application and the native Media Foundation pipeline on Windows, allowing .NET code to instantiate COM objects, build media topologies, process streams, do capture, playback, etc.
File structure
• Top level
• README, Docs/, license files, solution (.sln) and project (.csproj)
• src/
• Core wrapper types (Alt.cs, Externs.cs, MFObjects.cs, MFPlay.cs, MFReadWrite.cs, MFTransform.cs, MFUtils.cs, OpmApi.cs, WMContainer.cs, etc.)
• feature-specific wrappers: e.g. mfmediaengine.cs, mfcaptureengine.cs, mfsharingengine.cs, mfmp2dlna.cs
• src/mfext/
• mfext/*.cs: hundreds of extension-method classes for every IMFXXX interface
• mfext/Interop/: the low-level COM interop helper classes (ComClass, GCPin, MemoryBuffer, RuntimeCallableStream, PropVariantExtensions, etc.)
• mfext/MFPlayer and mfext/Transform: higher-level managed helpers for players and transforms
• No frontend, no database—this is strictly a library.
Main components
1. .NET Client (any .NET application referencing the library)
2. MediaFoundationNet Core Assembly
– Wrappers for all MF COM interfaces (src/*.cs)
– Feature groups: CaptureEngine, MediaEngine, Container, MP2DLNA, SharingEngine
3. MediaFoundationNet Extension Assembly
– Extension methods (mfext/*.cs)
– COM interop helpers (mfext/Interop)
– High-level helpers (MFPlayer, MFT)
4. COM Interop Layer
– RCW/CCW plumbing created by .NET runtime
– Low-level COM calls into native DLLs
5. Native Media Foundation components
– MediaSources, MediaSinks, MediaTransforms, MediaSession, Topology
– Windows system DLLs (mf.dll, mfplat.dll, mfreadwrite.dll, dxvahd.dll, etc.)
Relationships and interactions
• The .NET Client calls methods on the Core Assembly’s interface classes (for example, IMFMediaSource, IMFTransform, IMFMediaSession).
• Core Assembly types defer to Extension methods and interop helpers for convenience or missing functionality.
• Both assemblies ultimately invoke COM calls (CoCreateInstance, QueryInterface, InvokeMethod) through the Interop layer.
• The COM layer dispatches into native Media Foundation DLLs, creating a pipeline: source → topology → transform → sink.
• Data flow: managed calls → wrappers → COM → native pipeline → back to managed callbacks or streams.
Architectural patterns and principles
• Wrapper/Adapter pattern: each COM interface gets a thin C# proxy class.
• Extension methods: augment interface classes without inheritance.
• Separation of concerns:
• Core interfaces vs. helpers/extensions vs. interop plumbing
• Feature modules (Capture, Playback, Transforms, DLNA, Sharing)
• COM interop boundary is explicit (Interop folder).
Technologies and frameworks
• .NET Framework / .NET Standard class libraries
• Visual Studio 2010 solution format
• C# 3.0+ extension methods
• Windows COM & Media Foundation native APIs