Skip to content

fix: add onInboundStreamNotification to keep onStreamAvailable backwards compatible#6

Closed
smoghe-bw wants to merge 1 commit into
metadata-for-stream-eventsfrom
backwards-compat-stream-notification
Closed

fix: add onInboundStreamNotification to keep onStreamAvailable backwards compatible#6
smoghe-bw wants to merge 1 commit into
metadata-for-stream-eventsfrom
backwards-compat-stream-notification

Conversation

@smoghe-bw

Copy link
Copy Markdown

Summary

  • The gateway SSRC mapping change causes a streamAvailable WS notification to fire before the WebRTC ontrack event arrives. The feature branch wired this notification through onStreamAvailable, but that callback previously always carried a mediaStream — breaking existing consumers.
  • Introduced onInboundStreamNotification as the dedicated callback for the pre-media signaling notification (carries callId/autoAccepted, mediaStream is always undefined here).
  • Restored onStreamAvailable to only fire from the WebRTC ontrack handler, where mediaStream is always present. Existing consumers are unaffected.

Before / After

Event Before (broken) After (fixed)
Gateway streamAvailable WS fires onStreamAvailable with no mediaStream fires onInboundStreamNotification with callId/autoAccepted
WebRTC ontrack fires onStreamAvailable with mediaStream fires onStreamAvailable with mediaStream (unchanged)

Migration for consumers using the accept/decline flow

Replace onStreamAvailable usage that inspects callId for accept/decline with onInboundStreamNotification:

// Before (broken with new gateway)
rtc.onStreamAvailable((stream) => {
  if (!stream.mediaStream) showAcceptUI(stream.callId);
});

// After
rtc.onInboundStreamNotification((stream) => {
  showAcceptUI(stream.callId);          // mediaStream is undefined here by design
});
rtc.onStreamAvailable((stream) => {
  playAudio(stream.mediaStream);        // always populated
});

Test plan

  • Inbound call with new gateway (SSRC mapping) — onInboundStreamNotification fires first (no media), then onStreamAvailable fires with a populated mediaStream
  • Inbound call with old gateway — only onStreamAvailable fires (from ontrack), onInboundStreamNotification never fires
  • Existing sample app with no onInboundStreamNotification registered — call connects normally, no errors

🤖 Generated with Claude Code

…mNotification callback

Previously the signaling-layer streamAvailable WS event was routed through
onStreamAvailable, which fires before the WebRTC ontrack event arrives and
therefore has no mediaStream. This broke existing consumers who assume
onStreamAvailable always carries a populated mediaStream.

Introduce onInboundStreamNotification as the dedicated callback for the
pre-media gateway notification (carries callId/autoAccepted, no mediaStream).
onStreamAvailable continues to fire only from the WebRTC ontrack handler,
so mediaStream is always present and existing consumers are unaffected.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@smoghe-bw smoghe-bw requested review from a team as code owners June 15, 2026 20:16
@bwappsec

bwappsec commented Jun 15, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@smoghe-bw

Copy link
Copy Markdown
Author

Superseded — changes pushed directly to metadata-for-stream-events.

@smoghe-bw smoghe-bw closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants