Story 4.2: Implement full AV replacement with WebRTC stream access

- Update FoundryAdapter to properly detect and expose WebRTC stream access
- Modify ScryingPoolStrip to create video elements with WebRTC streams
- Add video container to roster-strip.hbs template with conditional rendering
- Add CSS to hide Foundry's AV dock (#av and .camera-view)
- Add CSS styling for video containers and elements
- Fix unused variable in FoundryAdapter.buildWebRTCSurface
- Add comprehensive test script for stream access implementation

Architecture: Full replacement mode where module hides Foundry's AV dock
and creates its own video elements using game.webrtc.client.getMediaStreamForUser()

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-05-24 09:12:06 +02:00
parent 20d13fc678
commit c4a375f4e3
7 changed files with 479 additions and 33 deletions
+21 -8
View File
@@ -57,15 +57,17 @@ let directorsBoardButtonAdded = false;
Hooks.once("init", () => {
console.log("[ScryingPool] init — module loading");
// OQ-1 resolved (Story 1.2 spike): probe result is 'css-fallback' — see FoundryAdapter.js
// WebRTC mode setting — determines how the module handles AV integration
// Updated for FULL REPLACEMENT architecture (hiding Foundry's dock, showing our own)
game.settings.register("scrying-pool", "webrtcMode", {
scope: "world",
config: false,
type: String,
default: "css-fallback",
default: "stream-access",
choices: {
"track-disable": "Track Disable (bandwidth-saving)",
"css-fallback": "CSS Fallback (cosmetic hiding)",
"stream-access": "Stream Access (full replacement - hide Foundry dock, show VVM dock with actual video)",
"track-disable": "Track Disable (bandwidth-saving) - DEPRECATED",
"css-fallback": "CSS Fallback (cosmetic hiding) - DEPRECATED",
"unsupported": "Unsupported (AV not available)",
},
});
@@ -175,14 +177,25 @@ Hooks.once("ready", () => {
// Hydrate StateStore from persisted world setting (AC-6, AC-7)
stateStore.init();
// Probe WebRTC capability and set adapter.webrtc (AC-8)
// Probe WebRTC capability and set adapter.webrtc
// For FULL REPLACEMENT: we need stream access to create our own video tiles
const outcome = FoundryAdapter.probeCapability(game.webrtc);
adapter.webrtc = outcome === 'track-disable'
? FoundryAdapter.buildWebRTCSurface(game.webrtc)
: null;
adapter.settings.set(FoundryAdapter.SETTING_WEBRTC_MODE, outcome).catch(err => {
console.error('[ScryingPool] Failed to set webrtcMode setting:', err);
});
// Build WebRTC surface for stream access (full replacement mode)
if (outcome === 'stream-access') {
adapter.webrtc = FoundryAdapter.buildWebRTCSurface(game.webrtc);
console.log('[ScryingPool] WebRTC stream access available - full replacement mode enabled');
} else if (outcome === 'unsupported') {
adapter.webrtc = null;
console.log('[ScryingPool] WebRTC not available - AV features disabled');
} else {
// Legacy: track-disable or css-fallback (deprecated)
adapter.webrtc = FoundryAdapter.buildWebRTCSurface(game.webrtc);
console.warn('[ScryingPool] WebRTC mode is deprecated:', outcome, '- consider using stream-access');
}
// Wire core managers — construct both before setReady so handler can reference both
visibilityManager = new VisibilityManager(stateStore, adapter);