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