Skip to content

Feature/inbound stream notification#13

Open
smoghe-bw wants to merge 18 commits into
mainfrom
feature/inbound-stream-notification
Open

Feature/inbound stream notification#13
smoghe-bw wants to merge 18 commits into
mainfrom
feature/inbound-stream-notification

Conversation

@smoghe-bw

Copy link
Copy Markdown
Contributor

No description provided.

smoghe-bw and others added 18 commits June 2, 2026 09:25
…call flow

onStreamAvailable now fires twice: first with callId (WS notification, no
mediaStream) for call-arrival UI, then with mediaStream (WebRTC ontrack) for
audio setup. Guard both handlers so audio setup only runs on the second fire.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- App.tsx owns all stream event registration (single onStreamAvailable
  handler); routes WS notification (callId only) to incoming call banner,
  routes WebRTC ontrack (mediaStream) to MediaPlayer for audio setup
- Incoming call banner with Accept/Decline buttons appears on streamAvailable
  WS notification; accept calls acceptStream(callId), decline calls
  declineStream(callId)
- MediaPlayer simplified: accepts inboundStream prop, wires audio via
  useEffect instead of relying on the stream callback directly

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
npm link symlinks are not followed by react-scripts' bundled TypeScript.
A file: reference causes npm install to copy the built dist/ directly
into node_modules so CRA resolves types correctly.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…l state

The subscribe peer's WebRTC ontrack fires on initial connection before any
call exists. callExpectedRef is set only when the WS streamAvailable
notification arrives, ensuring the MediaStream and inCall state are only
set when a real call is active.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…cation arrives

WebRTC ontrack fires once at connection setup, before the WS streamAvailable
notification. Store the stream in subscribeStreamRef regardless of call state;
wire it to inboundStream when the notification arrives (or on explicit accept)
so the audio visualization always receives the stream.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
- Remove setInboundStream from WS notification path; audio only wires up
  on explicit accept, preventing the stream from playing before the user
  answers
- CallController.handleHangUp now calls setInCall(false) directly after
  hangupConnection resolves instead of waiting for streamUnavailable; the
  gateway also returns {status} not {result} so dropped the stale field read

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
hangupConnection set inCall=false but left inboundStream populated, so
MediaPlayer kept rendering the remote audio visualization after call end.
A useEffect on inCall ensures the stream is cleared for all exit paths.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
ontrack fires once per WS session lifetime — the subscribe peer's
MediaStream is permanent. Clearing it on streamUnavailable left
subscribeStreamRef null for the second call, so accept had no stream
to wire up. callExpectedRef still gates when the stream is used.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
When inboundStream becomes null the audio element's srcObject was left
pointing at the old MediaStream so the browser kept playing buffered audio
from the ended call. Clear it explicitly in the cleanup path.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
The SDK may call onStreamAvailable twice when the new gateway SSRC mapping
is in use: once from the signaling WS notification (no mediaStream) and
once from the WebRTC ontrack event (with mediaStream). Guard against null
mediaStream by returning early rather than throwing so the second call
(which carries the real stream) can proceed normally.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…eam together)

The updated SDK (metadata-for-stream-events) now fires onStreamAvailable once with
both callId and mediaStream set, correlating the WS notification and WebRTC ontrack
internally. The previous handler only covered two cases: WS-only (callId, no stream)
and ontrack-only (stream, no callId), so the combined event fell through without
setting inboundStream.

Add an explicit combined-event branch that handles accept/decline/autoAccept
the same way as the split paths, while keeping the old two-phase and ontrack-only
branches for backwards compat with older SDK versions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant