#define MS_CLASS "RTC::SCTP::PacketSender"
#include "RTC/SCTP/association/PacketSender.hpp"
#include "Logger.hpp"
namespace RTC
{
namespace SCTP
{
PacketSender::PacketSender(Listener* listener, AssociationListenerInterface& associationListener)
: listener(listener), associationListener(associationListener)
{
MS_TRACE();
}
PacketSender::~PacketSender()
{
MS_TRACE();
}
bool PacketSender::SendPacket(Packet* packet, bool writeChecksum)
{
MS_TRACE();
if (packet->GetChunksCount() == 0)
{
return false;
}
if (writeChecksum)
{
packet->WriteCRC32cChecksum();
}
MS_ASSERT(!packet->NeedsConsolidation(), "cannot send a SCTP packet that needs consolidation");
const bool sent =
this->associationListener.OnAssociationSendData(packet->GetBuffer(), packet->GetLength());
this->listener->OnPacketSenderPacketSent(this, packet, sent);
if (!sent)
{
MS_WARN_TAG(sctp, "couldn't send SCTP packet");
}
return sent;
}
} }