Automatically subscribe to Producer

Hello, I’m new to media soup, really excited to work with it. I’m integrating socket io through one of the examples. I’m trying to navigate auto subscribing peers as they come into a “room”. Is there a convention in approaching this? I’m able to pass peerIds and peerDevice data around in the signaling but having trouble resolving the actual peer connection that is “producer”. My thought is when producer enable cam it auto subscribes the rest of the peers to producer’s feed. I may be complicating the approach… Perhaps there’s a more direct way? Been through documentation and happy for any guidance. Thanks!

-Luis

There is full API documentation and there are example projects. I’m afraid we cannot provide much more guidelines.

mediasoup is a low level library. It’s up to you how to store and how to communicate different “peers” (note that mediasoup does not even define “peers”, that’s a concept at the application level).

1 Like

I understand that mediasoup doesn’t define peers … I’ve been looking at examples and documentation … I was just looking for some guidance since I don’t believe the behavior that I’m inquiring currently exists in the examples. I appreciate the work you’ve done on this so thank you for responding.

Ok. Try to explain in more detail the exact issue you have and we’ll try to help. Specify among others whether you mean client side or server side.

In my case, I have “peers” or “sockets”(socket io) coming into a router or “room”. When a producer is created I would like to auto connect the current sockets that are in the router to the producers transport. I’m not sure if I should focus on achieving this in the client or attempt to work it out on the server side? From what I understand, and correct me if I’m wrong, in my case, the actual socket and device object of the producer needs to be provided to the other sockets so they can begin to create the receive transport to the producer?

I don’t fully understand what you mean. IMHO users should already be “connected” via “sockets” (socket.io in your case) once they “connect” to the same room.

Once a Producer is created in server side, your server logic should decide which peers should receive the media of that Producer and should create a Consumer for each of them (in an already created WebRtcTransport). Then your server side app should signal the Consumer parameters (plus the “peerId” of the producing peer) to each remote participant.

Please take a look to this: mediasoup :: Communication Between Client and Server