What's the trick to remove media sections with Unified Plan?

Hey everyone,

trying my luck here as it’s not really mediasoup-specific, but mediasoup does it in a smart way I cannot seem to figure out.

When consumers are closed that are not related to the very first mid of a transport, mediasoup actually completely removes them from the SDP. However, when I try to replicate this behavior in my custom Android client that communicates with mediasoup, I always end up with peer connection errors stating that the order of m-lines has changed.

Is this simply a difference between the browser implementations and Android being more strict, or is there something special that needs to be done in order to avoid this issue when setting a new description with removed values? I’d really love to clean up my SDPs a little bit as having 20+ m-lines at some point is just ridiculous when just two streams are still running.

Any advice appreciated :).