Add DV (MiniDV camcorder) capture: IR tap to .dv file, plus FCP quadlet-write response fix#28
Merged
Merged
Conversation
Short AV/C responses (e.g. the 4-byte ACCEPTED a camcorder sends for a tape transport command) arrive as quadlet writes (tCode 0x0) to the FCP response register, not block writes. FcpLocalHandler only claimed block writes, so these responses fell through and every short AV/C command timed out on the response path. Handle kTcodeWriteQuad by rebuilding wire byte order from the host-order quadlet value and routing through the same path as block writes. The handler still self-filters by destination offset, so non-FCP quadlet writes continue to fall through to DICE/SBP-2. Verified on hardware: tape subunit PLAY/STOP/WIND against a Panasonic MiniDV camcorder now complete with ACCEPTED instead of timing out. Co-authored-by: Cursor <cursoragent@cursor.com>
Adds a minimal DV capture tap to the IR receive path so MiniDV camcorder video can be captured to a raw .dv file: - DVCaptureSink (driver): hooks the existing per-packet callback in IsochReceiveContext::Poll(), filters CIP FMT=0x00, and writes raw 480-byte DIF chunks into a shared memory SPSC ring (~3.9MB, drop-on-full). Handles both SPH=0 streams (consumer camcorders, dv1394-style: timestamp in CIP.SYT, plain 480-byte blocks) and SPH=1 (per-block source packet header). - IsochService: StartDVCapture/StopDVCapture start IR on a given channel with no direct-audio binding source; the per-packet callback is installed before Start() to avoid racing Poll(). StartReceive gains an optional packet callback parameter (default unchanged). - User client: selectors 50/51 (start/stop DV capture) and CopyClientMemoryForType type 1 to map the DIF ring into the app. - App: new "DV Capture" view with AV/C tape transport controls (PLAY/STOP/REWIND via existing raw FCP path), channel selection (default 63), live stats (frames, drops, CIP diagnostics), and a frame-aware .dv writer that only emits exact-size frames so a glitched packet costs one frame instead of misaligning the file. Verified on hardware (Panasonic MiniDV over OHCI FireWire 400): 32s NTSC capture, 971/973 clean frames, output plays in QuickTime and remuxes losslessly with ffmpeg -c copy. (Validation was performed with this change set on main; re-validation on DICE pending.) Known limitations (intentionally minimal first pass): shares the single IR context with audio receive (mutually exclusive, guarded with kIOReturnBusy), no CMP connection management (listens on the broadcast channel), no DBC continuity tracking in the driver. Co-authored-by: Cursor <cursoragent@cursor.com>
d979b35 to
2fa9b10
Compare
Author
|
Rebased onto the DICE branch and retargeted the PR base accordingly (was main). The port adapts to the DICE architecture: the FCP fix now lives in |
Cross-checked the capture path against Apple's AVCVideoServices-42 DVReceiver/DVFramer (FireWire SDK 26 reference implementation): - Frame-start detection now uses Apple's masked comparison ((first two DIF bytes & 0xE0FC) == 0x0004, i.e. SCT=header and Dseq=0) instead of an exact 0x1F 0x07 0x00 match; the unmasked bits are reserved/arbitrary and vary between devices. - The sink rejects packets whose CIP.DBS is not 120 quadlets (SD-DVCR) rather than mis-slicing other DV variants (e.g. DVCPRO50) into 480-byte records, and validates the payload is a whole number of blocks (Apple checks expected packet size the same way). Apple's receiver also confirms the SPH=0 consumer-DV payload layout (plain DBS-sized DIF blocks after the CIP, no per-block source packet header) that the previous commit implemented empirically. Co-authored-by: Cursor <cursoragent@cursor.com>
Owner
|
Thanks a lot for contributing! Everything is nice and clean, I would take it as is. |
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.
Summary
Adds a minimal DV (IEC 61883-2) capture path so MiniDV camcorders can be dumped to playable raw
.dvfiles, validated end-to-end on real hardware (Panasonic MiniDV camcorder over OHCI FireWire 400 on macOS Tahoe). Also includes a standalone FCP bug fix found during testing.DV capture path
DVCaptureSink(new, header-only): hooks the existing per-packet callback, filters CIP FMT=0x00, and streams raw 480-byte DIF chunks into the shared ring (drop-on-full, never blocks the poll loop). Handles both SPH=0 streams (consumer camcorders, dv1394-style: timestamp in CIP.SYT, plain 480-byte blocks) and SPH=1 (per-block source packet header).IsochService::StartDVCapture/StopDVCapture: start the IR context on a chosen channel (default 63, camcorder broadcast) without requiring a published audio nub. The packet callback is installed beforeStart()so it never racesPoll().CopyClientMemoryForTypetype 1 for the ring..dvwriter that only emits exact-size frames — a glitched packet costs one dropped frame instead of misaligning the entire fixed-record DV file.The audio RX pipeline is deliberately untouched. DV capture and audio receive are mutually exclusive (guarded with
kIOReturnBusy) since both use IR context 0.Bug fix: FCP responses sent as quadlet writes were dropped
Short AV/C responses (e.g. the 4-byte
ACCEPTEDa camcorder returns for a transport command) arrive as quadlet writes (tCode 0x0) to the FCP response register, not block writes. The quadlet-write request handler only consulted SBP-2 and returnedAddressErrorfor everything else, silently dropping these responses — every short AV/C command timed out on the response path.The handler now falls through to
FCPResponseRouter, reconstructing wire byte order from the little-endian AR header quadlet. Happy to split this into its own PR if preferred.Hardware test results
ACCEPTED(timed out before the FCP fix)ffmpeg -c copyKnown limitations (intentionally minimal first pass)
If the in-progress IR refactor is introducing a pluggable packet sink,
DVCaptureSinkcan become an implementation of it — happy to adjust the integration shape.