提交 5be7578a authored 作者: José Luis Millán's avatar José Luis Millán

Worker Transport: add send/recv options to mirror socket

上级 05d633c4
......@@ -59,8 +59,10 @@ namespace RTC
{
std::string remoteIP;
uint16_t remotePort;
bool rtp{ true };
bool rtcp{ true };
bool sendRtp{ true };
bool sendRtcp{ true };
bool recvRtp{ true };
bool recvRtcp{ true };
};
public:
......
......@@ -125,6 +125,10 @@ namespace RTC
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
// Mirror RTP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.sendRtp)
this->mirrorTuple->Send(data, len);
this->tuple->Send(data, len);
}
......@@ -138,6 +142,10 @@ namespace RTC
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
// Mirror RTCP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.sendRtcp)
this->mirrorTuple->Send(data, len);
this->tuple->Send(data, len);
}
......@@ -156,6 +164,10 @@ namespace RTC
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
// Mirror RTCP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.sendRtcp)
this->mirrorTuple->Send(data, len);
this->tuple->Send(data, len);
}
......@@ -185,7 +197,7 @@ namespace RTC
MS_TRACE();
// Mirror RTP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.rtp)
if (this->mirrorTuple != nullptr && this->mirroringOptions.recvRtp)
this->mirrorTuple->Send(data, len);
RTC::RtpPacket* packet = RTC::RtpPacket::Parse(data, len);
......@@ -243,7 +255,7 @@ namespace RTC
MS_TRACE();
// Mirror RTCP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.rtcp)
if (this->mirrorTuple != nullptr && this->mirroringOptions.recvRtcp)
this->mirrorTuple->Send(data, len);
RTC::RTCP::Packet* packet = RTC::RTCP::Packet::Parse(data, len);
......
......@@ -828,8 +828,10 @@ namespace RTC
{
static const Json::StaticString JsonStringRemoteIP{ "remoteIP" };
static const Json::StaticString JsonStringRemotePort{ "remotePort" };
static const Json::StaticString JsonStringRtp{ "rtp" };
static const Json::StaticString JsonStringRtcp{ "rtcp" };
static const Json::StaticString JsonStringSendRtp{ "sendRtp" };
static const Json::StaticString JsonStringSendRtcp{ "sendRtcp" };
static const Json::StaticString JsonStringRecvRtp{ "recvRtp" };
static const Json::StaticString JsonStringRecvRtcp{ "recvRtcp" };
RTC::Transport* transport;
......@@ -856,10 +858,14 @@ namespace RTC
options.remotePort = request->data[JsonStringRemotePort].asUInt();
if (request->data[JsonStringRtp].isBool())
options.rtp = request->data[JsonStringRtp].asBool();
if (request->data[JsonStringRtcp].isBool())
options.rtcp = request->data[JsonStringRtcp].asBool();
if (request->data[JsonStringSendRtp].isBool())
options.sendRtp = request->data[JsonStringSendRtp].asBool();
if (request->data[JsonStringSendRtcp].isBool())
options.sendRtcp = request->data[JsonStringSendRtcp].asBool();
if (request->data[JsonStringRecvRtp].isBool())
options.recvRtp = request->data[JsonStringRecvRtp].asBool();
if (request->data[JsonStringRecvRtcp].isBool())
options.recvRtcp = request->data[JsonStringRecvRtcp].asBool();
try
{
......
......@@ -556,6 +556,10 @@ namespace RTC
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
// Mirror RTP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.sendRtp)
this->mirrorTuple->Send(data, len);
if (!this->srtpSendSession->EncryptRtp(&data, &len))
return;
......@@ -569,6 +573,13 @@ namespace RTC
if (!IsConnected())
return;
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
// Mirror RTCP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.sendRtcp)
this->mirrorTuple->Send(data, len);
// Ensure there is sending SRTP session.
if (this->srtpSendSession == nullptr)
{
......@@ -577,9 +588,6 @@ namespace RTC
return;
}
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
if (!this->srtpSendSession->EncryptRtcp(&data, &len))
return;
......@@ -657,6 +665,13 @@ namespace RTC
if (!IsConnected())
return;
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
// Mirror RTCP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.sendRtcp)
this->mirrorTuple->Send(data, len);
// Ensure there is sending SRTP session.
if (this->srtpSendSession == nullptr)
{
......@@ -665,9 +680,6 @@ namespace RTC
return;
}
const uint8_t* data = packet->GetData();
size_t len = packet->GetSize();
if (!this->srtpSendSession->EncryptRtcp(&data, &len))
return;
......@@ -808,7 +820,7 @@ namespace RTC
}
// Mirror RTP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.rtp)
if (this->mirrorTuple != nullptr && this->mirroringOptions.recvRtp)
this->mirrorTuple->Send(data, len);
RTC::RtpPacket* packet = RTC::RtpPacket::Parse(data, len);
......@@ -904,7 +916,7 @@ namespace RTC
return;
// Mirror RTCP if needed.
if (this->mirrorTuple != nullptr && this->mirroringOptions.rtcp)
if (this->mirrorTuple != nullptr && this->mirroringOptions.recvRtcp)
this->mirrorTuple->Send(data, len);
RTC::RTCP::Packet* packet = RTC::RTCP::Packet::Parse(data, len);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论