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

Some work done in RtpReceiver and RtpSender.

上级 c21757a0
......@@ -40,11 +40,11 @@ namespace RTC
RTC::Transport* GetTransport();
void RemoveTransport(RTC::Transport* transport);
RTC::RtpParameters* GetParameters();
RTC::RtpParameters* GetSenderParameters();
void SetPayloadMapping(); // TODO
void CreateSenderParameters(); // TODO
void ReceiveRtpPacket(RTC::RtpPacket* packet);
private:
void FillRtpParameters();
public:
// Passed by argument.
uint32_t rtpReceiverId;
......@@ -57,7 +57,6 @@ namespace RTC
RTC::Transport* transport = nullptr;
// Allocated by this.
RTC::RtpParameters* rtpParameters = nullptr;
RTC::RtpParameters* senderRtpParameters = nullptr;
// Others.
bool rtpRawEventEnabled = false;
bool rtpObjectEventEnabled = false;
......@@ -89,12 +88,6 @@ namespace RTC
{
return this->rtpParameters;
}
inline
RTC::RtpParameters* RtpReceiver::GetSenderParameters()
{
return this->senderRtpParameters;
}
}
#endif
......@@ -48,8 +48,10 @@ namespace RTC
Listener* listener = nullptr;
Channel::Notifier* notifier = nullptr;
RTC::Transport* transport = nullptr;
RTC::RtpParameters* rtpParameters = nullptr;
RTC::RtpCapabilities* peerCapabilities = nullptr;
// Allocated by this.
RTC::RtpParameters* rtpParameters = nullptr;
// Others.
// Whether this RtpSender is valid according to Peer capabilities.
bool available = false;
};
......
......@@ -560,9 +560,6 @@ namespace RTC
if (transport)
transport->AddRtpReceiver(rtpReceiver);
// TODO
rtpReceiver->CreateSenderParameters();
// Notify the listener (Room).
this->listener->onPeerRtpReceiverParametersDone(this, rtpReceiver);
}
......
......@@ -260,8 +260,8 @@ namespace RTC
// Store into the map.
this->mapRtpReceiverRtpSenders[rtpReceiver].insert(rtpSender);
// Take the sender parameters of the receiver.
rtpSender->Send(rtpReceiver->GetSenderParameters());
// Provide the RtpSender with the parameters of the RtpReceiver.
rtpSender->Send(rtpReceiver->GetParameters());
// Attach the RtpSender to peer.
peer->AddRtpSender(rtpSender, receiver_peer->peerName);
......@@ -499,7 +499,6 @@ namespace RTC
MS_TRACE();
auto rtpParameters = rtpReceiver->GetParameters();
std::unordered_map<uint8_t, RTC::RtpCodecParameters*> mapPyloadTypeRtpCodecParameters;
// Check codecs availability. If it fails, throw.
......@@ -550,8 +549,8 @@ namespace RTC
// Store into the map.
this->mapRtpReceiverRtpSenders[rtpReceiver].insert(rtpSender);
// Take the sender parameters of the receiver.
rtpSender->Send(rtpReceiver->GetSenderParameters());
// Provide the RtpSender with the parameters of the RtpReceiver.
rtpSender->Send(rtpReceiver->GetParameters());
// Attach the RtpSender to sender_peer.
sender_peer->AddRtpSender(rtpSender, peer->peerName);
......@@ -563,8 +562,8 @@ namespace RTC
{
for (auto rtpSender : this->mapRtpReceiverRtpSenders[rtpReceiver])
{
// Take the sender parameters of the receiver.
rtpSender->Send(rtpReceiver->GetSenderParameters());
// Provide the RtpSender with the parameters of the RtpReceiver.
rtpSender->Send(rtpReceiver->GetParameters());
}
}
}
......
......@@ -34,9 +34,6 @@ namespace RTC
if (this->rtpParameters)
delete this->rtpParameters;
if (this->senderRtpParameters)
delete this->senderRtpParameters;
// Notify.
event_data[k_class] = "RtpReceiver";
this->notifier->Emit(this->rtpReceiverId, "close", event_data);
......@@ -138,12 +135,16 @@ namespace RTC
}
// Free the previous rtpParameters.
delete previousRtpParameters;
if (previousRtpParameters)
delete previousRtpParameters;
Json::Value data = this->rtpParameters->toJson();
request->Accept(data);
// Fill RTP parameters.
FillRtpParameters();
break;
}
......@@ -237,17 +238,14 @@ namespace RTC
}
}
void RtpReceiver::CreateSenderParameters()
void RtpReceiver::FillRtpParameters()
{
MS_TRACE();
// Clone receiver parameters.
this->senderRtpParameters = new RTC::RtpParameters(this->rtpParameters);
// TODO: Must override payloadType/ssrc values in senderRtpParameters and
// override muxId, rtcp, etc.
// Set a random muxId.
this->senderRtpParameters->muxId = Utils::Crypto::GetRandomString(8);
this->rtpParameters->muxId = Utils::Crypto::GetRandomString(8);
// TODO: Fill SSRCs with random values and set some mechanism to replace
// SSRC values in received RTP packets to match the chosen random values.
}
}
......@@ -28,6 +28,9 @@ namespace RTC
static const Json::StaticString k_class("class");
if (this->rtpParameters)
delete this->rtpParameters;
Json::Value event_data(Json::objectValue);
event_data[k_class] = "RtpSender";
......@@ -106,23 +109,23 @@ namespace RTC
static const Json::StaticString k_rtpParameters("rtpParameters");
static const Json::StaticString k_available("available");
bool hadParameters = false;
auto previousRtpParameters = this->rtpParameters;
// Free the previous rtpParameters.
if (this->rtpParameters)
{
hadParameters = true;
if (previousRtpParameters)
delete this->rtpParameters;
}
this->rtpParameters = rtpParameters;
// Clone given RTP parameters so we manage our own sender parameters.
this->rtpParameters = new RTC::RtpParameters(rtpParameters);
// TODO: Must check new parameters to set this->available.
// TODO: Must check new parameters and:
// - remove unsuported capabilities,
// - set this->available if at least there is a capable encoding.
// For now make it easy:
this->available = true;
// Emit "updateparameters" if those are new parameters.
if (hadParameters)
if (previousRtpParameters)
{
Json::Value event_data(Json::objectValue);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论