Repository navigation
feat(video): port the video event source, legacy-free - #583
Merged
Merged
Conversation
@dcmjs-org/parser joins the dependencies — the video event source imports fromDataSet and EVENT_STREAM_VOCABULARY — and @dcmjs-org/generator the devDependencies (StreamingPart10Writer, tests only). Deliberately NOT @dcmjs-org/legacy: this package stays off the legacy surface. Co-Authored-By: Claude Fable 5 <[email protected]>
createVideoEventSource — MP4 → contract events with the Supplement 225
dataset shell replayed first and the stream emitted as encapsulated
PixelData fragments, one in memory at a time, backpressure between
fragments via awaitDrain().
The run loop, exactFragment, withoutEndDataSet and sortDict are verbatim
from v2.0-development src/eventStream/fromVideo.js. One seam is reworked
and hand-written: v2 imported datasetToDict from what is now
@dcmjs-org/legacy, which this package must not depend on, so a local
datasetToMetaDict helper mints the same file meta group (element list and
implementation UID copied from legacy's datasetToDict) and denaturalizes
both halves via core's DicomMetaDictionary — returning the plain
{ meta, dict } shape, which is all parser's fromDataSet reads.
The suite is the v2 fromVideo suite reworked off the DicomEventStream
facade (media wave): the source drives StreamingPart10Writer directly
and reads back through fromPart10/fromPart10Stream + NaturalizedListener
+ extractEncapsulatedVideo. All load-bearing assertions carried over:
byte-identical round trips (buffered and streaming reader), the
(7FE0,0003) UV uint64 pinned on the wire, the Sup 225 fragment layout,
single-endDataSet ordering, per-fragment backpressure, and the ffmpeg
corrective error. The facade-specific toVideo/fromPdf case stays with
the media wave, as does fromImage.test.js.
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This ports the video event source — the last slice of the package — reworked at one seam to keep
@dcmjs-org/videooff the legacy package.createVideoEventSourceis MP4 → event stream: the Supplement 225 dataset shell is built eagerly (stable UIDs across re-runs), and running the stream replays the shell throughfromDataSet, then emits the MP4 as encapsulated PixelData fragments read one at a time from a random-access reader — so a 21.8 GB file streams with at most one fragment in memory, and the same code path serves in-memory bytes. The natural sink isStreamingPart10Writer, with backpressure honored between fragments viaawaitDrain().On provenance, this one needs more words than the earlier ports. The core of
fromVideo.js—exactFragment,withoutEndDataSet,sortDict, and therunloop — is verbatim from v2. But v2's file importeddatasetToDictfrom what is now@dcmjs-org/legacy, and this package must not depend on legacy (core/parser/generator are the allowed engine deps). So I replaced that one import with a local ~25-linedatasetToMetaDicthelper: it mints the file meta group from the dataset identity exactly the way legacy'sdatasetToDictdoes (same element list, same implementation UID, copied from that function) and denaturalizes both halves withDicomMetaDictionary.denaturalizeDatasetfrom core — but returns a plain{ meta, dict }instead of aDicomDict. That's allfromDataSetactually consumes (it reads only.metaand.dict; nothing in this path writes bytes through the wrapper), which I verified against the parser source before relying on it.The test suite is the v2
fromVideosuite reworked off theDicomEventStreamfacade, since the facade factories belong to the media wave: where v2 calledDicomEventStream.fromVideo(...).toPart10()and.toVideo(), this suite drivescreateVideoEventSourceintoStreamingPart10Writerdirectly and reads back through the parser'sfromPart10/fromPart10StreamintoNaturalizedListener, then extracts withextractEncapsulatedVideo. All the load-bearing assertions carried over intact: the byte-identical round trip over an odd-length stream, the streaming-reader round trip, the (7FE0,0003) UV uint64 pinned byte-for-byte on the wire, the Sup 225 fragment layout (empty Basic Offset Table, even-padded items, sequence delimiter), the single-endDataSet ordering, the per-fragment backpressure checkpoint, and the ffmpeg-corrective rejection of unsupported codecs. Two v2 tests deliberately did not come along: thetoVideo-rejects-a-PDF-stream case (it tests the facade andfromPdf, both media-wave; the underlyingextractEncapsulatedVideorejection is already covered in the encapsulation suite), andfromImage.test.jsas a whole (a facade-factory suite — media wave).Two honest gaps for the record. First, every MP4 in this package is synthesized by
makeTinyMp4— structurally valid ISO BMFF with a real video trak, but no real-world encoder output exercises the parser yet. That's a known gap; it should become a DATACITATION row when a suitable real fixture is sourced. Second, the 12-bit BitsAllocated question raised in #576 is still open and still deliberately unanswered in code.Fifty-seven tests in the package across five suites, all green.
@dcmjs-org/parserjoins the dependencies (the source importsfromDataSetandEVENT_STREAM_VOCABULARY) and@dcmjs-org/generatorthe devDependencies (tests only).🤖 Generated with Claude Code