ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.17k stars 618 forks source link

JS SDK: Add event for local stream being available #6409

Open MaZZly opened 3 weeks ago

MaZZly commented 3 weeks ago

Is your feature request related to a problem? Please describe.

There is no event/callback for when localStream has been set/changed. We need this to be able to render the video element.

Initializing webRTCAdaptor with localVideoId is not an option since we are using React, and need to render video elements according to what streams (local/remote) are available, i.e. we can't have a video-placeholder that webRTCAdaptor modifies..

Describe the solution you'd like

A callback like localStreamAvailable (or similar) that triggers when the localStream is updated. It should probably also include the stream in question. (can also ofc be fetched from webRTCAdaptor.mediaManager.localStream)

Probably triggering the callback at the end of mediaManager.gotStream() would be sufficient? :thinking:

Describe alternatives you've considered Now, if we want to keep track of the local stream, we would have to have an interval or something running to check its state...

Alternatively we could listen to newTrackAvailable, but that one @mustafaboleken said is probably a bug that it triggers for localStream (So I'm guessing it will be fixed...), and that callback arrives way too late...

mekya commented 2 weeks ago

Hi @MaZZly,

Thank you for the issue.

What do you think about sending a PR to the repo? It will be a great help for us.

Cheers Oz