mediasoup icon indicating copy to clipboard operation
mediasoup copied to clipboard

consumer#resume/pause not working as it should

Open conradbekondo opened this issue 2 years ago • 2 comments

Bug Report

Your environment

  • Operating system: WSL Ubuntu
  • Node version: 21.6.2
  • npm version: 10.5.0
  • gcc/clang version: GCC v11.4.0
  • mediasoup version: 3.13.23
  • mediasoup-client version: 3.7.6

Issue description

When a consumer is created with paused: true, toggling the paused state of the consumer subsequently does not change the state of the consumer. The code and logs can be seen below.

Code Snippet

  async toggleConsumer(consumerId: string) {
    const consumer = this.consumers[consumerId];
    if (!consumer) throw new NotFoundException('Consumer not found');
    this.logger.debug(`Consumer State before toggling: paused = ${consumer.paused}`);
    if (consumer.paused) await consumer.resume();
    await consumer.pause();
    this.logger.debug(`Consumer State after toggling: paused = ${consumer.paused}`);

    const ans = { paused: consumer.paused };
    return ans;
  }

Logs image

conradbekondo avatar Jul 18 '24 01:07 conradbekondo

if (consumer.paused) await consumer.resume(); await consumer.pause();

You are literally pausing it after resuming it so of course it will be paused.

No bug here. There are tons of unit tests about this.

ibc avatar Jul 18 '24 07:07 ibc

if (consumer.paused) await consumer.resume(); await consumer.pause();

You are literally pausing it after resuming it so of course it will be paused.

No bug here. There are tons of unit tests about this.

Oh. I'm so sorry about this, I can't believe I didn't see that after looking at it over 10 times. Thanks.

conradbekondo avatar Jul 18 '24 14:07 conradbekondo