提交 33d3bc88 authored 作者: José Luis Millán's avatar José Luis Millán

Rtcp: Move RTCP to its own namespace

上级 0de6be31
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "RTC/RtpSender.h" #include "RTC/RtpSender.h"
#include "RTC/RtpDictionaries.h" #include "RTC/RtpDictionaries.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RtcpPacket.h" #include "RTC/RTCP/Packet.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <string> #include <string>
...@@ -33,7 +33,7 @@ namespace RTC ...@@ -33,7 +33,7 @@ namespace RTC
virtual void onPeerRtpSenderClosed(RTC::Peer* peer, RTC::RtpSender* rtpSender) = 0; virtual void onPeerRtpSenderClosed(RTC::Peer* peer, RTC::RtpSender* rtpSender) = 0;
virtual void onPeerRtpPacket(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RtpPacket* packet) = 0; virtual void onPeerRtpPacket(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RtpPacket* packet) = 0;
// TODO: TMP // TODO: TMP
virtual void onPeerRtcpPacket(RTC::Peer* peer, RTC::RtcpPacket* packet) = 0; virtual void onPeerRtcpPacket(RTC::Peer* peer, RTC::RTCP::Packet* packet) = 0;
}; };
public: public:
...@@ -64,7 +64,7 @@ namespace RTC ...@@ -64,7 +64,7 @@ namespace RTC
public: public:
virtual void onTransportClosed(RTC::Transport* transport) override; virtual void onTransportClosed(RTC::Transport* transport) override;
// TODO: TMP // TODO: TMP
virtual void onTransportRtcpPacket(RTC::Transport* transport, RTC::RtcpPacket* packet) override; virtual void onTransportRtcpPacket(RTC::Transport* transport, RTC::RTCP::Packet* packet) override;
/* Pure virtual methods inherited from RTC::RtpReceiver::Listener. */ /* Pure virtual methods inherited from RTC::RtpReceiver::Listener. */
public: public:
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
namespace RTC namespace RTC
{ {
class RtcpPacket namespace RTCP
{
class Packet
{ {
public: public:
/* Struct for RTCP common header. */ /* Struct for RTCP common header. */
...@@ -26,11 +28,11 @@ namespace RTC ...@@ -26,11 +28,11 @@ namespace RTC
public: public:
static bool IsRtcp(const uint8_t* data, size_t len); static bool IsRtcp(const uint8_t* data, size_t len);
static RtcpPacket* Parse(const uint8_t* data, size_t len); static Packet* Parse(const uint8_t* data, size_t len);
public: public:
RtcpPacket(CommonHeader* header, const uint8_t* raw, size_t length); Packet(CommonHeader* header, const uint8_t* raw, size_t length);
~RtcpPacket(); ~Packet();
const uint8_t* GetRaw(); const uint8_t* GetRaw();
size_t GetLength(); size_t GetLength();
...@@ -45,7 +47,7 @@ namespace RTC ...@@ -45,7 +47,7 @@ namespace RTC
/* Inline static methods. */ /* Inline static methods. */
inline inline
bool RtcpPacket::IsRtcp(const uint8_t* data, size_t len) bool Packet::IsRtcp(const uint8_t* data, size_t len)
{ {
CommonHeader* header = (CommonHeader*)data; CommonHeader* header = (CommonHeader*)data;
...@@ -65,16 +67,17 @@ namespace RTC ...@@ -65,16 +67,17 @@ namespace RTC
/* Inline instance methods. */ /* Inline instance methods. */
inline inline
const uint8_t* RtcpPacket::GetRaw() const uint8_t* Packet::GetRaw()
{ {
return this->raw; return this->raw;
} }
inline inline
size_t RtcpPacket::GetLength() size_t Packet::GetLength()
{ {
return this->length; return this->length;
} }
} }
}
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "RTC/RtpReceiver.h" #include "RTC/RtpReceiver.h"
#include "RTC/RtpSender.h" #include "RTC/RtpSender.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RtcpPacket.h" #include "RTC/RTCP/Packet.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <unordered_map> #include <unordered_map>
...@@ -55,7 +55,7 @@ namespace RTC ...@@ -55,7 +55,7 @@ namespace RTC
virtual void onPeerRtpSenderClosed(RTC::Peer* peer, RTC::RtpSender* rtpSender) override; virtual void onPeerRtpSenderClosed(RTC::Peer* peer, RTC::RtpSender* rtpSender) override;
virtual void onPeerRtpPacket(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RtpPacket* packet) override; virtual void onPeerRtpPacket(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RtpPacket* packet) override;
// TODO: TMP // TODO: TMP
virtual void onPeerRtcpPacket(RTC::Peer* peer, RTC::RtcpPacket* packet) override; virtual void onPeerRtcpPacket(RTC::Peer* peer, RTC::RTCP::Packet* packet) override;
public: public:
// Passed by argument. // Passed by argument.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "RTC/Transport.h" #include "RTC/Transport.h"
#include "RTC/RtpDictionaries.h" #include "RTC/RtpDictionaries.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RtcpPacket.h" #include "RTC/RTCP/Packet.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <unordered_map> #include <unordered_map>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "RTC/RtpListener.h" #include "RTC/RtpListener.h"
#include "RTC/RtpReceiver.h" #include "RTC/RtpReceiver.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RtcpPacket.h" #include "RTC/RTCP/Packet.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <string> #include <string>
...@@ -36,7 +36,7 @@ namespace RTC ...@@ -36,7 +36,7 @@ namespace RTC
public: public:
virtual void onTransportClosed(RTC::Transport* transport) = 0; virtual void onTransportClosed(RTC::Transport* transport) = 0;
// TODO: TMP // TODO: TMP
virtual void onTransportRtcpPacket(RTC::Transport* transport, RTC::RtcpPacket* packet) = 0; virtual void onTransportRtcpPacket(RTC::Transport* transport, RTC::RTCP::Packet* packet) = 0;
}; };
public: public:
...@@ -49,7 +49,7 @@ namespace RTC ...@@ -49,7 +49,7 @@ namespace RTC
void AddRtpReceiver(RTC::RtpReceiver* rtpReceiver); void AddRtpReceiver(RTC::RtpReceiver* rtpReceiver);
void RemoveRtpReceiver(RTC::RtpReceiver* rtpReceiver); void RemoveRtpReceiver(RTC::RtpReceiver* rtpReceiver);
void SendRtpPacket(RTC::RtpPacket* packet); void SendRtpPacket(RTC::RtpPacket* packet);
void SendRtcpPacket(RTC::RtcpPacket* packet); void SendRtcpPacket(RTC::RTCP::Packet* packet);
private: private:
void MayRunDtlsTransport(); void MayRunDtlsTransport();
......
...@@ -651,7 +651,7 @@ namespace RTC ...@@ -651,7 +651,7 @@ namespace RTC
} }
// TODO: TMP // TODO: TMP
void Peer::onTransportRtcpPacket(RTC::Transport* transport, RTC::RtcpPacket* packet) void Peer::onTransportRtcpPacket(RTC::Transport* transport, RTC::RTCP::Packet* packet)
{ {
MS_TRACE(); MS_TRACE();
......
#define MS_CLASS "RTC::RtcpPacket" #define MS_CLASS "RTC::Packet"
#include "RTC/RtcpPacket.h" #include "RTC/RtcpPacket.h"
#include "Logger.h" #include "Logger.h"
namespace RTC namespace RTC
{
namespace RTCP
{ {
/* Class methods. */ /* Class methods. */
RtcpPacket* RtcpPacket::Parse(const uint8_t* data, size_t len) Packet* Packet::Parse(const uint8_t* data, size_t len)
{ {
MS_TRACE(); MS_TRACE();
if (!RtcpPacket::IsRtcp(data, len)) if (!Packet::IsRtcp(data, len))
return nullptr; return nullptr;
// TODO: just for now // TODO: just for now
CommonHeader* header = (CommonHeader*)data; CommonHeader* header = (CommonHeader*)data;
RtcpPacket* compoundPacket = new RtcpPacket(header, data, len); Packet* compoundPacket = new Packet(header, data, len);
// MS_DEBUG("RTCP compound packet parsing begins"); // MS_DEBUG("RTCP compound packet parsing begins");
...@@ -24,7 +26,7 @@ namespace RTC ...@@ -24,7 +26,7 @@ namespace RTC
while (more) while (more)
{ {
if (!RtcpPacket::IsRtcp(data, len)) if (!Packet::IsRtcp(data, len))
{ {
MS_WARN("data is not a RTCP packet"); MS_WARN("data is not a RTCP packet");
...@@ -77,7 +79,7 @@ namespace RTC ...@@ -77,7 +79,7 @@ namespace RTC
/* Instance methods. */ /* Instance methods. */
RtcpPacket::RtcpPacket(CommonHeader* header, const uint8_t* raw, size_t length) : Packet::Packet(CommonHeader* header, const uint8_t* raw, size_t length) :
header(header), header(header),
raw((uint8_t*)raw), raw((uint8_t*)raw),
length(length) length(length)
...@@ -85,8 +87,9 @@ namespace RTC ...@@ -85,8 +87,9 @@ namespace RTC
MS_TRACE(); MS_TRACE();
} }
RtcpPacket::~RtcpPacket() Packet::~Packet()
{ {
MS_TRACE(); MS_TRACE();
} }
} }
}
...@@ -596,7 +596,7 @@ namespace RTC ...@@ -596,7 +596,7 @@ namespace RTC
} }
// TODO: TMP // TODO: TMP
void Room::onPeerRtcpPacket(RTC::Peer* peer, RTC::RtcpPacket* packet) void Room::onPeerRtcpPacket(RTC::Peer* peer, RTC::RTCP::Packet* packet)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -512,7 +512,7 @@ namespace RTC ...@@ -512,7 +512,7 @@ namespace RTC
this->selectedTuple->Send(data, len); this->selectedTuple->Send(data, len);
} }
void Transport::SendRtcpPacket(RTC::RtcpPacket* packet) void Transport::SendRtcpPacket(RTC::RTCP::Packet* packet)
{ {
MS_TRACE(); MS_TRACE();
...@@ -604,7 +604,7 @@ namespace RTC ...@@ -604,7 +604,7 @@ namespace RTC
onStunDataRecv(tuple, data, len); onStunDataRecv(tuple, data, len);
} }
// Check if it's RTCP. // Check if it's RTCP.
else if (RtcpPacket::IsRtcp(data, len)) else if (RTCP::Packet::IsRtcp(data, len))
{ {
onRtcpDataRecv(tuple, data, len); onRtcpDataRecv(tuple, data, len);
} }
...@@ -779,7 +779,7 @@ namespace RTC ...@@ -779,7 +779,7 @@ namespace RTC
if (!this->srtpRecvSession->DecryptSrtcp(data, &len)) if (!this->srtpRecvSession->DecryptSrtcp(data, &len))
return; return;
RTC::RtcpPacket* compoundPacket = RTC::RtcpPacket::Parse(data, len); RTC::RTCP::Packet* compoundPacket = RTC::RTCP::Packet::Parse(data, len);
if (!compoundPacket) if (!compoundPacket)
{ {
MS_WARN("received data is not a valid RTCP compound or single packet"); MS_WARN("received data is not a valid RTCP compound or single packet");
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论