{"_id":"@bun-win32/mfreadwrite","_rev":"3-cc6abdce2876a8d635bb2f404ad22ae6","name":"@bun-win32/mfreadwrite","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/mfreadwrite","version":"1.0.0","keywords":["bindings","bun","dll","ffi","media-foundation","mf","mfreadwrite","sink-writer","source-reader","typescript","win32","windows"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/mfreadwrite@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"d9d1c7f6bf3b0137f6a23b1dd6152cf7524379d2","tarball":"https://registry.npmjs.org/@bun-win32/mfreadwrite/-/mfreadwrite-1.0.0.tgz","fileCount":6,"integrity":"sha512-nDOpCAJrs6kmzheK2HpU0w0iGoMF6Dl8ORC6CijbDcHTZyvhfqsWpnMbcSQ/eBnLuHQFoYPfyjmr9zyhk/f5dw==","signatures":[{"sig":"MEYCIQDRxa91U3Cbb+QkKuPPvR7y5VrlDeJJa/Iy/9pIuRDMFQIhAIEOeCQnp0YOVwyvh2GrqD29Zb5yEjuqIeHGjctNko9r","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12559},"main":"./index.ts","type":"module","module":"index.ts","shasum":"d9d1c7f6bf3b0137f6a23b1dd6152cf7524379d2","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:media-library-dashboard":"bun ./example/media-library-dashboard.ts","example:mfreadwrite-factory-probe":"bun ./example/mfreadwrite-factory-probe.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-nDOpCAJrs6kmzheK2HpU0w0iGoMF6Dl8ORC6CijbDcHTZyvhfqsWpnMbcSQ/eBnLuHQFoYPfyjmr9zyhk/f5dw==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/mfreadwrite"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 Media Foundation source reader / sink writer factory bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mfreadwrite_1.0.0_1776867981898_0.04445095722367576","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/mfreadwrite","version":"2.0.0","keywords":["bindings","bun","dll","ffi","media-foundation","mf","mfreadwrite","sink-writer","source-reader","typescript","win32","windows"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/mfreadwrite@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"20abdf0b297a4d0b07f233a0c83025eef541a0db","tarball":"https://registry.npmjs.org/@bun-win32/mfreadwrite/-/mfreadwrite-2.0.0.tgz","fileCount":6,"integrity":"sha512-Zo2GEuRdZT1wOnch34HvUzirCQWe/4VW3T5zzSM1bJ7ql6tccUCRdFx8w8n62zAmEDTm5IeLfqUg3d3KrGXGjQ==","signatures":[{"sig":"MEYCIQDRSZ/6gp/BNlmgFIzdR54T8tUP61hpsp7kcCrXQ2uPnAIhAOwB1NwzSh+8CJcXfUTb/8BAZHIBvhdX8OoZQyAZoQLN","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13856},"main":"./index.ts","type":"module","module":"index.ts","shasum":"20abdf0b297a4d0b07f233a0c83025eef541a0db","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:media-library-dashboard":"bun ./example/media-library-dashboard.ts","example:mfreadwrite-factory-probe":"bun ./example/mfreadwrite-factory-probe.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-Zo2GEuRdZT1wOnch34HvUzirCQWe/4VW3T5zzSM1bJ7ql6tccUCRdFx8w8n62zAmEDTm5IeLfqUg3d3KrGXGjQ==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/mfreadwrite"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 Media Foundation source reader / sink writer factory bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/mfreadwrite_2.0.0_1782435469741_0.40391893267813517","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 Media Foundation source reader / sink writer factory bindings for Bun (FFI) on Windows.","devDependencies":{"@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/mfreadwrite","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/mfreadwrite"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bindings","bun","dll","ffi","media-foundation","mf","mfreadwrite","sink-writer","source-reader","typescript","win32","windows"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:media-library-dashboard":"bun ./example/media-library-dashboard.ts","example:mfreadwrite-factory-probe":"bun ./example/mfreadwrite-factory-probe.ts"},"_id":"@bun-win32/mfreadwrite@2.0.1","_integrity":"sha512-8J1RwvVZKsx4hTQWivU57MFrNguHHBOPbO8WLCAmv9KdfI2asyxidlYLM39uUE32zL2uMp9wiD+toBBgaUUHGw==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"2b0d3306fe6fb86290ba2050b12747b84b47cc7d","dist":{"integrity":"sha512-8J1RwvVZKsx4hTQWivU57MFrNguHHBOPbO8WLCAmv9KdfI2asyxidlYLM39uUE32zL2uMp9wiD+toBBgaUUHGw==","shasum":"2b0d3306fe6fb86290ba2050b12747b84b47cc7d","tarball":"https://registry.npmjs.org/@bun-win32/mfreadwrite/-/mfreadwrite-2.0.1.tgz","fileCount":6,"unpackedSize":13856,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEgCLAVV85LAFJf/LX6hgKDHEJOFoImNhnP1IsDOPgGHAiBaMhaz8Bsxalg433l18MqLx5R8lSVOZNqmvd/E0aMbdQ=="}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mfreadwrite_2.0.1_1782438126626_0.8032682824631143"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-22T14:26:21.738Z","modified":"2026-06-26T01:42:06.981Z","1.0.0":"2026-04-22T14:26:22.038Z","2.0.0":"2026-06-26T00:57:49.865Z","2.0.1":"2026-06-26T01:42:06.837Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bindings","bun","dll","ffi","media-foundation","mf","mfreadwrite","sink-writer","source-reader","typescript","win32","windows"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/mfreadwrite"},"description":"Zero-dependency, zero-overhead Win32 Media Foundation source reader / sink writer factory bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/mfreadwrite\r\n\r\nZero-dependency, zero-overhead Win32 Mfreadwrite bindings for [Bun](https://bun.sh) on Windows.\r\n\r\n## Overview\r\n\r\n`@bun-win32/mfreadwrite` exposes the documented `mfreadwrite.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Mfreadwrite`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\r\n\r\nThe package intentionally stays export-accurate: `mfreadwrite.dll` exports the `MFCreateSourceReader*` / `MFCreateSinkWriter*` factory entry points plus the COM server shims (`DllGetClassObject`, `DllCanUnloadNow`). It does not expose the `IMFSourceReader` / `IMFSinkWriter` vtables themselves. The runnable examples show how to call the factories and drive the returned COM objects through their vtables.\r\n\r\n## Features\r\n\r\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\r\n- Direct FFI to `mfreadwrite.dll` (Media Foundation source reader / sink writer factory entry points).\r\n- In-source docs in `structs/Mfreadwrite.ts` with links to Microsoft Learn.\r\n- Lazy binding on first call; optional eager preload (`Mfreadwrite.Preload()`).\r\n- No wrapper overhead; calls map 1:1 to native exports.\r\n- Strongly-typed COM pointer aliases for `IMFSourceReader`, `IMFSinkWriter`, `IMFByteStream`, and factory parameters (see `types/Mfreadwrite.ts`).\r\n\r\n## Requirements\r\n\r\n- [Bun](https://bun.sh) runtime\r\n- Windows 10 or later\r\n\r\n## Installation\r\n\r\n```sh\r\nbun add @bun-win32/mfreadwrite\r\n```\r\n\r\n## Quick Start\r\n\r\n```ts\r\nimport Mfreadwrite from '@bun-win32/mfreadwrite';\r\n\r\nMfreadwrite.Preload(['MFCreateSourceReaderFromURL']);\r\n\r\n// MF requires ole32!CoInitializeEx + mfplat!MFStartup before use.\r\nconst url = Buffer.from('C:\\\\Windows\\\\Media\\\\chimes.wav\\0', 'utf16le');\r\nconst readerOut = Buffer.alloc(8);\r\nconst hr = Mfreadwrite.MFCreateSourceReaderFromURL(url.ptr, null, readerOut.ptr);\r\nif (hr === 0) {\r\n  const reader = readerOut.readBigUInt64LE(0);\r\n  console.log(`IMFSourceReader @ 0x${reader.toString(16)}`);\r\n}\r\n```\r\n\r\n> [!NOTE]\r\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\r\n\r\n## Examples\r\n\r\nRun the included examples:\r\n\r\n```sh\r\nbun run example:media-library-dashboard\r\nbun run example:mfreadwrite-factory-probe\r\n```\r\n\r\n## Notes\r\n\r\n- Either rely on lazy binding or call `Mfreadwrite.Preload()`.\r\n- `mfreadwrite.dll` exports `DllCanUnloadNow`, `DllGetClassObject`, `MFCreateSinkWriterFromMediaSink`, `MFCreateSinkWriterFromURL`, `MFCreateSourceReaderFromByteStream`, `MFCreateSourceReaderFromMediaSource`, and `MFCreateSourceReaderFromURL`.\r\n- Media Foundation requires `ole32!CoInitializeEx` (STA or MTA) and `mfplat!MFStartup(MF_VERSION)` before the `MFCreate*` factories work. Pair them with `MFShutdown` + `CoUninitialize` on exit.\r\n- `CLSID_MFSourceReader` and `CLSID_MFSinkWriter` are documented CLSIDs but are **not** exposed as class factories by `mfreadwrite.dll`; `DllGetClassObject` returns `CLASS_E_CLASSNOTAVAILABLE` for both. Use the dedicated `MFCreate*` factories instead — `example/mfreadwrite-factory-probe.ts` demonstrates this behavior.\r\n- The returned `IMFSourceReader` / `IMFSinkWriter` objects are COM interfaces. Drive them through their vtable (see `example/media-library-dashboard.ts` for a `GetPresentationAttribute` / `Release` walkthrough).\r\n- Windows only. Bun runtime required.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}