Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented fast reconnection #235

Merged
merged 7 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### ✅ Added
- Add support for pre-built XCFrameworks
- Fast reconnection

### 🔄 Changed
- You can now focus on a desired point in the local video stream. [#221](https://github.com/GetStream/stream-video-swift/pull/221)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ Video roadmap and changelog is available [here](https://github.com/GetStream/pro

### 0.5.0 milestone

- [x] Tap to focus
- [x] Complete reconnection flows
- [ ] Video UIKit tutorial
- [ ] Improve logging / Sentry integration
- [ ] Camera controls
- [x] Tap to focus
- [ ] Complete reconnection flows
- [ ] Complete Livestreaming APIs and Tutorials for hosting & watching
- [ ] Dynascale 2.0
- [ ] Buttons to simulate ice-restart and SFU switching
Expand Down
8 changes: 8 additions & 0 deletions Sources/StreamVideo/WebRTC/PeerConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class PeerConnection: NSObject, RTCPeerConnectionDelegate, @unchecked Sendable {
var onStreamRemoved: ((RTCMediaStream) -> Void)?

var paused = false

var connectionState: RTCPeerConnectionState {
pc.connectionState
}

init(
sessionId: String,
Expand Down Expand Up @@ -167,6 +171,10 @@ class PeerConnection: NSObject, RTCPeerConnectionDelegate, @unchecked Sendable {
}
try await add(candidate: iceCandidate)
}

func restartIce() {
pc.restartIce()
}

func close() {
pc.close()
Expand Down
4 changes: 2 additions & 2 deletions Sources/StreamVideo/WebRTC/SfuMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SfuMiddleware: EventMiddleware {
var signalService: Stream_Video_Sfu_Signal_SignalServer
private var subscriber: PeerConnection?
private var publisher: PeerConnection?
var onSocketConnected: (() -> Void)?
var onSocketConnected: ((Bool) -> Void)?
var onParticipantCountUpdated: ((UInt32) -> ())?
var onSessionMigrationEvent: (() -> Void)?
var onPinsChanged: (([Stream_Video_Sfu_Models_Pin]) -> ())?
Expand Down Expand Up @@ -71,7 +71,7 @@ class SfuMiddleware: EventMiddleware {
case .dominantSpeakerChanged(let event):
await handleDominantSpeakerChanged(event)
case .joinResponse(let event):
onSocketConnected?()
onSocketConnected?(event.reconnected)
await loadParticipants(from: event)
case .healthCheckResponse(let event):
onParticipantCountUpdated?(event.participantCount.total)
Expand Down
Loading
Loading