inlivedev / sfu Goto Github PK
View Code? Open in Web Editor NEWWebRTC Selective Forwarder Unit(SFU) Golang Library
Home Page: https://inlive.app/realtime-interactive
License: MIT License
WebRTC Selective Forwarder Unit(SFU) Golang Library
Home Page: https://inlive.app/realtime-interactive
License: MIT License
Just found out that when a race condition of renegotiation happens between the client and SFU after adding new tracks, we always let the SFU do the renegotiation first and not continue the renegotiation on the client side. This makes the new tracks added to the client not trigger the ontrack event on the SFU side. Ideally, when the SFU finish the renegotiation, the SFU let the client knows that they can continue the previous renegotiation.
I will try to create a test to verify this.
Another idea for perfect renegotiation based on conversations on the Pion Slack channel is to separate the publisher and subscriber connection. This will prevent a race condition when both sides add a new track because it will trigger the renegotiation on different connections.
one room on different server
When a client connected to the room then suddenly their internet is drop or disconnected, their connection will be failed after a timeout but the other clients in the room is not receiving track removed event and it make the client video still exists even the client already disconnected.
To reproduce:
There is a reported issue that the onTrack
event won't be triggered when the remote client is using Firefox and sending simulcast track with H264. Similar issue also exist on Chrome mobile.
Based on this conversation the issue may be because:
When a participant publishes a track to a room, they will call peerConnection.AddTrack()
, and this will trigger thepeerConnection.OnTrack()
event on the SFU side. We face an issue once more than one type of video is published in a room, for example, once a screensharing stream is published in a room. How do we know which track is from the camera and which is from screensharing? So far, I haven't found a spec from WebRTC that specifies how to tell the difference between video sources. The media track has label property that can be used for the source, but I don't think it's available to use in Pion.
To make it easier to identify the tracks in the room, the user it belong, or the input device of that track, we need to change how we publish and subscribe to the media tracks. This is what I have that I think can help us with that need:
client.SubscribeAllTracks()
room.GetTracks()
to get a list of available tracks to subscribe to and subscribe to each track that they like by calling client.SubscribeTrack(MSID)
or client.SubscribeTracksByClient(clientid)
peerConnection.OnTrack()
event on the pair peerConnection on the SFU side. That event then will make the pair client trigger OnTrackAdded(ssrc)
, which is only received by the participant who previously added it.OnTrackAdded()
event, the publisher must set the metadata of that track to include the source of that track. This can be done by calling client.SetTrackMetadata(SSRC, metadata)
room.GetTracks()
to know what tracks to subscribe to. Each track will contains MSID, clientID, source type(camera, screen, or microphone), and added timestampclient.SubscribeTracks([]MSID)
to subscribe to each track they like.client.OnTrackAvailable(trackDetail)
will trigger, and the participant can subscribe by calling the same client.SubscribeTracks([]MSID)
if they want to.By doing this way, we can manage the publishing and subscription to tracks easier. Either a participant joins as a publisher or only as a subscriber, or as a passive participant.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.