Meonardo / janus-videoroom-ios

An iOS AppRTC example for janus videoroom plugin, written in Swift.
16 stars 4 forks source link

Understand Code Logic #9

Open iOSDevGarg opened 2 years ago

iOSDevGarg commented 2 years ago

Can you please help me understand the core Logic of your app? whenever a new user joins the same room. are you creating a new Peer connection with local track as yours own track and remote Description of new user? is it due to multiple users?

Meonardo commented 2 years ago

sorry for the late reply.

whenever a new user joins the same room. are you creating a new Peer connection with local track as yours own track and remote Description of new user? is it due to multiple users?

Yes, but it is not necessary to add local track to the new created pc(if subscribe other publisher in the room only).

iOSDevGarg commented 2 years ago

So you are maintaining janusconnection class inside there’s a webrtc instance. but you create a new instance of webrtc after setting the remote description and all. For an ex. Two users are there in a call now third ones join in same webrtc instance you are updating the remote description or in the new webrtc instance ? If i use the same instance and update the remote description will that stop my first user video ?

Meonardo commented 2 years ago

Two users are there in a call now third ones join in same webrtc instance you are updating the remote description or in the new webrtc instance ?

in the new webrtc instance.

here is my main logic: create RTCPeerConnection instances for every publisher in the room(even there are only two publishers in the room); means one JanusConnection to one publisher.

If i use the same instance and update the remote description will that stop my first user video ?

I have not tried this, so I cant give you correct answer.

iOSDevGarg commented 2 years ago

Would you like to give a try if you have little time. I tried following your approach but fails. I don't have any server I just have firebase integrated. if possible else I am gonna scratch my head on this for sure.

Meonardo commented 2 years ago

Would you like to give a try if you have little time. I tried following your approach but fails. I don't have any server I just have firebase integrated. if possible else I am gonna scratch my head on this for sure.

Can you elaborate your usecase? If I understand you correctly, you want to add one or more remote track(s) to the same PeerConnection?

I highly suggest you to build your own janus server, it will help you to understand the way how WebRTC works, for example: to check the janus serve log, use the admin api of janus and etc...

iOSDevGarg commented 2 years ago

Mine issue first one started 2 connected - it showed 1st user and self video 1st user - shows self and second user video

3 connected - 1 - shows all three self and other two video 2 - self and first video (3rd user video no) 3 - self and first user video

I haven't used that publisher subscriber All users are on same level and responds to the new user to set offer and answer

when ever a user tries to join the room, I get a callback from firebase for new user. I create new WebRTC object and set new offer

JFYI, What actually happening is. Let me try to explain

Peer 1 - Peer 2 connection works perfect no issues Issue occurs when Peer 3 is joined When Peer 3 Joins - it is able to see only one either Peer 1 or Peer 2 in short who ever responded to Peer 3 Offer and made an answer. Peer 2 Video is not visible to the Peer 3. I tried getting the ice candidates also but now sure what to do?

Meonardo commented 2 years ago

I haven't used that publisher subscriber

What do you mean?

I get a callback from firebase for new user

I did not see any transport api related to Firebase. Any chance you are not using the janus WebRTC server?

iOSDevGarg commented 2 years ago

I am using firebase as signaling service instead of sockets to communicate and using default STUN servers for p2p connection. Is this server code is the entire backend code ? Any API Key is required ?

Meonardo commented 2 years ago

Please pay the project website a visit specially the VideoRoom plugin.

fukemy commented 2 years ago

great topic, but you need to know this library work with Janus, so you need to learn how it's work with janus event first to compare with your logic code in Firebase

as i know about this lib, each peerconnection require to handle audio. and video, but only localPeerConnection work with server, if you want to avoid this, just compare the handleID of peerconnection with handleID of roomJanus data

fukemy commented 2 years ago

@Meonardo if my explain wrong, please tech me about the problem, thanks

Meonardo commented 2 years ago

@Meonardo if my explain wrong, please tech me about the problem, thanks

You are not wrong, we can find the project site notice

Notice that this is the original VideoRoom demo, and uses a different PeerConnections per each subscription: if you want to test the new multistream support, instead, try the multistream VideoRoom demo instead. The two demos are interoperable, if you want to see how different subscription mechanisms are used on the same sources.

and the project demo(janus.js) file it shows how to create & save RTCPeerConnection.

Just for my understanding, to understand Janus videoroom plugin simply, forget the WebRTC stack temporarily,