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

Lot of work done in new design.

上级 683b7f3e
# TODO in mediasoup v2 (server-side) # TODO in mediasoup v2 (server-side)
* Does `PRODUCER_SEND` makes sense? why not just requiring RTP parameters (and mapping) in the constructor?
* 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.
* Handle all the XXXXX_CLOSE in the parent by calling `xxxxx->Destroy()`. * Handle all the XXXXX_CLOSE in the parent by calling `xxxxx->Destroy()`.
......
...@@ -30,9 +30,6 @@ namespace RTC ...@@ -30,9 +30,6 @@ namespace RTC
{ {
public: public:
virtual void OnProducerClosed(RTC::Producer* producer) = 0; virtual void OnProducerClosed(RTC::Producer* producer) = 0;
virtual void OnProducerRtpParameters(RTC::Producer* producer) = 0;
virtual void OnProducerPaused(RTC::Producer* producer) = 0;
virtual void OnProducerResumed(RTC::Producer* producer) = 0;
virtual void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) = 0; virtual void OnProducerRtpPacket(RTC::Producer* producer, RTC::RtpPacket* packet) = 0;
}; };
...@@ -51,7 +48,7 @@ namespace RTC ...@@ -51,7 +48,7 @@ namespace RTC
}; };
public: public:
Producer(Listener* listener, Channel::Notifier* notifier, uint32_t producerId, RTC::Media::Kind kind); Producer(Listener* listener, Channel::Notifier* notifier, uint32_t producerId, RTC::Media::Kind kind, RTC::Transport* transport);
private: private:
virtual ~Producer(); virtual ~Producer();
...@@ -60,11 +57,9 @@ namespace RTC ...@@ -60,11 +57,9 @@ namespace RTC
void Destroy(); void Destroy();
Json::Value ToJson() const; Json::Value ToJson() const;
void HandleRequest(Channel::Request* request); void HandleRequest(Channel::Request* request);
void SetTransport(RTC::Transport* transport); RTC::Transport* GetTransport() const; // TODO: YES?
RTC::Transport* GetTransport() const; void RemoveTransport(RTC::Transport* transport); // TODO: better close this.
void RemoveTransport(RTC::Transport* transport); RTC::RtpParameters* GetParameters() const; // TODO: What for?
RTC::RtpParameters* GetParameters() const;
bool IsPaused() const;
void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtpPacket(RTC::RtpPacket* packet);
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report); void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now); void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now);
...@@ -110,11 +105,6 @@ namespace RTC ...@@ -110,11 +105,6 @@ namespace RTC
/* Inline methods. */ /* Inline methods. */
inline void Producer::SetTransport(RTC::Transport* transport)
{
this->transport = transport;
}
inline RTC::Transport* Producer::GetTransport() const inline RTC::Transport* Producer::GetTransport() const
{ {
return this->transport; return this->transport;
...@@ -131,11 +121,6 @@ namespace RTC ...@@ -131,11 +121,6 @@ namespace RTC
return this->rtpParameters; return this->rtpParameters;
} }
inline bool Producer::IsPaused() const
{
return this->paused;
}
inline void Producer::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report) inline void Producer::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report)
{ {
auto it = this->rtpStreams.find(report->GetSsrc()); auto it = this->rtpStreams.find(report->GetSsrc());
......
...@@ -37,9 +37,6 @@ namespace RTC ...@@ -37,9 +37,6 @@ namespace RTC
{ {
public: public:
virtual void OnTransportClosed(RTC::Transport* transport) = 0; virtual void OnTransportClosed(RTC::Transport* transport) = 0;
virtual void OnTransportConnected(RTC::Transport* transport) = 0;
virtual void OnTransportRtcpPacket(RTC::Transport* transport, RTC::RTCP::Packet* packet) = 0;
virtual void OnTransportFullFrameRequired(RTC::Transport* transport) = 0;
}; };
public: public:
......
...@@ -14,7 +14,7 @@ namespace Channel ...@@ -14,7 +14,7 @@ namespace Channel
{ {
{ "worker.dump", Request::MethodId::WORKER_DUMP }, { "worker.dump", Request::MethodId::WORKER_DUMP },
{ "worker.updateSettings", Request::MethodId::WORKER_UPDATE_SETTINGS }, { "worker.updateSettings", Request::MethodId::WORKER_UPDATE_SETTINGS },
{ "worker.createRouter", Request::MethodId::WORKER_CREATE_ROTER }, { "worker.createRouter", Request::MethodId::WORKER_CREATE_ROUTER },
{ "router.close", Request::MethodId::ROUTER_CLOSE }, { "router.close", Request::MethodId::ROUTER_CLOSE },
{ "router.dump", Request::MethodId::ROUTER_DUMP }, { "router.dump", Request::MethodId::ROUTER_DUMP },
{ "router.createTransport", Request::MethodId::ROUTER_CREATE_TRANSPORT }, { "router.createTransport", Request::MethodId::ROUTER_CREATE_TRANSPORT },
......
...@@ -14,8 +14,8 @@ namespace RTC ...@@ -14,8 +14,8 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
Producer::Producer( Producer::Producer(
Listener* listener, Channel::Notifier* notifier, uint32_t producerId, RTC::Media::Kind kind) Listener* listener, Channel::Notifier* notifier, uint32_t producerId, RTC::Media::Kind kind, RTC::Transport* transport)
: producerId(producerId), kind(kind), listener(listener), notifier(notifier) : producerId(producerId), kind(kind), listener(listener), notifier(notifier), transport(transport)
{ {
MS_TRACE(); MS_TRACE();
...@@ -165,9 +165,6 @@ namespace RTC ...@@ -165,9 +165,6 @@ namespace RTC
// NOTE: This may throw. // NOTE: This may throw.
CreateRtpMapping(request->data[JsonStringRtpMapping]); CreateRtpMapping(request->data[JsonStringRtpMapping]);
// NOTE: This may throw.
this->listener->OnProducerRtpParameters(this);
} }
catch (const MediaSoupError& error) catch (const MediaSoupError& error)
{ {
...@@ -195,15 +192,10 @@ namespace RTC ...@@ -195,15 +192,10 @@ namespace RTC
case Channel::Request::MethodId::PRODUCER_PAUSE: case Channel::Request::MethodId::PRODUCER_PAUSE:
{ {
bool wasPaused = this->paused;
this->paused = true; this->paused = true;
request->Accept(); request->Accept();
if (!wasPaused)
this->listener->OnProducerPaused(this);
break; break;
} }
...@@ -216,10 +208,7 @@ namespace RTC ...@@ -216,10 +208,7 @@ namespace RTC
request->Accept(); request->Accept();
if (wasPaused) if (wasPaused)
{
this->listener->OnProducerResumed(this);
RequestFullFrame(); RequestFullFrame();
}
break; break;
} }
...@@ -626,6 +615,7 @@ namespace RTC ...@@ -626,6 +615,7 @@ namespace RTC
void Producer::OnPliRequired(RTC::RtpStreamRecv* rtpStream) void Producer::OnPliRequired(RTC::RtpStreamRecv* rtpStream)
{ {
// TODO: Can this happen?
if (this->transport == nullptr) if (this->transport == nullptr)
return; return;
......
...@@ -268,7 +268,7 @@ namespace RTC ...@@ -268,7 +268,7 @@ namespace RTC
// Create a Producer instance. // Create a Producer instance.
try try
{ {
producer = new RTC::Producer(this, this->notifier, producerId, RTC::Media::GetKind(kind)); producer = new RTC::Producer(this, this->notifier, producerId, RTC::Media::GetKind(kind), transport);
} }
catch (const MediaSoupError& error) catch (const MediaSoupError& error)
{ {
...@@ -281,9 +281,6 @@ namespace RTC ...@@ -281,9 +281,6 @@ namespace RTC
MS_DEBUG_DEV("Producer created [producerId:%" PRIu32 "]", producerId); MS_DEBUG_DEV("Producer created [producerId:%" PRIu32 "]", producerId);
// Set the Transport.
producer->SetTransport(transport);
request->Accept(); request->Accept();
break; break;
...@@ -602,16 +599,15 @@ namespace RTC ...@@ -602,16 +599,15 @@ namespace RTC
this->producers.erase(producer->producerId); this->producers.erase(producer->producerId);
// If the Producer is not in the map, do nothing. // Remove the Producer from the map.
if (this->mapProducerConsumers.find(producer) == this->mapProducerConsumers.end()) if (this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end())
return; {
// Iterate the map and close all the Consumers associated to it. // Iterate the map and close all the Consumers associated to it.
auto& consumers = this->mapProducerConsumers[producer]; auto& consumers = this->mapProducerConsumers[producer];
for (auto it = this->consumers.begin(); it != this->consumers.end();) for (auto it = consumers.begin(); it != consumers.end();)
{ {
auto* consumer = it->second; auto* consumer = *it;
it = consumers.erase(it); it = consumers.erase(it);
consumer->Destroy(); consumer->Destroy();
...@@ -619,6 +615,7 @@ namespace RTC ...@@ -619,6 +615,7 @@ namespace RTC
// Finally delete the Producer entry in the map. // Finally delete the Producer entry in the map.
this->mapProducerConsumers.erase(producer); this->mapProducerConsumers.erase(producer);
}
// Also delete it from the map of audio levels. // Also delete it from the map of audio levels.
this->mapProducerAudioLevelContainer.erase(producer); this->mapProducerAudioLevelContainer.erase(producer);
...@@ -639,6 +636,7 @@ namespace RTC ...@@ -639,6 +636,7 @@ namespace RTC
for (auto& consumer : consumers) for (auto& consumer : consumers)
{ {
// TODO: just if enabled? // TODO: just if enabled?
// Mmmm, can it be "non" enabled? how?
consumer->SendRtpPacket(packet); consumer->SendRtpPacket(packet);
} }
...@@ -679,7 +677,7 @@ namespace RTC ...@@ -679,7 +677,7 @@ namespace RTC
this->mapConsumerProducer.erase(consumer); this->mapConsumerProducer.erase(consumer);
} }
void Peer::OnConsumerFullFrameRequired(RTC::Consumer* consumer) void Router::OnConsumerFullFrameRequired(RTC::Consumer* consumer)
{ {
MS_TRACE(); MS_TRACE();
...@@ -720,7 +718,7 @@ namespace RTC ...@@ -720,7 +718,7 @@ namespace RTC
Json::Value entry(Json::arrayValue); Json::Value entry(Json::arrayValue);
entry.append(Json::UInt{ producer.producerId }); entry.append(Json::UInt{ producer->producerId });
entry.append(Json::Int{ avgdBov }); entry.append(Json::Int{ avgdBov });
eventData[JsonStringEntries].append(entry); eventData[JsonStringEntries].append(entry);
......
...@@ -936,7 +936,10 @@ namespace RTC ...@@ -936,7 +936,10 @@ namespace RTC
return; return;
} }
this->listener->OnTransportRtcpPacket(this, packet); // TODO: No. Instead, process here the packet, get corresponding producers/consumers
// and do stuff here. We may need another listener callback to forward certain
// RTCP messages between consumers and is producers. Let's see.
// this->listener->OnTransportRtcpPacket(this, packet);
// Trick for clients performing aggressive ICE regardless we are ICE-Lite. // Trick for clients performing aggressive ICE regardless we are ICE-Lite.
// this->iceServer->ForceSelectedTuple(tuple); // this->iceServer->ForceSelectedTuple(tuple);
...@@ -1148,7 +1151,8 @@ namespace RTC ...@@ -1148,7 +1151,8 @@ namespace RTC
eventData[JsonStringDtlsRemoteCert] = remoteCert; eventData[JsonStringDtlsRemoteCert] = remoteCert;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData); this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
this->listener->OnTransportConnected(this); // TODO: No. Instead iterate consumers and request full frame.
// this->listener->OnTransportConnected(this);
} }
void Transport::OnDtlsFailed(const RTC::DtlsTransport* /*dtlsTransport*/) void Transport::OnDtlsFailed(const RTC::DtlsTransport* /*dtlsTransport*/)
...@@ -1260,7 +1264,8 @@ namespace RTC ...@@ -1260,7 +1264,8 @@ namespace RTC
{ {
MS_WARN_TAG(rbe, "uplink effective max bitrate abruptly decrease, requesting full frames"); MS_WARN_TAG(rbe, "uplink effective max bitrate abruptly decrease, requesting full frames");
this->listener->OnTransportFullFrameRequired(this); // TODO: No. Iterate producers and call RequestFullFrame() on them.
// this->listener->OnTransportFullFrameRequired(this);
} }
this->lastEffectiveMaxBitrateAt = now; this->lastEffectiveMaxBitrateAt = now;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论