提交 e8f218d7 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

worker: Transport closure also closes its handled Producers and Consumers.

上级 670a5f6c
# TODO in mediasoup v2 (server-side) # TODO in mediasoup v2 (server-side)
* When a producer is locally closed, the remote `RtpListener.RemoveProducer()` is not called. The question is: how to tell the transport of the producer about this? * JS: Do we need to close Producers/Consumers in Peer.close? If we close Transports then Producers and Consumers get also closed in the worker. The C++ Transport closes all its Producers and Consumers, and the client side gets producer.on('unhandled'), there is no need to close/destroy its local Producer.
- Yes, double listeners... - So, do we need to `producerClosed` notification? I don't think so...
* Does `PRODUCER_SEND` makes sense? why not just requiring RTP parameters (and mapping) in the constructor? ```js
// On Transport closure close the Producer.
transport.on('@close', () =>
{
if (!producer.closed)
producer.close();
});
```
* If a Transport is closed, Producers using it do not realize, and will crash if they try to send RTCP or whatever.
- Yep, we'd should just close Producers if their Transport is closed.
- Not sure if the same for Consumers. Let's see.
* Does `CONSUMER_ENABLE` makes sense? IMHO it's better to keep the Consumer just in JS and call `CREATE_CONSUMER` (by passing `rtpParameters` and `transportId`) once enabled for reception in JS. * Does `CONSUMER_ENABLE` makes sense? IMHO it's better to keep the Consumer just in JS and call `CREATE_CONSUMER` (by passing `rtpParameters` and `transportId`) once enabled for reception in JS.
- I've removed it. - I've removed it.
- mmm... not sure.
* Handle all the XXXXX_CLOSE in the parent by calling `xxxxx->Destroy()`. * Remove all the "close" events in C++. May be leave the `transport.on('close')`.
* Remove all the "close" events in C++.
* Move the RTCP timer from Peer to Transport. * Move the RTCP timer from Peer to Transport.
* worker `Producer` / `Consumer` may need various listeners, so `Add/RemoveListener(listener)` is required.
* `then()` of Promises is async so if we create an instance (Peer, Producer, Transport, etc) within the `channel.request().then(....)` and an event happens for that instance immediately, such an event may be lost. * `then()` of Promises is async so if we create an instance (Peer, Producer, Transport, etc) within the `channel.request().then(....)` and an event happens for that instance immediately, such an event may be lost.
- The solution is creating the instance before calling `channel.request()`. - The solution is creating the instance before calling `channel.request()`.
- DOC: https://stackoverflow.com/questions/36726890/why-are-javascript-promises-asynchronous-when-calling-only-synchronous-functions - DOC: https://stackoverflow.com/questions/36726890/why-are-javascript-promises-asynchronous-when-calling-only-synchronous-functions
...@@ -23,6 +31,7 @@ ...@@ -23,6 +31,7 @@
- "The callback passed to a Promise constructor is always called synchronously, but the callbacks passed into then are always called asynchronously" - "The callback passed to a Promise constructor is always called synchronously, but the callbacks passed into then are always called asynchronously"
* worker: If a `Producer` is paused and a new `Peer` joins (so a new `Consumer` is generated) such a new `Consumer` does not know that its associated `Producer` is paused. When creating a `Consumer` the `Room` should check `producer->IsPaused()` and call `consumer->setSourcePaused(true)` or similar. * worker: If a `Producer` is paused and a new `Peer` joins (so a new `Consumer` is generated) such a new `Consumer` does not know that its associated `Producer` is paused. When creating a `Consumer` the `Room` should check `producer->IsPaused()` and call `consumer->setSourcePaused(true)` or similar.
- NOTE: Won't happen with the new design since that's done in JS land.
* If the transport of a consumer is closed, and the consumer was "enabled", it should become "disabled" and emit event (and send `consumerDisabled` notification? I think yes. Enabled should mean "it has a transport and RTP parameters. * If the transport of a consumer is closed, and the consumer was "enabled", it should become "disabled" and emit event (and send `consumerDisabled` notification? I think yes. Enabled should mean "it has a transport and RTP parameters.
- NOTE: We don't need `consumerDisabled` since we already receive `transportClosed` which fires `unhandled` in the client's `Consumer`. - NOTE: We don't need `consumerDisabled` since we already receive `transportClosed` which fires `unhandled` in the client's `Consumer`.
......
...@@ -636,6 +636,9 @@ class Peer extends EnhancedEventEmitter ...@@ -636,6 +636,9 @@ class Peer extends EnhancedEventEmitter
this._sendNotification(method, data2); this._sendNotification(method, data2);
}); });
// TODO: Do we need this? The C++ Transport closes all its Producers and
// Consumers, and the client side gets producer.on('unhandled'), there is
// no need to close/destroy its local Producer.
// On Transport closure close the Producer. // On Transport closure close the Producer.
transport.on('@close', () => transport.on('@close', () =>
{ {
......
...@@ -235,15 +235,15 @@ namespace RTC ...@@ -235,15 +235,15 @@ namespace RTC
this->selectedTuple = nullptr; this->selectedTuple = nullptr;
// Remove us from as listener in our handled Producers and Consumers. // Close all the handled Producers and Consumers.
for (auto& producer : this->producers) for (auto& producer : this->producers)
{ {
producer->RemoveListener(this); producer->Destroy();
} }
for (auto& consumer : this->consumers) for (auto& consumer : this->consumers)
{ {
consumer->RemoveListener(this); consumer->Destroy();
} }
// TODO: yes? May be since we allow Transport being closed from on DtlsTransport // TODO: yes? May be since we allow Transport being closed from on DtlsTransport
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论