提交 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)
* 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.
- I've removed it.
* Handle all the XXXXX_CLOSE in the parent by calling `xxxxx->Destroy()`.
......
......@@ -30,9 +30,6 @@ namespace RTC
{
public:
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;
};
......@@ -51,7 +48,7 @@ namespace RTC
};
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:
virtual ~Producer();
......@@ -60,11 +57,9 @@ namespace RTC
void Destroy();
Json::Value ToJson() const;
void HandleRequest(Channel::Request* request);
void SetTransport(RTC::Transport* transport);
RTC::Transport* GetTransport() const;
void RemoveTransport(RTC::Transport* transport);
RTC::RtpParameters* GetParameters() const;
bool IsPaused() const;
RTC::Transport* GetTransport() const; // TODO: YES?
void RemoveTransport(RTC::Transport* transport); // TODO: better close this.
RTC::RtpParameters* GetParameters() const; // TODO: What for?
void ReceiveRtpPacket(RTC::RtpPacket* packet);
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
void GetRtcp(RTC::RTCP::CompoundPacket* packet, uint64_t now);
......@@ -110,11 +105,6 @@ namespace RTC
/* Inline methods. */
inline void Producer::SetTransport(RTC::Transport* transport)
{
this->transport = transport;
}
inline RTC::Transport* Producer::GetTransport() const
{
return this->transport;
......@@ -131,11 +121,6 @@ namespace RTC
return this->rtpParameters;
}
inline bool Producer::IsPaused() const
{
return this->paused;
}
inline void Producer::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report)
{
auto it = this->rtpStreams.find(report->GetSsrc());
......
......@@ -36,10 +36,7 @@ namespace RTC
class Listener
{
public:
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;
virtual void OnTransportClosed(RTC::Transport* transport) = 0;
};
public:
......
......@@ -14,7 +14,7 @@ namespace Channel
{
{ "worker.dump", Request::MethodId::WORKER_DUMP },
{ "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.dump", Request::MethodId::ROUTER_DUMP },
{ "router.createTransport", Request::MethodId::ROUTER_CREATE_TRANSPORT },
......
......@@ -14,8 +14,8 @@ namespace RTC
/* Instance methods. */
Producer::Producer(
Listener* listener, Channel::Notifier* notifier, uint32_t producerId, RTC::Media::Kind kind)
: producerId(producerId), kind(kind), listener(listener), notifier(notifier)
Listener* listener, Channel::Notifier* notifier, uint32_t producerId, RTC::Media::Kind kind, RTC::Transport* transport)
: producerId(producerId), kind(kind), listener(listener), notifier(notifier), transport(transport)
{
MS_TRACE();
......@@ -165,9 +165,6 @@ namespace RTC
// NOTE: This may throw.
CreateRtpMapping(request->data[JsonStringRtpMapping]);
// NOTE: This may throw.
this->listener->OnProducerRtpParameters(this);
}
catch (const MediaSoupError& error)
{
......@@ -195,15 +192,10 @@ namespace RTC
case Channel::Request::MethodId::PRODUCER_PAUSE:
{
bool wasPaused = this->paused;
this->paused = true;
request->Accept();
if (!wasPaused)
this->listener->OnProducerPaused(this);
break;
}
......@@ -216,10 +208,7 @@ namespace RTC
request->Accept();
if (wasPaused)
{
this->listener->OnProducerResumed(this);
RequestFullFrame();
}
break;
}
......@@ -626,6 +615,7 @@ namespace RTC
void Producer::OnPliRequired(RTC::RtpStreamRecv* rtpStream)
{
// TODO: Can this happen?
if (this->transport == nullptr)
return;
......
......@@ -268,7 +268,7 @@ namespace RTC
// Create a Producer instance.
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)
{
......@@ -281,9 +281,6 @@ namespace RTC
MS_DEBUG_DEV("Producer created [producerId:%" PRIu32 "]", producerId);
// Set the Transport.
producer->SetTransport(transport);
request->Accept();
break;
......@@ -602,24 +599,24 @@ namespace RTC
this->producers.erase(producer->producerId);
// If the Producer is not in the map, do nothing.
if (this->mapProducerConsumers.find(producer) == this->mapProducerConsumers.end())
return;
// Remove the Producer from the map.
if (this->mapProducerConsumers.find(producer) != this->mapProducerConsumers.end())
{
// Iterate the map and close all the Consumers associated to it.
auto& consumers = this->mapProducerConsumers[producer];
// Iterate the map and close all the Consumers associated to it.
auto& consumers = this->mapProducerConsumers[producer];
for (auto it = consumers.begin(); it != consumers.end();)
{
auto* consumer = *it;
for (auto it = this->consumers.begin(); it != this->consumers.end();)
{
auto* consumer = it->second;
it = consumers.erase(it);
consumer->Destroy();
}
it = consumers.erase(it);
consumer->Destroy();
// Finally delete the Producer entry in the map.
this->mapProducerConsumers.erase(producer);
}
// Finally delete the Producer entry in the map.
this->mapProducerConsumers.erase(producer);
// Also delete it from the map of audio levels.
this->mapProducerAudioLevelContainer.erase(producer);
}
......@@ -639,6 +636,7 @@ namespace RTC
for (auto& consumer : consumers)
{
// TODO: just if enabled?
// Mmmm, can it be "non" enabled? how?
consumer->SendRtpPacket(packet);
}
......@@ -679,7 +677,7 @@ namespace RTC
this->mapConsumerProducer.erase(consumer);
}
void Peer::OnConsumerFullFrameRequired(RTC::Consumer* consumer)
void Router::OnConsumerFullFrameRequired(RTC::Consumer* consumer)
{
MS_TRACE();
......@@ -720,7 +718,7 @@ namespace RTC
Json::Value entry(Json::arrayValue);
entry.append(Json::UInt{ producer.producerId });
entry.append(Json::UInt{ producer->producerId });
entry.append(Json::Int{ avgdBov });
eventData[JsonStringEntries].append(entry);
......
......@@ -936,7 +936,10 @@ namespace RTC
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.
// this->iceServer->ForceSelectedTuple(tuple);
......@@ -1148,7 +1151,8 @@ namespace RTC
eventData[JsonStringDtlsRemoteCert] = remoteCert;
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*/)
......@@ -1260,7 +1264,8 @@ namespace RTC
{
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;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论