@webex/plugin-meetings 3.13.0-next.12 → 3.13.0-next.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/.repo-context.json +577 -0
  2. package/.sdd/manifest.json +1320 -428
  3. package/AGENTS.md +528 -72
  4. package/dist/aiEnableRequest/index.js +1 -1
  5. package/dist/breakouts/breakout.js +1 -1
  6. package/dist/breakouts/index.js +1 -1
  7. package/dist/config.js +1 -1
  8. package/dist/interpretation/index.js +1 -1
  9. package/dist/interpretation/siLanguage.js +1 -1
  10. package/dist/webinar/index.js +1 -1
  11. package/docs/adr/0001-migrate-existing-docs-into-sdd.md +141 -0
  12. package/docs/adr/index.md +26 -0
  13. package/docs/architecture.md +816 -0
  14. package/docs/getting-started.md +177 -0
  15. package/docs/index.md +53 -0
  16. package/docs/specs/README.md +126 -0
  17. package/package.json +21 -21
  18. package/schemas/repo-context.schema.json +796 -0
  19. package/src/aiEnableRequest/docs/README.md +376 -0
  20. package/src/annotation/docs/README.md +402 -0
  21. package/src/breakouts/docs/README.md +643 -0
  22. package/src/controls-options-manager/docs/README.md +365 -0
  23. package/src/hashTree/docs/README.md +566 -0
  24. package/src/interceptors/docs/README.md +434 -0
  25. package/src/interpretation/docs/README.md +420 -0
  26. package/src/locus-info/docs/README.md +609 -0
  27. package/src/media/docs/README.md +488 -0
  28. package/src/meeting/docs/README.md +834 -0
  29. package/src/meeting-info/docs/README.md +352 -0
  30. package/src/meetings/docs/README.md +549 -0
  31. package/src/member/docs/README.md +347 -0
  32. package/src/members/docs/README.md +514 -0
  33. package/src/metrics/docs/README.md +287 -0
  34. package/src/multistream/docs/README.md +523 -0
  35. package/src/personal-meeting-room/docs/README.md +322 -0
  36. package/src/reachability/docs/README.md +548 -0
  37. package/src/reactions/docs/README.md +296 -0
  38. package/src/reconnection-manager/docs/README.md +485 -0
  39. package/src/recording-controller/docs/README.md +335 -0
  40. package/src/roap/docs/README.md +444 -0
  41. package/src/webinar/docs/README.md +425 -0
  42. package/.sdd/templates/.source.json +0 -30
  43. package/.sdd/templates/component-repo/module-docs/module-spec-quality.md +0 -111
  44. package/.sdd/templates/component-repo/module-docs/module-spec.template.md +0 -321
  45. package/.sdd/templates/component-repo/reference-docs/adr/_adr-example.md +0 -59
  46. package/.sdd/templates/component-repo/reference-docs/patterns/_pattern-example.md +0 -49
  47. package/.sdd/templates/component-repo/reference-docs/rules/_rule-example.md +0 -42
  48. package/.sdd/templates/component-repo/standing-docs/AGENTS.template.md +0 -120
  49. package/.sdd/templates/component-repo/standing-docs/ARCHITECTURE.template.md +0 -206
  50. package/.sdd/templates/component-repo/standing-docs/CONTRACTS.template.md +0 -90
  51. package/.sdd/templates/component-repo/standing-docs/DATA_MODEL.template.md +0 -68
  52. package/.sdd/templates/component-repo/standing-docs/GETTING_STARTED.template.md +0 -111
  53. package/.sdd/templates/component-repo/standing-docs/GLOSSARY.template.md +0 -57
  54. package/.sdd/templates/component-repo/standing-docs/REVIEW_CHECKLIST.template.md +0 -69
  55. package/.sdd/templates/component-repo/standing-docs/RULES.template.md +0 -96
  56. package/.sdd/templates/component-repo/standing-docs/SECURITY.template.md +0 -84
  57. package/.sdd/templates/component-repo/standing-docs/SERVICE_STATE.template.md +0 -82
  58. package/.sdd/templates/component-repo/standing-docs/SPEC_INDEX.template.md +0 -94
  59. package/.sdd/templates/component-repo/standing-docs/TEST_INDEX.template.md +0 -64
  60. package/.sdd/templates/component-repo/template-map.json +0 -112
  61. package/ai-docs/ARCHITECTURE.md +0 -208
  62. package/ai-docs/CONTRACTS.md +0 -267
  63. package/ai-docs/DATA_MODEL.md +0 -64
  64. package/ai-docs/GETTING_STARTED.md +0 -73
  65. package/ai-docs/GLOSSARY.md +0 -56
  66. package/ai-docs/REVIEW_CHECKLIST.md +0 -45
  67. package/ai-docs/RULES.md +0 -79
  68. package/ai-docs/SECURITY.md +0 -74
  69. package/ai-docs/SERVICE_STATE.md +0 -59
  70. package/ai-docs/SPEC_INDEX.md +0 -85
  71. package/ai-docs/TEST_INDEX.md +0 -45
  72. package/ai-docs/adr/0001-migrate-existing-docs-into-sdd.md +0 -61
  73. package/ai-docs/patterns/defensive-error-propagation.md +0 -55
  74. package/ai-docs/patterns/event-scope-emission.md +0 -46
  75. package/ai-docs/patterns/source-to-test-path-mirroring.md +0 -45
  76. package/ai-docs/patterns/stateless-plugin-request-classes.md +0 -53
  77. package/ai-docs/patterns/typed-constants-and-enum-values.md +0 -47
  78. package/src/aiEnableRequest/ai-docs/ai-enable-request-spec.md +0 -223
  79. package/src/annotation/ai-docs/annotation-spec.md +0 -236
  80. package/src/breakouts/ai-docs/breakouts-spec.md +0 -324
  81. package/src/controls-options-manager/ai-docs/controls-options-manager-spec.md +0 -243
  82. package/src/hashTree/ai-docs/hash-tree-spec.md +0 -267
  83. package/src/interceptors/ai-docs/interceptors-spec.md +0 -247
  84. package/src/interpretation/ai-docs/interpretation-spec.md +0 -256
  85. package/src/locus-info/ai-docs/locus-info-spec.md +0 -293
  86. package/src/media/ai-docs/media-spec.md +0 -267
  87. package/src/meeting/ai-docs/meeting-spec.md +0 -404
  88. package/src/meeting-info/ai-docs/meeting-info-spec.md +0 -261
  89. package/src/meetings/ai-docs/meetings-spec.md +0 -298
  90. package/src/member/ai-docs/member-spec.md +0 -196
  91. package/src/members/ai-docs/members-spec.md +0 -256
  92. package/src/metrics/ai-docs/metrics-spec.md +0 -185
  93. package/src/multistream/ai-docs/multistream-spec.md +0 -295
  94. package/src/personal-meeting-room/ai-docs/personal-meeting-room-spec.md +0 -234
  95. package/src/reachability/ai-docs/reachability-spec.md +0 -261
  96. package/src/reactions/ai-docs/reactions-spec.md +0 -198
  97. package/src/reconnection-manager/ai-docs/reconnection-manager-spec.md +0 -272
  98. package/src/recording-controller/ai-docs/recording-controller-spec.md +0 -223
  99. package/src/roap/ai-docs/roap-spec.md +0 -241
  100. package/src/webinar/ai-docs/webinar-spec.md +0 -243
