Feature suggestion: producer.on("consumerpause", fn) and producer.on("consumerresume", fn) events

Analogous to consumer.on(“producerpause”, fn()) and consumer.on(“producerresume”, fn())

I think it would be:

  1. A more consistent API across producers and consumers.
  2. Easier to maintain for application developers on top of mediasoup.

Please let me know what you think. I could try to implement this if it’s of interest.

A Producer has many associated Consumer, not just one.

Yes, so we would pass the consumer(Id) in the fn as a parameter.

I see. However I do not see the benefit of this and if we do this we should also emit producer.on('consumerclose'), producer.on('consumerlayerschange'), etc etc.

We need to emit producerpause in a Consumer because when a Producer is paused it affects to its Consumers. The opposite is not true.

So if you want to do something in the Producer when one of its Consumers is paused, you can do it at JS level within your application. No need to add it to mediasoup.

Indeed, they would be just convenience events that are definitely doable at app level.

But I could argue that the same is true for producerpause and producerresume not only because they are also doable at app level, but also because one needs to call producer.pause() and producer.resume() in order to trigger them. But I do agree that it’s not exactly the same case.

Right, good point. Consider that an exception. We try to never generate events that are triggered due to user actions. However, when the action is done on an entity and it affects other entities, we do generate events in those other entities.

OK, cool!