-
Notifications
You must be signed in to change notification settings - Fork 28
Multi Stream in SDK 3.0 Using Aux Streams
With multi-stream, you'll see the video of the most active participants in your meetings.
- Stream order will be allocated in the order of joining the meeting.
- If the joined participant count goes above 6 (self + remote + aux streams), they will get into the queue and will not be allocated to any of the available streams as our limit is reached.
- If some one from the queue will speak he will get into the allocated stream and will replace the stream who is less active in the meeting.
- If some one from the allocated stream leaves the meeting, the random participant from the queue will replace the stream.
- The Active Speaker API can be used to check if the participant is active speaker.
- The ActiveSpeakerChangedEvent is triggered if active speaker changes.
In a meeting with more than two participants, if you want to see the active speaker along with other joined participants, you can use multi-stream to achieve it.
- You can only open 4 video streams at most.
- You cannot specify a stream showing a specific participant, as it is only determined by the activity of the participants.
To implement multi-stream, clients should first inherit from the MultiStreamObserver interface and then implement it. The following are the main steps you should follow.
class ViewController: UIViewController, MultiStreamObserver {
var onAuxStreamAvailable: (()-> MediaRenderView?)?
var onAuxStreamChanged: ((AuxStreamChangeEvent) -> Void)?
var onAuxStreamUnavailable: (() -> MediaRenderView?)?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.call.multiStreamObserver = self
}
}
When there is a new available stream, such as a new participant join in the meeting, SDK will trigger callback OnAuxStreamAvailable and the client should give SDK a view for rendering, and the AuxStreamOpenedEvent would be triggered indicating whether the stream is successfully opened.
var onAuxStreamAvailable: (() -> MediaRenderView?)? = {
}
If a stream is unavailable, such as a participant left the meeting and the number of joined participants is smaller than the number of opened streams, SDK will trigger callback OnAuxStreamUnavailable and the client should give SDK a view handle which will be closed or if the given view is null, SDK will automatically close the last opened stream if needed.
var onAuxStreamUnavailable: (() -> MediaRenderView?)? = {
}
When a stream is opened (successfully or not), AuxStreamOpenedEvent will be triggered. On this event, the client can display the view of the stream if the result is successful.
When a stream is closed (successfully or not), AuxStreamClosedEvent will be triggered. On this event, the client can hide the view of the stream if the result is successful.
var onAuxStreamChanged: ((AuxStreamChangeEvent) -> Void)? = { event in
switch event {
case .auxStreamOpenedEvent(let view, let result):
switch result {
case .success(let auxStream):
case .failure(let error):
@unknown default:
break
}
case .auxStreamPersonChangedEvent(let auxStream, let old, let new):
case .auxStreamSendingVideoEvent(let auxStream):
case .auxStreamSizeChangedEvent(let auxStream):
case .auxStreamClosedEvent(let view, let error):
if error == nil {
} else {
}
@unknown default:
break
}
}