提交 55e122f9 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

- Split RtpStream into RtpStreamRecv and RtpStreamSend.

- Manage NACK in the RtpSender.
上级 962719b0
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
#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/RTCP/SenderReport.h"
#include "RTC/RTCP/ReceiverReport.h" #include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/SenderReport.h"
#include "RTC/RTCP/Feedback.h" #include "RTC/RTCP/Feedback.h"
#include "RTC/RTCP/Sdes.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <string> #include <string>
......
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
#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/RTCP/ReceiverReport.h"
#include "RTC/RTCP/SenderReport.h"
#include "RTC/RTCP/Feedback.h"
#include "RTC/RTCP/Sdes.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <unordered_map> #include <unordered_map>
...@@ -74,7 +78,6 @@ namespace RTC ...@@ -74,7 +78,6 @@ namespace RTC
std::unordered_map<uint32_t, RTC::Peer*> peers; std::unordered_map<uint32_t, RTC::Peer*> peers;
std::unordered_map<RTC::RtpReceiver*, std::unordered_set<RTC::RtpSender*>> mapRtpReceiverRtpSenders; std::unordered_map<RTC::RtpReceiver*, std::unordered_set<RTC::RtpSender*>> mapRtpReceiverRtpSenders;
std::unordered_map<RTC::RtpSender*, RTC::RtpReceiver*> mapRtpSenderRtpReceiver; std::unordered_map<RTC::RtpSender*, RTC::RtpReceiver*> mapRtpSenderRtpReceiver;
std::vector<RTC::RtpPacket*> rtpRetransmissionContainer;
}; };
/* Inline static methods. */ /* Inline static methods. */
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
#include "common.h" #include "common.h"
#include "RTC/RtpDictionaries.h" #include "RTC/RtpDictionaries.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RtpStream.h" #include "RTC/RtpStreamRecv.h"
#include "RTC/RTCP/ReceiverReport.h" #include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/Feedback.h" #include "RTC/RTCP/Feedback.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <string> #include <string>
#include <vector>
#include <json/json.h> #include <json/json.h>
namespace RTC namespace RTC
...@@ -49,7 +48,6 @@ namespace RTC ...@@ -49,7 +48,6 @@ namespace RTC
void RemoveTransport(RTC::Transport* transport); void RemoveTransport(RTC::Transport* transport);
RTC::RtpParameters* GetParameters(); RTC::RtpParameters* GetParameters();
void ReceiveRtpPacket(RTC::RtpPacket* packet); void ReceiveRtpPacket(RTC::RtpPacket* packet);
void RequestRtpRetransmission(uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container);
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report); void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
RTC::RTCP::ReceiverReport* GetRtcpReceiverReport(); RTC::RTCP::ReceiverReport* GetRtcpReceiverReport();
void ReceiveRtcpFeedback(RTC::RTCP::FeedbackPsPacket* packet); void ReceiveRtcpFeedback(RTC::RTCP::FeedbackPsPacket* packet);
...@@ -70,7 +68,8 @@ namespace RTC ...@@ -70,7 +68,8 @@ namespace RTC
RTC::Transport* transport = nullptr; RTC::Transport* transport = nullptr;
// Allocated by this. // Allocated by this.
RTC::RtpParameters* rtpParameters = nullptr; RTC::RtpParameters* rtpParameters = nullptr;
RTC::RtpStream* rtpStream = nullptr; // TODO: For now just one.
RTC::RtpStreamRecv* rtpStream = nullptr;
// Others. // Others.
bool rtpRawEventEnabled = false; bool rtpRawEventEnabled = false;
bool rtpObjectEventEnabled = false; bool rtpObjectEventEnabled = false;
......
...@@ -3,13 +3,16 @@ ...@@ -3,13 +3,16 @@
#include "common.h" #include "common.h"
#include "RTC/Transport.h" #include "RTC/Transport.h"
#include "RTC/RtpStreamSend.h"
#include "RTC/RtpDictionaries.h" #include "RTC/RtpDictionaries.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RTCP/SenderReport.h" #include "RTC/RTCP/SenderReport.h"
#include "RTC/RTCP/Sdes.h" #include "RTC/RTCP/Sdes.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "Channel/Request.h" #include "Channel/Request.h"
#include "Channel/Notifier.h" #include "Channel/Notifier.h"
#include <unordered_set> #include <unordered_set>
#include <vector>
#include <json/json.h> #include <json/json.h>
namespace RTC namespace RTC
...@@ -26,6 +29,10 @@ namespace RTC ...@@ -26,6 +29,10 @@ namespace RTC
virtual void onRtpSenderClosed(RtpSender* rtpSender) = 0; virtual void onRtpSenderClosed(RtpSender* rtpSender) = 0;
}; };
private:
// Container of RTP packets to retransmit.
static std::vector<RTC::RtpPacket*> rtpRetransmissionContainer;
public: public:
RtpSender(Listener* listener, Channel::Notifier* notifier, uint32_t rtpSenderId, RTC::Media::Kind kind); RtpSender(Listener* listener, Channel::Notifier* notifier, uint32_t rtpSenderId, RTC::Media::Kind kind);
virtual ~RtpSender(); virtual ~RtpSender();
...@@ -40,11 +47,14 @@ namespace RTC ...@@ -40,11 +47,14 @@ namespace RTC
void RemoveTransport(RTC::Transport* transport); void RemoveTransport(RTC::Transport* transport);
RTC::RtpParameters* GetParameters(); RTC::RtpParameters* GetParameters();
void SendRtpPacket(RTC::RtpPacket* packet); void SendRtpPacket(RTC::RtpPacket* packet);
void RetransmitRtpPacket(RTC::RtpPacket* packet);
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report); void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
RTC::RTCP::SenderReport* GetRtcpSenderReport(); RTC::RTCP::SenderReport* GetRtcpSenderReport();
void ReceiveRtcpSdesChunk(RTC::RTCP::SdesChunk* chunk); void ReceiveRtcpSdesChunk(RTC::RTCP::SdesChunk* chunk);
RTC::RTCP::SdesChunk* GetRtcpSdesChunk(); RTC::RTCP::SdesChunk* GetRtcpSdesChunk();
void ReceiveNack(RTC::RTCP::FeedbackRtpNackPacket* nackPacket);
private:
void RetransmitRtpPacket(RTC::RtpPacket* packet);
public: public:
// Passed by argument. // Passed by argument.
...@@ -59,6 +69,7 @@ namespace RTC ...@@ -59,6 +69,7 @@ namespace RTC
RTC::RtpCapabilities* peerCapabilities = nullptr; RTC::RtpCapabilities* peerCapabilities = nullptr;
// Allocated by this. // Allocated by this.
RTC::RtpParameters* rtpParameters = nullptr; RTC::RtpParameters* rtpParameters = nullptr;
RTC::RtpStreamSend* rtpStream = nullptr;
// Others. // Others.
std::unordered_set<uint8_t> supportedPayloadTypes; std::unordered_set<uint8_t> supportedPayloadTypes;
// Whether this RtpSender is valid according to Peer capabilities. // Whether this RtpSender is valid according to Peer capabilities.
......
...@@ -3,46 +3,22 @@ ...@@ -3,46 +3,22 @@
#include "common.h" #include "common.h"
#include "RTC/RtpPacket.h" #include "RTC/RtpPacket.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/SenderReport.h"
#include <vector>
#include <list>
namespace RTC namespace RTC
{ {
class RtpStream class RtpStream
{ {
private:
struct StorageItem
{
uint8_t store[65536];
};
private:
struct BufferItem
{
uint32_t seq32 = 0; // RTP seq in 32 bytes plus 16 bits cycles.
RTC::RtpPacket* packet = nullptr;
};
public: public:
explicit RtpStream(uint32_t clockRate, size_t bufferSize); explicit RtpStream(uint32_t clockRate);
~RtpStream(); virtual ~RtpStream();
bool ReceivePacket(RTC::RtpPacket* packet); virtual bool ReceivePacket(RTC::RtpPacket* packet);
void RequestRtpRetransmission(uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container);
RTC::RTCP::ReceiverReport* GetRtcpReceiverReport();
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
private: private:
void InitSeq(uint16_t seq); void InitSeq(uint16_t seq);
bool UpdateSeq(uint16_t seq); bool UpdateSeq(uint16_t seq);
void ClearBuffer();
void StorePacket(RTC::RtpPacket* packet);
void CalculateJitter(uint32_t rtpTimestamp);
void Dump();
private: protected:
// Given as argument. // Given as argument.
uint32_t clockRate = 0; uint32_t clockRate = 0;
bool started = false; // Whether at least a RTP packet has been received. bool started = false; // Whether at least a RTP packet has been received.
...@@ -57,13 +33,8 @@ namespace RTC ...@@ -57,13 +33,8 @@ namespace RTC
uint32_t received = 0; // Packets received. uint32_t received = 0; // Packets received.
uint32_t expected_prior = 0; // Packet expected at last interval. uint32_t expected_prior = 0; // Packet expected at last interval.
uint32_t received_prior = 0; // Packet received at last interval. uint32_t received_prior = 0; // Packet received at last interval.
uint32_t transit = 0; // Relative trans time for prev pkt. // Others.
uint32_t jitter = 0; // Estimated jitter.
// RTP buffer.
uint32_t max_timestamp = 0; // Highest timestamp seen. uint32_t max_timestamp = 0; // Highest timestamp seen.
std::vector<StorageItem> storage;
typedef std::list<BufferItem> Buffer;
Buffer buffer;
}; };
} }
......
#ifndef MS_RTC_RTP_STREAM_RECV_H
#define MS_RTC_RTP_STREAM_RECV_H
#include "RTC/RtpStream.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/SenderReport.h"
namespace RTC
{
class RtpStreamRecv :
public RtpStream
{
public:
explicit RtpStreamRecv(uint32_t clockRate);
virtual ~RtpStreamRecv();
virtual bool ReceivePacket(RTC::RtpPacket* packet);
RTC::RTCP::ReceiverReport* GetRtcpReceiverReport();
void ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report);
private:
void CalculateJitter(uint32_t rtpTimestamp);
private:
uint32_t transit = 0; // Relative trans time for prev pkt.
uint32_t jitter = 0; // Estimated jitter.
};
}
#endif
#ifndef MS_RTC_RTP_STREAM_SEND_H
#define MS_RTC_RTP_STREAM_SEND_H
#include "RTC/RtpStream.h"
#include <vector>
#include <list>
namespace RTC
{
class RtpStreamSend :
public RtpStream
{
private:
struct StorageItem
{
uint8_t store[65536];
};
private:
struct BufferItem
{
uint32_t seq32 = 0; // RTP seq in 32 bytes plus 16 bits cycles.
RTC::RtpPacket* packet = nullptr;
};
public:
explicit RtpStreamSend(uint32_t clockRate, size_t bufferSize);
virtual ~RtpStreamSend();
bool ReceivePacket(RTC::RtpPacket* packet);
void RequestRtpRetransmission(uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container);
private:
void ClearBuffer();
void StorePacket(RTC::RtpPacket* packet);
void Dump();
private:
std::vector<StorageItem> storage;
typedef std::list<BufferItem> Buffer;
Buffer buffer;
};
}
#endif
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
'src/RTC/RtpReceiver.cpp', 'src/RTC/RtpReceiver.cpp',
'src/RTC/RtpSender.cpp', 'src/RTC/RtpSender.cpp',
'src/RTC/RtpStream.cpp', 'src/RTC/RtpStream.cpp',
'src/RTC/RtpStreamRecv.cpp',
'src/RTC/RtpStreamSend.cpp',
'src/RTC/SrtpSession.cpp', 'src/RTC/SrtpSession.cpp',
'src/RTC/StunMessage.cpp', 'src/RTC/StunMessage.cpp',
'src/RTC/TcpConnection.cpp', 'src/RTC/TcpConnection.cpp',
...@@ -110,6 +112,8 @@ ...@@ -110,6 +112,8 @@
'include/RTC/RtpReceiver.h', 'include/RTC/RtpReceiver.h',
'include/RTC/RtpSender.h', 'include/RTC/RtpSender.h',
'include/RTC/RtpStream.h', 'include/RTC/RtpStream.h',
'include/RTC/RtpStreamRecv.h',
'include/RTC/RtpStreamSend.h',
'include/RTC/SrtpSession.h', 'include/RTC/SrtpSession.h',
'include/RTC/StunMessage.h', 'include/RTC/StunMessage.h',
'include/RTC/TcpConnection.h', 'include/RTC/TcpConnection.h',
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "RTC/Peer.h" #include "RTC/Peer.h"
#include "RTC/RtpDictionaries.h" #include "RTC/RtpDictionaries.h"
#include "RTC/RTCP/CompoundPacket.h" #include "RTC/RTCP/CompoundPacket.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
...@@ -806,6 +807,7 @@ namespace RTC ...@@ -806,6 +807,7 @@ namespace RTC
break; break;
} }
} }
break; break;
} }
...@@ -821,11 +823,13 @@ namespace RTC ...@@ -821,11 +823,13 @@ namespace RTC
if (rtpSender) if (rtpSender)
{ {
this->listener->onPeerRtcpFeedback(this, rtpSender, feedback); RTC::RTCP::FeedbackRtpNackPacket* nackPacket = static_cast<RTC::RTCP::FeedbackRtpNackPacket*>(packet);
rtpSender->ReceiveNack(nackPacket);
} }
else else
{ {
MS_WARN_TAG(rtcp, "no RtpSender found while procesing a Feedback packet '%s' [sender_ssrc:%" PRIu32 ", media_ssrc:%" PRIu32 "]", MS_WARN_TAG(rtcp, "no RtpSender found while procesing a NACK packet '%s' [sender_ssrc:%" PRIu32 ", media_ssrc:%" PRIu32 "]",
RTCP::FeedbackRtpPacket::MessageType2String(feedback->GetMessageType()).c_str(), feedback->GetMediaSsrc(), feedback->GetMediaSsrc()); RTCP::FeedbackRtpPacket::MessageType2String(feedback->GetMessageType()).c_str(), feedback->GetMediaSsrc(), feedback->GetMediaSsrc());
} }
...@@ -848,6 +852,7 @@ namespace RTC ...@@ -848,6 +852,7 @@ namespace RTC
break; break;
} }
} }
break; break;
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// #define MS_LOG_DEV // #define MS_LOG_DEV
#include "RTC/Room.h" #include "RTC/Room.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include "Utils.h" #include "Utils.h"
...@@ -62,8 +61,7 @@ namespace RTC ...@@ -62,8 +61,7 @@ namespace RTC
Room::Room(Listener* listener, Channel::Notifier* notifier, uint32_t roomId, Json::Value& data) : Room::Room(Listener* listener, Channel::Notifier* notifier, uint32_t roomId, Json::Value& data) :
roomId(roomId), roomId(roomId),
listener(listener), listener(listener),
notifier(notifier), notifier(notifier)
rtpRetransmissionContainer(18) // Can retransmit up to 17 RTP packets.
{ {
MS_TRACE(); MS_TRACE();
...@@ -654,40 +652,7 @@ namespace RTC ...@@ -654,40 +652,7 @@ namespace RTC
auto& rtpReceiver = this->mapRtpSenderRtpReceiver[rtpSender]; auto& rtpReceiver = this->mapRtpSenderRtpReceiver[rtpSender];
switch (packet->GetMessageType()) rtpReceiver->ReceiveRtcpFeedback(packet);
{
case RTC::RTCP::FeedbackRtp::NACK:
{
RTC::RTCP::FeedbackRtpNackPacket* nackPacket = static_cast<RTC::RTCP::FeedbackRtpNackPacket*>(packet);
for (auto it = nackPacket->Begin(); it != nackPacket->End(); ++it)
{
RTC::RTCP::NackItem* item = *it;
rtpReceiver->RequestRtpRetransmission(item->GetPacketId(), item->GetLostPacketBitmask(), this->rtpRetransmissionContainer);
for (auto it = this->rtpRetransmissionContainer.begin(); it != this->rtpRetransmissionContainer.end(); ++it)
{
RTC::RtpPacket* packet = *it;
if (packet == nullptr)
break;
rtpSender->RetransmitRtpPacket(packet);
}
// Reset the container by setting its first element to nullptr.
this->rtpRetransmissionContainer[0] = nullptr;
}
break;
}
default:
{
rtpReceiver->ReceiveRtcpFeedback(packet);
}
}
} }
void Room::onPeerRtcpSenderReport(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RTCP::SenderReport* report) void Room::onPeerRtcpSenderReport(RTC::Peer* peer, RTC::RtpReceiver* rtpReceiver, RTC::RTCP::SenderReport* report)
......
...@@ -27,6 +27,12 @@ namespace RTC ...@@ -27,6 +27,12 @@ namespace RTC
RtpReceiver::~RtpReceiver() RtpReceiver::~RtpReceiver()
{ {
MS_TRACE(); MS_TRACE();
if (this->rtpParameters)
delete this->rtpParameters;
if (this->rtpStream)
delete this->rtpStream;
} }
void RtpReceiver::Close() void RtpReceiver::Close()
...@@ -37,12 +43,6 @@ namespace RTC ...@@ -37,12 +43,6 @@ namespace RTC
Json::Value event_data(Json::objectValue); Json::Value event_data(Json::objectValue);
if (this->rtpParameters)
delete this->rtpParameters;
if (this->rtpStream)
delete this->rtpStream;
// Notify. // Notify.
event_data[k_class] = "RtpReceiver"; event_data[k_class] = "RtpReceiver";
this->notifier->Emit(this->rtpReceiverId, "close", event_data); this->notifier->Emit(this->rtpReceiverId, "close", event_data);
...@@ -160,7 +160,7 @@ namespace RTC ...@@ -160,7 +160,7 @@ namespace RTC
// And notify again. // And notify again.
this->listener->onRtpReceiverParametersDone(this); this->listener->onRtpReceiverParametersDone(this);
// Set the RtpStream. // Set the RtpStreamRecv.
// TODO: This assumes a single stream for now. // TODO: This assumes a single stream for now.
// TODO: We need a much better way to get the clock rate. // TODO: We need a much better way to get the clock rate.
...@@ -186,20 +186,8 @@ namespace RTC ...@@ -186,20 +186,8 @@ namespace RTC
MS_ABORT("no valid codec payload type found for the first encoding"); MS_ABORT("no valid codec payload type found for the first encoding");
} }
switch (this->kind) // Create a RtpStreamRecv for receiving a media stream.
{ this->rtpStream = new RTC::RtpStreamRecv(streamClockRate);
case RTC::Media::Kind::VIDEO:
case RTC::Media::Kind::DEPTH:
// Buffer up to 200 packets.
this->rtpStream = new RTC::RtpStream(streamClockRate, 200);
break;
case RTC::Media::Kind::AUDIO:
// No buffer for audio streams.
this->rtpStream = new RTC::RtpStream(streamClockRate, 0);
break;
default:
;
}
break; break;
} }
...@@ -305,15 +293,6 @@ namespace RTC ...@@ -305,15 +293,6 @@ namespace RTC
} }
} }
void RtpReceiver::RequestRtpRetransmission(uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container)
{
MS_TRACE();
// Proxy the request to the RtpStream.
if (this->rtpStream)
this->rtpStream->RequestRtpRetransmission(seq, bitmask, container);
}
void RtpReceiver::FillRtpParameters() void RtpReceiver::FillRtpParameters()
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -2,12 +2,18 @@ ...@@ -2,12 +2,18 @@
// #define MS_LOG_DEV // #define MS_LOG_DEV
#include "RTC/RtpSender.h" #include "RTC/RtpSender.h"
#include "RTC/RTCP/FeedbackRtpNack.h"
#include "MediaSoupError.h" #include "MediaSoupError.h"
#include "Logger.h" #include "Logger.h"
#include <unordered_set> #include <unordered_set>
namespace RTC namespace RTC
{ {
/* Class variables. */
// Can retransmit up to 17 RTP packets.
std::vector<RTC::RtpPacket*> RtpSender::rtpRetransmissionContainer(18);
/* Instance methods. */ /* Instance methods. */
RtpSender::RtpSender(Listener* listener, Channel::Notifier* notifier, uint32_t rtpSenderId, RTC::Media::Kind kind) : RtpSender::RtpSender(Listener* listener, Channel::Notifier* notifier, uint32_t rtpSenderId, RTC::Media::Kind kind) :
...@@ -22,6 +28,12 @@ namespace RTC ...@@ -22,6 +28,12 @@ namespace RTC
RtpSender::~RtpSender() RtpSender::~RtpSender()
{ {
MS_TRACE(); MS_TRACE();
if (this->rtpParameters)
delete this->rtpParameters;
if (this->rtpStream)
delete this->rtpStream;
} }
void RtpSender::Close() void RtpSender::Close()
...@@ -30,9 +42,6 @@ namespace RTC ...@@ -30,9 +42,6 @@ namespace RTC
static const Json::StaticString k_class("class"); static const Json::StaticString k_class("class");
if (this->rtpParameters)
delete this->rtpParameters;
Json::Value event_data(Json::objectValue); Json::Value event_data(Json::objectValue);
event_data[k_class] = "RtpSender"; event_data[k_class] = "RtpSender";
...@@ -180,9 +189,55 @@ namespace RTC ...@@ -180,9 +189,55 @@ namespace RTC
// If there are no encodings set not available. // If there are no encodings set not available.
if (this->rtpParameters->encodings.size() > 0) if (this->rtpParameters->encodings.size() > 0)
{
this->available = true; this->available = true;
// Set the RtpStreamSend.
// TODO: This assumes a single stream for now.
// TODO: We need a much better way to get the clock rate.
uint8_t streamPayloadType = this->rtpParameters->encodings[0].codecPayloadType;
uint32_t streamClockRate;
auto it = this->rtpParameters->codecs.begin();
for (; it != this->rtpParameters->codecs.end(); ++it)
{
auto& codec = *it;
if (codec.payloadType == streamPayloadType)
{
streamClockRate = codec.clockRate;
break;
}
}
// This should never happen.
if (it == this->rtpParameters->codecs.end())
{
MS_ABORT("no valid codec payload type found for the first encoding");
}
// Create a RtpStreamSend for sending a single media stream.
switch (this->kind)
{
case RTC::Media::Kind::VIDEO:
case RTC::Media::Kind::DEPTH:
// Buffer up to 200 packets.
this->rtpStream = new RTC::RtpStreamSend(streamClockRate, 200);
break;
case RTC::Media::Kind::AUDIO:
// No buffer for audio streams.
this->rtpStream = new RTC::RtpStreamSend(streamClockRate, 0);
break;
default:
;
}
}
else else
{
this->available = false; this->available = false;
}
// Emit "parameterschange" if these are updated parameters. // Emit "parameterschange" if these are updated parameters.
if (previousRtpParameters) if (previousRtpParameters)
...@@ -204,8 +259,15 @@ namespace RTC ...@@ -204,8 +259,15 @@ namespace RTC
if (!this->available || !this->transport) if (!this->available || !this->transport)
return; return;
// Map the payload type. MS_ASSERT(this->rtpStream, "no RtpStream set");
// Process the packet.
// TODO: Must check what kind of packet we are checking. For example, RTX
// packets (once implemented) should have a different handling.
if (!this->rtpStream->ReceivePacket(packet))
return;
// Map the payload type.
uint8_t payloadType = packet->GetPayloadType(); uint8_t payloadType = packet->GetPayloadType();
auto it = this->supportedPayloadTypes.find(payloadType); auto it = this->supportedPayloadTypes.find(payloadType);
...@@ -222,6 +284,39 @@ namespace RTC ...@@ -222,6 +284,39 @@ namespace RTC
this->transport->SendRtpPacket(packet); this->transport->SendRtpPacket(packet);
} }
void RtpSender::ReceiveNack(RTC::RTCP::FeedbackRtpNackPacket* nackPacket)
{
MS_TRACE();
if (!this->rtpStream)
{
MS_WARN_TAG(rtp, "no RtpStreamSend");
return;
}
for (auto it = nackPacket->Begin(); it != nackPacket->End(); ++it)
{
RTC::RTCP::NackItem* item = *it;
this->rtpStream->RequestRtpRetransmission(item->GetPacketId(), item->GetLostPacketBitmask(), RtpSender::rtpRetransmissionContainer);
for (auto it = RtpSender::rtpRetransmissionContainer.begin(); it != RtpSender::rtpRetransmissionContainer.end(); ++it)
{
RTC::RtpPacket* packet = *it;
if (packet == nullptr)
break;
RetransmitRtpPacket(packet);
}
// Reset the container by setting its first element to nullptr.
RtpSender::rtpRetransmissionContainer[0] = nullptr;
}
}
void RtpSender::RetransmitRtpPacket(RTC::RtpPacket* packet) void RtpSender::RetransmitRtpPacket(RTC::RtpPacket* packet)
{ {
MS_TRACE(); MS_TRACE();
......
...@@ -4,22 +4,19 @@ ...@@ -4,22 +4,19 @@
// #define MS_LOG_DEV // #define MS_LOG_DEV
#include "RTC/RtpStream.h" #include "RTC/RtpStream.h"
#include "DepLibUV.h"
#include "Logger.h" #include "Logger.h"
#define MIN_SEQUENTIAL 0 #define MIN_SEQUENTIAL 0
#define MAX_DROPOUT 3000 #define MAX_DROPOUT 3000
#define MAX_MISORDER 100 #define MAX_MISORDER 100
#define RTP_SEQ_MOD (1<<16) #define RTP_SEQ_MOD (1<<16)
#define MAX_RETRANSMISSION_AGE 200 // Don't retransmit packets older than this (ms).
namespace RTC namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
RtpStream::RtpStream(uint32_t clockRate, size_t bufferSize) : RtpStream::RtpStream(uint32_t clockRate) :
clockRate(clockRate), clockRate(clockRate)
storage(bufferSize)
{ {
MS_TRACE(); MS_TRACE();
} }
...@@ -27,9 +24,6 @@ namespace RTC ...@@ -27,9 +24,6 @@ namespace RTC
RtpStream::~RtpStream() RtpStream::~RtpStream()
{ {
MS_TRACE(); MS_TRACE();
// Clear buffer.
ClearBuffer();
} }
bool RtpStream::ReceivePacket(RTC::RtpPacket* packet) bool RtpStream::ReceivePacket(RTC::RtpPacket* packet)
...@@ -56,121 +50,13 @@ namespace RTC ...@@ -56,121 +50,13 @@ namespace RTC
return false; return false;
} }
// Update highest timestamp seen. // Update highest seen RTP timestamp.
if (packet->GetTimestamp() > this->max_timestamp) if (packet->GetTimestamp() > this->max_timestamp)
this->max_timestamp = packet->GetTimestamp(); this->max_timestamp = packet->GetTimestamp();
// If bufferSize was given, store the packet into the buffer.
if (this->storage.size() > 0)
StorePacket(packet);
// Calculate Jitter.
CalculateJitter(packet->GetTimestamp());
return true; return true;
} }
// This method looks for the requested RTP packets and inserts them into the
// given container (and set to null the next container position).
void RtpStream::RequestRtpRetransmission(uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container)
{
MS_TRACE();
// 17: 16 bit mask + the initial sequence number.
static size_t maxRequestedPackets = 17;
// If the buffer is empty, just return.
if (this->buffer.size() == 0)
return;
// Convert the given sequence numbers to 32 bits.
uint32_t first_seq32 = (uint32_t)seq + this->cycles;
uint32_t last_seq32 = first_seq32 + maxRequestedPackets - 1;
size_t container_idx = 0;
// Number of requested packets cannot be greater than the container size - 1.
MS_ASSERT(container.size() - 1 >= maxRequestedPackets, "RtpPacket container is too small");
auto buffer_it = this->buffer.begin();
auto buffer_it_r = this->buffer.rbegin();
uint32_t buffer_first_seq32 = (*buffer_it).seq32;
uint32_t buffer_last_seq32 = (*buffer_it_r).seq32;
// Requested packet range not found.
if (first_seq32 > buffer_last_seq32 || last_seq32 < buffer_first_seq32)
{
// Let's try with sequence numbers in the previous 16 cycle.
if (this->cycles > 0)
{
first_seq32 -= RTP_SEQ_MOD;
last_seq32 -= RTP_SEQ_MOD;
// Try again.
if (first_seq32 > buffer_last_seq32 || last_seq32 < buffer_first_seq32)
return;
}
// Otherwise just return.
else
{
MS_WARN_TAG(rtp, "requested range not in the buffer");
return;
}
}
// Look for each requested packet.
uint32_t seq32 = first_seq32;
bool requested = true;
do
{
if (requested)
{
bool found = false;
for (; buffer_it != this->buffer.end(); ++buffer_it)
{
auto current_seq32 = (*buffer_it).seq32;
// Found.
if (current_seq32 == seq32)
{
found = true;
auto current_packet = (*buffer_it).packet;
// Just provide the packet if no older than MAX_RETRANSMISSION_AGE ms.
uint16_t diff = (this->max_timestamp - current_packet->GetTimestamp()) * 1000 / this->clockRate;
if (diff <= MAX_RETRANSMISSION_AGE)
{
// Store the packet in the container and then increment its index.
container[container_idx++] = current_packet;
}
else
{
MS_WARN_TAG(rtp, "ignoring retransmission for a packet older than %d ms", MAX_RETRANSMISSION_AGE);
}
// Exit the loop.
break;
}
}
if (!found)
MS_WARN_TAG(rtp, "requested packet not found in the buffer");
}
requested = (bitmask & 1) ? true : false;
bitmask >>= 1;
++seq32;
}
while (bitmask != 0);
// Set the next container element to null.
container[container_idx] = nullptr;
}
void RtpStream::InitSeq(uint16_t seq) void RtpStream::InitSeq(uint16_t seq)
{ {
MS_TRACE(); MS_TRACE();
...@@ -183,9 +69,8 @@ namespace RTC ...@@ -183,9 +69,8 @@ namespace RTC
this->received = 0; this->received = 0;
this->received_prior = 0; this->received_prior = 0;
this->expected_prior = 0; this->expected_prior = 0;
// Also reset the highest seen RTP timestamp.
// Clean buffer. this->max_timestamp = 0;
ClearBuffer();
} }
bool RtpStream::UpdateSeq(uint16_t seq) bool RtpStream::UpdateSeq(uint16_t seq)
...@@ -262,189 +147,4 @@ namespace RTC ...@@ -262,189 +147,4 @@ namespace RTC
return true; return true;
} }
void RtpStream::ClearBuffer()
{
MS_TRACE();
// Delete cloned packets.
for (auto& buffer_item : this->buffer)
{
delete buffer_item.packet;
}
// Clear list.
this->buffer.clear();
}
inline
void RtpStream::StorePacket(RTC::RtpPacket* packet)
{
MS_TRACE();
// Sum the packet seq number and the number of 16 bits cycles.
uint32_t packet_seq32 = (uint32_t)packet->GetSequenceNumber() + this->cycles;
BufferItem buffer_item;
buffer_item.seq32 = packet_seq32;
// If empty do it easy.
if (this->buffer.size() == 0)
{
auto store = this->storage[0].store;
buffer_item.packet = packet->Clone(store);
this->buffer.push_back(buffer_item);
return;
}
// Otherwise, do the stuff.
Buffer::iterator new_buffer_it;
uint8_t* store = nullptr;
// Iterate the buffer in reverse order and find the proper place to store the
// packet.
auto buffer_it_r = this->buffer.rbegin();
for (; buffer_it_r != this->buffer.rend(); ++buffer_it_r)
{
auto current_seq32 = (*buffer_it_r).seq32;
if (packet_seq32 > current_seq32)
{
// Get a forward iterator pointing to the same element.
auto it = buffer_it_r.base();
new_buffer_it = this->buffer.insert(it, buffer_item);
// Exit the loop.
break;
}
}
// If the packet was older than anything in the buffer, just ignore it.
// NOTE: This should never happen.
if (buffer_it_r == this->buffer.rend())
{
MS_WARN_TAG(rtp, "packet is older than anything in the buffer, ignoring it");
return;
}
// If the buffer is not full use the next free storage item.
if (this->buffer.size() - 1 < this->storage.size())
{
store = this->storage[this->buffer.size() - 1].store;
}
// Otherwise remove the first packet of the buffer and replace its storage area.
else
{
auto& first_buffer_item = *(this->buffer.begin());
auto first_packet = first_buffer_item.packet;
// Store points to the store used by the first packet.
store = (uint8_t*)first_packet->GetData();
// Free the first packet.
delete first_packet;
// Remove the first element in the list.
this->buffer.pop_front();
}
// Update the new buffer item so it points to the cloned packed.
(*new_buffer_it).packet = packet->Clone(store);
}
void RtpStream::CalculateJitter(uint32_t rtpTimestamp)
{
if (!this->clockRate)
return;
int transit = DepLibUV::GetTime() - (rtpTimestamp * 1000 / this->clockRate);
int d = transit - this->transit;
this->transit = transit;
if (d < 0) d = -d;
this->jitter += (1./16.) * ((double)d - this->jitter);
}
RTC::RTCP::ReceiverReport* RtpStream::GetRtcpReceiverReport()
{
RTC::RTCP::ReceiverReport* report = new RTC::RTCP::ReceiverReport();
// Calculate Packets Expected and Lost.
uint32_t expected = (this->cycles + this->max_seq) - this->base_seq + 1;
int32_t total_lost = expected - this->received;
report->SetTotalLost(total_lost);
// Calculate Fraction Lost.
uint32_t expected_interval = expected - this->expected_prior;
this->expected_prior = expected;
uint32_t received_interval = this->received - this->received_prior;
this->received_prior = this->received;
int32_t lost_interval = expected_interval - received_interval;
uint8_t fraction_lost;
if (expected_interval == 0 || lost_interval <= 0)
fraction_lost = 0;
else
fraction_lost = (lost_interval << 8) / expected_interval;
report->SetFractionLost(fraction_lost);
// Fill the rest of the report.
report->SetLastSeq((uint32_t)this->max_seq + this->cycles);
report->SetJitter(this->jitter);
if (this->last_sr_received)
{
// Get delay in milliseconds.
uint32_t delayMs = (DepLibUV::GetTime() - this->last_sr_received);
// Express delay in units of 1/65536 seconds.
uint32_t dlsr = (delayMs / 1000) << 16;
dlsr |= (uint32_t)((delayMs % 1000) * 65536 / 1000);
report->SetDelaySinceLastSenderReport(dlsr);
report->SetLastSenderReport(this->last_sr_timestamp);
}
else
{
report->SetDelaySinceLastSenderReport(0);
report->SetLastSenderReport(0);
}
return report;
}
void RtpStream::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report)
{
this->last_sr_received = DepLibUV::GetTime();
this->last_sr_timestamp = htonl(report->GetNtpSec()) << 16;
this->last_sr_timestamp += htonl(report->GetNtpFrac()) >> 16;
}
// TODO: TMP
void RtpStream::Dump()
{
MS_TRACE();
MS_DEBUG_TAG(rtp, "<RtpStream>");
MS_DEBUG_TAG(rtp, " [buffer.size:%zu, storage.size:%zu]", this->buffer.size(), this->storage.size());
for (auto& buffer_item : this->buffer)
{
auto packet = buffer_item.packet;
MS_DEBUG_TAG(rtp, " packet [seq:%" PRIu16 ", seq32:%" PRIu32 "]", packet->GetSequenceNumber(), buffer_item.seq32);
}
MS_DEBUG_TAG(rtp, "</RtpStream>");
}
} }
#define MS_CLASS "RTC::RtpStreamRecv"
// #define MS_LOG_DEV
#include "RTC/RtpStreamRecv.h"
#include "DepLibUV.h"
#include "Logger.h"
namespace RTC
{
/* Instance methods. */
RtpStreamRecv::RtpStreamRecv(uint32_t clockRate) :
RtpStream::RtpStream(clockRate)
{
MS_TRACE();
}
RtpStreamRecv::~RtpStreamRecv()
{
MS_TRACE();
}
bool RtpStreamRecv::ReceivePacket(RTC::RtpPacket* packet)
{
MS_TRACE();
// Call the parent method.
if (!RtpStream::ReceivePacket(packet))
return false;
// Calculate Jitter.
CalculateJitter(packet->GetTimestamp());
return true;
}
RTC::RTCP::ReceiverReport* RtpStreamRecv::GetRtcpReceiverReport()
{
RTC::RTCP::ReceiverReport* report = new RTC::RTCP::ReceiverReport();
// Calculate Packets Expected and Lost.
uint32_t expected = (this->cycles + this->max_seq) - this->base_seq + 1;
int32_t total_lost = expected - this->received;
report->SetTotalLost(total_lost);
// Calculate Fraction Lost.
uint32_t expected_interval = expected - this->expected_prior;
this->expected_prior = expected;
uint32_t received_interval = this->received - this->received_prior;
this->received_prior = this->received;
int32_t lost_interval = expected_interval - received_interval;
uint8_t fraction_lost;
if (expected_interval == 0 || lost_interval <= 0)
fraction_lost = 0;
else
fraction_lost = (lost_interval << 8) / expected_interval;
report->SetFractionLost(fraction_lost);
// Fill the rest of the report.
report->SetLastSeq((uint32_t)this->max_seq + this->cycles);
report->SetJitter(this->jitter);
if (this->last_sr_received)
{
// Get delay in milliseconds.
uint32_t delayMs = (DepLibUV::GetTime() - this->last_sr_received);
// Express delay in units of 1/65536 seconds.
uint32_t dlsr = (delayMs / 1000) << 16;
dlsr |= (uint32_t)((delayMs % 1000) * 65536 / 1000);
report->SetDelaySinceLastSenderReport(dlsr);
report->SetLastSenderReport(this->last_sr_timestamp);
}
else
{
report->SetDelaySinceLastSenderReport(0);
report->SetLastSenderReport(0);
}
return report;
}
void RtpStreamRecv::ReceiveRtcpSenderReport(RTC::RTCP::SenderReport* report)
{
this->last_sr_received = DepLibUV::GetTime();
this->last_sr_timestamp = htonl(report->GetNtpSec()) << 16;
this->last_sr_timestamp += htonl(report->GetNtpFrac()) >> 16;
}
void RtpStreamRecv::CalculateJitter(uint32_t rtpTimestamp)
{
if (!this->clockRate)
return;
int transit = DepLibUV::GetTime() - (rtpTimestamp * 1000 / this->clockRate);
int d = transit - this->transit;
this->transit = transit;
if (d < 0) d = -d;
this->jitter += (1./16.) * ((double)d - this->jitter);
}
}
#define MS_CLASS "RTC::RtpStreamSend"
// #define MS_LOG_DEV
#include "RTC/RtpStreamSend.h"
#include "Logger.h"
#define RTP_SEQ_MOD (1<<16)
#define MAX_RETRANSMISSION_AGE 200 // Don't retransmit packets older than this (ms).
// Usage:
// MS_DEBUG_DEV("Leading text "UINT16_TO_BINARY_PATTERN, UINT16_TO_BINARY(bytes));
#define UINT16_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c"
#define UINT16_TO_BINARY(bytes) \
(bytes & 0x8000 ? '1' : '0'), \
(bytes & 0x4000 ? '1' : '0'), \
(bytes & 0x2000 ? '1' : '0'), \
(bytes & 0x1000 ? '1' : '0'), \
(bytes & 0x800 ? '1' : '0'), \
(bytes & 0x400 ? '1' : '0'), \
(bytes & 0x200 ? '1' : '0'), \
(bytes & 0x100 ? '1' : '0'), \
(bytes & 0x80 ? '1' : '0'), \
(bytes & 0x40 ? '1' : '0'), \
(bytes & 0x20 ? '1' : '0'), \
(bytes & 0x10 ? '1' : '0'), \
(bytes & 0x08 ? '1' : '0'), \
(bytes & 0x04 ? '1' : '0'), \
(bytes & 0x02 ? '1' : '0'), \
(bytes & 0x01 ? '1' : '0')
namespace RTC
{
/* Instance methods. */
RtpStreamSend::RtpStreamSend(uint32_t clockRate, size_t bufferSize) :
RtpStream::RtpStream(clockRate),
storage(bufferSize)
{
MS_TRACE();
}
RtpStreamSend::~RtpStreamSend()
{
MS_TRACE();
// Clear buffer.
ClearBuffer();
}
bool RtpStreamSend::ReceivePacket(RTC::RtpPacket* packet)
{
MS_TRACE();
// Call the parent method.
if (!RtpStream::ReceivePacket(packet))
return false;
// If bufferSize was given, store the packet into the buffer.
if (this->storage.size() > 0)
StorePacket(packet);
return true;
}
// This method looks for the requested RTP packets and inserts them into the
// given container (and set to null the next container position).
void RtpStreamSend::RequestRtpRetransmission(uint16_t seq, uint16_t bitmask, std::vector<RTC::RtpPacket*>& container)
{
MS_TRACE();
// 17: 16 bit mask + the initial sequence number.
static size_t maxRequestedPackets = 17;
// If the buffer is empty, just return.
if (this->buffer.size() == 0)
return;
// Convert the given sequence numbers to 32 bits.
uint32_t first_seq32 = (uint32_t)seq + this->cycles;
uint32_t last_seq32 = first_seq32 + maxRequestedPackets - 1;
size_t container_idx = 0;
// Number of requested packets cannot be greater than the container size - 1.
MS_ASSERT(container.size() - 1 >= maxRequestedPackets, "RtpPacket container is too small");
auto buffer_it = this->buffer.begin();
auto buffer_it_r = this->buffer.rbegin();
uint32_t buffer_first_seq32 = (*buffer_it).seq32;
uint32_t buffer_last_seq32 = (*buffer_it_r).seq32;
// Requested packet range not found.
if (first_seq32 > buffer_last_seq32 || last_seq32 < buffer_first_seq32)
{
// Let's try with sequence numbers in the previous 16 cycle.
if (this->cycles > 0)
{
first_seq32 -= RTP_SEQ_MOD;
last_seq32 -= RTP_SEQ_MOD;
// Try again.
if (first_seq32 > buffer_last_seq32 || last_seq32 < buffer_first_seq32)
return;
}
// Otherwise just return.
else
{
MS_WARN_TAG(rtp, "requested range not in the buffer");
return;
}
}
// Look for each requested packet.
uint32_t seq32 = first_seq32;
bool requested = true;
// Some variables for debugging.
uint16_t orig_bitmask = bitmask;
uint16_t sent_bitmask = 0b0000000000000000;
uint8_t counter = 0;
do
{
bool sent = false;
if (requested)
{
for (; buffer_it != this->buffer.end(); ++buffer_it)
{
auto current_seq32 = (*buffer_it).seq32;
// Found.
if (current_seq32 == seq32)
{
auto current_packet = (*buffer_it).packet;
// Just provide the packet if no older than MAX_RETRANSMISSION_AGE ms.
uint16_t diff = (this->max_timestamp - current_packet->GetTimestamp()) * 1000 / this->clockRate;
if (diff <= MAX_RETRANSMISSION_AGE)
{
// Store the packet in the container and then increment its index.
container[container_idx++] = current_packet;
sent = true;
}
else
{
MS_WARN_TAG(rtp, "ignoring retransmission for a packet older than %d ms", MAX_RETRANSMISSION_AGE);
}
// Exit the loop.
break;
}
}
}
requested = (bitmask & 1) ? true : false;
bitmask >>= 1;
++seq32;
// For debugging.
sent_bitmask |= (sent ? 1 : 0) << counter;
++counter;
}
while (bitmask != 0);
// TODO:
MS_WARN_TAG(rtcp, "[orig_bitmask:" UINT16_TO_BINARY_PATTERN ", sent_bitmask: " UINT16_TO_BINARY_PATTERN "]",
UINT16_TO_BINARY(orig_bitmask), UINT16_TO_BINARY(sent_bitmask));
// Set the next container element to null.
container[container_idx] = nullptr;
}
void RtpStreamSend::ClearBuffer()
{
MS_TRACE();
// Delete cloned packets.
for (auto& buffer_item : this->buffer)
{
delete buffer_item.packet;
}
// Clear list.
this->buffer.clear();
}
inline
void RtpStreamSend::StorePacket(RTC::RtpPacket* packet)
{
MS_TRACE();
// Sum the packet seq number and the number of 16 bits cycles.
uint32_t packet_seq32 = (uint32_t)packet->GetSequenceNumber() + this->cycles;
BufferItem buffer_item;
buffer_item.seq32 = packet_seq32;
// If empty do it easy.
if (this->buffer.size() == 0)
{
auto store = this->storage[0].store;
buffer_item.packet = packet->Clone(store);
this->buffer.push_back(buffer_item);
return;
}
// Otherwise, do the stuff.
Buffer::iterator new_buffer_it;
uint8_t* store = nullptr;
// Iterate the buffer in reverse order and find the proper place to store the
// packet.
auto buffer_it_r = this->buffer.rbegin();
for (; buffer_it_r != this->buffer.rend(); ++buffer_it_r)
{
auto current_seq32 = (*buffer_it_r).seq32;
if (packet_seq32 > current_seq32)
{
// Get a forward iterator pointing to the same element.
auto it = buffer_it_r.base();
new_buffer_it = this->buffer.insert(it, buffer_item);
// Exit the loop.
break;
}
}
// If the packet was older than anything in the buffer, just ignore it.
// NOTE: This should never happen.
if (buffer_it_r == this->buffer.rend())
{
MS_WARN_TAG(rtp, "packet is older than anything in the buffer, ignoring it");
return;
}
// If the buffer is not full use the next free storage item.
if (this->buffer.size() - 1 < this->storage.size())
{
store = this->storage[this->buffer.size() - 1].store;
}
// Otherwise remove the first packet of the buffer and replace its storage area.
else
{
auto& first_buffer_item = *(this->buffer.begin());
auto first_packet = first_buffer_item.packet;
// Store points to the store used by the first packet.
store = (uint8_t*)first_packet->GetData();
// Free the first packet.
delete first_packet;
// Remove the first element in the list.
this->buffer.pop_front();
}
// Update the new buffer item so it points to the cloned packed.
(*new_buffer_it).packet = packet->Clone(store);
}
// TODO: TMP
void RtpStreamSend::Dump()
{
MS_TRACE();
MS_DEBUG_TAG(rtp, "<RtpStreamSend>");
MS_DEBUG_TAG(rtp, " [buffer.size:%zu, storage.size:%zu]", this->buffer.size(), this->storage.size());
for (auto& buffer_item : this->buffer)
{
auto packet = buffer_item.packet;
MS_DEBUG_TAG(rtp, " packet [seq:%" PRIu16 ", seq32:%" PRIu32 "]", packet->GetSequenceNumber(), buffer_item.seq32);
}
MS_DEBUG_TAG(rtp, "</RtpStreamSend>");
}
}
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论