Skip to content

fix: rebuild media stream when switching camera#33

Merged
BackGwa merged 1 commit intodevelopfrom
bugs/stream-interruption
Feb 24, 2026
Merged

fix: rebuild media stream when switching camera#33
BackGwa merged 1 commit intodevelopfrom
bugs/stream-interruption

Conversation

@BackGwa
Copy link
Owner

@BackGwa BackGwa commented Feb 24, 2026

Description

Return and set a new MediaStream instance on camera switch so React and peer connections detect the stream change reliably. This prevents stale stream references from interrupting video track replacement.

Type of Change

  • Bug fix (bugs/)
  • New feature (features/)
  • Refactoring (refactor/)
  • Hotfix (hotfix/)
  • Chore (chore/)

Related Issues

Stream interruption during screen transitions #31

Changes Made

  • mediaService.switchCamera now constructs and returns a new MediaStream instance (new video track + existing audio tracks) instead of mutating the current stream in place, so the stream reference changes on every switch
  • useMediaStream.switchCamera now calls setStream(newStream, 'camera') with the returned stream to update React context, propagating the new reference through the component tree
  • The changed reference causes the usePeerConnection effect to re-run and invoke sender.replaceTrack(track) on all active peer connections, delivering the new camera feed to participants without dropping the WebRTC connection

Checklist

  • Code follows the project's coding style
  • Self-review completed

Return and set a new MediaStream instance on camera switch so React and peer connections detect the stream change reliably. This prevents stale stream references from interrupting video track replacement.
@BackGwa BackGwa added the bug Something isn't working label Feb 24, 2026
@BackGwa BackGwa merged commit 0f54bae into develop Feb 24, 2026
4 checks passed
@BackGwa BackGwa deleted the bugs/stream-interruption branch February 24, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant