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

RtpStream: pass clockRate as argument

上级 7cc292c4
...@@ -24,7 +24,7 @@ namespace RTC ...@@ -24,7 +24,7 @@ namespace RTC
}; };
public: public:
explicit RtpStream(size_t bufferSize); explicit RtpStream(uint32_t clockRate, size_t bufferSize);
~RtpStream(); ~RtpStream();
bool ReceivePacket(RTC::RtpPacket* packet); bool ReceivePacket(RTC::RtpPacket* packet);
...@@ -38,6 +38,8 @@ namespace RTC ...@@ -38,6 +38,8 @@ namespace RTC
void Dump(); void Dump();
private: private:
// Given as argument.
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.
// https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff. // https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
uint16_t max_seq = 0; // Highest seq. number seen. uint16_t max_seq = 0; // Highest seq. number seen.
......
...@@ -649,6 +649,9 @@ namespace RTC ...@@ -649,6 +649,9 @@ namespace RTC
rtpSender->RetransmitRtpPacket(packet); rtpSender->RetransmitRtpPacket(packet);
} }
// Reset the container by setting its first element to nullptr.
this->rtpRetransmissionContainer[0] = nullptr;
} }
break; break;
......
...@@ -22,20 +22,6 @@ namespace RTC ...@@ -22,20 +22,6 @@ namespace RTC
notifier(notifier) notifier(notifier)
{ {
MS_TRACE(); MS_TRACE();
// Create an RtpStream.
switch (kind)
{
case RTC::Media::Kind::VIDEO:
case RTC::Media::Kind::DEPTH:
this->rtpStream = new RTC::RtpStream(200); // Buffer up to 200 packets.
break;
case RTC::Media::Kind::AUDIO:
this->rtpStream = new RTC::RtpStream(0); // No buffer for audio streams.
break;
default:
;
}
} }
RtpReceiver::~RtpReceiver() RtpReceiver::~RtpReceiver()
...@@ -174,6 +160,45 @@ namespace RTC ...@@ -174,6 +160,45 @@ namespace RTC
// And notify again. // And notify again.
this->listener->onRtpReceiverParametersDone(this); this->listener->onRtpReceiverParametersDone(this);
// Set the RtpStream.
// 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");
switch (this->kind)
{
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;
} }
...@@ -234,6 +259,9 @@ namespace RTC ...@@ -234,6 +259,9 @@ namespace RTC
// TODO: Check if stopped, etc (not yet done). // TODO: Check if stopped, etc (not yet done).
// TODO: Handle multiple streams.
MS_ASSERT(this->rtpStream, "no RtpStream set");
// Process the packet. // Process the packet.
// TODO: Must check what kind of packet we are checking. For example, RTX // TODO: Must check what kind of packet we are checking. For example, RTX
// packets (once implemented) should have a different handling. // packets (once implemented) should have a different handling.
......
...@@ -15,7 +15,8 @@ namespace RTC ...@@ -15,7 +15,8 @@ namespace RTC
{ {
/* Instance methods. */ /* Instance methods. */
RtpStream::RtpStream(size_t bufferSize) : RtpStream::RtpStream(uint32_t clockRate, size_t bufferSize) :
clockRate(clockRate),
storage(bufferSize) storage(bufferSize)
{ {
MS_TRACE(); MS_TRACE();
...@@ -73,10 +74,6 @@ namespace RTC ...@@ -73,10 +74,6 @@ namespace RTC
// 17: 16 bit mask + the initial sequence number. // 17: 16 bit mask + the initial sequence number.
static size_t maxRequestedPackets = 17; static size_t maxRequestedPackets = 17;
// First of all, set the first element of the container to null so, in case
// no packet is inserted into it, the reader will know it.
container[0] = nullptr;
// If the buffer is empty, just return. // If the buffer is empty, just return.
if (this->buffer.size() == 0) if (this->buffer.size() == 0)
return; return;
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论