Mediasoup Learning Notes
A simple mediasoup demo is used in learning.
Steps of Producing Media
For a mediasoup based server application, media should first be produced, which means inputing media data into mediasoup. Now, we assumes there is only one router. The following are the basic steps:
- Client connects to mediasoup server. This step isn’t included in the mediasoup part, but in the signaling system.
- Client gets rtp capabilities from server, and do some check on it.
- Client creates a device (such as mediasoup.Device), using rtp capabilities. It represents an endpoint connecting to a mediasoup router.
- Client signals to server, requesting it to create a server-side webrtc transport, which is used to receive media data later. And server passes created transport info back to client.
- Client uses server-side webrtc transport info to create a send transport, to send media to server later.
- Provide client send transport info to server-side transport.
- Client sends video/audio track info to server (using transport.produce).
- Server instructs the router to receive audio/video data.
Steps of Consuming Media
- Client connects to mediasoup server, to get existing routers and other information.
- Client creates a device to represent the local endpoint.
- Client signals to server, requesting it to create a server-side webrtc transport, used to send media data later. And server passes the created transport info back to client.
- Client creates receive transport using remote endpoint transport data, and starts consuming.
- Client signals to server when receive transport is ready. Server inputs the client-side transport info into server-side transport.
- Server receives consume signal and creates a consumer, with specific producer.