@@ -0,0 +1,523 @@
1
+ ---
2
+ type: Module Spec
3
+ title: 'Multistream module specification'
4
+ description: Responsibilities, boundaries, design, state, invariants, and verification for the plugin-meetings multistream module.
5
+ tags: [module, specification]
6
+ ---
7
+ <!-- sdd-generated-metadata
8
+ doc_kind: module-spec
9
+ generated_from: module-spec@0.3.0
10
+ generated_by: claude-code
11
+ approved_by: rarajes2@cisco.com
12
+ updated_at: 2026-11-17T03:14:21Z
13
+ validation_status: pass-with-warnings
14
+ -->
15
+
16
+ # Multistream
17
+
18
+ This source-local document at `src/multistream/docs/README.md` is the canonical source-local spec
19
+ for `src/multistream/` and owns the stable specification for **the multistream module** of
20
+ `@webex/plugin-meetings`: the receive-slot pool, the `RemoteMedia` and `RemoteMediaGroup` objects
21
+ that applications render, the `RemoteMediaManager` that turns layouts into receive slots and media
22
+ requests, the `MediaRequestManager` that batches those requests for internal-media-core, and the
23
+ `SendSlotManager` that owns outgoing send slots. Ground every claim in package evidence and link to
24
+ the [package architecture](../../../docs/architecture.md) instead of repeating broader facts. No
25
+ service specification exists because this package is a library.
26
+
27
+ Related context: [documentation index](../../../docs/index.md) ·
28
+ [package agent instructions](../../../AGENTS.md) · repo architecture:
29
+ [package architecture](../../../docs/architecture.md) · registry:
30
+ [specification registry](../../../docs/specs/README.md) · related module:
31
+ [media](../../media/docs/README.md)
32
+
33
+ ## Metadata
34
+
35
+ | Field | Value |
36
+ | ----- | ----- |
37
+ | Owner | @webex/web-client, @webex/web-sdk |
38
+ | Source path | `src/multistream` |
39
+ | Resource kind | module |
40
+ | Status | Draft |
41
+ | Last verified | 2026-11-16 at `0b8c34db7f` |
42
+ | Module id | `plugin-meetings/multistream` |
43
+ | Parent spec | — |
44
+ | Doc kind | Module spec |
45
+ | Coverage score | Pending coverage assessment |
46
+ | Validation status | not-run |
47
+
48
+ Coverage state and the contracts baseline are recorded in `.sdd/manifest.json`.
49
+
50
+ ## Applicability
51
+
52
+ | Condition ID | Status | Evidence or reason | Owned section |
53
+ | ------------ | ------ | ------------------ | ------------- |
54
+ | `module.has_tiers` | N/A | No tier policy exists in `package.json` | Tier |
55
+ | `module.has_ui` | N/A | `src/multistream/remoteMedia.ts` exposes streams; the application renders them | UI use-case flow |
56
+ | `module.crosses_service_boundaries` | Applicable | `src/multistream/mediaRequestManager.ts` delivers stream requests to internal-media-core through a Meeting callback; `src/multistream/receiveSlot.ts` and `src/multistream/sendSlotManager.ts` wrap internal-media-core slots | Cross-boundary use-case flow |
57
+ | `module.holds_client_state` | Applicable | Slot pools in `src/multistream/receiveSlotManager.ts`; layout, slot, and media maps in `src/multistream/remoteMediaManager.ts`; client requests in `src/multistream/mediaRequestManager.ts` | Client state model |
58
+ | `module.enforces_domain_rules` | Applicable | Pinning, preferLiveVideo, slot-pool, and send-slot media-type rules in `src/multistream/remoteMediaGroup.ts`, `src/multistream/mediaRequestManager.ts`, `src/multistream/sendSlotManager.ts` | Business rules and invariants |
59
+ | `module.is_concurrent_async` | Applicable | Async slot allocation in `src/multistream/remoteMediaManager.ts`; debounced and event-driven commits in `src/multistream/mediaRequestManager.ts` | Concurrency and reactive flow |
60
+ | `module.owns_persistence` | N/A | All state in `src/multistream/remoteMediaManager.ts` and its siblings is in memory | Data, schema, and migration discipline |
61
+ | `module.stateful_transitions` | Applicable | Source state of `src/multistream/receiveSlot.ts`; started and layout state of `src/multistream/remoteMediaManager.ts` | State machine |
62
+ | `module.exposes_wire_protocol` | Applicable | `src/multistream/mediaRequestManager.ts` builds internal-media-core StreamRequest objects and codec infos | Protocol and wire format |
63
+ | `module.ui_multi_screen` | N/A | No UI in `src/multistream/remoteMediaManager.ts` | UI flow |
64
+ | `module.large_data_model` | N/A | The layout and request types in `src/multistream/remoteMediaManager.ts` and `src/multistream/mediaRequestManager.ts` are covered by Public surface | Data model |
65
+ | `module.returns_caller_errors` | Applicable | Synchronous throws and rejections across `src/multistream/remoteMediaManager.ts`, `src/multistream/remoteMediaGroup.ts`, `src/multistream/remoteMedia.ts`, `src/multistream/sendSlotManager.ts`, `src/multistream/mediaRequestManager.ts` | Caller-visible failure modes |
66
+ | `module.module_specific_conventions` | N/A | The manifest section profile resolves this to false; repository rules in `AGENTS.md` apply | Module-specific rules |
67
+ | `module.published_package` | Applicable | `src/index.ts` re-exports RemoteMedia from `src/multistream/remoteMedia.ts`, and `package.json` publishes the package | Export stability |
68
+ | `module.embedded_in_host` | N/A | No host mount API in `src/multistream/remoteMediaManager.ts` | Host integration and theming |
69
+ | `module.has_design_tradeoff` | Applicable | Stable RemoteMedia objects over raw slots in `src/multistream/remoteMedia.ts` and `src/multistream/remoteMediaManager.ts` | Key design trade-off |
70
+ | `module.has_submodules` | N/A | src/multistream/codec holds one constants file and is not a manifest module in `.sdd/manifest.json` | Sub-modules |
71
+
72
+ ## Evidence register
73
+
74
+ Requirements cite current implementation and mirrored unit-test paths. Current code wins over
75
+ retained prose when they conflict; commit and PR history are excluded by repository-owner decision.
76
+ Missing test evidence is stated as a gap rather than inferred.
77
+
78
+ | Evidence | What it establishes |
79
+ | -------- | ------------------- |
80
+ | `src/multistream/receiveSlot.ts` | `ReceiveSlot` wraps one internal-media-core receive slot; initial source state `no source`; `sourceUpdate` and `maxFsUpdate` emissions; `findMemberId()`; `ReceiveSlotEvents`, `CSI`, `MemberId`, `ReceiveSlotId`, `FindMemberIdCallback`; re-export of `StreamState` |
81
+ | `src/multistream/receiveSlotManager.ts` | Per-media-type allocated and free pools; slots are reused because internal-media-core receive slots cannot be deleted (class JSDoc) |
82
+ | `src/multistream/remoteMedia.ts` | `RemoteMedia`, `RemoteMediaEvents`, `RemoteVideoResolution`, `MAX_FS_VALUES`, `getMaxFs()`, `RemoteMediaId`; `stop()` calls `removeAllListeners()` on its slot |
83
+ | `src/multistream/remoteMediaGroup.ts` | Pinned and unpinned `RemoteMedia` lists sharing one active-speaker request |
84
+ | `src/multistream/remoteMediaManager.ts` | Predefined layouts and `DefaultConfiguration`; `start`, `stop`, `setLayout`; slot preallocation and reuse; `Event` enum and `Events` interface |
85
+ | `src/multistream/mediaRequestManager.ts` | Request map, commit, trimming, degradation, codec info, and the synchronous `preferLiveVideo` check |
86
+ | `src/multistream/sendSlotManager.ts` | Send-slot map, publication, codec parameters, source-state override, and `reset()` |
87
+ | `src/multistream/codec/constants.ts` | `AV1_CODEC_PARAMETERS` per resolution and `H264_CODEC_PARAMETERS` (`maxFs` 8192, `maxFps` 3000, `maxMbps` 245760) |
88
+ | `src/meeting/index.ts` | Builds the receive-slot manager, the four media request managers whose callbacks call `webrtcMediaConnection.requestMedia`, and the send-slot manager; resets them before closing the connection |
89
+ | `src/index.ts` | Re-exports `RemoteMedia` from the package entry |
90
+ | `package.json` | Pins `@webex/internal-media-core` 2.32.1, whose `SendSlot.unpublishStream` detaches the published stream's listeners before awaiting the sender change |
91
+ | `test/unit/spec/multistream/remoteMediaManager.ts` and six sibling suites | Mirrored unit coverage for every file above |
92
+ | Observation, no stated WHY | `addMemberVideoPane` tests `newPane.id in this.currentLayout.memberVideoPanes` on an array, so a duplicate pane id is not rejected; `removeMemberVideoPane` deletes `memberVideoPanes[paneId]` from that array, which leaves the pane in the current layout until the next `setLayout` (`src/multistream/remoteMediaManager.ts`). `MediaRequestManager.reset()` clears requests without removing their slot listeners (`src/multistream/mediaRequestManager.ts`). None is a requirement until a reason is recorded |
93
+
94
+ ## Purpose and boundary
95
+
96
+ - Responsibility: maps multistream media-core slots to stable remote-media objects/groups and
97
+ arbitrates send/receive requests.
98
+ - In scope: receive-slot allocation and reuse; `RemoteMedia` and `RemoteMediaGroup` objects with
99
+ pinning and size hints; layouts, active-speaker and receiver-selected panes, interpretation and
100
+ screen-share audio; batching media requests into `StreamRequest[]` with degradation and trimming;
101
+ outgoing send slots, publication, codec parameters, named media groups, and source-state overrides.
102
+ - Out of scope: creating and closing the multistream connection (`src/media`, `Meeting`); ROAP
103
+ signaling (`src/roap`); member and CSI data (`src/members`); emitting the `media:*` events
104
+ (`Meeting`); the WebRTC slot implementation (`@webex/internal-media-core`).
105
+ - Consumers: `Meeting` (`src/meeting/index.ts`) and applications that receive `RemoteMedia`,
106
+ `RemoteMediaGroup`, and `RemoteMediaManager` objects through Meeting events.
107
+
108
+ ## Structure and key files
109
+
110
+ `src/multistream/` contains 7 direct source/reference file(s) and has 7 mirrored unit-test file(s)
111
+ under `test/unit/spec/multistream/`, plus `codec/constants.ts`. The request coordination and payload
112
+ types are in `mediaRequestManager.ts`; `receiveSlot.ts`, `receiveSlotManager.ts`, `remoteMedia.ts`,
113
+ `remoteMediaGroup.ts`, `remoteMediaManager.ts`, and `sendSlotManager.ts` sit beside it, and this
114
+ canonical module specification is `src/multistream/docs/README.md`. The code is TypeScript in the
115
+ Node 22.14 Yarn workspace; Webex core/plugin abstractions and Mocha/Sinon/`@webex/test-helper-chai`
116
+ tests. Build target: `yarn workspace @webex/plugin-meetings build:src`.
117
+
118
+ | File | Holds |
119
+ | ---- | ----- |
120
+ | `src/multistream/mediaRequestManager.ts` | request coordination and payload types: `MediaRequestManager`, policy and codec info types |
121
+ | `src/multistream/receiveSlot.ts` | `ReceiveSlot`: one wrapped internal-media-core receive slot with source state, CSI, and member id |
122
+ | `src/multistream/receiveSlotManager.ts` | `ReceiveSlotManager`: the reusable receive-slot pool per media type |
123
+ | `src/multistream/remoteMedia.ts` | `RemoteMedia`: one remote stream bound to one receive slot and an optional receiver-selected request; max-fs helpers |
124
+ | `src/multistream/remoteMediaGroup.ts` | `RemoteMediaGroup`: a set of `RemoteMedia` sharing one active-speaker request, with pinning |
125
+ | `src/multistream/remoteMediaManager.ts` | `RemoteMediaManager`: layouts, slot allocation per layout, audio and screen-share groups, layout events |
126
+ | `src/multistream/sendSlotManager.ts` | `SendSlotManager`: outgoing send slots per media type, publication, codec parameters, overrides |
127
+ | `test/unit/spec/multistream/mediaRequestManager.ts` and 6 sibling test file(s) | mirrored characterization/unit coverage, one suite per source file |
128
+
129
+ ## Public surface
130
+
131
+ `RemoteMedia` is re-exported by `src/index.ts`; the other classes are reached through `Meeting`
132
+ (`meeting.remoteMediaManager`, `meeting.receiveSlotManager`) and Meeting events. Contract ID
133
+ `remote-media-api` is registered in `.sdd/manifest.json` and indexed in the
134
+ [package architecture](../../../docs/architecture.md#public-and-consumer-surfaces).
135
+
136
+ Manifest contracts: provides `remote-media-api`; requires `internal-media-core`.
137
+
138
+ | Contract ID | Type | Surface | Purpose | Compatibility / deprecation | Schema / detail link | Root index |
139
+ | ----------- | ---- | ------- | ------- | --------------------------- | -------------------- | ---------- |
140
+ | `remote-media-api` | SDK / in-process | `ReceiveSlot`: `id`, `mediaType`, `memberId`, `csi`, `sourceState`, `stream`, `setMaxFs()`, `findMemberId()`, the `logString` getter, and `wcmeReceiveSlot` | Expose one stable wrapper around a media-core receive slot and its resolved participant/source state. | Preserve accessors and source-state event behavior across slot reassignment. | `src/multistream/receiveSlot.ts` | package architecture |
141
+ | `remote-media-api` | SDK / lifecycle | `ReceiveSlotManager.allocateSlot()`, `releaseSlot()`, `reset()`, `getStats()`, `updateMemberIds()`, `findReceiveSlotBySsrc()` | Allocate, recycle, inspect, and reconcile the finite receive-slot pool. | `releaseSlot()` only moves the same slot object from the allocated pool to the free pool; it does not reset CSI/member/source state or detach listeners. | `src/multistream/receiveSlotManager.ts` | package architecture |
142
+ | `remote-media-api` | SDK / in-process | `RemoteMedia.setSizeHint()`, `getEffectiveMaxFs()`, `stop()`, `sendMediaRequest()`, `cancelMediaRequest()`, `id`, `mediaType`, `memberId`, `csi`, `sourceState`, `stream`, and `getUnderlyingReceiveSlot()` | Give consumers a stable remote-media identity while the source on its receive slot and its receiver-selected request change; the slot is fixed for the object's life. | `stop()` cancels the request and removes all listeners from its receive slot; it is not an async transport result. `stop()`, `sendMediaRequest()`, `cancelMediaRequest()`, and `getUnderlyingReceiveSlot()` are marked `@internal`. | `src/multistream/remoteMedia.ts` | package architecture |
143
+ | `remote-media-api` | SDK / in-process | `RemoteMediaGroup.getRemoteMedia()`, `setActiveSpeakerCsis()`, `pin()`, `unpin()`, `isPinned()`, `setPreferLiveVideo()`, `setNamedMediaGroup()`, `stop()`, `includes()`, and `getEffectiveMaxFs()` | Coordinate a related set of stable remote-media objects and pin/preference policy. | Preserve group membership and pinning semantics when layouts change. | `src/multistream/remoteMediaGroup.ts` | package architecture |
144
+ | `remote-media-api` | SDK / lifecycle | `RemoteMediaManager.start()`, `stop()`, `setLayout()`, `getLayoutId()`, `setPreferLiveVideo()`, `setActiveSpeakerCsis()`, `setReceiveNamedMediaGroup()`, `logAllReceiveSlots()`, `setRemoteVideoCsis()`, `setRemoteVideoCsi()`, `addMemberVideoPane()`, `removeMemberVideoPane()`, `pinActiveSpeakerVideoPane()`, `unpinActiveSpeakerVideoPane()`, and `isPinned()` | Translate meeting layout and CSI intent into remote-media groups and receive-slot assignments. | Preserve manager-scoped event/listener cleanup and current layout identifiers (`AllEqual`, `AllEqual25`, `OnePlusFive`, `Single`, `Stage`, `ScreenShareView`). | `src/multistream/remoteMediaManager.ts` | package architecture |
145
+ | `remote-media-api` | SDK / in-process | `MediaRequestManager.addRequest()`, `cancelRequest()`, `commit()`, `reset()`, `setDegradationPreferences()`, and `setNumCurrentSources()` | Batch active-speaker/receiver-selected constraints and synchronously deliver `StreamRequest[]` to media core. | Mixed active-speaker `preferLiveVideo` values throw synchronously; the callback returns `void`. | `src/multistream/mediaRequestManager.ts` | package architecture |
146
+ | `remote-media-api` | SDK / lifecycle | `SendSlotManager.createSlot()`, `getSlot()`, `setNamedMediaGroups()`, `setSourceStateOverride()`, `publishStream()`, `unpublishStream()`, `setActive()`, `setCodecParameters()`, `deleteCodecParameters()`, `setCustomCodecParameters()`, `markCustomCodecParametersForDeletion()`, and `reset()` | Own outgoing media-core send-slot publication and codec configuration. | Preserve explicit publication and codec-deletion operations; `setCodecParameters()` and `deleteCodecParameters()` are deprecated in favor of the MIME-scoped methods and send a deprecation metric. `reset()` calls `unpublishStream()` on every slot (best-effort, logging and swallowing rejection) before clearing them, so each slot detaches its publishedStream's track-change/constraints/mute/ended listeners instead of being discarded while still subscribed. | `src/multistream/sendSlotManager.ts` | package architecture |
147
+ | `remote-media-api` | exported layout/configuration | `VideoLayout`, `ActiveSpeakerVideoPaneGroup`, `MemberVideoPane`, `Configuration`, `DefaultConfiguration`, `Event`, `Events`, `LayoutId`, `PaneSize`, `PaneId`, `PaneGroupId`, `VideoLayoutChangedEventData`, and `getRemoteMediaManagerConfigForLogging()` | Define the layout model and events consumed by `RemoteMediaManager`. | Add layout fields and events compatibly; existing ids and defaults are observable. | `src/multistream/remoteMediaManager.ts` | package architecture |
148
+ | `remote-media-api` | exported media contracts | `AV1_CODEC_PARAMETERS`, `H264_CODEC_PARAMETERS`, `ActiveSpeakerPolicyInfo`, `ReceiverSelectedPolicyInfo`, `PolicyInfo`, `H264CodecInfo`, `CodecInfo`, `MediaRequest`, `MediaRequestId`, `ReceiveSlotEvents`, `StreamState`, `CSI`, `MemberId`, `ReceiveSlotId`, `FindMemberIdCallback`, `CreateSlotCallback`, `RemoteMediaEvents`, `RemoteVideoResolution`, `MAX_FS_VALUES`, `getMaxFs()`, and `RemoteMediaId` | Share the exact request, codec, resolution, event, and identity vocabulary across Meeting and media-core adapters. | `StreamState` is imported and re-exported from `@webex/internal-media-core` by `receiveSlot.ts`, not defined locally; preserve that upstream type identity plus raw codec values (now in `codec/constants.ts`), max-fs mapping, event names, and other identifier types. | `src/multistream/receiveSlot.ts`, `src/multistream/codec/constants.ts`, `src/multistream/mediaRequestManager.ts`, `src/multistream/remoteMedia.ts`, `src/multistream/receiveSlotManager.ts` | package architecture |
149
+
150
+ These are object-local `EventsScope` emissions on exported consumer-reachable classes, not package-wide `Trigger`/`TriggerProxy` events. Preserve each literal, emitting object, timing, and payload.
151
+
152
+ | Emitter | Event literal | Timing | Payload | Emission evidence |
153
+ |---|---|---|---|---|
154
+ | `ReceiveSlot` | `sourceUpdate` | After an internal-media-core source update refreshes state/CSI/member id, or when `findMemberId()` later resolves a previously unknown member. | `{state, csi, memberId}` | `src/multistream/receiveSlot.ts` |
155
+ | `ReceiveSlot` | `maxFsUpdate` | Synchronously when `setMaxFs(newFs)` is called. | `{maxFs: newFs}` | `src/multistream/receiveSlot.ts` |
156
+ | `RemoteMedia` | `sourceUpdate` | When the associated `ReceiveSlot` emits `sourceUpdate`; the same payload is forwarded. | `{state, csi, memberId}` | `src/multistream/remoteMedia.ts` |
157
+ | `RemoteMedia` | `stopped` | After `stop()` cancels its request, removes receive-slot listeners, and clears the slot association. | `{}` | `src/multistream/remoteMedia.ts` |
158
+ | `RemoteMediaManager` | `AudioCreated` | After the main-audio `RemoteMediaGroup` is created during startup. | main-audio `RemoteMediaGroup` | `src/multistream/remoteMediaManager.ts` |
159
+ | `RemoteMediaManager` | `InterpretationAudioCreated` | After a configured interpretation/named-audio `RemoteMediaGroup` is created. | interpretation-audio `RemoteMediaGroup` | `src/multistream/remoteMediaManager.ts` |
160
+ | `RemoteMediaManager` | `ScreenShareAudioCreated` | After screen-share audio slots exist and their `RemoteMediaGroup` is created. | screen-share-audio `RemoteMediaGroup` | `src/multistream/remoteMediaManager.ts` |
161
+ | `RemoteMediaManager` | `VideoLayoutChanged` | After `setLayout()` updates receive slots and remote-media objects for the selected layout. | `VideoLayoutChangedEventData` (`layoutId`, active-speaker groups, member panes, optional screen-share video) | `src/multistream/remoteMediaManager.ts` |
162
+
163
+ Compatibility notes:
164
+
165
+ - Prefer additive options and payload fields. Preserve method/event names, rejection semantics, and cleanup timing; route public changes through `src/index.ts` or the documented owning object.
166
+
167
+ ## Dependencies
168
+
169
+ internal-media-core multistream connection, member CSI data, codecs, event callbacks, and Meeting
170
+ media state; each is injected by `Meeting` rather than imported as a service.
171
+
172
+ | Dependency | Why it is required | Failure behavior |
173
+ | ---------- | ------------------ | ---------------- |
174
+ | `@webex/internal-media-core` (`internal-media-core`) | `ReceiveSlot`, `SendSlot`, `StreamRequest`, `Policy`, `ActiveSpeakerInfo`, `ReceiverSelectedInfo`, `CodecInfo`, `H264Codec`, `AV1Codec`, `MediaType`, bitrate helpers | Errors from slot calls propagate to the caller, except in `SendSlotManager.reset()` |
175
+ | Meeting create-slot callback (`CreateSlotCallback`) | Creates a new internal-media-core receive slot when the pool is empty | A rejection rejects `allocateSlot()` and the manager operation awaiting it |
176
+ | Meeting find-member callback (`FindMemberIdCallback`) | Resolves a CSI to a member id from the members list | Returns `undefined` until the member is known; `updateMemberIds()` retries |
177
+ | Meeting send-requests callback (`StreamRequest[]` to `void`) | Delivers committed requests to `webrtcMediaConnection.requestMedia` | Meeting logs and drops requests when no connection exists yet |
178
+ | Meeting ingress payload-type callback | Supplies the H264 and AV1 payload types for codec infos | `undefined` omits that codec info |
179
+ | `src/common/events/events-scope.ts`, `src/common/logs/logger-proxy.ts` | Object-local events and logging | — |
180
+ | `src/metrics/index.ts` | Deprecation and custom-codec metrics from `SendSlotManager` | — |
181
+ | `lodash` (`cloneDeep`, `cloneDeepWith`, `debounce`, `forEach`, `remove`) | Layout cloning, request cloning, max-fs debounce | — |
182
+
183
+ ## Requirements
184
+
185
+ | ID | WHAT | WHY | Source evidence | Test / example evidence | Assumptions / gaps | Confidence |
186
+ | --- | ---- | --- | --------------- | ----------------------- | ------------------ | ---------- |
187
+ | `MULTISTREAM-R-001` | manage receive slots and remote-media groups. | Maps multistream media-core slots to stable remote-media objects/groups and arbitrates send/receive requests. | `src/multistream/remoteMediaManager.ts` | `test/unit/spec/multistream/remoteMediaManager.ts` | none | PRESENT |
188
+ | `MULTISTREAM-R-002` | Map member/CSI/layout requests to media-core. `ReceiveSlotManager.releaseSlot()` changes pool membership only; any association/listener cleanup must already be owned by `RemoteMedia.stop()`, request cancellation, or the surrounding manager flow. | Member, CSI, slot, and layout mappings must remain consistent while media-core reuses transport resources, without assigning cleanup behavior to a pool operation that does not perform it. | `src/multistream/remoteMediaManager.ts`, `src/multistream/receiveSlotManager.ts`, `src/multistream/remoteMedia.ts` | `test/unit/spec/multistream/remoteMediaManager.ts`, `test/unit/spec/multistream/receiveSlotManager.ts` | simultaneous slot reuse and layout change needs listener-identity coverage | PRESENT |
189
+ | `MULTISTREAM-R-003` | `MediaRequestManager` performs synchronous validation and calls its `sendMediaRequestsCallback(StreamRequest[])`, whose return type is `void`; it has no async rejection path. A mix of active-speaker requests with different `preferLiveVideo` values throws synchronously. `RemoteMedia.stop()` and request cancellation detach their owned associations/listeners; `releaseSlot()` does not. | Callers must handle the implemented synchronous validation boundary without inventing a rejected media-request promise, and cleanup must remain attributed to the object that performs it. | `src/multistream/mediaRequestManager.ts`, `src/multistream/remoteMedia.ts`, `src/multistream/receiveSlotManager.ts` | `test/unit/spec/multistream/mediaRequestManager.ts`, `test/unit/spec/multistream/remoteMedia.ts`, `test/unit/spec/multistream/receiveSlotManager.ts` | none | PRESENT |
190
+ | `MULTISTREAM-R-004` | A RemoteMedia identity remains stable while the track, source state, and member CSI mapping on its receive slot change; its slot is fixed for its life. `setLayout()` stops the previous video `RemoteMedia` and `RemoteMediaGroup` objects and announces the new ones in `VideoLayoutChanged`. Exported `ReceiveSlot`, `RemoteMedia`, and `RemoteMediaManager` objects emit the object-local event literals and payloads listed above at their concrete update/creation/stop boundaries. | Consumers keep references to remote media across layout and transport updates and rely on scoped events to know when those stable objects change. | `src/multistream/receiveSlot.ts`, `src/multistream/remoteMedia.ts`, `src/multistream/remoteMediaManager.ts` | `test/unit/spec/multistream/receiveSlot.ts`, `test/unit/spec/multistream/remoteMedia.ts`, `test/unit/spec/multistream/remoteMediaManager.ts` | none | PRESENT |
191
+ | `MULTISTREAM-R-005` | `RemoteMedia.stop()` cancels its request, removes all listeners from its receive slot (`removeAllListeners()`), and invalidates the association. `MediaRequestManager.cancelRequest()` removes its `SourceUpdate` and `MaxFsUpdate` handlers from every request slot before deletion. | Slot reuse must not deliver another participant's media or request callbacks through stale listeners. | `src/multistream/remoteMedia.ts`, `src/multistream/mediaRequestManager.ts` | `test/unit/spec/multistream/remoteMedia.ts`, `test/unit/spec/multistream/mediaRequestManager.ts` | none | PRESENT |
192
+ | `MULTISTREAM-R-006` | Media request arbitration and send-slot management preserve the latest supported layout/send intent: every commit clones the current request map and sends the whole set, so a cancelled or replaced request is absent from the next `StreamRequest[]`. | Concurrent layout/member changes should not apply obsolete stream requests. | `src/multistream/mediaRequestManager.ts`, `src/multistream/sendSlotManager.ts` | `test/unit/spec/multistream/mediaRequestManager.ts`, `test/unit/spec/multistream/sendSlotManager.ts` | none | PRESENT |
193
+ | `MULTISTREAM-R-007` | `SendSlotManager.reset()` calls `unpublishStream()` on every slot (catching and logging any rejection) before clearing the slot map. `unpublishStream()` detaches the slot's `OutputTrackChange`/`ConstraintsChange`/mute-state/`Ended` listeners from its `publishedStream` synchronously, before any awaited sender-replace work. | Simply clearing the slot map (as before) abandons each `SendSlot` still subscribed to its last published stream. If that stream object is reused by a later, unrelated meeting instance (the stream is owned by the caller, not the slot), the abandoned slot's handler fires on the new meeting's stream activity and throws trying to replace a track on its own (already-closed) connection's sender. | `src/multistream/sendSlotManager.ts` | `test/unit/spec/multistream/sendSlotManager.ts` | none | PRESENT |
194
+ | `MULTISTREAM-R-008` | Before sending, `MediaRequestManager` lowers every request's `maxFs` step by step from 1080p to 90p until the macroblocks of slots with a `live` source fit `degradationPreferences.maxMacroblocksLimit`, and logs a warning when it degrades or still exceeds the limit at 90p. | The code comment: reduce max-fs until total macroblocks is below the configured limit, so the client does not ask for more decode load than allowed. | `src/multistream/mediaRequestManager.ts` | `test/unit/spec/multistream/mediaRequestManager.ts` | none | PRESENT |
195
+ | `MULTISTREAM-R-009` | With `trimRequestsToNumOfSources`, active-speaker requests are trimmed so the total requested slots do not exceed the live (when `preferLiveVideo`) or total source count from `setNumCurrentSources()`, receiver-selected requests first and active-speaker groups by descending priority. | The code comment: the client should not ask for more than the streams available in total, and the lowest-priority requests are trimmed first. | `src/multistream/mediaRequestManager.ts` | `test/unit/spec/multistream/mediaRequestManager.ts` | none | PRESENT |
196
+
197
+ ## Design overview
198
+
199
+ The module is a set of cooperating media managers rather than one entry controller: receive slots
200
+ project remote sources, remote-media groups expose them, the media-request manager batches receive
201
+ requests, and the send-slot manager owns publication, codec parameters, named media groups, and
202
+ source-state overrides.
203
+
204
+ `RemoteMediaManager` owns the receive slots it allocates. `start()` creates the main and
205
+ interpretation audio groups, the screen-share slots and audio group, preallocates the largest number
206
+ of video slots any layout needs, and applies the initial layout. `setLayout()` moves every video slot
207
+ back to an unused list, keeps receiver-selected slots whose CSI the new layout still needs, allocates
208
+ more slots only if the total is short, assigns slots to active-speaker groups by descending priority
209
+ and to member panes, releases what is left, and then replaces the video `RemoteMedia` and
210
+ `RemoteMediaGroup` objects. Each `RemoteMedia` is bound to one slot for its life; an active-speaker
211
+ group shares one request across its unpinned members, and each pinned or member-pane `RemoteMedia`
212
+ holds its own receiver-selected request.
213
+
214
+ ## Data flow and sequence coverage
215
+
216
+ Call style: in-process method calls from `Meeting` and applications; object-local `EventsScope`
217
+ events; injected callbacks into internal-media-core (`createReceiveSlot`, `requestMedia`).
218
+
219
+ Sequence coverage:
220
+
221
+ | Operation group | Diagram | Failure coverage |
222
+ |---|---|---|
223
+ | UC-1…UC-6 — multistream slot and request operation groups | Multistream slot and request primary sequence | unknown/reused slot, pool-only release, removed source, mixed-preference validation, and owner-specific listener detachment |
224
+ | UC-1…UC-6 — multistream slot and request alternate/failure paths | Multistream slot and request alternate/failure sequence | stopped (invalidated) `RemoteMedia`, removed remote source, or mixed `preferLiveVideo` validation |
225
+ | UC-3 — layout change | Layout change sequence | invalid layout id or call before `start()` throws; old video objects are stopped before new ones are announced |
226
+ | UC-6 — send-slot reset | Send-slot reset sequence | a rejected `unpublishStream()` is logged and the slot is still removed |
227
+
228
+ ```mermaid
229
+ flowchart LR
230
+ MediaCore[internal-media-core slots/events] --> Slot[receiveSlot.ts]
231
+ SlotManager[receiveSlotManager.ts] --> Slot
232
+ RemoteManager[remoteMediaManager.ts] --> SlotManager
233
+ RemoteManager --> Group[remoteMediaGroup.ts]
234
+ Group --> Remote[remoteMedia.ts]
235
+ Slot --> Remote
236
+ Remote --> RequestManager[mediaRequestManager.ts]
237
+ Group --> RequestManager
238
+ Slot --> RequestManager
239
+ RequestManager --> Meeting[Meeting media request owner]
240
+ Meeting --> MediaCore
241
+ SendCore[send slots] --> SendManager[sendSlotManager.ts]
242
+ ```
243
+
244
+ Multistream slot and request primary sequence:
245
+
246
+ ```mermaid
247
+ sequenceDiagram
248
+ participant C as Media core
249
+ participant S as ReceiveSlot
250
+ participant P as ReceiveSlotManager
251
+ participant M as RemoteMediaManager
252
+ participant R as RemoteMedia
253
+ participant Q as MediaRequestManager
254
+ participant A as Meeting / application consumer
255
+ C-->>S: source state / CSI / track event
256
+ S-->>R: ReceiveSlotEvents.SourceUpdate
257
+ R-->>A: RemoteMediaEvents.SourceUpdate
258
+ M->>P: allocateSlot(...)
259
+ P-->>M: allocated ReceiveSlot
260
+ M->>R: construct RemoteMedia with the allocated slot
261
+ M->>Q: commit() after request/allocation changes
262
+ Q->>A: sendMediaRequestsCallback(StreamRequest[]), returns void
263
+ ```
264
+
265
+ Multistream slot and request alternate/failure sequence:
266
+
267
+ ```mermaid
268
+ sequenceDiagram
269
+ participant C as Media-core slot event
270
+ participant S as ReceiveSlot
271
+ participant R as RemoteMedia
272
+ participant Q as MediaRequestManager
273
+ participant A as Meeting / application consumer
274
+ C-->>S: source state, CSI, or track update
275
+ S-->>R: ReceiveSlotEvents.SourceUpdate
276
+ R-->>A: forwarded RemoteMediaEvents.SourceUpdate
277
+ A->>R: sendMediaRequest(csi, commit) through RemoteMediaManager.setRemoteVideoCsi
278
+ alt RemoteMedia still owns a ReceiveSlot
279
+ R->>Q: cancel any previous request, addRequest(...) and optionally commit
280
+ Q-->>R: media request id
281
+ else RemoteMedia was stopped
282
+ R--xA: synchronous invalidated-media error
283
+ else commit finds mixed preferLiveVideo
284
+ Q--xA: synchronous mixed-preference error
285
+ end
286
+ ```
287
+
288
+ Layout change sequence:
289
+
290
+ ```mermaid
291
+ sequenceDiagram
292
+ participant A as Application
293
+ participant M as RemoteMediaManager
294
+ participant P as ReceiveSlotManager
295
+ participant G as Old RemoteMediaGroup / RemoteMedia
296
+ participant Q as MediaRequestManager (video)
297
+ A->>M: setLayout(layoutId)
298
+ alt unknown layoutId or not started
299
+ M--xA: throws
300
+ else
301
+ M->>M: move slots to unused, keep receiver-selected slots still needed
302
+ M->>P: allocateSlot(VideoMain) while short
303
+ M->>P: releaseSlot(left-over unused slots)
304
+ M->>G: stop(false) on every previous video object
305
+ M->>M: new RemoteMediaGroup per active-speaker group, new RemoteMedia per member pane
306
+ M->>Q: commit()
307
+ M-->>A: VideoLayoutChanged {layoutId, activeSpeakerVideoPanes, memberVideoPanes, screenShareVideo}
308
+ end
309
+ ```
310
+
311
+ Send-slot reset sequence:
312
+
313
+ ```mermaid
314
+ sequenceDiagram
315
+ participant Mt as Meeting
316
+ participant SM as SendSlotManager
317
+ participant SS as SendSlot
318
+ Mt->>SM: reset() before closing the connection
319
+ loop every slot
320
+ SM->>SS: unpublishStream() (stream listeners detached synchronously)
321
+ opt rejection
322
+ SS--xSM: error
323
+ SM->>SM: log warning
324
+ end
325
+ end
326
+ SM->>SM: slots.clear()
327
+ ```
328
+
329
+ ## Class and component relationships
330
+
331
+ ```mermaid
332
+ classDiagram
333
+ class MediaCore
334
+ class Slot
335
+ class SlotManager
336
+ class Remote
337
+ class Group
338
+ class RemoteManager
339
+ class RequestManager
340
+ class SendCore
341
+ class SendManager
342
+ class Meeting
343
+ MediaCore <-- Slot : wraps
344
+ SlotManager --> Slot : pools
345
+ RemoteManager --> SlotManager : allocates from
346
+ RemoteManager --> Group : creates
347
+ RemoteManager --> Remote : creates member panes
348
+ Group --> Remote : owns
349
+ Remote --> Slot : bound to one
350
+ Remote --> RequestManager : receiver-selected request
351
+ Group --> RequestManager : active-speaker request
352
+ SendManager --> SendCore : owns
353
+ Meeting --> RemoteManager
354
+ Meeting --> SendManager
355
+ RequestManager --> Meeting : send callback
356
+ ```
357
+
358
+ The arrows identify ownership and delegation inside `src/multistream/`; files that only declare types or constants are not presented as transports.
359
+
360
+ ## Use cases and flows
361
+
362
+ | Use case | Actor or caller | Primary steps and outcome | Failure or boundary behavior | Evidence |
363
+ | -------- | --------------- | ------------------------- | ---------------------------- | -------- |
364
+ | `UC-1` | `RemoteMediaManager`, Meeting | Allocate receive slots and return them to the free pool. `releaseSlot()` preserves the slot object's current CSI/member/source/listener state; callers must perform any required association cleanup through its actual owner before pool reuse. | Releasing an unmanaged slot logs a warning | `src/multistream/receiveSlotManager.ts`, `src/multistream/receiveSlot.ts`, `src/multistream/remoteMedia.ts` |
365
+ | `UC-2` | Application | Keep a `RemoteMedia` identity stable as the track, source state, member id, or size hint on its receive slot changes | A layout change replaces video `RemoteMedia` objects | `src/multistream/remoteMedia.ts`, `src/multistream/remoteMediaManager.ts` |
366
+ | `UC-3` | Application | Build remote-media groups, switch layouts, update active-speaker/CSI intent, and pin or unpin the active-speaker pane | Unknown layout, unknown `RemoteMedia`, or pinning without a CSI throws | `src/multistream/remoteMediaGroup.ts`, `src/multistream/remoteMediaManager.ts` |
367
+ | `UC-4` | `RemoteMedia`, `RemoteMediaGroup` | Add, cancel, and commit media requests, applying degradation and current-source limits before synchronously delivering `StreamRequest[]` | No connection yet: Meeting logs and drops the requests | `src/multistream/mediaRequestManager.ts`, `src/meeting/index.ts` |
368
+ | `UC-5` | `MediaRequestManager` | Reject a commit synchronously when active-speaker request groups disagree on `preferLiveVideo` | Throws before the callback runs | `src/multistream/mediaRequestManager.ts` |
369
+ | `UC-6` | Meeting | Publish/unpublish outgoing send slots and update named media groups, source-state overrides, active state, and codec parameters | Missing slot or wrong media type throws or rejects | `src/multistream/sendSlotManager.ts` |
370
+ | `UC-7` | Application | Receive interpretation audio with `setReceiveNamedMediaGroup(AudioMain, languageId)` | Non-audio media type throws; the same language is a no-op | `src/multistream/remoteMediaManager.ts` |
371
+
372
+ ### Cross-boundary use-case flow
373
+
374
+ | Boundary | Transport and ordering | Compatibility | Timeout, retry, and recovery |
375
+ | -------- | ---------------------- | ------------- | ---------------------------- |
376
+ | internal-media-core receive slots (`UC-1`) | Async create-slot callback; then `sourceUpdate`, media started/stopped/ended events | Slots cannot be deleted, so they are pooled | No retry; a rejected create rejects the allocation |
377
+ | internal-media-core stream requests (`UC-4`, `UC-5`) | Synchronous `requestMedia(mediaType, StreamRequest[])` per media request manager; every commit sends the full set | Fields under Protocol and wire format | No retry; the next commit resends the current set |
378
+ | internal-media-core send slots (`UC-6`) | Async publish, unpublish, and codec calls per slot | Media-type restrictions under Business rules and invariants | `reset()` swallows unpublish failures |
379
+
380
+ ## Client state model
381
+
382
+ Receive/send slots, remote-media objects/groups, requested layouts, CSI mappings, and pending media
383
+ requests live for the connection lifetime.
384
+
385
+ | State or slice | Owner | Initial state | Transition triggers | Reset or persistence boundary |
386
+ | -------------- | ----- | ------------- | ------------------- | ----------------------------- |
387
+ | Allocated and free slot pools per media type | `ReceiveSlotManager` | Empty | `allocateSlot`, `releaseSlot` | `reset()` empties both pools when Meeting tears media down |
388
+ | Slot lists (`audio.main`, `audio.si`, `screenShare`, `video.unused`/`activeSpeaker`/`receiverSelected`) and allocations | `RemoteMediaManager` | Empty | `start`, `setLayout`, `addMemberVideoPane`, `removeMemberVideoPane` | `stop()` releases every slot |
389
+ | `media` objects (audio, interpretation, video groups and panes, screen share) | `RemoteMediaManager` | Undefined | `start`, `setLayout`, `setReceiveNamedMediaGroup` | `stop()` stops them all |
390
+ | `started`, `currentLayout`, `currentLayoutId` | `RemoteMediaManager` | `false`, undefined | `start`, `setLayout` | `stop()` clears them |
391
+ | Pinned and unpinned lists, active-speaker request id | `RemoteMediaGroup` | All unpinned | `pin`, `unpin`, `setActiveSpeakerCsis` | `stop()` |
392
+ | `clientRequests`, `numTotalSources`, `numLiveSources` | `MediaRequestManager` | `{}`, 0, 0 | `addRequest`, `cancelRequest`, `setNumCurrentSources` | `reset()` |
393
+ | Send slots and source-state overrides | `SendSlotManager` | Empty | `createSlot`, `setSourceStateOverride` | `reset()` clears the slots |
394
+
395
+ ## Business rules and invariants
396
+
397
+ | ID | Invariant | WHY | Enforcement source | Test evidence |
398
+ | --- | --------- | --- | ------------------ | ------------- |
399
+ | `INV-001` | A slot has one active owner/mapping while allocated. Returning it to the free pool does not itself detach tracks/listeners or reset CSI/member/source state; `RemoteMedia.stop()` and request cancellation own their respective cleanup. | internal-media-core receive slots cannot be deleted, so they are reused (class JSDoc of `ReceiveSlotManager`); cleanup must stay with the object that registered the listeners. | `src/multistream/receiveSlotManager.ts`, `src/multistream/remoteMedia.ts` | `test/unit/spec/multistream/receiveSlotManager.ts`, `test/unit/spec/multistream/remoteMedia.ts` |
400
+ | `INV-002` | Object-local emissions retain the exact literals/payloads listed under Public surface, and request arbitration preserves the latest supported layout intent. | Applications subscribe to these literals on the objects they hold. | `src/multistream/receiveSlot.ts`, `src/multistream/remoteMedia.ts`, `src/multistream/remoteMediaManager.ts`, `src/multistream/mediaRequestManager.ts` | `test/unit/spec/multistream/receiveSlot.ts`, `test/unit/spec/multistream/remoteMediaManager.ts` |
401
+ | `INV-003` | All active-speaker requests of one `MediaRequestManager` share one `preferLiveVideo` value. | The thrown message: a mix of active-speaker groups with different values for preferLiveVideo is not supported. | `src/multistream/mediaRequestManager.ts` | `test/unit/spec/multistream/mediaRequestManager.ts` |
402
+ | `INV-004` | Named media groups can be set only on the `AudioMain` send slot, and source-state overrides only on the `VideoMain` send slot; one send slot exists per media type. | The thrown messages state the restriction; a duplicate slot is rejected with `Slot for <mediaType> already exists`. | `src/multistream/sendSlotManager.ts` | `test/unit/spec/multistream/sendSlotManager.ts` |
403
+ | `INV-005` | Pinning needs a CSI (given or current) and a `RemoteMedia` from the group; a pinned `RemoteMedia` holds its own receiver-selected request and leaves the group's active-speaker request. | Pinning means the media no longer comes from the active speaker but from that CSI (JSDoc of `pin`). | `src/multistream/remoteMediaGroup.ts` | `test/unit/spec/multistream/remoteMediaGroup.ts` |
404
+
405
+ ## Concurrency and reactive flow
406
+
407
+ - Execution model: one JavaScript event loop; slot allocation and send-slot calls are async, request
408
+ commits are synchronous.
409
+ - Receive-slot and RemoteMedia identity is checked at each association change. `RemoteMedia.stop()` and `MediaRequestManager.cancelRequest()` detach the listeners they own; `ReceiveSlotManager.releaseSlot()` only changes pool membership. `MediaRequestManager` has no request result to wait for: each commit sends the whole current request set, so a superseded slot/group is simply absent from the next set.
410
+ - Reactive input: a `sourceUpdate` on any request slot commits immediately; a `maxFsUpdate` from
411
+ `setSizeHint()` commits after a 1000 ms debounce.
412
+ - Ordering guarantees: `setLayout()` awaits slot allocation before replacing objects and emitting
413
+ `VideoLayoutChanged`; concurrent `setLayout()` calls are not serialized.
414
+ - Idempotency: `setPreferLiveVideo`, `setNamedMediaGroup`, `setReceiveNamedMediaGroup`, and
415
+ `setSourceStateOverride` do nothing when the value is unchanged; `start()` throws when already
416
+ started.
417
+
418
+ ## State machine
419
+
420
+ Receive-slot source state, as stored by `ReceiveSlot`:
421
+
422
+ ```mermaid
423
+ stateDiagram-v2
424
+ state "no source" as NO_SOURCE
425
+ [*] --> NO_SOURCE
426
+ NO_SOURCE --> live: slot reports a live source
427
+ live --> NO_SOURCE: receive slot reports source removed
428
+ live --> live: CSI/track/source-state update
429
+ live --> other: slot reports invalid source, avatar, bandwidth disabled, policy violation, or away
430
+ other --> live: slot reports a live source
431
+ other --> NO_SOURCE: receive slot reports source removed
432
+ ```
433
+
434
+ The diagram records the initialized `no source` value and the `live` source path consumed by current
435
+ multistream code and tests; `ReceiveSlot` stores whichever `StreamState` internal-media-core reports,
436
+ and `MediaRequestManager` counts only `live` slots when it degrades `maxFs`.
437
+
438
+ `RemoteMediaManager` lifecycle:
439
+
440
+ ```mermaid
441
+ stateDiagram-v2
442
+ [*] --> Stopped
443
+ Stopped --> Started: start() creates audio and screen-share media, applies the initial layout
444
+ Started --> Started: setLayout(layoutId) replaces video objects
445
+ Started --> Started: start() again throws
446
+ Stopped --> Stopped: setLayout() throws before start()
447
+ Started --> Stopped: stop() stops every object and releases every slot
448
+ ```
449
+
450
+ ## Protocol and wire format
451
+
452
+ Requests are internal-media-core objects built by `MediaRequestManager`; preserve current field
453
+ names, enum/raw values, and compatibility behavior, and do not treat the normalized client model as
454
+ the wire schema.
455
+
456
+ | Message or frame | Version | Producer or serializer | Consumer or parser | Compatibility and ordering rule |
457
+ | ---------------- | ------- | ---------------------- | ------------------ | ------------------------------- |
458
+ | `StreamRequest(policy, policyInfo, receiveSlots, maxPayloadBitsPerSecond, codecInfos)` | internal-media-core 2.32.1 | `MediaRequestManager.sendRequests` | `webrtcMediaConnection.requestMedia` | One per client request with at least one slot; the full set is sent on every commit |
459
+ | `ActiveSpeakerInfo(priority, crossPriorityDuplication, crossPolicyDuplication, preferLiveVideo, namedMediaGroups)` / `ReceiverSelectedInfo(csi)` | — | `MediaRequestManager` from `PolicyInfo` | internal-media-core | `RemoteMediaGroup` sends priority, `false`, `false`, its `preferLiveVideo`, and its named group |
460
+ | `maxPayloadBitsPerSecond` | — | `MediaRequestManager` | internal-media-core | Audio: `RecommendedOpusBitrates.FB_MONO_MUSIC`; video: `getRecommendedMaxBitrateForFrameSize(maxFs)` |
461
+ | H264 codec info `(payloadType, maxFs, maxFps, maxMbps, maxWidth, maxHeight)` | — | `MediaRequestManager` | internal-media-core | `maxFps` defaults to 3000 and `maxMbps` is `maxFs * maxFps / 100`; omitted when the payload type is unknown |
462
+ | AV1 codec info | — | `MediaRequestManager` when `enableAv1` | internal-media-core | Parameters from `AV1_CODEC_PARAMETERS` by the smallest resolution bucket that fits `maxFs`, else 1080p |
463
+ | Max-fs values `90p` 60, `180p` 240, `360p` 920, `540p` 2040, `720p` 3600, `1080p` 8192 | — | `MAX_FS_VALUES`, `getMaxFs`, `setSizeHint` | `MediaRequestManager` | Pane size `best` maps to 1080p; unknown sizes fall back to 720p with a warning |
464
+
465
+ ## Caller-visible failure modes
466
+
467
+ | Condition | Signal | Caller recovery |
468
+ |---|---|---|
469
+ | Slot/CSI is unknown or a remote source is removed | The owning association is absent or detached by its `RemoteMedia`/request lifecycle. Merely calling `releaseSlot()` changes pool membership and provides no cleanup signal. | Reconcile against the current slot/member mapping and invoke the actual association owner before returning a slot to the pool. |
470
+ | Active-speaker requests mix different `preferLiveVideo` values | `MediaRequestManager.commit()` throws synchronously before delivering stream requests. | Make the grouped active-speaker policy consistent, then commit again. |
471
+ | Current slot reports a live source | The stable `RemoteMedia` object receives the slot/track update and emits its scoped update. | Continue using the stable remote-media identity. |
472
+ | `SendSlotManager.reset()` is called and a slot's `unpublishStream()` rejects (e.g. the underlying connection is already closing) | The rejection is caught and logged as a warning; the slot is still removed from the map. `reset()` itself never throws. | No caller action needed; the slot map is cleared regardless of the unpublish outcome. |
473
+ | `sendMediaRequest()` on a stopped `RemoteMedia` | Throws `sendMediaRequest() called on an invalidated RemoteMedia instance`. | Use the `RemoteMedia` from the latest `VideoLayoutChanged`. |
474
+ | `setLayout()` with an unknown id, before `start()`, or `start()` twice | Throws (`invalid layoutId`, `setLayout() called before start()`, `start() failure: already started`). | Use a configured layout id; call `start()` once. |
475
+ | Pin, unpin, `isPinned`, or `setRemoteVideoCsis` with a `RemoteMedia` outside the group or panes | Throws with the `RemoteMedia` id. | Pass a `RemoteMedia` from the current layout. |
476
+ | `addMemberVideoPane()` or `removeMemberVideoPane()` before `start()` | `addMemberVideoPane` rejects; `removeMemberVideoPane` returns a rejected promise. | Call `start()` first. |
477
+ | A send-slot operation for a missing slot or the wrong media type | Throws, or rejects for the async methods, `Slot for <mediaType> does not exist` or the media-type message. | Create the slot first; use `AudioMain` for named groups and `VideoMain` for overrides. |
478
+
479
+ ## Pitfalls and constraints
480
+
481
+ - Remote-media identity is not the same as a transient track or slot. Recreating objects on every update breaks consumer references; source updates keep the object, but a layout change stops the previous video objects (each emits `stopped`) and hands out new ones in `VideoLayoutChanged`.
482
+ - `Event.InterpretationAudioCreated` is emitted at runtime, but the current exported `Events` interface does not declare its callback alongside the other manager events. Treat the runtime event as observable and the type-interface omission as a separate possible product/type defect.
483
+ - Public behavior may be reachable through a parent `Meeting`/`Meetings` object even when the source helper is not exported directly.
484
+ - `RemoteMedia.stop()` calls `removeAllListeners()` on its receive slot, which also drops listeners an application attached through `getUnderlyingReceiveSlot()`.
485
+ - `addMemberVideoPane` and `removeMemberVideoPane` treat the `memberVideoPanes` array like a map: duplicate pane ids are not rejected, and a removed pane stays in the current layout until the next `setLayout` (Evidence register observation).
486
+
487
+ ## Export stability
488
+
489
+ | Export or entry point | Consumer | Stability | Versioning and deprecation rule | Declaration or API report |
490
+ | --------------------- | -------- | --------- | ------------------------------- | ------------------------- |
491
+ | Named export `RemoteMedia` from the package entry | Applications importing `@webex/plugin-meetings` | Published (`remote-media-api`) | No versioning or deprecation rule is declared in the package; `deploy:npm` publishes it, and its declaration ships in `dist/types/index.d.ts` built from `src/index.ts` | `src/index.ts`, `src/multistream/remoteMedia.ts`, `package.json` |
492
+ | `RemoteMedia` members not marked `@internal`: `id`, `mediaType`, `memberId`, `csi`, `sourceState`, `stream`, `setSizeHint()`, `getEffectiveMaxFs()`, and the `sourceUpdate` and `stopped` events | Applications | Published | Same; `stop()`, `sendMediaRequest()`, `cancelMediaRequest()`, and `getUnderlyingReceiveSlot()` are `@internal` and not a supported entry | `src/multistream/remoteMedia.ts` |
493
+ | `RemoteMediaGroup`, `RemoteMediaManager`, `ReceiveSlot`, `ReceiveSlotManager`, `MediaRequestManager`, `SendSlotManager`, and their types | Applications reach them through `Meeting` and its events, not as package exports | Reachable, not exported | No declared rule; compatibility commitments are under Public surface | `src/meeting/index.ts`, `src/index.ts` |
494
+
495
+ ## Key design trade-off
496
+
497
+ - Stable remote-media objects are favored over exposing raw media-core slots, requiring explicit mapping and lifecycle management.
498
+
499
+ | Chosen trade-off | Preserved invariant or benefit | Cost or limitation | Decision evidence |
500
+ | ---------------- | ------------------------------ | ------------------ | ----------------- |
501
+ | Pool and reuse receive slots across layouts | Slots that cannot be deleted are not leaked, and preallocation avoids creating slots after the SDP exchange (JSDoc of `preallocateVideoReceiveSlots`) | Pool release does no cleanup, so owners must stop their `RemoteMedia` (`INV-001`) | `src/multistream/receiveSlotManager.ts`, `src/multistream/remoteMediaManager.ts` |
502
+ | Send the full request set on every commit | The latest intent always wins (`MULTISTREAM-R-006`) | Every source update re-sends every request | `src/multistream/mediaRequestManager.ts` |
503
+
504
+ ## Verification
505
+
506
+ Use the current mirrored suites: `test/unit/spec/multistream/mediaRequestManager.ts`, `test/unit/spec/multistream/receiveSlot.ts`, `test/unit/spec/multistream/receiveSlotManager.ts`, `test/unit/spec/multistream/remoteMedia.ts`, `test/unit/spec/multistream/remoteMediaGroup.ts`, `test/unit/spec/multistream/remoteMediaManager.ts`, `test/unit/spec/multistream/sendSlotManager.ts`. Characterize the multistream-specific use cases above and each listed failure condition; add cleanup or transition cases only for resources and state this module actually owns.
507
+
508
+ | Behavior / Requirement | Existing test evidence | Gap |
509
+ |---|---|---|
510
+ | `MULTISTREAM-R-001` | `test/unit/spec/multistream/remoteMediaManager.ts` | cover each receive-slot, remote-media/group/manager, request-manager, layout, and send-slot family |
511
+ | `MULTISTREAM-R-002` | `test/unit/spec/multistream/remoteMediaManager.ts` | simultaneous slot reuse and layout change needs listener-identity coverage |
512
+ | `MULTISTREAM-R-003` | `test/unit/spec/multistream/mediaRequestManager.ts` | the synchronous mixed-`preferLiveVideo` throw is asserted; no case asserts that the `void` callback is not treated as a promise |
513
+ | `MULTISTREAM-R-004` | `test/unit/spec/multistream/remoteMedia.ts`, `test/unit/spec/multistream/remoteMediaManager.ts` | none |
514
+ | `MULTISTREAM-R-005` | `test/unit/spec/multistream/remoteMedia.ts`, `test/unit/spec/multistream/mediaRequestManager.ts`, `test/unit/spec/multistream/receiveSlotManager.ts` | verify rapid slot reuse while distinguishing pool-only release from RemoteMedia/request listener cleanup |
515
+ | `MULTISTREAM-R-006` | `test/unit/spec/multistream/mediaRequestManager.ts`, `test/unit/spec/multistream/sendSlotManager.ts` | verify stale request suppression |
516
+ | `MULTISTREAM-R-007` | `test/unit/spec/multistream/sendSlotManager.ts` | covered for the unpublish-before-clear happy path and the rejected-unpublish warning/no-throw path |
517
+ | `MULTISTREAM-R-008` | `test/unit/spec/multistream/mediaRequestManager.ts` | none |
518
+ | `MULTISTREAM-R-009` | `test/unit/spec/multistream/mediaRequestManager.ts` | none |
519
+ | `INV-003` to `INV-005` | `test/unit/spec/multistream/mediaRequestManager.ts`, `test/unit/spec/multistream/sendSlotManager.ts`, `test/unit/spec/multistream/remoteMediaGroup.ts` | no case for duplicate member pane ids |
520
+
521
+ A module specification is complete only when its public surface, invariants, failure modes, and
522
+ test evidence agree with the implementation. Coverage measurement is pending; semantic validation
523
+ has not run.